diff options
Diffstat (limited to 'src/toml/TomlDocument.cpp')
-rw-r--r-- | src/toml/TomlDocument.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/toml/TomlDocument.cpp b/src/toml/TomlDocument.cpp new file mode 100644 index 00000000..a785b4e4 --- /dev/null +++ b/src/toml/TomlDocument.cpp @@ -0,0 +1,40 @@ +#include "cru/toml/TomlDocument.hpp" + +namespace cru::toml { +std::optional<String> TomlSection::GetValue(const String& key) const { + auto it = values_.find(key); + if (it == values_.end()) { + return std::nullopt; + } + return it->second; +} + +void TomlSection::SetValue(const String& key, String value) { + values_[key] = std::move(value); +} + +void TomlSection::DeleteValue(const String& key) { values_.erase(key); } + +TomlSection* TomlDocument::GetSection(const String& name) { + auto it = sections_.find(name); + if (it == sections_.end()) { + return nullptr; + } + return &it->second; +} + +const TomlSection* TomlDocument::GetSection(const String& name) const { + auto it = sections_.find(name); + if (it == sections_.end()) { + return nullptr; + } + return &it->second; +} + +void TomlDocument::SetSection(const String& name, TomlSection section) { + sections_[name] = std::move(section); +} + +void TomlDocument::DeleteSection(const String& name) { sections_.erase(name); } + +} // namespace cru::toml |