diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-23 23:37:55 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2014-12-23 23:37:55 +0100 |
commit | 5beaf5c18d8690b88981c30ff210dce86fd8e515 (patch) | |
tree | edb6aca54ca983b2c1eb38214fb6373871e16400 /src/core/common/VariantReader.hpp | |
parent | c32c2d53c34e80a2681442afa11540fdde404fdc (diff) |
implemented routines for automatically extracting arrays when parsing generics
Diffstat (limited to 'src/core/common/VariantReader.hpp')
-rw-r--r-- | src/core/common/VariantReader.hpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/src/core/common/VariantReader.hpp b/src/core/common/VariantReader.hpp index 2ccfed7..abf529c 100644 --- a/src/core/common/VariantReader.hpp +++ b/src/core/common/VariantReader.hpp @@ -98,8 +98,9 @@ public: } /** - * Extracts an unescaped string from the given CharReader instance. - * This function just reads text until one of the given delimiter + * Extracts a single token from the given CharReader instance. Skips any + * whitespace character until a non-whitespace character is reached. Stops + * if another whitespace character is read or one of the given delimiters * characters is reached. * * @param reader is a reference to the CharReader instance which is @@ -110,6 +111,23 @@ public: * @param delims is a set of characters which will terminate the string. * These characters are not included in the result. */ + static std::pair<bool, std::string> parseToken( + CharReader &reader, Logger &logger, + const std::unordered_set<char> &delims); + + /** + * Extracts an unescaped string from the given CharReader instance. Skips + * any whitespace character one of the given delimiters is reached. Strips + * whitespace at the end of the string. + * + * @param reader is a reference to the CharReader instance which is + * the source for the character data. The reader will be positioned 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 characters which will terminate the string. + * These characters are not included in the result. + */ static std::pair<bool, std::string> parseUnescapedString( CharReader &reader, Logger &logger, const std::unordered_set<char> &delims); @@ -178,8 +196,9 @@ public: /** * Tries to parse the most specific item from the given stream until one of - * the given delimiters is reached or a meaningful literal has been read. - * The resulting variant represents the value that has been read. + * the given delimiters is reached or a meaningful literal (possibly an + * array of literals) has been read. The resulting variant represents the + * value that has been read. * * @param reader is a reference to the CharReader instance which is * the source for the character data. The reader will be positioned @@ -190,6 +209,26 @@ public: static std::pair<bool, Variant> parseGeneric( CharReader &reader, Logger &logger, const std::unordered_set<char> &delims); + + /** + * Tries to parse the most specific item from the given stream until one of + * the given delimiters is reached or a meaningful literal has been read. + * The resulting variant represents the value that has been read. + * + * @param reader is a reference to the CharReader instance which is + * the source for the character data. The reader will be positioned + * at the terminating delimiting character. + * @param delims is a set of characters which will terminate the string. + * These characters are not included in the result. May not be nullptr. + * @param extractUnescapedStrings if set to true, interprets non-primitive + * literals as unescaped strings, which may also contain whitespace + * characters. Otherwise string literals are only generated until the next + * whitespace character. + */ + static std::pair<bool, Variant> parseGenericToken( + CharReader &reader, Logger &logger, + const std::unordered_set<char> &delims, + bool extractUnescapedStrings = false); }; } |