aboutsummaryrefslogtreecommitdiff
path: root/include/cru/base/toml/TomlParser.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-04 22:06:39 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-04 22:06:39 +0800
commit8bea03e0811588e741050b598b8123865b333999 (patch)
treedab70865e53fca11960cb899454d64db9e8ed98d /include/cru/base/toml/TomlParser.h
parent1a6111e3f02b0a9cff0f81fb524b4dfb7d69854b (diff)
downloadcru-8bea03e0811588e741050b598b8123865b333999.tar.gz
cru-8bea03e0811588e741050b598b8123865b333999.tar.bz2
cru-8bea03e0811588e741050b598b8123865b333999.zip
Move toml to base.
Diffstat (limited to 'include/cru/base/toml/TomlParser.h')
-rw-r--r--include/cru/base/toml/TomlParser.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/cru/base/toml/TomlParser.h b/include/cru/base/toml/TomlParser.h
new file mode 100644
index 00000000..ac7d0217
--- /dev/null
+++ b/include/cru/base/toml/TomlParser.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "../Exception.h"
+#include "TomlDocument.h"
+
+#include <optional>
+
+namespace cru::toml {
+// A very simple and tolerant TOML parser.
+class CRU_BASE_API TomlParsingException : public Exception {
+ public:
+ using Exception::Exception;
+};
+
+class CRU_BASE_API TomlParser : public Object {
+ public:
+ explicit TomlParser(std::string input);
+ ~TomlParser();
+
+ public:
+ TomlDocument Parse();
+
+ private:
+ // The document is empty to begin with.
+ void DoParse(TomlDocument& document);
+
+ private:
+ std::string input_;
+
+ std::optional<TomlDocument> cache_;
+};
+} // namespace cru::toml