config_parser: Allow modifying Parser map
This makes it possible to mutate the map owned by the parser. This will
eventually be used for implementing write updates.
Change-Id: I89deb4073a0a3bd59528c6b70fc55b49bc6cd944
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/config_parser.cpp b/src/config_parser.cpp
index 867d611..cd9960d 100644
--- a/src/config_parser.cpp
+++ b/src/config_parser.cpp
@@ -147,7 +147,7 @@
struct Parse
{
std::reference_wrapper<const fs::path> filename;
- SectionMap sections;
+ SectionMap map;
KeyValuesMap* section;
std::vector<std::string> warnings;
size_t lineno;
@@ -179,10 +179,10 @@
}
}
auto s = line.substr(0, cpos);
- auto it = sections.find(s);
- if (it == sections.end())
+ auto it = map.find(s);
+ if (it == map.end())
{
- std::tie(it, std::ignore) = sections.emplace(
+ std::tie(it, std::ignore) = map.emplace(
Section(Section::unchecked(), s), KeyValuesMapList{});
}
section = &it->second.emplace_back();
@@ -270,8 +270,8 @@
fmt::format("{}: Read error: {}", filename.native(), e.what()));
}
+ this->map = std::move(parse.map);
this->filename = filename;
- this->sections = std::move(parse.sections);
this->warnings = std::move(parse.warnings);
}