summaryrefslogtreecommitdiff
path: root/src/core/common/VariantReader.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/common/VariantReader.hpp')
-rw-r--r--src/core/common/VariantReader.hpp49
1 files changed, 47 insertions, 2 deletions
diff --git a/src/core/common/VariantReader.hpp b/src/core/common/VariantReader.hpp
index 6b157d8..1232f6e 100644
--- a/src/core/common/VariantReader.hpp
+++ b/src/core/common/VariantReader.hpp
@@ -133,6 +133,19 @@ public:
const std::unordered_set<char> &delims);
/**
+ * Parses a bool from the given CharReader instance (the strings "true" or
+ * "false").
+ *
+ * @param reader is a reference to the CharReader instance which is
+ * the source for the character data. The reader will be positioned after
+ * the bool.
+ * @param logger is the logger instance that should be used to log error
+ * messages and warnings.
+ */
+ static std::pair<bool, Variant::boolType> parseBool(CharReader &reader,
+ Logger &logger);
+
+ /**
* Parses an integer from the given CharReader instance until one of the
* given delimiter characters is reached.
*
@@ -169,7 +182,7 @@ public:
*
* @param reader is a reference to the CharReader instance which is
* the source for the character data. The reader will be positioned after
- * the number or at the terminating delimiting character.
+ * the array or at the terminating delimiting character.
* @param logger is the logger instance that should be used to log error
* messages and warnings.
* @param delim is the terminating character. If nonzero, the parse function
@@ -185,7 +198,7 @@ public:
*
* @param reader is a reference to the CharReader instance which is
* the source for the character data. The reader will be positioned after
- * the number or at the terminating delimiting character.
+ * the object or at the terminating delimiting character.
* @param logger is the logger instance that should be used to log error
* messages and warnings.
* @param delim is the terminating character. If nonzero, the parse function
@@ -293,6 +306,38 @@ public:
static std::pair<bool, Variant> parseGenericString(
const std::string &str, Logger &logger,
SourceId sourceId = InvalidSourceId, size_t offs = 0);
+
+ /**
+ * Tries to parse an instance of the given type from the given stream. The
+ * called method is one of the parse methods defined here and adheres to the
+ * specifications defined there.
+ *
+ * @param type is the VariantType for which an instance shall be parsed.
+ * @param reader is a reference to the CharReader instance which is
+ * the source for the character data. The reader will be positioned
+ * at the end of the type instance (or the delimiting character).
+ * @param delims is a set of characters which will terminate the typed
+ * instance if the according parser uses delimiting characters.
+ * These characters are not included in the result. May not be nullptr.
+ */
+ static std::pair<bool, Variant> parseTyped(
+ VariantType type, CharReader &reader, Logger &logger,
+ const std::unordered_set<char> &delims = {});
+ /**
+ * Tries to parse an instance of the given type from the given string. The
+ * called method is one of the parse methods defined here and adheres to the
+ * specifications defined there.
+ *
+ * @param type is the VariantType for which an instance shall be parsed.
+ * @param str is the string from which the value should be read.
+ * @param sourceId is an optional descriptor of the source file from which
+ * the element is being read.
+ * @param offs is the by offset in the source file at which the string
+ * starts.
+ */
+ static std::pair<bool, Variant> parseTyped(
+ VariantType type, const std::string &str, Logger &logger,
+ SourceId sourceId = InvalidSourceId, size_t offs = 0);
};
}