intermediate changes

This commit is contained in:
3lswear
2022-01-13 09:25:04 +03:00
parent 7c6d0783f1
commit ebd09bbcdc
5 changed files with 115 additions and 79 deletions

View File

@@ -23,19 +23,27 @@
/* } */
namespace config
{
void display(TOMLMap *config)
void display(toml_node *config)
{
std::cout << ">>> printing config: <<<" << std::endl;
if (config->get_type() != toml_node::MAPARRAY)
throw std::logic_error("Attempting to display not map_array");
TOMLMapArray *root_map_array = config->getMapArray();
TOMLMapArray::iterator root_it;
TOMLMap::iterator it;
for (it = config->begin(); it != config->end(); ++it)
{
std::cout << it->first
<< ": "
<< *(it->second->toString())
<< std::endl;
}
for (root_it = root_map_array->begin(); root_it != root_map_array->end(); ++root_it)
{
for (it = (*root_it)->begin(); it != (*root_it)->end(); ++it)
{
std::cout << it->first
<< ": "
<< *(it->second->toString())
<< std::endl;
}
std::cout << "-------" << std::endl;
}
}
}
@@ -44,5 +52,5 @@ void parse(void)
std::string filename = "config/simple.toml";
config::TOMLParser parser(filename);
toml_node *root = parser.parse();
config::display(root->getMap());
config::display(root);
}