2018-12-15 16:21:52 +00:00
|
|
|
#include <service/config.hpp>
|
2019-01-11 00:12:43 +00:00
|
|
|
|
2019-07-02 21:28:28 +00:00
|
|
|
#include <config/ini.hpp>
|
2019-01-11 00:12:43 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
bool
|
2019-07-02 21:28:28 +00:00
|
|
|
Config::Load(string_view fname)
|
2019-01-11 00:12:43 +00:00
|
|
|
{
|
2019-04-22 18:35:19 +00:00
|
|
|
ConfigParser parser;
|
2019-07-02 21:28:28 +00:00
|
|
|
if(!parser.LoadFile(fname))
|
2019-01-22 14:13:26 +00:00
|
|
|
return false;
|
2019-04-22 18:35:19 +00:00
|
|
|
parser.IterAll([&](const ConfigParser::String_t& name,
|
|
|
|
const ConfigParser::Section_t& section) {
|
|
|
|
Config::section_t values;
|
2019-02-24 02:45:40 +00:00
|
|
|
values.first.assign(name.begin(), name.end());
|
2019-01-22 14:13:26 +00:00
|
|
|
for(const auto& item : section)
|
2019-04-11 15:36:20 +00:00
|
|
|
values.second.emplace_back(string_view_string(item.first),
|
|
|
|
string_view_string(item.second));
|
2019-01-22 14:13:26 +00:00
|
|
|
services.emplace_back(values);
|
|
|
|
});
|
2019-01-11 00:12:43 +00:00
|
|
|
return services.size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|