aboutsummaryrefslogtreecommitdiff
path: root/include/cru/toml/TomlParser.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-08 16:53:51 +0800
committercrupest <crupest@outlook.com>2022-02-08 16:53:51 +0800
commit74bb9cd27242b9320f99ff4d2b50c3051576cc14 (patch)
tree744bac5799c593d1d6f81e7b09581bea626f2cde /include/cru/toml/TomlParser.h
parentb90c398de829d1ba5329651d75bae82f5e4085fe (diff)
downloadcru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.gz
cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.bz2
cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.zip
...
Diffstat (limited to 'include/cru/toml/TomlParser.h')
-rw-r--r--include/cru/toml/TomlParser.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/cru/toml/TomlParser.h b/include/cru/toml/TomlParser.h
new file mode 100644
index 00000000..dcef2920
--- /dev/null
+++ b/include/cru/toml/TomlParser.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "cru/common/Exception.h"
+#include "cru/toml/TomlDocument.h"
+
+#include <optional>
+
+namespace cru::toml {
+// A very simple and tolerant TOML parser.
+class CRU_TOML_API TomlParsingException : public Exception {
+ public:
+ using Exception::Exception;
+};
+
+class CRU_TOML_API TomlParser {
+ public:
+ explicit TomlParser(String input);
+
+ CRU_DELETE_COPY(TomlParser)
+ CRU_DELETE_MOVE(TomlParser)
+
+ ~TomlParser();
+
+ public:
+ TomlDocument Parse();
+
+ private:
+ // The document is empty to begin with.
+ void DoParse(TomlDocument& document);
+
+ private:
+ String input_;
+
+ std::optional<TomlDocument> cache_;
+};
+} // namespace cru::toml