summaryrefslogtreecommitdiff
path: root/src/core/common/VariantReader.hpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-18 13:28:36 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-18 13:28:36 +0100
commit89e0b786d01246d1e8e57cc5da855372e27e7b63 (patch)
tree9808fd1ab44349741368994b18f09f48000e9a9a /src/core/common/VariantReader.hpp
parent86d11c73f637f5e858ecb84fe6dfb90281f266a9 (diff)
Added function for parsing complete strings (as needed in the xml parser)
Diffstat (limited to 'src/core/common/VariantReader.hpp')
-rw-r--r--src/core/common/VariantReader.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/common/VariantReader.hpp b/src/core/common/VariantReader.hpp
index abf529c..8aaffd8 100644
--- a/src/core/common/VariantReader.hpp
+++ b/src/core/common/VariantReader.hpp
@@ -229,6 +229,26 @@ public:
CharReader &reader, Logger &logger,
const std::unordered_set<char> &delims,
bool extractUnescapedStrings = false);
+
+ /**
+ * Tries to parse the most specific item from the given string. The
+ * resulting variant represents the value that has been read. If the end of
+ * the string was not reached while parsing an element, the result is
+ * returned as string.
+ *
+ * @param str is the string from which the value should be read.
+ * @param logger is the logger instance to which errors or warnings will be
+ * written.
+ * @return a pair indicating whether the operation was successful and the
+ * extracted variant value. Note that the variant value most times contains
+ * some meaningful data that can be worked with even if the operation was
+ * not successful (e.g. if a syntax error is encountered while reading an
+ * array, the successfully read elements will still be in the returned
+ * variant.) Information on why the operation has failed is passed to the
+ * logger.
+ */
+ static std::pair<bool, Variant> parseGenericString(
+ const std::string &str, Logger &logger);
};
}