From 101116268030596e8445a5c83fb966e14de9d01d Mon Sep 17 00:00:00 2001 From: Talyx Date: Sun, 23 Jan 2022 19:39:34 +0300 Subject: [PATCH] TOMLMap parser startv1 --- src/Server/Server.cpp | 1 - src/Server/ServerConfig.cpp | 17 ++++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Server/Server.cpp b/src/Server/Server.cpp index 9b7b321..6161153 100644 --- a/src/Server/Server.cpp +++ b/src/Server/Server.cpp @@ -33,7 +33,6 @@ void Server::readConfig(void) while (it != arr->end()) { _configs.push_back(new ServerConfig(*it)); - std::cout << "biba\n"; ++it; } diff --git a/src/Server/ServerConfig.cpp b/src/Server/ServerConfig.cpp index dcbf8cb..7680d0d 100644 --- a/src/Server/ServerConfig.cpp +++ b/src/Server/ServerConfig.cpp @@ -88,32 +88,34 @@ void ServerConfig::setRoot(TOMLMap * data) int ServerConfig::putBodySizeLimit(toml_node *node) { - std::cout << TURGUOISE << node << ZERO_C << std::endl; + if (node->get_type() != toml_node::e_type::NUM) + return (1); + std::cout << TURGUOISE << *node->toString() << ZERO_C << std::endl; return (0); } int ServerConfig::putErrorPage(toml_node *node) { - std::cout << TURGUOISE << node << ZERO_C << std::endl; + std::cout << TURGUOISE << *node->toString() << ZERO_C << std::endl; return (0); } int ServerConfig::putHost(toml_node *node) { - std::cout << TURGUOISE << node << ZERO_C << std::endl; + std::cout << TURGUOISE << *node->toString() << ZERO_C << std::endl; return (0); } int ServerConfig::putName(toml_node *node) { - std::cout << TURGUOISE << node << ZERO_C << std::endl; + std::cout << TURGUOISE << *node->toString() << ZERO_C << std::endl; return (0); } int ServerConfig::putPort(toml_node *node) { - std::cout << TURGUOISE << node << ZERO_C << std::endl; + std::cout << TURGUOISE << *node->toString() << ZERO_C << std::endl; return (0); } int ServerConfig::putLocation(toml_node *node) { - std::cout << TURGUOISE << node << ZERO_C << std::endl; + std::cout << TURGUOISE << *node->toString() << ZERO_C << std::endl; return (0); } @@ -125,7 +127,7 @@ int ServerConfig::identify(TOMLMap::iterator it) putErrorPage(it->second); else if (it->first == "host") putHost(it->second); - else if (it->first == "loacation") + else if (it->first == "location") putLocation(it->second); else if (it->first == "name") putName(it->second); @@ -144,6 +146,7 @@ void ServerConfig::fillFields(void) block = server->begin(); while (block != server->end() && ret == 0) { + std::cout << GREEN << block->first << ZERO_C << std::endl; ret = identify(block); ++block; }