diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/common/CharReader.cpp | 20 | ||||
| -rw-r--r-- | src/core/common/CharReader.hpp | 20 | 
2 files changed, 36 insertions, 4 deletions
diff --git a/src/core/common/CharReader.cpp b/src/core/common/CharReader.cpp index 4d3638c..3e95280 100644 --- a/src/core/common/CharReader.cpp +++ b/src/core/common/CharReader.cpp @@ -468,15 +468,27 @@ bool CharReader::read(char &c)  	return res;  } +bool CharReader::fetch(char &c) +{ +	return buffer->fetch(readCursor, c); +} + +bool CharReader::fetchPeek(char &c) +{ +	if (coherent) { +		return fetch(c); +	} +	return buffer->fetch(peekCursor, c); +} +  bool CharReader::expect(char c)  { -	char actual = 0; -	peek(actual); -	if (c == actual) { +	char actual; +	if (fetch(actual) && (actual == c)) { +		peek(actual);  		consumePeek();  		return true;  	} -	resetPeek();  	return false;  } diff --git a/src/core/common/CharReader.hpp b/src/core/common/CharReader.hpp index 64c80af..a90d337 100644 --- a/src/core/common/CharReader.hpp +++ b/src/core/common/CharReader.hpp @@ -490,6 +490,26 @@ public:  	bool read(char &c);  	/** +	 * Returns the current character at the read cursor without advancing it. +	 * +	 * @param c is a reference to the character into which the result should be +	 * written. +	 * @return true if the operation was successful, false if the cursor is at +	 * the end of the file. +	 */ +	bool fetch(char &c); + +	/** +	 * Returns the current character at the peek cursor without advancing it. +	 * +	 * @param c is a reference to the character into which the result should be +	 * written. +	 * @return true if the operation was successful, false if the cursor is at +	 * the end of the file. +	 */ +	bool fetchPeek(char &c); + +	/**  	 * Peeks a character, checks whether this character equals the given  	 * character -- and if yes -- consumes the peek, otherwise resets it.  	 *  | 
