GCC Code Coverage Report


Directory: ./
File: src/PFileParser.h
Date: 2025-09-08 16:55:04
Exec Total Coverage
Lines: 0 0 -%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #ifndef __PFILE_PARSER_H__
8 #define __PFILE_PARSER_H__
9
10 #include <iostream>
11 #include <vector>
12 #include <map>
13
14 #include "PPath.h"
15
16 #include "PParseSeqDef.h"
17 #include "PLocation.h"
18
19 ///@brief classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
20 class PFileParser{
21 public:
22 PFileParser();
23 virtual ~PFileParser();
24
25 bool open(const PPath & fileName);
26
27 void setWhiteSpace(const PString & whiteSpace);
28 void setSeparator(const PString & separator);
29 void setFileContent(const PString & fileContent);
30 void setEscapeChar(char escapeChar);
31 void setLocation(const PLocation & location);
32 void setLine(size_t currentLine);
33 void setColumn(size_t currentCol);
34 bool isEndOfFile() const;
35
36 void pushPosition();
37 void popPosition();
38 void clear();
39
40 bool isChSpace() const;
41 bool isChSeparator() const;
42 char getEscapeChar() const;
43
44 PPath getFileName() const;
45 PString getNextToken();
46 PString getNextToken(PString & skippedStr);
47
48 char getNextChar();
49
50 PString getUntilKey(const PString & patern);
51 PString getUntilKeyWithoutPatern(const PString & patern);
52 PString getUntilKeyWithoutPaternExclude(const PString & patern, const PString & strNotBeforeEndPatern);
53 PString getUntilKeyWithoutPaternRecurse(const PString & patern, const PString & beginPatern, const PString & allowedCharAfterBegin);
54 PString getUntilKeyWithoutPaternRecurseExclude(const PString & patern, const PString & beginPatern,
55 const PString & echapExpr);
56 PString getUntilKeyWithoutPaternRecurse(const PString & patern, const PString & beginPatern);
57 PString getStrComposedOf(const PString & charset);
58 PString getCurrentRow() const;
59
60 bool isMatch(const PString & patern);
61 bool isMatchRewind(const PString & patern);
62 bool isMatchSeq(const PVecString & patern, bool alwaysPopBack = false);
63 bool isMatch(const PString & patern, const PString & forbiddenCharBefore);
64 bool isMatchToken(const PString & patern);
65 PString isMatch(const PVecString & patern);
66 PString isMatchToken(const PVecString & patern);
67
68 template<typename T>
69 bool isMatchToken(PString & matchKey, T & matchValue, const std::map<PString, T> & patern);
70
71 PString isMatch(const std::vector<PVecString > & patern);
72 PString isMatch(const PParseSeq & seq);
73
74 bool isWhiteSpace();
75 void skipWhiteSpace();
76 void skipChars(const PString & chToSkip);
77 PString getWhiteSpace() const;
78 PString getSeparator() const;
79 char getCurrentCh() const;
80 char getPrevCh() const;
81 size_t getLine() const;
82 size_t getColumn() const;
83
84 size_t getNbTotalChar() const;
85 size_t getCurrentCharIdx() const;
86 size_t getLineIndentation();
87
88 PLocation getLocation() const;
89
90 friend std::ostream & operator << (std::ostream & out, const PFileParser & other);
91
92 private:
93 void initialisationPFileParser();
94 void incrementCurrentLine();
95 void incrementCurrentChar(size_t nbChar = 1lu);
96 ///Nom du fichier que l'on veut parser
97 PPath p_fileName;
98 ///Contenu du fichier de configuration
99 PString p_fileContent;
100 ///Numéro du caractère courant
101 size_t p_currentChar;
102 ///Nombre de caractères total
103 size_t p_nbTotalChar;
104 ///Numéro de la ligne courante
105 size_t p_currentLine;
106 ///Number of the first column caracter of the current line
107 size_t p_currentLineFirstColumn;
108 ///liste des espaces blancs
109 PString p_listWhiteSpace;
110 ///liste des séparateurs
111 PString p_listSeparator;
112 ///Echap caracter
113 char p_echapChar;
114 ///Vector of all the checkpoint positions in the text file (added with pushPosition() and removed with popPosition() or clear()
115 std::vector<size_t> p_vecPosition;
116 ///Vector of all the checkpoint rows in the text file (added with pushPosition() and removed with popPosition() or clear()
117 std::vector<size_t> p_vecLine;
118 ///Say if we don't want to skip the spaces
119 bool p_dontSkipSpace;
120 ///True if the current char is escaped
121 bool p_currentCharEchaped;
122 };
123
124 #include "PFileParser_impl.h"
125
126 #endif
127