aboutsummaryrefslogtreecommitdiff
path: root/src/toml/TomlDocument.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-08 19:24:44 +0800
committercrupest <crupest@outlook.com>2022-01-08 19:24:44 +0800
commit0c7153db084060034092c1dc24222cae384722ec (patch)
tree9de1bc4636732e3cc1e1fb7309fdf2ff60683f69 /src/toml/TomlDocument.cpp
parentc38f1f7c273e85c0a6d197cb27424c9ca69e234d (diff)
downloadcru-0c7153db084060034092c1dc24222cae384722ec.tar.gz
cru-0c7153db084060034092c1dc24222cae384722ec.tar.bz2
cru-0c7153db084060034092c1dc24222cae384722ec.zip
...
Diffstat (limited to 'src/toml/TomlDocument.cpp')
-rw-r--r--src/toml/TomlDocument.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/toml/TomlDocument.cpp b/src/toml/TomlDocument.cpp
index a785b4e4..052af170 100644
--- a/src/toml/TomlDocument.cpp
+++ b/src/toml/TomlDocument.cpp
@@ -31,6 +31,15 @@ const TomlSection* TomlDocument::GetSection(const String& name) const {
return &it->second;
}
+TomlSection* TomlDocument::GetSectionOrCreate(const String& name) {
+ auto it = sections_.find(name);
+ if (it == sections_.end()) {
+ sections_[name] = TomlSection();
+ return &sections_[name];
+ }
+ return &it->second;
+}
+
void TomlDocument::SetSection(const String& name, TomlSection section) {
sections_[name] = std::move(section);
}