diff --git a/config/simple.toml b/config/simple.toml index 0f96880..a464a76 100644 --- a/config/simple.toml +++ b/config/simple.toml @@ -1,2 +1,4 @@ name = "jopa" port = 6969 +ip = "127.0.0.1" +methods = ["GET", "POST", 1, "piska", false, false] diff --git a/src/config/TOMLNode.hpp b/src/config/TOMLNode.hpp index 2d976cb..f265d31 100644 --- a/src/config/TOMLNode.hpp +++ b/src/config/TOMLNode.hpp @@ -104,6 +104,15 @@ class toml_node *result += " ]"; return (result); } + case BOOL: + { + std::string *result; + if (value.boolean) + result = new std::string("true"); + else + result = new std::string("false"); + return (result); + } default: return ( new std::string("Not implemented :)")); } diff --git a/src/config/TOMLParser.hpp b/src/config/TOMLParser.hpp index ed632f3..92ed80a 100644 --- a/src/config/TOMLParser.hpp +++ b/src/config/TOMLParser.hpp @@ -62,6 +62,7 @@ namespace config } case BOOL: { + tokenizer.rollBackToken(); (*mapObject)[key] = parseBool(); break; } @@ -197,8 +198,10 @@ namespace config s_token token = tokenizer.getToken(); if (token.value == "true") value = true; - else + else if (token.value == "false") value = false; + else + throw std::invalid_argument("Unexpected bool value"); node->setBool(value); return (node); diff --git a/src/config/Tokenizer.hpp b/src/config/Tokenizer.hpp index 6efb75b..e2990f3 100644 --- a/src/config/Tokenizer.hpp +++ b/src/config/Tokenizer.hpp @@ -209,12 +209,25 @@ namespace config token.type = BOOL; token.value = "false"; file.seekg(4, std::ios_base::cur); + + /* token.value = ""; */ + /* while (std::isalpha(c)) */ + /* { */ + /* token.value += c; */ + /* file.get(c); */ + /* } */ + std::cerr << "value is: " << token.value << std::endl; + std::cerr << "c is: " << c << std::endl; } else if (c == 't') { token.type = BOOL; - token.value = "true"; - file.seekg(3, std::ios_base::cur); + while (std::isalpha(c)) + { + token.value += c; + file.get(c); + } + /* file.seekg(3, std::ios_base::cur); */ } else if (c == 'n') {