-
Notifications
You must be signed in to change notification settings - Fork 0
ParserCore Declerations #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,15 +1,40 @@ | ||||||||
| #ifndef PARSER_HPP | ||||||||
| #define PARSER_HPP | ||||||||
|
|
||||||||
| #include <Server.hpp> | ||||||||
| #include <ServerContainer.hpp> | ||||||||
| #include <utils.hpp> | ||||||||
|
|
||||||||
| typedef struct tagParserEntry | ||||||||
| { | ||||||||
| std::string entryName; | ||||||||
| std::deque<std::string> values; | ||||||||
| } ParserEntry; | ||||||||
|
|
||||||||
| typedef struct tagParserBlock | ||||||||
| { | ||||||||
| std::string blockName; | ||||||||
| std::deque<std::string> headerData; | ||||||||
| std::deque<ParserEntry> entries; | ||||||||
| std::deque<struct tagParserBlock *> innerBlocks; | ||||||||
| } ParserBlock; | ||||||||
|
|
||||||||
| class Parser | ||||||||
| { | ||||||||
| private: | ||||||||
| std::vector<Server> _servers; | ||||||||
| std::string _filePath; | ||||||||
| std::deque<std::string> _tokens; | ||||||||
| /* | ||||||||
| I tried to keep the parser 2 phases but dealing with ParserBlock directly can be difficult | ||||||||
| because of inner blocks which would require hardcoding the behaviour and especially | ||||||||
| inheritance handling which can be painful if we would process entries one by one | ||||||||
| */ | ||||||||
| void parseTokinizer(); | ||||||||
| ParserBlock *parserPrepBlocks(); | ||||||||
| ServerContainer *parserProcess(); | ||||||||
|
|
||||||||
| public: | ||||||||
| Parser(const std::string &filePath); | ||||||||
|
||||||||
| Parser(const std::string &filePath); | |
| Parser(const std::string &filePath); | |
| ~Parser(); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,26 +1,33 @@ | ||||||||
| #include <Parser.hpp> | ||||||||
|
|
||||||||
| Parser::Parser(const std::string &filePath) | ||||||||
| Parser::Parser(const std::string &filePath) : _filePath(filePath) | ||||||||
| { | ||||||||
| std::ifstream file(filePath); | ||||||||
| if (!file.is_open()) | ||||||||
| throw CommonExceptions::OpenFileException(); | ||||||||
| try | ||||||||
| { | ||||||||
| file.exceptions(std::ios::badbit); | ||||||||
|
|
||||||||
| } | ||||||||
| catch (...) | ||||||||
| { | ||||||||
| file.close(); | ||||||||
| throw; | ||||||||
| } | ||||||||
| file.close(); | ||||||||
| } | ||||||||
|
|
||||||||
| Parser::~Parser() {} | ||||||||
| Parser::~Parser() | ||||||||
| { | ||||||||
| } | ||||||||
|
|
||||||||
| void Parser::validateServers() const | ||||||||
| void Parser::parseTokinizer() | ||||||||
|
||||||||
| void Parser::parseTokinizer() | |
| void Parser::parseTokenizer() |
Copilot
AI
Aug 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using raw pointer with 'new' without corresponding 'delete' can lead to memory leaks. Consider using smart pointers or ensure proper memory management.
Copilot
AI
Aug 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using raw pointer with 'new' without corresponding 'delete' can lead to memory leaks. Consider using smart pointers or ensure proper memory management.
Copilot
AI
Aug 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ParserBlock pointer returned from parserPrepBlocks() is not used or freed, creating a potential memory leak.
| ServerContainer* serverContainer = parserProcess(); | |
| ServerContainer* serverContainer = parserProcess(); | |
| delete parserBlock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name 'parseTokinizer' contains a spelling error. It should be 'parseTokenizer'.