![]() |
PhoenixFileParser
1.0.0
Set of tools to ease file parsing
|
Class used to parse file with possibility of inclusion. More...
#include <PMultiFileParser.h>
Public Member Functions | |
void | addCommentConfig (const PMultiCommentConfig &commentConfig) |
Adds a comment config for the parser. | |
void | addCommentConfig (const PString &beginStringComment, const PString &endStringComment="\n") |
Adds a comment config for the parser. | |
bool | checkExpectedMatch (const PString &tokenExpected, const PString &tokenBefore="") |
Check if the tokenExpected match. | |
bool | checkExpectedToken (const PString &tokenExpected, const PString &tokenBefore="") |
Check if the p_currentToken == tokenExpected. | |
void | clearComment () |
Clear comment. | |
void | errorAt () |
Write a parsing error. | |
bool | fullParsing () |
Perform the full parsing pf data. | |
PFileParser * | getCurrentParser () |
Gets the current parser. | |
void | getCurrentTokenWithoutComment () |
Get the current token and skip the comment. | |
PString & | getLastComment () |
Get the last comment. | |
const PString & | getLastComment () const |
Get the last comment. | |
PString | getStrComposedOf (const PString &charset) |
Get the string composed of charset charcters. | |
bool | isMatch (const PString &patern, const PString &forbiddenCharBefore) |
Says if the patern match with the current caracters of the PFileParser. | |
bool | isMatch (const PString &token) |
Check if the given token matches the current read file. | |
PString | isMatch (const PVecString &vecToken) |
Check if the one entry of the vector of token matches. | |
bool | isMatchRewind (const PString &token) |
Check if the given token matches the current read file and goes back even if the token matches. | |
bool | isMatchSeq (const PVecString &patern, bool alwaysPopBack=false) |
Match a sequence of token in a vector. | |
PString | isMatchToken (const PVecString &vecToken) |
Check the matching between the current caracters and all the string in the vector but treats the string as a token (cannot be part of a word) | |
bool | load (const PPath &configFile) |
Load the PMultiFileParser with the configFile. | |
PMultiFileParser (const PPath &inputDirectory=PPath(), const PPath &outputDirectory=PPath()) | |
Default constructeur of PMultiFileParser. | |
void | pointAtRow () |
Point the problem. | |
void | setFileContent (const PString &fileContent) |
Set the file content to be parsed. | |
void | skipComment () |
Skip comment. | |
void | stopParsing () |
Stop the parsing of all the files. | |
void | unexpectedToken () |
Print unexpected token error. | |
virtual | ~PMultiFileParser () |
Destructeur of PMultiFileParser. | |
Protected Member Functions | |
virtual bool | parseFile ()=0 |
virtual void | postLoadFile () |
Post load file. | |
virtual void | preLoadFile () |
Pre load file. | |
Protected Attributes | |
PString | p_currentToken |
CurrentToken parsed. | |
PPath | p_inputDirectory |
Input directory of the parser. | |
PString | p_lastComment |
last comment | |
std::list< PFileParser > | p_listFileParser |
List of all the parsers for all the loaded files. | |
PPath | p_outputDirectory |
Output directory of the parser. | |
PFileParser * | p_parser |
Parser helper for the config file. | |
bool | p_run |
Run the parsing if true. | |
Private Member Functions | |
void | initialisationPMultiFileParser (const PPath &inputDirectory, const PPath &outputDirectory) |
Initialisation function of the class PMultiFileParser. | |
Private Attributes | |
PListMultiCommentConfig | p_listCommentConfig |
Defines the differents comments we allow in the parsing. | |
Class used to parse file with possibility of inclusion.
Definition at line 28 of file PMultiFileParser.h.
PMultiFileParser::PMultiFileParser | ( | const PPath & | inputDirectory = PPath(), |
const PPath & | outputDirectory = PPath() ) |
Default constructeur of PMultiFileParser.
inputDirectory | : input directory of the PMultiFileParser |
outputDirectory | : output directory of the PMultiFileParser |
Definition at line 14 of file PMultiFileParser.cpp.
References initialisationPMultiFileParser().
|
virtual |
void PMultiFileParser::addCommentConfig | ( | const PMultiCommentConfig & | commentConfig | ) |
Adds a comment config for the parser.
commentConfig | : comment config for the PMultiFileParser |
Definition at line 84 of file PMultiFileParser.cpp.
References p_listCommentConfig.
void PMultiFileParser::addCommentConfig | ( | const PString & | beginStringComment, |
const PString & | endStringComment = "\n" ) |
Adds a comment config for the parser.
beginStringComment | : string which defines the begining of a comment |
endStringComment | : string which defines the ending of a comment |
Definition at line 92 of file PMultiFileParser.cpp.
References p_listCommentConfig.
bool PMultiFileParser::checkExpectedMatch | ( | const PString & | tokenExpected, |
const PString & | tokenBefore = "" ) |
Check if the tokenExpected match.
tokenExpected | : token we expect |
tokenBefore | : token before the exprected one |
Definition at line 166 of file PMultiFileParser.cpp.
References errorAt(), p_parser, and stopParsing().
bool PMultiFileParser::checkExpectedToken | ( | const PString & | tokenExpected, |
const PString & | tokenBefore = "" ) |
Check if the p_currentToken == tokenExpected.
tokenExpected | : token we expect |
tokenBefore | : token before the exprected one |
Definition at line 151 of file PMultiFileParser.cpp.
References errorAt(), p_currentToken, and stopParsing().
void PMultiFileParser::clearComment | ( | ) |
Clear comment.
Definition at line 193 of file PMultiFileParser.cpp.
References p_lastComment.
Referenced by initialisationPMultiFileParser().
void PMultiFileParser::errorAt | ( | ) |
Write a parsing error.
Definition at line 126 of file PMultiFileParser.cpp.
References p_parser.
Referenced by checkExpectedMatch(), checkExpectedToken(), and unexpectedToken().
bool PMultiFileParser::fullParsing | ( | ) |
Perform the full parsing pf data.
Definition at line 57 of file PMultiFileParser.cpp.
References p_listFileParser, p_parser, p_run, parseFile(), pointAtRow(), postLoadFile(), preLoadFile(), and unexpectedToken().
Referenced by load().
PFileParser * PMultiFileParser::getCurrentParser | ( | ) |
Gets the current parser.
Definition at line 303 of file PMultiFileParser.cpp.
References p_parser.
void PMultiFileParser::getCurrentTokenWithoutComment | ( | ) |
Get the current token and skip the comment.
Definition at line 280 of file PMultiFileParser.cpp.
References p_currentToken, p_lastComment, p_listCommentConfig, p_parser, and p_run.
PString & PMultiFileParser::getLastComment | ( | ) |
Get the last comment.
Definition at line 106 of file PMultiFileParser.cpp.
References p_lastComment.
const PString & PMultiFileParser::getLastComment | ( | ) | const |
Get the last comment.
Definition at line 99 of file PMultiFileParser.cpp.
References p_lastComment.
PString PMultiFileParser::getStrComposedOf | ( | const PString & | charset | ) |
Get the string composed of charset charcters.
charset | : set of allowed characters |
Definition at line 272 of file PMultiFileParser.cpp.
References p_parser, and skipComment().
|
private |
Initialisation function of the class PMultiFileParser.
inputDirectory | : input directory of the PMultiFileParser |
outputDirectory | : output directory of the PMultiFileParser |
Definition at line 311 of file PMultiFileParser.cpp.
References clearComment(), p_currentToken, p_inputDirectory, p_outputDirectory, p_parser, and p_run.
Referenced by PMultiFileParser().
bool PMultiFileParser::isMatch | ( | const PString & | patern, |
const PString & | forbiddenCharBefore ) |
Says if the patern match with the current caracters of the PFileParser.
patern | : patern we want to check (this patern should not begin with white caracters) |
forbiddenCharBefore | : lisr of characters which cannot be just before the first character of the patern |
Definition at line 239 of file PMultiFileParser.cpp.
References p_parser, and skipComment().
bool PMultiFileParser::isMatch | ( | const PString & | token | ) |
Check if the given token matches the current read file.
token | : token to be checked |
Definition at line 202 of file PMultiFileParser.cpp.
References p_parser, and skipComment().
PString PMultiFileParser::isMatch | ( | const PVecString & | vecToken | ) |
Check if the one entry of the vector of token matches.
vecToken | : vector of token |
Definition at line 250 of file PMultiFileParser.cpp.
References p_parser, and skipComment().
bool PMultiFileParser::isMatchRewind | ( | const PString & | token | ) |
Check if the given token matches the current read file and goes back even if the token matches.
token | : token to be checked |
Definition at line 214 of file PMultiFileParser.cpp.
References p_parser, and skipComment().
bool PMultiFileParser::isMatchSeq | ( | const PVecString & | patern, |
bool | alwaysPopBack = false ) |
Match a sequence of token in a vector.
patern | : set of token to match in this order and totally |
alwaysPopBack | : true to make the PFileParser at the exact same place before the check even is the sequence matches |
Definition at line 226 of file PMultiFileParser.cpp.
References p_parser, and skipComment().
PString PMultiFileParser::isMatchToken | ( | const PVecString & | vecToken | ) |
Check the matching between the current caracters and all the string in the vector but treats the string as a token (cannot be part of a word)
vecToken | : vector of token |
Definition at line 261 of file PMultiFileParser.cpp.
References p_parser, and skipComment().
bool PMultiFileParser::load | ( | const PPath & | configFile | ) |
Load the PMultiFileParser with the configFile.
configFile | : file name of the cnofiguration file |
Definition at line 27 of file PMultiFileParser.cpp.
References fullParsing(), MULTI_PARSER_SEPARATORS_STRING, p_listFileParser, and p_parser.
|
protectedpure virtual |
void PMultiFileParser::pointAtRow | ( | ) |
Point the problem.
Definition at line 138 of file PMultiFileParser.cpp.
References p_parser.
Referenced by fullParsing().
|
protectedvirtual |
Post load file.
Definition at line 116 of file PMultiFileParser.cpp.
Referenced by fullParsing().
|
protectedvirtual |
Pre load file.
Definition at line 111 of file PMultiFileParser.cpp.
Referenced by fullParsing().
void PMultiFileParser::setFileContent | ( | const PString & | fileContent | ) |
Set the file content to be parsed.
fileContent | : file content to be parsed |
Definition at line 43 of file PMultiFileParser.cpp.
References MULTI_PARSER_SEPARATORS_STRING, p_listFileParser, and p_parser.
void PMultiFileParser::skipComment | ( | ) |
Skip comment.
Definition at line 177 of file PMultiFileParser.cpp.
References p_lastComment, p_listCommentConfig, p_parser, and p_run.
Referenced by getStrComposedOf(), isMatch(), isMatch(), isMatch(), isMatchRewind(), isMatchSeq(), and isMatchToken().
void PMultiFileParser::stopParsing | ( | ) |
Stop the parsing of all the files.
Definition at line 121 of file PMultiFileParser.cpp.
References p_run.
Referenced by checkExpectedMatch(), checkExpectedToken(), and unexpectedToken().
void PMultiFileParser::unexpectedToken | ( | ) |
Print unexpected token error.
Definition at line 131 of file PMultiFileParser.cpp.
References errorAt(), p_parser, and stopParsing().
Referenced by fullParsing().
|
protected |
CurrentToken parsed.
Definition at line 78 of file PMultiFileParser.h.
Referenced by checkExpectedToken(), getCurrentTokenWithoutComment(), and initialisationPMultiFileParser().
|
protected |
Input directory of the parser.
Definition at line 80 of file PMultiFileParser.h.
Referenced by initialisationPMultiFileParser().
|
protected |
last comment
Definition at line 76 of file PMultiFileParser.h.
Referenced by clearComment(), getCurrentTokenWithoutComment(), getLastComment(), getLastComment(), and skipComment().
|
private |
Defines the differents comments we allow in the parsing.
Definition at line 88 of file PMultiFileParser.h.
Referenced by addCommentConfig(), addCommentConfig(), getCurrentTokenWithoutComment(), and skipComment().
|
protected |
List of all the parsers for all the loaded files.
Definition at line 72 of file PMultiFileParser.h.
Referenced by fullParsing(), load(), and setFileContent().
|
protected |
Output directory of the parser.
Definition at line 82 of file PMultiFileParser.h.
Referenced by initialisationPMultiFileParser().
|
protected |
Parser helper for the config file.
Definition at line 70 of file PMultiFileParser.h.
Referenced by checkExpectedMatch(), errorAt(), fullParsing(), getCurrentParser(), getCurrentTokenWithoutComment(), getStrComposedOf(), initialisationPMultiFileParser(), isMatch(), isMatch(), isMatch(), isMatchRewind(), isMatchSeq(), isMatchToken(), load(), pointAtRow(), setFileContent(), skipComment(), and unexpectedToken().
|
protected |
Run the parsing if true.
Definition at line 74 of file PMultiFileParser.h.
Referenced by fullParsing(), getCurrentTokenWithoutComment(), initialisationPMultiFileParser(), skipComment(), and stopParsing().