From 5beaf5c18d8690b88981c30ff210dce86fd8e515 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 23 Dec 2014 23:37:55 +0100 Subject: implemented routines for automatically extracting arrays when parsing generics --- src/core/common/VariantReader.hpp | 47 +++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'src/core/common/VariantReader.hpp') 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 parseToken( + CharReader &reader, Logger &logger, + const std::unordered_set &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 parseUnescapedString( CharReader &reader, Logger &logger, const std::unordered_set &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 parseGeneric( CharReader &reader, Logger &logger, const std::unordered_set &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 parseGenericToken( + CharReader &reader, Logger &logger, + const std::unordered_set &delims, + bool extractUnescapedStrings = false); }; } -- cgit v1.2.3