summaryrefslogtreecommitdiff
path: root/src/core/variant/Reader.hpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2014-12-05 16:09:59 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2014-12-05 16:09:59 +0100
commit03b90ef542844febe6a9f99b830d67ff1c8dfb9c (patch)
treea1211d631c12bfae94bc46785fbe1cc326267976 /src/core/variant/Reader.hpp
parent30711f43a6cad9889ee1af8539658c4ca1f59854 (diff)
parente06e7ae19851acf5e397f579d6c8459e87086d30 (diff)
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core/variant/Reader.hpp')
-rw-r--r--src/core/variant/Reader.hpp56
1 files changed, 48 insertions, 8 deletions
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<bool, std::string> parseString(
- BufferedCharReader &reader,
- const unordered_set<char> *delims = nullptr,
- Logger *logger = nullptr);
+ BufferedCharReader &reader, Logger &logger,
+ const std::unordered_set<char> *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<bool, std::string> parseString(
+ BufferedCharReader &reader, Logger &logger,
+ const std::unordered_set<char> &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<bool, std::string> 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<bool, std::string> parseUnescapedString(
- BufferedCharReader &reader, const unordered_set<char> *delims,
- Logger *logger = nullptr);
+ BufferedCharReader &reader, Logger &logger,
+ const std::unordered_set<char> &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<bool, Variant> parseGeneric(
- BufferedCharReader &reader, const unordered_set<char> *delims,
- Logger *logger = nullptr);
+ BufferedCharReader &reader, Logger &logger,
+ const std::unordered_set<char> &delims);
};
}
}