blob: e9351538d100707e482259ee84d146f346ea1a37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include "cru/toml/TomlDocument.h"
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;
}
TomlSection* TomlDocument::GetSectionOrCreate(const String& name) {
auto it = sections_.find(name);
if (it == sections_.end()) {
sections_[name] = TomlSection();
return §ions_[name];
}
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
|