Skip to content

Commit

Permalink
configparser: compiles again. start of syntax check;
Browse files Browse the repository at this point in the history
  • Loading branch information
Tentanus committed Nov 8, 2023
1 parent e29b109 commit 44a38d3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 2 additions & 0 deletions include/ConfigParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <LocationSettings.hpp>
#include <ServerSettings.hpp>

#include <stdexcept>
#include <string>
#include <unordered_map>
#include <vector>
Expand All @@ -15,6 +16,7 @@ class ConfigParser
std::vector<ServerSettings> _server_settings;

std::stringstream OpenFile();
void syntaxCheck(std::vector<Token>::iterator);

public:
ConfigParser(const std::string &file_path);
Expand Down
18 changes: 4 additions & 14 deletions src/ConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <filesystem>
#include <ios>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>

Expand Down Expand Up @@ -48,23 +47,14 @@ void ConfigParser::ParseConfig()
std::vector<Token> tokenlist;

tokenizeStream(OpenFile(), tokenlist);
syntaxCheck(tokenlist.begin());

size_t block_nbr = 0;
for (std::vector<Token>::iterator it = tokenlist.begin();
it != tokenlist.end(); it++)
{
block_nbr++;
try
{
_server_settings.emplace_back(ServerSettings(it));
}
catch ()
{
}
}
_server_settings.emplace_back(ServerSettings(it));

// for (auto &it : _server_settings)
// it.printServerSettings();
for (auto &it : _server_settings)
it.printServerSettings();

logger.log(INFO, "Parsed configfile: " + _config_file_path);
}
9 changes: 9 additions & 0 deletions src/ConfigSyntax.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#include <ConfigParser.hpp>
#include <Logger.hpp>
#include <Token.hpp>

void ConfigParser::syntaxCheck(std::vector<Token>::iterator token)
{
(void)token;
}
2 changes: 1 addition & 1 deletion src/LocationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void LocationSettings::printLocationSettings() const
{
Logger &logger = Logger::getInstance();

logger.log(DEBUG, "\tLocation_ Instance: " + _directory);
logger.log(DEBUG, "\tLocation Prefix:\t" + _directory);
logger.log(DEBUG, "\t\tAlias:\t\t\t" + _alias);
logger.log(DEBUG, "\t\tIndex:\t\t\t" + _index);
logger.log(DEBUG, "\t\tAllowed_methods:\t" + _allowed_methods);
Expand Down

0 comments on commit 44a38d3

Please sign in to comment.