feat: simplify parse control flow

This commit is contained in:
3lswear
2022-02-19 18:45:24 +03:00
parent 2beed8da19
commit d1bd273173

View File

@@ -37,11 +37,12 @@ void Server::print_epoll_events(unsigned int events)
//----------------------------------------------Configuration----------------------------------------------------------------------------------- //----------------------------------------------Configuration-----------------------------------------------------------------------------------
void Server::readConfig(char *filename) void Server::readConfig(char *filename)
{ {
TOMLMap *root = NULL; // TOMLMap *root = NULL;
// root = parse(filename); // root = parse(filename);
config::TOMLParser parser(filename);
try try
{ {
root = parse(filename); parser.parse();
} }
catch (std::domain_error &e) catch (std::domain_error &e)
@@ -71,7 +72,7 @@ void Server::readConfig(char *filename)
TOMLMapArray::iterator it; TOMLMapArray::iterator it;
arr = root->find("server")->second->getMapArray(); arr = parser.root->find("server")->second->getMapArray();
it = arr->begin(); it = arr->begin();
while (it != arr->end()) while (it != arr->end())