213 size_t sizePatern(patern.size());
216 size_t beginTest(0lu), beginLine(0lu), beginI(0lu), nbMatch(0lu);
217 for(
size_t i(0lu); i < sizeSrc; ++i){
225 if(nbMatch == sizePatern){
256 bool skiptNextEnd(
false);
258 if(
isMatch(strNotBeforeEndPatern)){
259 out += strNotBeforeEndPatern;
261 }
else if(skiptNextEnd){
262 skiptNextEnd =
false;
284 const PString & allowedCharAfterBegin)
290 long int nbEmbeded(1lu);
300 }
else if(
isMatch(beginPatern)){
327 long int nbEmbeded(1lu);
328 bool skiptNextEnd(
false);
333 }
else if(skiptNextEnd){
334 skiptNextEnd =
false;
345 }
else if(
isMatch(beginPatern)){
368 long int nbEmbeded(1l);
378 }
else if(
isMatch(beginPatern)){
396 if(tmpWhiteSpace !=
""){
400 bool isInCharSet(
true);
403 isInCharSet = charset.
find(ch);
419 size_t indexBeginRow(currentCharIndex);
420 size_t indexEndRow(currentCharIndex);
426 if(ch ==
'\n' && indexBeginRow != 0lu){
429 while(
p_fileContent[indexBeginRow] !=
'\n' && indexBeginRow != 0lu){
433 return p_fileContent.substr(indexBeginRow, indexEndRow - indexBeginRow);
444 size_t nbCharPatern(patern.size());
448 while(match && i < nbCharPatern){
477 PVecString::const_iterator it(patern.begin());
478 bool matchPatern(
true);
479 while(it != patern.end() && matchPatern){
483 if(!matchPatern || alwaysPopBack){
516 PString letterNumberUnderscore(
"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
537 if(patern.size() == 0lu)
return "";
538 PVecString::const_iterator it(patern.begin());
539 while(it != patern.end()){
551 if(patern.size() == 0lu)
return "";
552 PVecString::const_iterator it(patern.begin());
553 while(it != patern.end()){
565 if(patern.size() == 0lu)
return "";
566 std::vector<PVecString >::const_iterator itList(patern.begin());
567 while(itList != patern.end()){
568 PVecString::const_iterator it(itList->begin());
569 while(it != itList->end()){
586 PVecParseStep::const_iterator itStep(vecStep.begin());
587 bool isParseNextStep(
true);
588 while(itStep != vecStep.end() && isParseNextStep){
589 isParseNextStep = itStep->getIsOptional();
591 bool isMatchedCmd(
false);
592 PVecParseCmd::const_iterator itCmd(vecCmd.begin());
593 while(itCmd != vecCmd.end() && !isMatchedCmd){
595 if(itCmd->getIsMatch()){
607 isParseNextStep |= isMatchedCmd;
610 if(!isParseNextStep){
768 bool currentCharEchaped(
false);
769 for(
size_t i(0lu); i < nbChar || currentCharEchaped; ++i){
774 currentCharEchaped =
true;
776 currentCharEchaped =
false;
std::ostream & operator<<(std::ostream &out, const PFileParser &other)
Définition de l'opérateur de flux sortant.
std::vector< PParseCmd > PVecParseCmd
std::vector< PParseStep > PVecParseStep
std::vector< PString > PVecString
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
size_t getLine() const
Fonction qui renvoie le numéro de la ligne courante.
PFileParser()
Constructeur de PFileParser.
std::vector< size_t > p_vecPosition
Vector of all the checkpoint positions in the text file (added with pushPosition() and removed with p...
virtual ~PFileParser()
Destructeur de PFileParser.
void skipChars(const PString &chToSkip)
Skip the characters in the given string.
bool isWhiteSpace()
Says if the current char is a white space.
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.
bool isChSpace() const
Dis si le caractère courant est un caractère blanc.
bool p_dontSkipSpace
Say if we don't want to skip the spaces.
PString getUntilKeyWithoutPaternExclude(const PString &patern, const PString &strNotBeforeEndPatern)
Parse a string until the patern is found, only if it has not strNotBeforeEndPatern before it.
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 getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.
void incrementCurrentChar(size_t nbChar=1lu)
Increment the current caracter.
void setEscapeChar(char escapeChar)
Sets the escape character of the PFileParser.
void clear()
Clear the save position of the parser in ther current file.
PString getWhiteSpace() const
renvoie la liste des caractères blancs
PString getSeparator() const
renvoie la liste des caractères séparateurs
PString getUntilKeyWithoutPaternRecurse(const PString &patern, const PString &beginPatern, const PString &allowedCharAfterBegin)
Get the string until end sequence and take account recursive patern (embeded strings)
void setLine(size_t currentLine)
Set the current line of the PFileParser.
PString getStrComposedOf(const PString &charset)
Get string composed of the characters in the string charset.
PString p_listSeparator
liste des séparateurs
void setWhiteSpace(const PString &whiteSpace)
Initialise la liste des caractères blancs.
bool isMatchRewind(const PString &patern)
Do a isMatch and then go back at the previous position.
std::vector< size_t > p_vecLine
Vector of all the checkpoint rows in the text file (added with pushPosition() and removed with popPos...
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.
char getCurrentCh() const
Renvoie le caractère courant.
char p_echapChar
Echap caracter.
size_t getLineIndentation()
Get the current line indentation.
void popPosition()
Get to the last saved position of the PFileParser in the current file.
size_t p_nbTotalChar
Nombre de caractères total.
PPath p_fileName
Nom du fichier que l'on veut parser.
PString getUntilKey(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern comprise.
void initialisationPFileParser()
Fonction d'initialisation du PFileParser.
void incrementCurrentLine()
Increment the current line.
PString p_fileContent
Contenu du fichier de configuration.
PLocation getLocation() const
Fonction qui renvoie la PLocation du PFileParser.
PPath getFileName() const
Fonction qui renvoie le nom du fichier que l'on a ouvert.
bool isChSeparator() const
Dis si le caractère courant est un séparateur.
void setColumn(size_t currentCol)
Set the current column of the PFileParser.
size_t p_currentLineFirstColumn
Number of the first column caracter of the current line.
void setLocation(const PLocation &location)
Set the current location of the PFileParser.
PString p_listWhiteSpace
liste des espaces blancs
void skipWhiteSpace()
Skip the white space if there is at the current caracter position.
void setFileContent(const PString &fileContent)
Set the file content.
void pushPosition()
Remember the current position of the PFileParser in the current file.
size_t p_currentChar
Numéro du caractère courant.
size_t p_currentLine
Numéro de la ligne courante.
PString getUntilKeyWithoutPaternRecurseExclude(const PString &patern, const PString &beginPatern, const PString &echapExpr)
Get the string until end sequence and take account recursive patern (embeded strings)
char getPrevCh() const
Renvoie le caractère courant.
size_t getCurrentCharIdx() const
Return the index of the current character.
bool isEndOfFile() const
Dit si on est à la fin du fichier.
char getEscapeChar() const
Gets the escape character of the PFileParser.
size_t getNbTotalChar() const
Return the number of characters in the current opened file.
char getNextChar()
Fonction qui renvoie le prochain caractère du fichier courant.
Classe qui permet de décrire une localisation, avec un nom de fichier et une ligne.
size_t getLine() const
renvoie la ligne du PLocation
PPath getFileName() const
renvoie le fichier du PLocation
size_t getColumn() const
renvoie la colonne du PLocation
const std ::vector< PParseStep > & getVecStep() const
Get the variable p_vecStep.
Path of a directory or a file.
PString loadFileContent() const
Get the file content in a PString.
PString eraseChar(char ch) const
Erase char ch of current string.
bool find(char ch) const
Find a char in a string.