![]() |
PhoenixPresentation
2.0.0
Set of cmake function to automate presentation generation
|
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. More... | |
void | addCommentConfig (const PString &beginStringComment, const PString &endStringComment="\n") |
Adds a comment config for the parser. More... | |
bool | checkExpectedMatch (const PString &tokenExpected, const PString &tokenBefore="") |
Check if the tokenExpected match. More... | |
bool | checkExpectedToken (const PString &tokenExpected, const PString &tokenBefore="") |
Check if the p_currentToken == tokenExpected. More... | |
void | clearComment () |
Clear comment. More... | |
void | errorAt () |
Write a parsing error. More... | |
bool | fullParsing () |
Perform the full parsing pf data. More... | |
PFileParser * | getCurrentParser () |
Gets the current parser. More... | |
void | getCurrentTokenWithoutComment () |
Get the current token and skip the comment. More... | |
PString & | getLastComment () |
Get the last comment. More... | |
const PString & | getLastComment () const |
Get the last comment. More... | |
PString | getStrComposedOf (const PString &charset) |
Get the string composed of charset charcters. More... | |
bool | isMatch (const PString &patern, const PString &forbiddenCharBefore) |
Says if the patern match with the current caracters of the PFileParser. More... | |
bool | isMatch (const PString &token) |
Check if the given token matches the current read file. More... | |
PString | isMatch (const PVecString &vecToken) |
Check if the one entry of the vector of token matches. More... | |
bool | isMatchRewind (const PString &token) |
Check if the given token matches the current read file and goes back even if the token matches. More... | |
bool | isMatchSeq (const PVecString &patern, bool alwaysPopBack=false) |
Match a sequence of token in a vector. More... | |
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) More... | |
bool | load (const PPath &configFile) |
Load the PMultiFileParser with the configFile. More... | |
PMultiFileParser (const PPath &inputDirectory=PPath(), const PPath &outputDirectory=PPath()) | |
Default constructeur of PMultiFileParser. More... | |
void | pointAtRow () |
Point the problem. More... | |
void | setFileContent (const PString &fileContent) |
Set the file content to be parsed. More... | |
void | skipComment () |
Skip comment. More... | |
void | stopParsing () |
Stop the parsing of all the files. More... | |
void | unexpectedToken () |
Print unexpected token error. More... | |
virtual | ~PMultiFileParser () |
Destructeur of PMultiFileParser. More... | |
Protected Member Functions | |
virtual bool | parseFile ()=0 |
virtual void | postLoadFile () |
Post load file. More... | |
virtual void | preLoadFile () |
Pre load file. More... | |
Protected Attributes | |
PString | p_currentToken |
CurrentToken parsed. More... | |
PPath | p_inputDirectory |
Input directory of the parser. More... | |
PString | p_lastComment |
last comment More... | |
std::list< PFileParser > | p_listFileParser |
List of all the parsers for all the loaded files. More... | |
PPath | p_outputDirectory |
Output directory of the parser. More... | |
PFileParser * | p_parser |
Parser helper for the config file. More... | |
bool | p_run |
Run the parsing if true. More... | |
Private Member Functions | |
void | initialisationPMultiFileParser (const PPath &inputDirectory, const PPath &outputDirectory) |
Initialisation function of the class PMultiFileParser. More... | |
Private Attributes | |
PListMultiCommentConfig | p_listCommentConfig |
Defines the differents comments we allow in the parsing. More... | |
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(), PFileParser::getNextToken(), PFileParser::isMatch(), 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 PFileParser::getLocation(), and 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 PFileParser::getCurrentCharIdx(), PFileParser::getLocation(), PFileParser::isEndOfFile(), p_listFileParser, p_parser, p_run, parseFile(), pointAtRow(), postLoadFile(), preLoadFile(), and unexpectedToken().
Referenced by checkPMultiFileParser(), and load().
PFileParser * PMultiFileParser::getCurrentParser | ( | ) |
Gets the current parser.
Definition at line 303 of file PMultiFileParser.cpp.
References p_parser.
Referenced by ConfigParser::preLoadFile().
void PMultiFileParser::getCurrentTokenWithoutComment | ( | ) |
Get the current token and skip the comment.
Definition at line 280 of file PMultiFileParser.cpp.
References PFileParser::getNextToken(), PFileParser::getUntilKey(), PFileParser::isEndOfFile(), PFileParser::isMatch(), 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.
Get the string composed of charset charcters.
charset | : set of allowed characters |
Definition at line 272 of file PMultiFileParser.cpp.
References PFileParser::getStrComposedOf(), 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().
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 PFileParser::isMatch(), 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 PFileParser::isMatch(), p_parser, and skipComment().
Referenced by ConfigParser::parseDocString(), and ConfigParser::parseFile().
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 PFileParser::isMatch(), 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 PFileParser::isMatchRewind(), 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 PFileParser::isMatchSeq(), 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 PFileParser::isMatchToken(), 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, PFileParser::open(), p_listFileParser, and p_parser.
Referenced by checkPMultiFileParser().
|
protectedpure virtual |
Implemented in ConfigParser.
Referenced by fullParsing().
void PMultiFileParser::pointAtRow | ( | ) |
Point the problem.
Definition at line 138 of file PMultiFileParser.cpp.
References PFileParser::getColumn(), PFileParser::getCurrentRow(), and p_parser.
Referenced by fullParsing(), and ConfigParser::parseFile().
|
protectedvirtual |
Post load file.
Reimplemented in ConfigParser.
Definition at line 116 of file PMultiFileParser.cpp.
Referenced by fullParsing().
|
protectedvirtual |
Pre load file.
Reimplemented in ConfigParser.
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, p_parser, and PFileParser::setFileContent().
Referenced by checkPMultiFileParser().
void PMultiFileParser::skipComment | ( | ) |
Skip comment.
Definition at line 177 of file PMultiFileParser.cpp.
References PFileParser::getUntilKey(), PFileParser::isEndOfFile(), PFileParser::isMatch(), p_lastComment, p_listCommentConfig, p_parser, and p_run.
Referenced by getStrComposedOf(), 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(), PFileParser::getNextToken(), p_parser, and stopParsing().
Referenced by fullParsing(), and ConfigParser::parseFile().
|
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(), and skipComment().
|
private |
Defines the differents comments we allow in the parsing.
Definition at line 88 of file PMultiFileParser.h.
Referenced by 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(), isMatchRewind(), isMatchSeq(), isMatchToken(), load(), ConfigParser::parseDocString(), ConfigParser::parseFile(), pointAtRow(), setFileContent(), skipComment(), and unexpectedToken().
|
protected |
Run the parsing if true.
Definition at line 74 of file PMultiFileParser.h.
Referenced by fullParsing(), getCurrentTokenWithoutComment(), initialisationPMultiFileParser(), ConfigParser::parseFile(), skipComment(), and stopParsing().