Introduced alias for parser’s underlying character type.

This commit is contained in:
Patrick Lühne 2016-05-27 19:25:59 +02:00
parent a1b334a302
commit f81fd1a1b4
2 changed files with 9 additions and 6 deletions

View File

@ -17,6 +17,9 @@ namespace utils
class Parser
{
public:
using CharacterType = unsigned char;
public:
explicit Parser(std::istream &istream);
@ -35,18 +38,18 @@ class Parser
std::string getLine();
private:
static const std::istream_iterator<unsigned char> EndOfFile;
static const std::istream_iterator<CharacterType> EndOfFile;
private:
void checkStream() const;
void advance();
bool advanceIf(unsigned char expectedCharacter);
bool advanceIf(CharacterType expectedCharacter);
uint64_t parseIntegerBody();
std::istream &m_istream;
std::istream_iterator<unsigned char> m_position;
std::istream_iterator<CharacterType> m_position;
size_t m_row;
size_t m_column;

View File

@ -17,7 +17,7 @@ namespace utils
//
////////////////////////////////////////////////////////////////////////////////////////////////////
const std::istream_iterator<unsigned char> Parser::EndOfFile = std::istream_iterator<unsigned char>();
const std::istream_iterator<Parser::CharacterType> Parser::EndOfFile = std::istream_iterator<Parser::CharacterType>();
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -84,7 +84,7 @@ void Parser::advance()
////////////////////////////////////////////////////////////////////////////////////////////////////
bool Parser::advanceIf(unsigned char expectedCharacter)
bool Parser::advanceIf(CharacterType expectedCharacter)
{
checkStream();
@ -198,7 +198,7 @@ uint64_t Parser::parseIntegerBody()
uint64_t value = 0;
while (m_position != std::istream_iterator<unsigned char>())
while (m_position != std::istream_iterator<CharacterType>())
{
const auto character = *m_position;