GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixPresentation/tmp_project/PhoenixInkscape/tmp_project/PhoenixFileParser/src/PFileParser.cpp
Date: 2025-07-04 20:24:11
Exec Total Coverage
Lines: 396 421 94.1%
Branches: 402 493 81.5%

Line Branch Exec Source
1
2 /***************************************
3 Auteur : Pierre Aubert
4 Mail : pierre.aubert@lapp.in2p3.fr
5 Licence : CeCILL-C
6 ****************************************/
7
8 #include "PFileParser.h"
9
10 ///Constructeur de PFileParser
11
3/3
✓ Branch 2 taken 55290 times.
✓ Branch 5 taken 55290 times.
✓ Branch 8 taken 55290 times.
55290 PFileParser::PFileParser(){
12
1/1
✓ Branch 1 taken 55290 times.
55290 initialisationPFileParser();
13 55290 }
14
15 ///Destructeur de PFileParser
16 112790 PFileParser::~PFileParser(){
17
18 }
19
20 ///Fonction qui ouvre le fichier que l'on va parser
21 /** @param fileName : nom du fichier à ouvrir
22 * @return true si la fonction à réussie, false sinon
23 */
24 360 bool PFileParser::open(const PPath & fileName){
25 360 p_fileName = fileName;
26
1/1
✓ Branch 2 taken 360 times.
360 p_fileContent = fileName.loadFileContent();
27 360 p_nbTotalChar = p_fileContent.size();
28 360 return (p_fileContent != "");
29 }
30
31 ///Initialise la liste des caractères blancs
32 /** @param whiteSpace : liste des caractères blancs
33 * Se sont les caractères que l'on ne prend jamais en compte
34 */
35 9225843 void PFileParser::setWhiteSpace(const PString & whiteSpace){
36 9225843 p_listWhiteSpace = whiteSpace;
37 9225843 }
38
39 ///Initialise la liste des caractères séparateurs
40 /** @param separator : liste des caractères séparateurs
41 * Se sont les caractères que l'on ne prend en compte un par un
42 */
43 3130347 void PFileParser::setSeparator(const PString & separator){
44 3130347 p_listSeparator = separator;
45 3130347 }
46
47 ///Set the file content
48 /** @param fileContent : file content
49 */
50 54931 void PFileParser::setFileContent(const PString & fileContent){
51 54931 p_fileContent = fileContent;
52 54931 p_nbTotalChar = p_fileContent.size();
53 54931 }
54
55 ///Sets the escape character of the PFileParser
56 /** @param escapeChar : escape character of the PFileParser
57 */
58 5848 void PFileParser::setEscapeChar(char escapeChar){
59 5848 p_echapChar = escapeChar;
60 5848 }
61
62 ///Set the current location of the PFileParser
63 /** @param location : current location of the PFileParser
64 */
65 1 void PFileParser::setLocation(const PLocation & location){
66 1 setLine(location.getLine());
67 1 setColumn(location.getColumn());
68
1/1
✓ Branch 2 taken 1 times.
1 p_fileName = location.getFileName();
69 1 }
70
71 ///Set the current line of the PFileParser
72 /** @param currentLine : current line of the PFileParser
73 */
74 2 void PFileParser::setLine(size_t currentLine){
75 2 p_currentLine = currentLine;
76 2 }
77
78 ///Set the current column of the PFileParser
79 /** @param currentCol : current column of the PFileParser
80 */
81 2 void PFileParser::setColumn(size_t currentCol){
82 2 p_currentLineFirstColumn = currentCol;
83 2 }
84
85 ///Dit si on est à la fin du fichier
86 /** @return true si on est à la fin du fichier, false sinon
87 */
88 104834330 bool PFileParser::isEndOfFile() const{
89 104834330 return (p_currentChar >= p_nbTotalChar);
90 }
91
92 ///Remember the current position of the PFileParser in the current file
93 15094124 void PFileParser::pushPosition(){
94 15094124 p_vecPosition.push_back(p_currentChar);
95 15094124 p_vecLine.push_back(p_currentLine);
96 15094124 }
97
98 ///Get to the last saved position of the PFileParser in the current file
99 13900028 void PFileParser::popPosition(){
100
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 13900027 times.
13900028 if(p_vecPosition.size() == 0lu){
101 1 return;
102 }
103 13900027 p_currentChar = p_vecPosition.back();
104 13900027 p_currentLine = p_vecLine.back();
105 13900027 p_vecPosition.pop_back();
106 13900027 p_vecLine.pop_back();
107 }
108
109 ///Clear the save position of the parser in ther current file
110 1 void PFileParser::clear(){
111 1 p_vecPosition.clear();
112 1 p_vecLine.clear();
113 1 }
114
115 ///Dis si le caractère courant est un caractère blanc
116 /** @return true si caractère courant est un caractère blanc
117 */
118 3 bool PFileParser::isChSpace() const{
119
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if(isEndOfFile()) return false;
120 3 return p_listWhiteSpace.find(p_fileContent[p_currentChar]);
121 }
122
123 ///Dis si le caractère courant est un séparateur
124 /** @return true si caractère courant est un séparateur
125 */
126 3 bool PFileParser::isChSeparator() const{
127
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if(isEndOfFile()) return false;
128 3 return p_listSeparator.find(p_fileContent[p_currentChar]);
129 }
130
131 ///Gets the escape character of the PFileParser
132 /** @return escape character of the PFileParser
133 */
134 232 char PFileParser::getEscapeChar() const{
135 232 return p_echapChar;
136 }
137
138 ///Fonction qui renvoie le nom du fichier que l'on a ouvert
139 /** @return nom du fichier que l'on a ouvert
140 */
141 1394 PPath PFileParser::getFileName() const{
142 1394 return p_fileName;
143 }
144
145 ///Get the next token
146 /** @return next token
147 */
148 12702 PString PFileParser::getNextToken(){
149
1/1
✓ Branch 1 taken 12702 times.
12702 PString dummySkipedStr("");
150
1/1
✓ Branch 1 taken 12702 times.
25404 return getNextToken(dummySkipedStr);
151 12702 }
152
153 ///Get the next token and return also the skipped characters until the next token
154 /** @param[out] skippedStr : string of skipped characters
155 * @return next token
156 */
157 13714 PString PFileParser::getNextToken(PString & skippedStr){
158
4/4
✓ Branch 1 taken 13714 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 13704 times.
✓ Branch 6 taken 10 times.
13714 if(isEndOfFile()) return "";
159
1/1
✓ Branch 1 taken 13704 times.
13704 char ch = p_fileContent[p_currentChar];
160
7/8
✓ Branch 1 taken 23684 times.
✓ Branch 3 taken 23684 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23684 times.
✓ Branch 8 taken 9983 times.
✓ Branch 9 taken 13701 times.
✓ Branch 10 taken 9983 times.
✓ Branch 11 taken 13701 times.
23684 while(!isEndOfFile() && p_listWhiteSpace.find(ch)){
161
1/1
✓ Branch 1 taken 9983 times.
9983 skippedStr += ch;
162
1/1
✓ Branch 1 taken 9983 times.
9983 incrementCurrentChar();
163
4/4
✓ Branch 1 taken 9983 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 9980 times.
✓ Branch 6 taken 3 times.
9983 if(isEndOfFile()) return "";
164
1/1
✓ Branch 1 taken 9980 times.
9980 ch = p_fileContent[p_currentChar];
165 }
166 //We are sur ethe current char is not a white character
167
7/8
✓ Branch 1 taken 13701 times.
✓ Branch 3 taken 8522 times.
✓ Branch 4 taken 5179 times.
✓ Branch 6 taken 8522 times.
✓ Branch 8 taken 8522 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8522 times.
✓ Branch 11 taken 5179 times.
13701 if(p_listSeparator.find(ch) && !isEndOfFile()){ //If is it a separator, we stop
168
1/1
✓ Branch 1 taken 8522 times.
8522 incrementCurrentChar();
169
1/1
✓ Branch 1 taken 8522 times.
8522 PString s("");
170
1/1
✓ Branch 1 taken 8522 times.
8522 s += ch;
171
1/1
✓ Branch 1 taken 8522 times.
8522 return s;
172 8522 }
173 //If not we get all characters until the next white character or separator character
174
1/1
✓ Branch 1 taken 5179 times.
5179 PString buf("");
175
10/11
✓ Branch 1 taken 32843 times.
✓ Branch 3 taken 32843 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 32843 times.
✓ Branch 8 taken 28735 times.
✓ Branch 9 taken 4108 times.
✓ Branch 11 taken 28735 times.
✓ Branch 13 taken 27668 times.
✓ Branch 14 taken 1067 times.
✓ Branch 15 taken 27668 times.
✓ Branch 16 taken 5175 times.
32843 while(!isEndOfFile() && !p_listWhiteSpace.find(ch) && !p_listSeparator.find(ch)){
176
1/1
✓ Branch 1 taken 27668 times.
27668 buf += ch;
177
1/1
✓ Branch 1 taken 27668 times.
27668 incrementCurrentChar();
178
4/4
✓ Branch 1 taken 27668 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 27664 times.
✓ Branch 6 taken 4 times.
27668 if(isEndOfFile()){return buf;}
179
1/1
✓ Branch 1 taken 27664 times.
27664 ch = p_fileContent[p_currentChar];
180 }
181
1/1
✓ Branch 1 taken 5175 times.
5175 return buf;
182 5179 }
183
184 ///Fonction qui renvoie le prochain caractère du fichier courant
185 /** @return prochain caractère du fichier courant ou le caractère NULL si on est à la fin
186 */
187 1621985 char PFileParser::getNextChar(){
188 1621985 incrementCurrentChar();
189
2/2
✓ Branch 0 taken 1598092 times.
✓ Branch 1 taken 23893 times.
1621985 if(p_currentChar < p_nbTotalChar){
190 1598092 char ch = p_fileContent[p_currentChar];
191 1598092 return ch;
192 }else{
193 23893 p_currentChar = p_nbTotalChar;
194 23893 return '\0';
195 }
196 }
197
198 ///Renvoie la chaine de caractère du caractère courant jusqu'à patern comprise
199 /** @param patern : séquence d'arrêt
200 * @return chaine de caractère du caractère courant jusqu'à patern comprise
201 */
202 1716 PString PFileParser::getUntilKey(const PString & patern){
203
6/8
✓ Branch 1 taken 1715 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1715 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1715 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1715 times.
1716 if(patern == "" || p_nbTotalChar == 0lu || isEndOfFile()) return "";
204
2/2
✓ Branch 2 taken 1715 times.
✓ Branch 5 taken 1715 times.
3430 return getUntilKeyWithoutPatern(patern) + patern;
205 }
206
207 ///Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu
208 /** @param patern : séquence d'arrêt
209 * @return chaine de caractère du caractère courant jusqu'à patern exclu
210 */
211 6598033 PString PFileParser::getUntilKeyWithoutPatern(const PString & patern){
212
8/10
✓ Branch 1 taken 6598033 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6598033 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 6598033 times.
✓ Branch 8 taken 134 times.
✓ Branch 9 taken 6597899 times.
✓ Branch 10 taken 134 times.
✓ Branch 11 taken 6597899 times.
✓ Branch 13 taken 134 times.
6598033 if(patern == "" || p_nbTotalChar == 0lu || isEndOfFile()) return "";
213 6597899 size_t sizePatern(patern.size());
214
1/1
✓ Branch 2 taken 6597899 times.
6597899 std::string out(""); //on évite les petits désagréments
215 6597899 size_t sizeSrc(p_nbTotalChar - p_currentChar);
216 6597899 size_t beginTest(0lu), beginLine(0lu), beginI(0lu), nbMatch(0lu);
217
2/2
✓ Branch 0 taken 49884891 times.
✓ Branch 1 taken 31259 times.
49916150 for(size_t i(0lu); i < sizeSrc; ++i){
218
7/7
✓ Branch 1 taken 49884891 times.
✓ Branch 4 taken 6597130 times.
✓ Branch 5 taken 43287761 times.
✓ Branch 6 taken 6597124 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 6597124 times.
✓ Branch 9 taken 43287767 times.
49884891 if(p_fileContent[p_currentChar] == patern[nbMatch] && !p_currentCharEchaped){ //si le caractère i est le même que le caractère nbMatch
219
2/2
✓ Branch 0 taken 6570343 times.
✓ Branch 1 taken 26781 times.
6597124 if(nbMatch == 0lu){ //c'est le premier qu'on teste
220 6570343 beginTest = p_currentChar; //il faut donc se rappeler où on a commencer à faire le test
221 6570343 beginLine = p_currentLine;
222 6570343 beginI = i;
223 }
224 6597124 ++nbMatch; //la prochaîne fois on testera le caractère suivant
225
2/2
✓ Branch 0 taken 6566640 times.
✓ Branch 1 taken 30484 times.
6597124 if(nbMatch == sizePatern){ //dans ce cas, on a tout testé et tout les caractères correspondent, donc on sauvegarde
226
1/1
✓ Branch 1 taken 6566640 times.
6566640 incrementCurrentChar();
227
1/1
✓ Branch 1 taken 6566640 times.
6566640 return out;
228 }
229 }else{ //si le caractère i n'est pas le même caractère que nbMatch
230
2/2
✓ Branch 0 taken 43284065 times.
✓ Branch 1 taken 3702 times.
43287767 if(nbMatch == 0lu){ //si on n'en avait pas trouver de bon avant
231
2/2
✓ Branch 1 taken 43284065 times.
✓ Branch 4 taken 43284065 times.
43284065 out += p_fileContent[p_currentChar]; //on ne change rien à ce caractère
232 }else{ //si on avais déjà tester des caractères avant
233
2/2
✓ Branch 1 taken 3702 times.
✓ Branch 4 taken 3702 times.
3702 out += p_fileContent[beginTest];
234 3702 p_currentChar = beginTest;
235 3702 p_currentLine = beginLine;
236 3702 i = beginI;
237 }
238 43287767 beginTest = 0lu; //on remet le début des tests à 0 (pour évité les dépassements, on ne sait jamais)
239 43287767 nbMatch = 0lu; //on remet ne nombre des tests à 0, comme on n'a pas trouver de nouveau le motif
240 }
241
1/1
✓ Branch 1 taken 43318251 times.
43318251 incrementCurrentChar();
242 }
243
1/1
✓ Branch 1 taken 31259 times.
31259 return out;
244 6597899 }
245
246 ///Parse a string until the patern is found, only if it has not strNotBeforeEndPatern before it
247 /** @param patern : patern to be found
248 * @param strNotBeforeEndPatern : string which cannot be found before the patern, otherwise the patern is not considered as the end
249 * @return string unit patern, without it
250 */
251 142 PString PFileParser::getUntilKeyWithoutPaternExclude(const PString & patern, const PString & strNotBeforeEndPatern){
252
5/11
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 142 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 142 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 142 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
142 if(patern == "" || p_nbTotalChar == 0lu || isEndOfFile()) return "";
253
1/1
✓ Branch 2 taken 142 times.
142 std::string out(""); //on évite les petits désagréments
254 142 bool prevSkipSpace(p_dontSkipSpace);
255 142 p_dontSkipSpace = true;
256 142 bool skiptNextEnd(false);
257
2/3
✓ Branch 1 taken 2419 times.
✓ Branch 3 taken 2419 times.
✗ Branch 4 not taken.
2419 while(!isEndOfFile()){
258
3/3
✓ Branch 1 taken 2419 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2418 times.
2419 if(isMatch(strNotBeforeEndPatern)){
259
1/1
✓ Branch 1 taken 1 times.
1 out += strNotBeforeEndPatern;
260 1 skiptNextEnd = true;
261
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2417 times.
2418 }else if(skiptNextEnd){
262 1 skiptNextEnd = false;
263
2/2
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
1 out += p_fileContent[p_currentChar];
264
1/1
✓ Branch 1 taken 1 times.
1 incrementCurrentChar();
265
3/3
✓ Branch 1 taken 2417 times.
✓ Branch 3 taken 142 times.
✓ Branch 4 taken 2275 times.
2417 }else if(isMatch(patern)){
266 142 p_dontSkipSpace = prevSkipSpace;
267
1/1
✓ Branch 1 taken 142 times.
142 return out;
268 }else{
269
2/2
✓ Branch 1 taken 2275 times.
✓ Branch 4 taken 2275 times.
2275 out += p_fileContent[p_currentChar];
270
1/1
✓ Branch 1 taken 2275 times.
2275 incrementCurrentChar();
271 }
272 }
273 p_dontSkipSpace = prevSkipSpace;
274 return out;
275 142 }
276
277 ///Get the string until end sequence and take account recursive patern (embeded strings)
278 /** @param patern : end patern
279 * @param beginPatern : definition of new embeded string
280 * @param allowedCharAfterBegin : characters allowed after the beginPatern
281 * @return output string
282 */
283 1 PString PFileParser::getUntilKeyWithoutPaternRecurse(const PString & patern, const PString & beginPatern,
284 const PString & allowedCharAfterBegin)
285 {
286
6/13
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
1 if(patern == "" || beginPatern == "" || p_nbTotalChar == 0lu || isEndOfFile()) return "";
287 1 bool prevSkipSpace(p_dontSkipSpace);
288 1 p_dontSkipSpace = true;
289
1/1
✓ Branch 2 taken 1 times.
1 std::string out("");
290 1 long int nbEmbeded(1lu);
291
2/3
✓ Branch 1 taken 34 times.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
34 while(!isEndOfFile()){
292
3/3
✓ Branch 1 taken 34 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 32 times.
34 if(isMatch(patern)){
293 2 --nbEmbeded;
294
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(nbEmbeded <= 0l){
295 1 p_dontSkipSpace = prevSkipSpace;
296
1/1
✓ Branch 1 taken 1 times.
1 return out;
297 }else{
298
1/1
✓ Branch 1 taken 1 times.
1 out += patern;
299 }
300
3/3
✓ Branch 1 taken 32 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 31 times.
32 }else if(isMatch(beginPatern)){
301
3/4
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 if(allowedCharAfterBegin.find(p_fileContent[p_currentChar])){
302
1/1
✓ Branch 1 taken 1 times.
1 out += beginPatern;
303 1 ++nbEmbeded;
304 }
305 }else{
306
2/2
✓ Branch 1 taken 31 times.
✓ Branch 4 taken 31 times.
31 out += p_fileContent[p_currentChar];
307
1/1
✓ Branch 1 taken 31 times.
31 incrementCurrentChar();
308 }
309 }
310 p_dontSkipSpace = prevSkipSpace;
311 return out;
312 1 }
313
314 ///Get the string until end sequence and take account recursive patern (embeded strings)
315 /** @param patern : end patern
316 * @param beginPatern : definition of new embeded string
317 * @param echapExpr : echap expression
318 * @return output string
319 */
320 2 PString PFileParser::getUntilKeyWithoutPaternRecurseExclude(const PString & patern, const PString & beginPatern,
321 const PString & echapExpr)
322 {
323
6/13
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
2 if(patern == "" || beginPatern == "" || p_nbTotalChar == 0lu || isEndOfFile()) return "";
324 2 bool prevSkipSpace(p_dontSkipSpace);
325 2 p_dontSkipSpace = true;
326
1/1
✓ Branch 2 taken 2 times.
2 std::string out("");
327 2 long int nbEmbeded(1lu);
328 2 bool skiptNextEnd(false);
329
2/3
✓ Branch 1 taken 32 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
32 while(!isEndOfFile()){
330
3/3
✓ Branch 1 taken 32 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 30 times.
32 if(isMatch(echapExpr)){
331
1/1
✓ Branch 1 taken 2 times.
2 out += echapExpr;
332 2 skiptNextEnd = true;
333
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
30 }else if(skiptNextEnd){
334 2 skiptNextEnd = false;
335
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 out += p_fileContent[p_currentChar];
336
1/1
✓ Branch 1 taken 2 times.
2 incrementCurrentChar();
337
3/3
✓ Branch 1 taken 28 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 26 times.
28 }else if(isMatch(patern)){
338 2 --nbEmbeded;
339
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(nbEmbeded <= 0l){
340 2 p_dontSkipSpace = prevSkipSpace;
341
1/1
✓ Branch 1 taken 2 times.
2 return out;
342 }else{
343 out += patern;
344 }
345
2/3
✓ Branch 1 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
26 }else if(isMatch(beginPatern)){
346 out += beginPatern;
347 ++nbEmbeded;
348 }else{
349
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
26 out += p_fileContent[p_currentChar];
350
1/1
✓ Branch 1 taken 26 times.
26 incrementCurrentChar();
351 }
352 }
353 p_dontSkipSpace = prevSkipSpace;
354 return out;
355 2 }
356
357 ///Get the string until end sequence and take account recursive patern (embeded strings)
358 /** @param patern : end patern
359 * @param beginPatern : definition of new embeded string
360 * @return output string
361 */
362 8344 PString PFileParser::getUntilKeyWithoutPaternRecurse(const PString & patern, const PString & beginPatern)
363 {
364
9/12
✓ Branch 1 taken 8344 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8344 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8344 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8344 times.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 8339 times.
✓ Branch 13 taken 5 times.
✓ Branch 14 taken 8339 times.
✓ Branch 16 taken 5 times.
8344 if(patern == "" || beginPatern == "" || p_nbTotalChar == 0lu || isEndOfFile()) return "";
365 8339 bool prevSkipSpace(p_dontSkipSpace);
366 8339 p_dontSkipSpace = true;
367
1/1
✓ Branch 2 taken 8339 times.
8339 std::string out("");
368 8339 long int nbEmbeded(1l);
369
3/3
✓ Branch 1 taken 185427 times.
✓ Branch 3 taken 185421 times.
✓ Branch 4 taken 6 times.
185427 while(!isEndOfFile()){
370
3/3
✓ Branch 1 taken 185421 times.
✓ Branch 3 taken 8858 times.
✓ Branch 4 taken 176563 times.
185421 if(isMatch(patern)){
371 8858 --nbEmbeded;
372
2/2
✓ Branch 0 taken 8333 times.
✓ Branch 1 taken 525 times.
8858 if(nbEmbeded <= 0l){
373 8333 p_dontSkipSpace = prevSkipSpace;
374
1/1
✓ Branch 1 taken 8333 times.
8333 return out;
375 }else{
376
1/1
✓ Branch 1 taken 525 times.
525 out += patern;
377 }
378
3/3
✓ Branch 1 taken 176563 times.
✓ Branch 3 taken 525 times.
✓ Branch 4 taken 176038 times.
176563 }else if(isMatch(beginPatern)){
379
1/1
✓ Branch 1 taken 525 times.
525 out += beginPatern;
380 525 ++nbEmbeded;
381 }else{
382
2/2
✓ Branch 1 taken 176038 times.
✓ Branch 4 taken 176038 times.
176038 out += p_fileContent[p_currentChar];
383
1/1
✓ Branch 1 taken 176038 times.
176038 incrementCurrentChar();
384 }
385 }
386 6 p_dontSkipSpace = prevSkipSpace;
387
1/1
✓ Branch 1 taken 6 times.
6 return out;
388 8339 }
389
390 ///Get string composed of the characters in the string charset
391 /** @param charset : set of the available characters to get the current string
392 * @return corresponding string
393 */
394 3534309 PString PFileParser::getStrComposedOf(const PString & charset){
395
1/1
✓ Branch 1 taken 3534309 times.
3534309 PString tmpWhiteSpace(p_listWhiteSpace.eraseChar(charset));
396
3/3
✓ Branch 1 taken 3534309 times.
✓ Branch 3 taken 420797 times.
✓ Branch 4 taken 3113512 times.
3534309 if(tmpWhiteSpace != ""){
397
1/1
✓ Branch 1 taken 420797 times.
420797 skipChars(tmpWhiteSpace);
398 }
399
1/1
✓ Branch 2 taken 3534309 times.
3534309 std::string out("");
400 3534309 bool isInCharSet(true);
401
7/7
✓ Branch 1 taken 28955841 times.
✓ Branch 3 taken 28955811 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 25421532 times.
✓ Branch 6 taken 3534279 times.
✓ Branch 7 taken 25421532 times.
✓ Branch 8 taken 3534309 times.
28955841 while(!isEndOfFile() && isInCharSet){
402
1/1
✓ Branch 1 taken 25421532 times.
25421532 char ch = p_fileContent[p_currentChar];
403
1/1
✓ Branch 1 taken 25421532 times.
25421532 isInCharSet = charset.find(ch);
404
2/2
✓ Branch 0 taken 21887253 times.
✓ Branch 1 taken 3534279 times.
25421532 if(isInCharSet){
405
1/1
✓ Branch 1 taken 21887253 times.
21887253 out += ch;
406
1/1
✓ Branch 1 taken 21887253 times.
21887253 incrementCurrentChar();
407 }
408 }
409
1/1
✓ Branch 1 taken 3534309 times.
7068618 return out;
410 3534309 }
411
412 ///Get the current parsed row
413 /** @return current parsed row
414 */
415 146 PString PFileParser::getCurrentRow() const{
416
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
146 if(p_fileContent.empty()) return "";
417 146 size_t currentCharIndex(p_currentChar);
418 146 char ch = p_fileContent[currentCharIndex];
419 146 size_t indexBeginRow(currentCharIndex);
420 146 size_t indexEndRow(currentCharIndex);
421
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 if(ch != '\n'){
422
5/6
✓ Branch 1 taken 3905 times.
✓ Branch 2 taken 146 times.
✓ Branch 4 taken 3905 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3905 times.
✓ Branch 7 taken 146 times.
4051 while(p_fileContent[indexEndRow] != '\n' && !isEndOfFile()){
423 3905 ++indexEndRow;
424 }
425 }
426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
146 if(ch == '\n' && indexBeginRow != 0lu){
427 --indexBeginRow;
428 }
429
6/6
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 649 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 649 times.
✓ Branch 6 taken 146 times.
795 while(p_fileContent[indexBeginRow] != '\n' && indexBeginRow != 0lu){
430 649 --indexBeginRow;
431 }
432
2/2
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 1 times.
146 if(p_fileContent[indexBeginRow] == '\n'){indexBeginRow++;}
433
1/1
✓ Branch 2 taken 146 times.
292 return p_fileContent.substr(indexBeginRow, indexEndRow - indexBeginRow);
434 }
435
436 ///Says if the patern match with the current caracters of the PFileParser
437 /** @param patern : patern we want to check (this patern should not begin with white caracters)
438 * @return true if the patern match, false otherwise
439 * If the patern match, the current char will be in the next char of the patern
440 */
441 55433935 bool PFileParser::isMatch(const PString & patern){
442
7/8
✓ Branch 1 taken 55286134 times.
✓ Branch 2 taken 147801 times.
✓ Branch 4 taken 55285629 times.
✓ Branch 5 taken 505 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 55285629 times.
✓ Branch 8 taken 148306 times.
✓ Branch 9 taken 55285629 times.
55433935 if(patern == "" || isEndOfFile() || p_currentCharEchaped) return false;
443 55285629 skipWhiteSpace();
444 55285629 size_t nbCharPatern(patern.size());
445
2/2
✓ Branch 0 taken 1849079 times.
✓ Branch 1 taken 53436550 times.
55285629 if(p_currentChar + nbCharPatern > p_nbTotalChar){return false;}
446 53436550 bool match = true;
447 53436550 size_t i(0lu);
448
4/4
✓ Branch 0 taken 83682868 times.
✓ Branch 1 taken 46401651 times.
✓ Branch 2 taken 76647969 times.
✓ Branch 3 taken 7034899 times.
130084519 while(match && i < nbCharPatern){
449 76647969 match = (patern[i] == p_fileContent[p_currentChar + i]);
450 76647969 ++i;
451 }
452
2/2
✓ Branch 0 taken 7034899 times.
✓ Branch 1 taken 46401651 times.
53436550 if(match){
453 7034899 incrementCurrentChar(nbCharPatern);
454 }
455 53436550 return match;
456 }
457
458 ///Do a isMatch and then go back at the previous position
459 /** @param patern : patern we want to check (this patern should not begin with white caracters)
460 * @return true if the patern match, false otherwise
461 * If the patern match, the current char will be in the next char of the patern
462 */
463 5556 bool PFileParser::isMatchRewind(const PString & patern){
464 5556 pushPosition();
465 5556 bool b = isMatch(patern);
466 5556 popPosition();
467 5556 return b;
468 }
469
470 ///Match a sequence of token in a vector
471 /** @param patern : set of token to match in this order and totally
472 * @param alwaysPopBack : true to make the PFileParser at the exact same place before the check even is the sequence matches
473 * @return true if the full sequence matches, false otherwise
474 */
475 2054062 bool PFileParser::isMatchSeq(const PVecString & patern, bool alwaysPopBack){
476
1/1
✓ Branch 1 taken 2054062 times.
2054062 pushPosition();
477 2054062 PVecString::const_iterator it(patern.begin());
478 2054062 bool matchPatern(true);
479
6/6
✓ Branch 2 taken 4126523 times.
✓ Branch 3 taken 990 times.
✓ Branch 4 taken 2073451 times.
✓ Branch 5 taken 2053072 times.
✓ Branch 6 taken 2073451 times.
✓ Branch 7 taken 2054062 times.
4127513 while(it != patern.end() && matchPatern){
480
1/1
✓ Branch 2 taken 2073451 times.
2073451 matchPatern = isMatch(*it);
481 2073451 ++it;
482 }
483
4/4
✓ Branch 0 taken 988 times.
✓ Branch 1 taken 2053074 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 978 times.
2054062 if(!matchPatern || alwaysPopBack){
484
1/1
✓ Branch 1 taken 2053084 times.
2053084 popPosition();
485 }
486 2054062 return matchPatern;
487 }
488
489 ///Says if the patern match with the current caracters of the PFileParser
490 /** @param patern : patern we want to check (this patern should not begin with white caracters)
491 * @param forbiddenCharBefore : lisr of characters which cannot be just before the first character of the patern
492 * @return true if the patern match, false otherwise
493 * If the patern match, the current char will be in the next char of the patern
494 */
495 332302 bool PFileParser::isMatch(const PString & patern, const PString & forbiddenCharBefore){
496
2/2
✓ Branch 0 taken 330160 times.
✓ Branch 1 taken 2142 times.
332302 if(p_currentChar > 0lu){
497 //If we find a forbidden character before the current char, the patern is canceled
498
2/2
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 330094 times.
330160 if(forbiddenCharBefore.find(p_fileContent[p_currentChar - 1lu])){
499 66 return false;
500 }
501 }
502 332236 return isMatch(patern);
503 }
504
505 ///Says if the patern match with the current caracters of the PFileParser but treats the string as a token (cannot be part of a word)
506 /** @param patern : patern we want to check (this patern should not begin with white caracters)
507 * @return true if the patern match, false otherwise
508 * If the patern match, the current char will be in the next char of the patern
509 */
510 10972299 bool PFileParser::isMatchToken(const PString & patern){
511
1/1
✓ Branch 1 taken 10972299 times.
10972299 pushPosition();
512
3/3
✓ Branch 1 taken 10972299 times.
✓ Branch 3 taken 10964157 times.
✓ Branch 4 taken 8142 times.
10972299 if(!isMatch(patern)){
513
1/1
✓ Branch 1 taken 10964157 times.
10964157 popPosition();
514 10964157 return false;
515 }
516
1/1
✓ Branch 1 taken 8142 times.
8142 PString letterNumberUnderscore("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
517
2/2
✓ Branch 1 taken 8040 times.
✓ Branch 2 taken 102 times.
8142 if(p_currentChar > patern.size()){
518
4/4
✓ Branch 2 taken 8040 times.
✓ Branch 5 taken 8040 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 8024 times.
8040 if(letterNumberUnderscore.find(p_fileContent[p_currentChar - patern.size() - 1lu])){
519
1/1
✓ Branch 1 taken 16 times.
16 popPosition();
520 16 return false;
521 }
522 }
523
2/2
✓ Branch 0 taken 8124 times.
✓ Branch 1 taken 2 times.
8126 if(p_nbTotalChar > p_currentChar){
524
4/4
✓ Branch 1 taken 8124 times.
✓ Branch 4 taken 8124 times.
✓ Branch 6 taken 38 times.
✓ Branch 7 taken 8086 times.
8124 if(letterNumberUnderscore.find(p_fileContent[p_currentChar])){
525
1/1
✓ Branch 1 taken 38 times.
38 popPosition();
526 38 return false;
527 }
528 }
529 8088 return true;
530 8142 }
531
532 ///Check the matching between the current caracters and all the string in the vector
533 /** @param patern : vector of the patern we want to check
534 * @return matching patern if there is one, empty string otherwise
535 */
536 1987712 PString PFileParser::isMatch(const PVecString & patern){
537
3/3
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1987711 times.
✓ Branch 4 taken 1 times.
1987712 if(patern.size() == 0lu) return "";
538 1987711 PVecString::const_iterator it(patern.begin());
539
2/2
✓ Branch 2 taken 17639700 times.
✓ Branch 3 taken 1965993 times.
19605693 while(it != patern.end()){
540
4/4
✓ Branch 2 taken 17639700 times.
✓ Branch 4 taken 21718 times.
✓ Branch 5 taken 17617982 times.
✓ Branch 8 taken 21718 times.
17639700 if(isMatch(*it)) return *it;
541 17617982 ++it;
542 }
543
1/1
✓ Branch 1 taken 1965993 times.
1965993 return "";
544 }
545
546 ///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)
547 /** @param patern : vector of the patern we want to check
548 * @return matching patern if there is one, empty string otherwise
549 */
550 138131 PString PFileParser::isMatchToken(const PVecString & patern){
551
3/3
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 138130 times.
✓ Branch 4 taken 1 times.
138131 if(patern.size() == 0lu) return "";
552 138130 PVecString::const_iterator it(patern.begin());
553
2/2
✓ Branch 2 taken 2588438 times.
✓ Branch 3 taken 136439 times.
2724877 while(it != patern.end()){
554
4/4
✓ Branch 2 taken 2588438 times.
✓ Branch 4 taken 1691 times.
✓ Branch 5 taken 2586747 times.
✓ Branch 8 taken 1691 times.
2588438 if(isMatchToken(*it)) return *it;
555 2586747 ++it;
556 }
557
1/1
✓ Branch 1 taken 136439 times.
136439 return "";
558 }
559
560 ///Check the matching between the current caracters and all the string in the list of list of string
561 /** @param patern : list of the list of the patern we want to check
562 * @return matching patern if there is one, empty string otherwise
563 */
564 3 PString PFileParser::isMatch(const std::vector<PVecString > & patern){
565
3/3
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 1 times.
3 if(patern.size() == 0lu) return "";
566 2 std::vector<PVecString >::const_iterator itList(patern.begin());
567
2/2
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
4 while(itList != patern.end()){
568 3 PVecString::const_iterator it(itList->begin());
569
2/2
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 2 times.
6 while(it != itList->end()){
570
4/4
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 1 times.
4 if(isMatch(*it)) return *it;
571 3 ++it;
572 }
573 2 ++itList;
574 }
575
1/1
✓ Branch 1 taken 1 times.
1 return "";
576 }
577
578 ///Check the matching of a sequence in the current file
579 /** @param seq : sequence to be checked
580 * @return matched string
581 */
582 22895 PString PFileParser::isMatch(const PParseSeq & seq){
583
1/1
✓ Branch 1 taken 22895 times.
22895 pushPosition();
584
1/1
✓ Branch 1 taken 22895 times.
22895 PString body("");
585
1/1
✓ Branch 1 taken 22895 times.
22895 const PVecParseStep & vecStep = seq.getVecStep();
586 22895 PVecParseStep::const_iterator itStep(vecStep.begin());
587 22895 bool isParseNextStep(true);
588
6/6
✓ Branch 2 taken 45606 times.
✓ Branch 3 taken 810 times.
✓ Branch 4 taken 23521 times.
✓ Branch 5 taken 22085 times.
✓ Branch 6 taken 23521 times.
✓ Branch 7 taken 22895 times.
46416 while(itStep != vecStep.end() && isParseNextStep){
589
1/1
✓ Branch 2 taken 23521 times.
23521 isParseNextStep = itStep->getIsOptional();
590
1/1
✓ Branch 2 taken 23521 times.
23521 const PVecParseCmd & vecCmd = itStep->getVecCmd();
591 23521 bool isMatchedCmd(false);
592 23521 PVecParseCmd::const_iterator itCmd(vecCmd.begin());
593
6/6
✓ Branch 2 taken 23522 times.
✓ Branch 3 taken 23520 times.
✓ Branch 4 taken 23521 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 23521 times.
✓ Branch 7 taken 23521 times.
47042 while(itCmd != vecCmd.end() && !isMatchedCmd){
594
2/2
✓ Branch 2 taken 23521 times.
✓ Branch 5 taken 23521 times.
23521 PString str(itCmd->getStr());
595
3/3
✓ Branch 2 taken 23521 times.
✓ Branch 4 taken 16320 times.
✓ Branch 5 taken 7201 times.
23521 if(itCmd->getIsMatch()){
596
1/1
✓ Branch 1 taken 16320 times.
16320 isMatchedCmd = isMatch(str);
597
1/1
✓ Branch 1 taken 16320 times.
16320 body += str;
598 }else{
599
1/1
✓ Branch 1 taken 7201 times.
7201 PString res(getStrComposedOf(str));
600
3/3
✓ Branch 1 taken 7201 times.
✓ Branch 3 taken 488 times.
✓ Branch 4 taken 6713 times.
7201 if(res != ""){
601
1/1
✓ Branch 1 taken 488 times.
488 body += res;
602 488 isMatchedCmd = true;
603 }
604 7201 }
605 23521 ++itCmd;
606 23521 }
607 23521 isParseNextStep |= isMatchedCmd;
608 23521 ++itStep;
609 }
610
2/2
✓ Branch 0 taken 22553 times.
✓ Branch 1 taken 342 times.
22895 if(!isParseNextStep){
611
1/1
✓ Branch 1 taken 22553 times.
22553 popPosition();
612
1/1
✓ Branch 1 taken 22553 times.
22553 body = "";
613 }
614 45790 return body;
615 }
616
617 ///Says if the current char is a white space
618 /** @return true if the current char is a white space, false if not
619 * If it matchs, the current caracter will be put on a non white space caracter
620 */
621 1 bool PFileParser::isWhiteSpace(){
622
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if(isEndOfFile()) return false;
623
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(p_listWhiteSpace.find(p_fileContent[p_currentChar])){
624 do{
625 1 incrementCurrentChar();
626
2/6
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
1 }while(p_listWhiteSpace.find(p_fileContent[p_currentChar]) && !isEndOfFile());
627 1 return true;
628 }else return false;
629 }
630
631 ///Skip the white space if there is at the current caracter position
632 55289996 void PFileParser::skipWhiteSpace(){
633
2/2
✓ Branch 0 taken 366972 times.
✓ Branch 1 taken 54923024 times.
55289996 if(p_dontSkipSpace){return;}
634
2/2
✓ Branch 2 taken 439404 times.
✓ Branch 3 taken 54483620 times.
54923024 if(p_listWhiteSpace.find(p_fileContent[p_currentChar])){
635 do{
636 641698 incrementCurrentChar();
637
5/6
✓ Branch 2 taken 202294 times.
✓ Branch 3 taken 439404 times.
✓ Branch 5 taken 202294 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 202294 times.
✓ Branch 8 taken 439404 times.
641698 }while(p_listWhiteSpace.find(p_fileContent[p_currentChar]) && !isEndOfFile());
638 }
639 }
640
641 ///Skip the characters in the given string
642 /** @param chToSkip : set of characters tb skip
643 */
644 425487 void PFileParser::skipChars(const PString & chToSkip){
645
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 425487 times.
425487 if(chToSkip.find(p_fileContent[p_currentChar])){
646 do{
647 incrementCurrentChar();
648 }while(chToSkip.find(p_fileContent[p_currentChar]) && !isEndOfFile());
649 }
650 425487 }
651
652 ///renvoie la liste des caractères blancs
653 /** @return liste des caractères blancs
654 */
655 PString PFileParser::getWhiteSpace() const{
656 return p_listWhiteSpace;
657 }
658
659 ///renvoie la liste des caractères séparateurs
660 /** @return liste des caractères séparateurs
661 */
662 1 PString PFileParser::getSeparator() const{
663 1 return p_listSeparator;
664 }
665
666 ///Renvoie le caractère courant
667 /** @return caractère courant
668 */
669 1623322 char PFileParser::getCurrentCh() const{
670
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1623320 times.
1623322 if(isEndOfFile()) return '\0';
671 1623320 return p_fileContent[p_currentChar];
672 }
673
674 ///Renvoie le caractère courant
675 /** @return caractère courant
676 */
677 1 char PFileParser::getPrevCh() const{
678
2/6
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
1 if(isEndOfFile() && p_currentChar > 0lu) return '\0';
679 1 return p_fileContent[p_currentChar - 1lu];
680 }
681
682 ///Fonction qui renvoie le numéro de la ligne courante
683 /** @return numéro de la ligne courante
684 */
685 2 size_t PFileParser::getLine() const{
686 2 return p_currentLine;
687 }
688
689 ///Fonction qui renvoie le numéro de la colonne du caractère courant
690 /** @return colonne du caractère courant
691 */
692 13872 size_t PFileParser::getColumn() const{
693
2/2
✓ Branch 0 taken 12284 times.
✓ Branch 1 taken 1588 times.
13872 if(p_currentChar > p_currentLineFirstColumn){
694 12284 return p_currentChar - p_currentLineFirstColumn;
695 1588 }else{return 0lu;}
696 }
697
698 ///Return the number of characters in the current opened file
699 /** @return number of characters in the current opened file
700 */
701 size_t PFileParser::getNbTotalChar() const{
702 return p_nbTotalChar;
703 }
704
705 ///Return the index of the current character
706 /** @return index of the current character
707 */
708 55203 size_t PFileParser::getCurrentCharIdx() const{
709 55203 return p_currentChar;
710 }
711
712 ///Get the current line indentation
713 /** @return current line indentation
714 */
715 size_t PFileParser::getLineIndentation(){
716 //First, let's get the current column
717 size_t indentation(0lu), currentCharIdx(p_currentLineFirstColumn);
718 while(currentCharIdx < p_nbTotalChar && PString(" \t").find(p_fileContent[currentCharIdx])){
719 ++indentation;
720 ++currentCharIdx;
721 }
722 if(currentCharIdx > p_currentChar){
723 p_currentChar = currentCharIdx; //Anyway, it was just white character
724 }
725
726 return indentation;
727 }
728
729 ///Fonction qui renvoie la PLocation du PFileParser
730 /** @return PLocation du PFileParser
731 */
732 2362 PLocation PFileParser::getLocation() const{
733 2362 return PLocation(p_fileName, p_currentLine, getColumn());
734 }
735
736 ///Définition de l'opérateur de flux sortant
737 /** @param out : flux dans lequel il faut écrire
738 * @param other : PFileParser
739 * @return flux contenant le PFileParser
740 */
741 1 std::ostream & operator << (std::ostream & out, const PFileParser & other){
742
7/7
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 9 taken 1 times.
✓ Branch 12 taken 1 times.
✓ Branch 15 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
1 out << "file '" << other.getFileName() << "' line " << other.getLine() << ":" << other.getColumn();
743 1 return out;
744 }
745
746 ///Fonction d'initialisation du PFileParser
747 55290 void PFileParser::initialisationPFileParser(){
748 55290 p_currentChar = 0lu;
749 55290 p_currentLine = 1lu;
750 55290 p_currentLineFirstColumn = 0lu;
751 55290 p_fileContent = "";
752 55290 p_listWhiteSpace = " \t\n";
753 55290 p_listSeparator = "()[]{}+=.;,:/*%<>#";
754 55290 p_echapChar = '\0';
755 55290 p_dontSkipSpace = false;
756 55290 p_currentCharEchaped = false;
757 55290 }
758
759 ///Increment the current line
760 4098477 void PFileParser::incrementCurrentLine(){
761 4098477 ++p_currentLine;
762 4098477 p_currentLineFirstColumn = p_currentChar + 1lu;
763 4098477 }
764
765 ///Increment the current caracter
766 /** @param nbChar : number of char to go ahead
767 */
768 81295273 void PFileParser::incrementCurrentChar(size_t nbChar){
769
2/2
✓ Branch 0 taken 104188713 times.
✓ Branch 1 taken 81295273 times.
185483986 for(size_t i(0lu); i < nbChar; ++i){
770
2/2
✓ Branch 1 taken 4098477 times.
✓ Branch 2 taken 100090236 times.
104188713 if(p_fileContent[p_currentChar] == '\n'){
771 4098477 incrementCurrentLine();
772 }
773
6/6
✓ Branch 0 taken 104188375 times.
✓ Branch 1 taken 338 times.
✓ Branch 3 taken 339 times.
✓ Branch 4 taken 104188036 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 1 times.
104188713 p_currentCharEchaped = !p_currentCharEchaped && p_fileContent[p_currentChar] == p_echapChar && p_echapChar != '\0';
774
2/2
✓ Branch 0 taken 104188712 times.
✓ Branch 1 taken 1 times.
104188713 if(p_currentChar < p_nbTotalChar){
775 104188712 ++p_currentChar;
776 }
777 }
778 81295273 }
779
780
781