mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
9d71228e74
This is an initial pass at doing explicit value checks when handling config parsing, as opposed to using a visiting pattern. The latter made it difficult to check for conditions such as missing required values, multiple values, etc. It was also generally less readable (think declarative) which further made it difficult to get a grasp for what our actual configuration file requirements were.
28 lines
691 B
C++
28 lines
691 B
C++
#include <service/config.hpp>
|
|
|
|
#include <config/ini.hpp>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace service
|
|
{
|
|
bool
|
|
Config::Load(string_view fname)
|
|
{
|
|
ConfigParser parser;
|
|
if (!parser.LoadFile(fname))
|
|
return false;
|
|
parser.IterAll(
|
|
[&](string_view name, const ConfigParser::SectionValues_t& section) {
|
|
Config::section_t values;
|
|
values.first.assign(name.begin(), name.end());
|
|
for(const auto& item : section)
|
|
values.second.emplace_back(item.first, item.second);
|
|
services.emplace_back(values);
|
|
});
|
|
return services.size() > 0;
|
|
}
|
|
|
|
} // namespace service
|
|
} // namespace llarp
|