You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include <iostream>
#include <string>
#include <string_view>
#include <toml++/toml.hpp>
// g++ tomldemo.cpp -I ../libs/tomlplusplus -std=c++17
// https://marzer.github.io/tomlplusplus/
using namespace std::literals; int main(int argc, char** argv) { toml::table tbl; try { tbl = toml::parse_file("config.ini"); std::cout << tbl << "\n";
std::cout << (toml::json_formatter{tbl}) << "\n\n";
if (auto channels = tbl["channels"].as_array()) { channels->for_each([&](auto&& ch) { //
std::cout << (toml::json_formatter{ch}) << "\n"; }); }
// tbl["server"]["port"] ;
std::cout <<"server.cmdport:"<< tbl["server"]["cmdport"].value_or(19004) << "\n"; std::cout <<"server.wsport:"<< tbl["server"]["wsport"].value_or(19005) << "\n";
} catch (const toml::parse_error& err) { std::cerr << "Parsing failed:\n" << err << "\n"; return 1; }
return 0; }
|