diff --git a/src/config/TOMLNode.cpp b/src/config/TOMLNode.cpp index 8026445..1210a64 100644 --- a/src/config/TOMLNode.cpp +++ b/src/config/TOMLNode.cpp @@ -97,32 +97,32 @@ void toml_node::setMapArray(TOMLMapArray *map_array) } -std::string *toml_node::toString(void) const +std::string toml_node::toString(void) const { switch (type) { case STRING: { - return (value.str); + return (*value.str); } case NUM: { std::stringstream ss; ss << value.integer; - std::string *result = new std::string(); - ss >> *result; + std::string result; + ss >> result; return (result); } case ARRAY: { TOMLArray::iterator it; - std::string *result = new std::string("[ "); + std::string result("[ "); for (it = value.array->begin(); it != value.array->end(); ++it) { - *result += *((*it)->toString()); - *result += ", "; + result += ((*it)->toString()); + result += ", "; } - *result += " ]"; + result += " ]"; return (result); } case MAP: @@ -132,41 +132,41 @@ std::string *toml_node::toString(void) const case MAPARRAY: { std::stringstream ss; - std::string *result = new std::string(); + std::string result; TOMLMapArray::iterator it; TOMLMapArray *map_array = value.map_array; ss << "[\n"; for (it = map_array->begin(); it != map_array->end(); ++it) { - ss << (*TOMLMap_to_string(*it)); + ss << (TOMLMap_to_string(*it)); ss << ", " << std::endl; } ss << "]\n"; /* ss >> *result; */ - *result = ss.str(); + result = ss.str(); return (result); } case BOOL: { - std::string *result; + std::string result; if (value.boolean) - result = new std::string("true"); + result = std::string("true"); else - result = new std::string("false"); + result = std::string("false"); return (result); } default: - return ( new std::string("Not implemented :)")); + return (std::string("Not implemented :)")); } } -std::string *toml_node::TOMLMap_to_string(TOMLMap *map) +std::string toml_node::TOMLMap_to_string(TOMLMap *map) { std::stringstream ss; - std::string *result = new std::string(); + std::string result; TOMLMap::iterator it; ss << "{\n"; @@ -174,13 +174,13 @@ std::string *toml_node::TOMLMap_to_string(TOMLMap *map) { ss << it->first << ": " - << *(it->second->toString()) + << (it->second->toString()) << std::endl; } ss << "}" << std::endl; /* ss >> *result; */ - *result = ss.str(); + result = ss.str(); return (result); } diff --git a/src/config/TOMLNode.hpp b/src/config/TOMLNode.hpp index 645669c..80dd645 100644 --- a/src/config/TOMLNode.hpp +++ b/src/config/TOMLNode.hpp @@ -54,8 +54,8 @@ class toml_node void setObject(TOMLMap *obj); void setMapArray(TOMLMapArray *map_array); - std::string *toString(void) const; - static std::string *TOMLMap_to_string(TOMLMap *map); + std::string toString(void) const; + static std::string TOMLMap_to_string(TOMLMap *map); }; diff --git a/src/config/parse.cpp b/src/config/parse.cpp index b178a75..503e69f 100644 --- a/src/config/parse.cpp +++ b/src/config/parse.cpp @@ -20,19 +20,18 @@ /* } */ namespace config { - void display(TOMLMap *root_map) { - std::cout << ">>> printing config: <<<" << std::endl; + DBOUT << ">>> printing config: <<<" << std::endl; TOMLMap::iterator it; for (it = root_map->begin(); it != root_map->end(); ++it) { - std::cout << it->first + DBOUT << it->first << ": " - << *(it->second->toString()); - std::cout << ", " << std::endl; + << (it->second->toString()); + DBOUT << ", " << std::endl; /* << std::endl << "-------" << std::endl; */ } } @@ -42,6 +41,7 @@ namespace config TOMLMap::iterator it; DBOUT << ">>> cleaning up: <<<" << std::endl; + DBOUT << root << ENDL; if (!root) return; for (it = root->begin(); it != root->end(); ++it) @@ -52,7 +52,7 @@ namespace config clean_generic(it->second); /* delete it->second; */ - std::cout << ", " << std::endl; + DBOUT << ", " << std::endl; } DBOUT << YELLO << "end of clean" << ENDL; root->clear(); diff --git a/src/config/parse.hpp b/src/config/parse.hpp index 5b0e1c2..0d57045 100644 --- a/src/config/parse.hpp +++ b/src/config/parse.hpp @@ -8,6 +8,5 @@ #include "TOMLParser.hpp" TOMLMap *parse(char *filename); -void display(TOMLMap *config); #endif diff --git a/src/config/tomlstuff.hpp b/src/config/tomlstuff.hpp index 49e084c..bee5436 100644 --- a/src/config/tomlstuff.hpp +++ b/src/config/tomlstuff.hpp @@ -9,7 +9,7 @@ typedef std::vector TOMLArray; namespace config { - + void display(TOMLMap *config); void clean_parsed(TOMLMap *root); void clean_generic(toml_node *node); }