add config file reader-parser

This commit is contained in:
Timur A. Fatkhullin
2025-02-23 19:22:03 +03:00
parent b9032f7034
commit a9974aab04
3 changed files with 189 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
#include <iostream>
#include "../comm_server_configfile.h"
int main(int argc, char* argv[])
{
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " cfg_filename\n";
return 1;
}
mcc::MccConfigfile cfg;
auto ec = cfg.load(std::string_view{argv[1]});
if (ec) {
std::cout << "ERR: " << ec.message() << "\n";
return 1;
}
for (auto& [key, v] : cfg.config()) {
std::cout << "<" << key << "> = ";
if (v.index()) {
if (v.index() > 1) {
for (auto& el : std::get<2>(v)) {
std::cout << "<" << el << "> ";
}
std::cout << "\n";
} else {
std::cout << "<" << std::get<1>(v) << ">\n";
}
} else {
std::cout << "<no value>\n";
}
}
return 0;
}