156 PString dummySkipedStr(
"");
220 size_t sizePatern(patern.size());
223 size_t beginTest(0lu), beginLine(0lu), beginI(0lu), nbMatch(0lu);
224 for(
size_t i(0lu); i < sizeSrc; ++i){
232 if(nbMatch == sizePatern){
263 bool skiptNextEnd(
false);
265 if(
isMatch(strNotBeforeEndPatern)){
266 out += strNotBeforeEndPatern;
268 }
else if(skiptNextEnd){
269 skiptNextEnd =
false;
291 const PString & allowedCharAfterBegin)
297 long int nbEmbeded(1lu);
307 }
else if(
isMatch(beginPatern)){
328 const PString & echapExpr)
334 long int nbEmbeded(1lu);
335 bool skiptNextEnd(
false);
340 }
else if(skiptNextEnd){
341 skiptNextEnd =
false;
352 }
else if(
isMatch(beginPatern)){
375 long int nbEmbeded(1l);
385 }
else if(
isMatch(beginPatern)){
403 if(tmpWhiteSpace !=
""){
407 bool isInCharSet(
true);
410 isInCharSet = charset.find(ch);
426 size_t indexBeginRow(currentCharIndex);
427 size_t indexEndRow(currentCharIndex);
433 if(ch ==
'\n' && indexBeginRow != 0lu){
436 while(
p_fileContent[indexBeginRow] !=
'\n' && indexBeginRow != 0lu){
440 return p_fileContent.substr(indexBeginRow, indexEndRow - indexBeginRow);
451 size_t nbCharPatern(patern.size());
455 while(match && i < nbCharPatern){
484 PVecString::const_iterator it(patern.begin());
485 bool matchPatern(
true);
486 while(it != patern.end() && matchPatern){
490 if(!matchPatern || alwaysPopBack){
523 PString letterNumberUnderscore(
"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
544 if(patern.size() == 0lu)
return "";
545 PVecString::const_iterator it(patern.begin());
546 while(it != patern.end()){
558 if(patern.size() == 0lu)
return "";
559 PVecString::const_iterator it(patern.begin());
560 while(it != patern.end()){
572 if(patern.size() == 0lu)
return "";
573 std::vector<PVecString >::const_iterator itList(patern.begin());
574 while(itList != patern.end()){
575 PVecString::const_iterator it(itList->begin());
576 while(it != itList->end()){
593 PVecParseStep::const_iterator itStep(vecStep.begin());
594 bool isParseNextStep(
true);
595 while(itStep != vecStep.end() && isParseNextStep){
596 isParseNextStep = itStep->getIsOptional();
598 bool isMatchedCmd(
false);
599 PVecParseCmd::const_iterator itCmd(vecCmd.begin());
600 while(itCmd != vecCmd.end() && !isMatchedCmd){
601 PString str(itCmd->getStr());
602 if(itCmd->getIsMatch()){
614 isParseNextStep |= isMatchedCmd;
617 if(!isParseNextStep){
785 for(
size_t i(0lu); i < nbChar; ++i){
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
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.
PString getWhiteSpace() const
renvoie la liste des caractères blancs
void setCurrentCharIdx(size_t index)
Set the index of the current char.
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)
char getChar(size_t index) const
Get the char at the given index.
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 p_currentCharEchaped
True if the current char is escaped.
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.
void clearPosition()
Clear the save position of the parser in ther current file.
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
const 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.