From d4457c98def55d694abc51e008d3fe5663768aab Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 23 Jan 2015 15:26:40 +0100 Subject: Improved and fixed CharReader --- src/core/common/CharReader.hpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src/core/common/CharReader.hpp') diff --git a/src/core/common/CharReader.hpp b/src/core/common/CharReader.hpp index 0957e97..5a4d906 100644 --- a/src/core/common/CharReader.hpp +++ b/src/core/common/CharReader.hpp @@ -367,7 +367,7 @@ private: * @param c a reference to the character that should be written. * @return true if another character needs to be read. */ - bool substituteLinebreaks(Cursor &cursor, char &c); + bool substituteLinebreaks(Buffer::CursorId &cursor, char &c); /** * Reads a single character from the given cursor. @@ -534,7 +534,14 @@ public: * * @return the offset of the read cursor in bytes. */ - size_t getOffset() const; + SourceOffset getOffset() const; + + /** + * Returns the offset of the read cursor in bytes. + * + * @return the offset of the read cursor in bytes. + */ + SourcePosition getPosition() const; /** * Returns a SourceLocation object describing the exact position (including @@ -544,6 +551,24 @@ public: * cursor. */ SourceLocation getLocation() const; + + /** + * Returns a SourceLocation object starting at the given start position and + * ending at the exact position (including the source file) of the read + * cursor. + * + * @return a SourceLocation object at the position of the current read + * cursor. + */ + SourceLocation getLocation(SourcePosition start) const; + + /** + * Returns the current SourceId which describes the Resource on which the + * CharReader is currently working. + * + * @return the current SourceId. + */ + SourceId getSourceId() const; }; /** @@ -577,9 +602,9 @@ private: * coherently. */ CharReaderFork(std::shared_ptr buffer, - Buffer::CursorId &parentReadCursor, - Buffer::CursorId &parentPeekCursor, - SourceContextCallback sourceId, size_t offs, bool coherent); + Buffer::CursorId parentReadCursor, + Buffer::CursorId parentPeekCursor, SourceId sourceId, + size_t offs, bool coherent); public: /** -- cgit v1.2.3