mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 13:27:59 +03:00
intermediate changes
This commit is contained in:
@@ -88,6 +88,25 @@ class toml_node
|
||||
value.map_array = map_array;
|
||||
type = MAPARRAY;
|
||||
}
|
||||
|
||||
static std::string *TOMLMap_to_string(TOMLMap *map)
|
||||
{
|
||||
std::stringstream ss;
|
||||
std::string *result = new std::string();
|
||||
TOMLMap::iterator it;
|
||||
|
||||
for (it = map->begin(); it != map->end(); ++it)
|
||||
{
|
||||
ss << it->first
|
||||
<< ": "
|
||||
<< *(it->second->toString())
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
ss >> *result;
|
||||
return (result);
|
||||
}
|
||||
|
||||
std::string *toString(void) const
|
||||
{
|
||||
switch (type)
|
||||
@@ -116,6 +135,28 @@ class toml_node
|
||||
*result += " ]";
|
||||
return (result);
|
||||
}
|
||||
case MAP:
|
||||
{
|
||||
return (TOMLMap_to_string(value.map));
|
||||
}
|
||||
case MAPARRAY:
|
||||
{
|
||||
std::stringstream ss;
|
||||
std::string *result = new std::string();
|
||||
TOMLMapArray::iterator it;
|
||||
TOMLMapArray *map_array = value.map_array;
|
||||
|
||||
ss << std::endl;
|
||||
for (it = map_array->begin(); it != map_array->end(); ++it)
|
||||
{
|
||||
ss << (TOMLMap_to_string(*it));
|
||||
}
|
||||
|
||||
ss << "-------" << std::endl;
|
||||
|
||||
ss >> *result;
|
||||
return (result);
|
||||
}
|
||||
case BOOL:
|
||||
{
|
||||
std::string *result;
|
||||
|
||||
@@ -36,6 +36,15 @@ namespace config
|
||||
std::cerr << e.what() << std::endl;
|
||||
break;
|
||||
}
|
||||
if (nextToken.type == MAPARRAY_DECL)
|
||||
{
|
||||
parseMapArray();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* take key make decision */
|
||||
}
|
||||
std::string key = nextToken.value;
|
||||
std::cerr << key << std::endl;
|
||||
if (tokenizer.getToken().type != ASSIGN)
|
||||
@@ -257,8 +266,8 @@ namespace config
|
||||
std::string key;
|
||||
key = "";
|
||||
|
||||
/* root = parseMap(); */
|
||||
root = parseMapArray();
|
||||
root = parseMap();
|
||||
/* root = parseMapArray(); */
|
||||
return (root);
|
||||
|
||||
/* while (tokenizer.hasMoreTokens()) */
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
/* } */
|
||||
namespace config
|
||||
{
|
||||
void display(toml_node *config)
|
||||
|
||||
void display(toml_node *root_node)
|
||||
{
|
||||
std::cout << ">>> printing config: <<<" << std::endl;
|
||||
if (config->get_type() != toml_node::MAPARRAY)
|
||||
|
||||
Reference in New Issue
Block a user