diff options
Diffstat (limited to 'include/cru/toml')
| -rw-r--r-- | include/cru/toml/Base.h | 11 | ||||
| -rw-r--r-- | include/cru/toml/TomlDocument.h | 57 | ||||
| -rw-r--r-- | include/cru/toml/TomlParser.h | 36 |
3 files changed, 0 insertions, 104 deletions
diff --git a/include/cru/toml/Base.h b/include/cru/toml/Base.h deleted file mode 100644 index 76c7ee71..00000000 --- a/include/cru/toml/Base.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#ifdef CRU_IS_DLL -#ifdef CRU_TOML_EXPORT_API -#define CRU_TOML_API __declspec(dllexport) -#else -#define CRU_TOML_API __declspec(dllimport) -#endif -#else -#define CRU_TOML_API -#endif diff --git a/include/cru/toml/TomlDocument.h b/include/cru/toml/TomlDocument.h deleted file mode 100644 index 22442096..00000000 --- a/include/cru/toml/TomlDocument.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "Base.h" - -#include "cru/base/Base.h" - -#include <optional> -#include <unordered_map> -#include <string> - -namespace cru::toml { -class CRU_TOML_API TomlSection { - public: - CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(TomlSection) - CRU_DEFAULT_COPY(TomlSection) - CRU_DEFAULT_MOVE(TomlSection) - - public: - std::optional<std::string> GetValue(const std::string& key) const; - void SetValue(const std::string& key, std::string value); - void DeleteValue(const std::string& key); - - auto begin() { return values_.begin(); } - auto end() { return values_.end(); } - auto begin() const { return values_.begin(); } - auto end() const { return values_.end(); } - auto cbegin() const { return values_.cbegin(); } - auto cend() const { return values_.cend(); } - - private: - std::unordered_map<std::string, std::string> values_; -}; - -class CRU_TOML_API TomlDocument { - public: - CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(TomlDocument) - CRU_DEFAULT_COPY(TomlDocument) - CRU_DEFAULT_MOVE(TomlDocument) - - public: - TomlSection* GetSection(const std::string& name); - TomlSection* GetSectionOrCreate(const std::string& name); - const TomlSection* GetSection(const std::string& name) const; - void SetSection(const std::string& name, TomlSection section); - void DeleteSection(const std::string& name); - - auto begin() { return sections_.begin(); } - auto end() { return sections_.end(); } - auto begin() const { return sections_.begin(); } - auto end() const { return sections_.end(); } - auto cbegin() const { return sections_.cbegin(); } - auto cend() const { return sections_.cend(); } - - private: - std::unordered_map<std::string, TomlSection> sections_; -}; -} // namespace cru::toml diff --git a/include/cru/toml/TomlParser.h b/include/cru/toml/TomlParser.h deleted file mode 100644 index b6532931..00000000 --- a/include/cru/toml/TomlParser.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "cru/base/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(std::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: - std::string input_; - - std::optional<TomlDocument> cache_; -}; -} // namespace cru::toml |
