From e06e7ae19851acf5e397f579d6c8459e87086d30 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 5 Dec 2014 16:08:34 +0100 Subject: added string reading functions of the Reader class --- src/core/variant/Reader.hpp | 56 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 8 deletions(-) (limited to 'src/core/variant/Reader.hpp') diff --git a/src/core/variant/Reader.hpp b/src/core/variant/Reader.hpp index 339127f..62592c1 100644 --- a/src/core/variant/Reader.hpp +++ b/src/core/variant/Reader.hpp @@ -40,7 +40,7 @@ namespace ousia { namespace variant { class Reader { -public: +private: /** * Parses a string which may either be enclosed by " or ', unescapes * entities in the string as specified for JavaScript. @@ -49,15 +49,55 @@ public: * the source for the character data. The reader will be positioned after * the terminating quote character or at the terminating delimiting * character. + * @param logger is the logger instance that should be used to log error + * messages and warnings. * @param delims is an optional set of delimiters after which parsing has to * be stopped (the delimiters may occur inside the actual string, but not * outside). If nullptr is given, no delimiter is used and a complete string * is read. */ static std::pair parseString( - BufferedCharReader &reader, - const unordered_set *delims = nullptr, - Logger *logger = nullptr); + BufferedCharReader &reader, Logger &logger, + const std::unordered_set *delims); + +public: + /** + * Parses a string which may either be enclosed by " or ', unescapes + * entities in the string as specified for JavaScript. + * + * @param reader is a reference to the BufferedCharReader instance which is + * the source for the character data. The reader will be positioned after + * the terminating quote character or at the terminating delimiting + * character. + * @param logger is the logger instance that should be used to log error + * messages and warnings. + * @param delims is a set of delimiters after which parsing has to + * be stopped (the delimiters may occur inside the actual string, but not + * outside). + */ + static std::pair parseString( + BufferedCharReader &reader, Logger &logger, + const std::unordered_set &delims) + { + return parseString(reader, logger, &delims); + } + + /** + * Parses a string which may either be enclosed by " or ', unescapes + * entities in the string as specified for JavaScript. + * + * @param reader is a reference to the BufferedCharReader instance which is + * the source for the character data. The reader will be positioned after + * the terminating quote character or at the terminating delimiting + * character. + * @param logger is the logger instance that should be used to log error + * messages and warnings. + */ + static std::pair parseString(BufferedCharReader &reader, + Logger &logger) + { + return parseString(reader, logger, nullptr); + } /** * Extracts an unescaped string from the given buffered char reader @@ -71,8 +111,8 @@ public: * These characters are not included in the result. May not be nullptr. */ static std::pair parseUnescapedString( - BufferedCharReader &reader, const unordered_set *delims, - Logger *logger = nullptr); + BufferedCharReader &reader, Logger &logger, + const std::unordered_set &delims); /** * Tries to parse the most specific item from the given stream until one of @@ -86,8 +126,8 @@ public: * These characters are not included in the result. May not be nullptr. */ static std::pair parseGeneric( - BufferedCharReader &reader, const unordered_set *delims, - Logger *logger = nullptr); + BufferedCharReader &reader, Logger &logger, + const std::unordered_set &delims); }; } } -- cgit v1.2.3