changes...

This commit is contained in:
3lswear
2022-01-04 18:31:10 +03:00
parent 4cc8dfeace
commit 4aec6d4657
6 changed files with 248 additions and 45 deletions

View File

@@ -1,3 +1,6 @@
#ifndef TOKENIZER_HPP
#define TOKENIZER_HPP
#include "webserv.hpp"
#include <map>
#include <vector>
@@ -6,7 +9,6 @@
#include <iostream>
#include <exception>
namespace config
{
enum e_token
@@ -29,7 +31,7 @@ namespace config
{
std::string value;
e_token type;
std::string to_string(void);
/* std::string to_string(void); */
};
class Tokenizer
@@ -38,10 +40,17 @@ namespace config
std::fstream file;
size_t prev_pos;
public:
Tokenizer(std::string filename);
Tokenizer(std::string filename)
{
file.open(filename.c_str(), std::ios::in);
if (!file.good())
{
std::cerr << "file didn't open" << std::endl;
}
}
char getWithoutWhiteSpace();
struct s_token getToken();
void *hasMoreTokens();
bool hasMoreTokens();
void rollBackToken();
};
@@ -61,6 +70,11 @@ namespace config
return (c);
}
bool Tokenizer::hasMoreTokens(void)
{
return (!file.eof());
}
void Tokenizer::rollBackToken(void)
{
if (file.eof())
@@ -143,3 +157,5 @@ namespace config
return (token);
}
}
#endif