28 if(configFile ==
"")
return false;
34 std::cerr <<
"PMultiFileParser::load : can't open file '" << configFile <<
"'" << std::endl;
59 std::cerr <<
"PMultiFileParser::fullParsing : the parser is not initialised, please call PMultiFileParser::load or PMultiFileParser::setFileContent before this function" << std::endl;
63 bool isParseGood(
true);
68 std::cerr <<
"PMultiFileParser::fullParsing : the parser is stucked at the position :" << std::endl <<
"\t" <<
p_parser->
getLocation() << std::endl;
133 std::cerr <<
"PMultiFileParser::parseFile : unexpected token '"<<
p_parser->
getNextToken()<<
"'" << std::endl;
143 std::cerr <<
"^" << std::endl;
154 std::cerr <<
"Unexpected token '"<<
p_currentToken<<
"'" << std::endl;
155 std::cerr <<
"Expected token '"<<tokenExpected<<
"'" << std::endl;
156 if(tokenBefore !=
"") std::cerr <<
" after " << tokenBefore << std::endl;
170 std::cerr <<
"Expected token '"<<tokenExpected<<
"'" << std::endl;
171 if(tokenBefore !=
"") std::cerr <<
" after " << tokenBefore << std::endl;
178 bool isCommentFound(
false);
180 isCommentFound =
false;
185 isCommentFound =
true;
284 bool currentTokenIsComment(
true);
287 currentTokenIsComment =
false;
291 currentTokenIsComment =
true;
std::pair< PString, PString > PMultiCommentConfig
Describes a comment config.
#define MULTI_PARSER_SEPARATORS_STRING
std::vector< PString > PVecString
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
bool isMatchSeq(const PVecString &patern, bool alwaysPopBack=false)
Match a sequence of token in a vector.
bool open(const PPath &fileName)
Fonction qui ouvre le fichier que l'on va parser.
PString getCurrentRow() const
Get the current parsed row.
size_t getColumn() const
Fonction qui renvoie le numéro de la colonne du caractère courant.
PString getNextToken()
Get the next token.
PString getStrComposedOf(const PString &charset)
Get string composed of the characters in the string charset.
bool isMatchRewind(const PString &patern)
Do a isMatch and then go back at the previous position.
bool isMatchToken(const PString &patern)
Says if the patern match with the current caracters of the PFileParser but treats the string as a tok...
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
PString getUntilKey(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern comprise.
PLocation getLocation() const
Fonction qui renvoie la PLocation du PFileParser.
void setFileContent(const PString &fileContent)
Set the file content.
size_t getCurrentCharIdx() const
Return the index of the current character.
bool isEndOfFile() const
Dit si on est à la fin du fichier.
void setFileContent(const PString &fileContent)
Set the file content to be parsed.
bool isMatchSeq(const PVecString &patern, bool alwaysPopBack=false)
Match a sequence of token in a vector.
virtual ~PMultiFileParser()
Destructeur of PMultiFileParser.
void getCurrentTokenWithoutComment()
Get the current token and skip the comment.
const PString & getLastComment() const
Get the last comment.
virtual void postLoadFile()
Post load file.
PMultiFileParser(const PPath &inputDirectory=PPath(), const PPath &outputDirectory=PPath())
Default constructeur of PMultiFileParser.
PString isMatchToken(const PVecString &vecToken)
Check the matching between the current caracters and all the string in the vector but treats the stri...
PPath p_inputDirectory
Input directory of the parser.
bool load(const PPath &configFile)
Load the PMultiFileParser with the configFile.
virtual bool parseFile()=0
void clearComment()
Clear comment.
PString getStrComposedOf(const PString &charset)
Get the string composed of charset charcters.
virtual void preLoadFile()
Pre load file.
std::list< PFileParser > p_listFileParser
List of all the parsers for all the loaded files.
bool isMatch(const PString &token)
Check if the given token matches the current read file.
void errorAt()
Write a parsing error.
void initialisationPMultiFileParser(const PPath &inputDirectory, const PPath &outputDirectory)
Initialisation function of the class PMultiFileParser.
void unexpectedToken()
Print unexpected token error.
PString p_lastComment
last comment
void pointAtRow()
Point the problem.
bool checkExpectedToken(const PString &tokenExpected, const PString &tokenBefore="")
Check if the p_currentToken == tokenExpected.
PFileParser * p_parser
Parser helper for the config file.
bool fullParsing()
Perform the full parsing pf data.
bool p_run
Run the parsing if true.
void addCommentConfig(const PMultiCommentConfig &commentConfig)
Adds a comment config for the parser.
bool isMatchRewind(const PString &token)
Check if the given token matches the current read file and goes back even if the token matches.
PListMultiCommentConfig p_listCommentConfig
Defines the differents comments we allow in the parsing.
void stopParsing()
Stop the parsing of all the files.
bool checkExpectedMatch(const PString &tokenExpected, const PString &tokenBefore="")
Check if the tokenExpected match.
PFileParser * getCurrentParser()
Gets the current parser.
PString p_currentToken
CurrentToken parsed.
PPath p_outputDirectory
Output directory of the parser.
void skipComment()
Skip comment.
Path of a directory or a file.