GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixPresentation/tmp_project/PhoenixInkscape/tmp_project/PhoenixFileParser/src/PFileParser.cpp
Date: 2025-03-24 18:12:43
Exec Total Coverage
Lines: 398 423 94.1%
Branches: 401 491 81.7%

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 8873706 void PFileParser::setWhiteSpace(const PString & whiteSpace){
36 8873706 p_listWhiteSpace = whiteSpace;
37 8873706 }
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 3012968 void PFileParser::setSeparator(const PString & separator){
44 3012968 p_listSeparator = separator;
45 3012968 }
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 3649 void PFileParser::setEscapeChar(char escapeChar){
59 3649 p_echapChar = escapeChar;
60 3649 }
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 102341620 bool PFileParser::isEndOfFile() const{
89 102341620 return (p_currentChar >= p_nbTotalChar);
90 }
91
92 ///Remember the current position of the PFileParser in the current file
93 15027551 void PFileParser::pushPosition(){
94 15027551 p_vecPosition.push_back(p_currentChar);
95 15027551 p_vecLine.push_back(p_currentLine);
96 15027551 }
97
98 ///Get to the last saved position of the PFileParser in the current file
99 13833469 void PFileParser::popPosition(){
100
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 13833468 times.
13833469 if(p_vecPosition.size() == 0lu){
101 1 return;
102 }
103 13833468 p_currentChar = p_vecPosition.back();
104 13833468 p_currentLine = p_vecLine.back();
105 13833468 p_vecPosition.pop_back();
106 13833468 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 12696 PString PFileParser::getNextToken(){
149
1/1
✓ Branch 1 taken 12696 times.
12696 PString dummySkipedStr("");
150
1/1
✓ Branch 1 taken 12696 times.
25392 return getNextToken(dummySkipedStr);
151 12696 }
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 13708 PString PFileParser::getNextToken(PString & skippedStr){
158
4/4
✓ Branch 1 taken 13708 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 13701 times.
✓ Branch 6 taken 7 times.
13708 if(isEndOfFile()) return "";
159
1/1
✓ Branch 1 taken 13701 times.
13701 char ch = p_fileContent[p_currentChar];
160
7/8
✓ Branch 1 taken 23681 times.
✓ Branch 3 taken 23681 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23681 times.
✓ Branch 8 taken 9983 times.
✓ Branch 9 taken 13698 times.
✓ Branch 10 taken 9983 times.
✓ Branch 11 taken 13698 times.
23681 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 13698 times.
✓ Branch 3 taken 8521 times.
✓ Branch 4 taken 5177 times.
✓ Branch 6 taken 8521 times.
✓ Branch 8 taken 8521 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8521 times.
✓ Branch 11 taken 5177 times.
13698 if(p_listSeparator.find(ch) && !isEndOfFile()){ //If is it a separator, we stop
168
1/1
✓ Branch 1 taken 8521 times.
8521 incrementCurrentChar();
169
1/1
✓ Branch 1 taken 8521 times.
8521 PString s("");
170
1/1
✓ Branch 1 taken 8521 times.
8521 s += ch;
171
1/1
✓ Branch 1 taken 8521 times.
8521 return s;
172 8521 }
173 //If not we get all characters until the next white character or separator character
174
1/1
✓ Branch 1 taken 5177 times.
5177 PString buf("");
175
10/11
✓ Branch 1 taken 32839 times.
✓ Branch 3 taken 32839 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 32839 times.
✓ Branch 8 taken 28731 times.
✓ Branch 9 taken 4108 times.
✓ Branch 11 taken 28731 times.
✓ Branch 13 taken 27664 times.
✓ Branch 14 taken 1067 times.
✓ Branch 15 taken 27664 times.
✓ Branch 16 taken 5175 times.
32839 while(!isEndOfFile() && !p_listWhiteSpace.find(ch) && !p_listSeparator.find(ch)){
176
1/1
✓ Branch 1 taken 27664 times.
27664 buf += ch;
177
1/1
✓ Branch 1 taken 27664 times.
27664 incrementCurrentChar();
178
4/4
✓ Branch 1 taken 27664 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 27662 times.
✓ Branch 6 taken 2 times.
27664 if(isEndOfFile()){return buf;}
179
1/1
✓ Branch 1 taken 27662 times.
27662 ch = p_fileContent[p_currentChar];
180 }
181
1/1
✓ Branch 1 taken 5175 times.
5175 return buf;
182 5177 }
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 6358887 PString PFileParser::getUntilKeyWithoutPatern(const PString & patern){
212
8/10
✓ Branch 1 taken 6358887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6358887 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 6358887 times.
✓ Branch 8 taken 134 times.
✓ Branch 9 taken 6358753 times.
✓ Branch 10 taken 134 times.
✓ Branch 11 taken 6358753 times.
✓ Branch 13 taken 134 times.
6358887 if(patern == "" || p_nbTotalChar == 0lu || isEndOfFile()) return "";
213 6358753 size_t sizePatern(patern.size());
214
1/1
✓ Branch 2 taken 6358753 times.
6358753 std::string out(""); //on évite les petits désagréments
215 6358753 size_t sizeSrc(p_nbTotalChar - p_currentChar);
216 6358753 size_t beginTest(0lu), beginLine(0lu), beginI(0lu), nbMatch(0lu);
217
2/2
✓ Branch 0 taken 47569875 times.
✓ Branch 1 taken 31259 times.
47601134 for(size_t i(0lu); i < sizeSrc; ++i){
218
3/3
✓ Branch 1 taken 47569875 times.
✓ Branch 4 taken 6357978 times.
✓ Branch 5 taken 41211897 times.
47569875 if(p_fileContent[p_currentChar] == patern[nbMatch]){ //si le caractère i est le même que le caractère nbMatch
219
2/2
✓ Branch 0 taken 6331197 times.
✓ Branch 1 taken 26781 times.
6357978 if(nbMatch == 0lu){ //c'est le premier qu'on teste
220 6331197 beginTest = p_currentChar; //il faut donc se rappeler où on a commencer à faire le test
221 6331197 beginLine = p_currentLine;
222 6331197 beginI = i;
223 }
224 6357978 ++nbMatch; //la prochaîne fois on testera le caractère suivant
225
2/2
✓ Branch 0 taken 6327494 times.
✓ Branch 1 taken 30484 times.
6357978 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 6327494 times.
6327494 incrementCurrentChar();
227
1/1
✓ Branch 1 taken 6327494 times.
6327494 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 41208195 times.
✓ Branch 1 taken 3702 times.
41211897 if(nbMatch == 0lu){ //si on n'en avait pas trouver de bon avant
231
2/2
✓ Branch 1 taken 41208195 times.
✓ Branch 4 taken 41208195 times.
41208195 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 41211897 beginTest = 0lu; //on remet le début des tests à 0 (pour évité les dépassements, on ne sait jamais)
239 41211897 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 41242381 times.
41242381 incrementCurrentChar();
242 }
243
1/1
✓ Branch 1 taken 31259 times.
31259 return out;
244 6358753 }
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 3412542 PString PFileParser::getStrComposedOf(const PString & charset){
395
1/1
✓ Branch 1 taken 3412542 times.
3412542 PString tmpWhiteSpace(p_listWhiteSpace.eraseChar(charset));
396
3/3
✓ Branch 1 taken 3412542 times.
✓ Branch 3 taken 416409 times.
✓ Branch 4 taken 2996133 times.
3412542 if(tmpWhiteSpace != ""){
397
1/1
✓ Branch 1 taken 416409 times.
416409 skipChars(tmpWhiteSpace);
398 }
399
1/1
✓ Branch 2 taken 3412542 times.
3412542 std::string out("");
400 3412542 bool isInCharSet(true);
401
7/7
✓ Branch 1 taken 27870908 times.
✓ Branch 3 taken 27870878 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 24458366 times.
✓ Branch 6 taken 3412512 times.
✓ Branch 7 taken 24458366 times.
✓ Branch 8 taken 3412542 times.
27870908 while(!isEndOfFile() && isInCharSet){
402
1/1
✓ Branch 1 taken 24458366 times.
24458366 char ch = p_fileContent[p_currentChar];
403
1/1
✓ Branch 1 taken 24458366 times.
24458366 isInCharSet = charset.find(ch);
404
2/2
✓ Branch 0 taken 21045854 times.
✓ Branch 1 taken 3412512 times.
24458366 if(isInCharSet){
405
1/1
✓ Branch 1 taken 21045854 times.
21045854 out += ch;
406
1/1
✓ Branch 1 taken 21045854 times.
21045854 incrementCurrentChar();
407 }
408 }
409
1/1
✓ Branch 1 taken 3412542 times.
6825084 return out;
410 3412542 }
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 54632821 bool PFileParser::isMatch(const PString & patern){
442
6/6
✓ Branch 1 taken 54485020 times.
✓ Branch 2 taken 147801 times.
✓ Branch 4 taken 501 times.
✓ Branch 5 taken 54484519 times.
✓ Branch 6 taken 148302 times.
✓ Branch 7 taken 54484519 times.
54632821 if(patern == "" || isEndOfFile()) return false;
443 54484519 skipWhiteSpace();
444 54484519 size_t nbCharPatern(patern.size());
445
2/2
✓ Branch 0 taken 1834930 times.
✓ Branch 1 taken 52649589 times.
54484519 if(p_currentChar + nbCharPatern > p_nbTotalChar){return false;}
446 52649589 bool match = true;
447 52649589 size_t i(0lu);
448
4/4
✓ Branch 0 taken 81714611 times.
✓ Branch 1 taken 45858232 times.
✓ Branch 2 taken 74923254 times.
✓ Branch 3 taken 6791357 times.
127572843 while(match && i < nbCharPatern){
449 74923254 match = (patern[i] == p_fileContent[p_currentChar + i]);
450 74923254 ++i;
451 }
452
2/2
✓ Branch 0 taken 6791357 times.
✓ Branch 1 taken 45858232 times.
52649589 if(match){
453 6791357 incrementCurrentChar(nbCharPatern);
454 }
455 52649589 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 5554 bool PFileParser::isMatchRewind(const PString & patern){
464 5554 pushPosition();
465 5554 bool b = isMatch(patern);
466 5554 popPosition();
467 5554 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 2054038 bool PFileParser::isMatchSeq(const PVecString & patern, bool alwaysPopBack){
476
1/1
✓ Branch 1 taken 2054038 times.
2054038 pushPosition();
477 2054038 PVecString::const_iterator it(patern.begin());
478 2054038 bool matchPatern(true);
479
6/6
✓ Branch 2 taken 4126475 times.
✓ Branch 3 taken 990 times.
✓ Branch 4 taken 2073427 times.
✓ Branch 5 taken 2053048 times.
✓ Branch 6 taken 2073427 times.
✓ Branch 7 taken 2054038 times.
4127465 while(it != patern.end() && matchPatern){
480
1/1
✓ Branch 2 taken 2073427 times.
2073427 matchPatern = isMatch(*it);
481 2073427 ++it;
482 }
483
4/4
✓ Branch 0 taken 988 times.
✓ Branch 1 taken 2053050 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 978 times.
2054038 if(!matchPatern || alwaysPopBack){
484
1/1
✓ Branch 1 taken 2053060 times.
2053060 popPosition();
485 }
486 2054038 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 332298 bool PFileParser::isMatch(const PString & patern, const PString & forbiddenCharBefore){
496
2/2
✓ Branch 0 taken 330156 times.
✓ Branch 1 taken 2142 times.
332298 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 330090 times.
330156 if(forbiddenCharBefore.find(p_fileContent[p_currentChar - 1lu])){
499 66 return false;
500 }
501 }
502 332232 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 10905768 bool PFileParser::isMatchToken(const PString & patern){
511
1/1
✓ Branch 1 taken 10905768 times.
10905768 pushPosition();
512
3/3
✓ Branch 1 taken 10905768 times.
✓ Branch 3 taken 10897626 times.
✓ Branch 4 taken 8142 times.
10905768 if(!isMatch(patern)){
513
1/1
✓ Branch 1 taken 10897626 times.
10897626 popPosition();
514 10897626 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 1987706 PString PFileParser::isMatch(const PVecString & patern){
537
3/3
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1987705 times.
✓ Branch 4 taken 1 times.
1987706 if(patern.size() == 0lu) return "";
538 1987705 PVecString::const_iterator it(patern.begin());
539
2/2
✓ Branch 2 taken 17638109 times.
✓ Branch 3 taken 1965989 times.
19604098 while(it != patern.end()){
540
4/4
✓ Branch 2 taken 17638109 times.
✓ Branch 4 taken 21716 times.
✓ Branch 5 taken 17616393 times.
✓ Branch 8 taken 21716 times.
17638109 if(isMatch(*it)) return *it;
541 17616393 ++it;
542 }
543
1/1
✓ Branch 1 taken 1965989 times.
1965989 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 2521995 times.
✓ Branch 3 taken 136439 times.
2658434 while(it != patern.end()){
554
4/4
✓ Branch 2 taken 2521995 times.
✓ Branch 4 taken 1691 times.
✓ Branch 5 taken 2520304 times.
✓ Branch 8 taken 1691 times.
2521995 if(isMatchToken(*it)) return *it;
555 2520304 ++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 54488886 void PFileParser::skipWhiteSpace(){
633
2/2
✓ Branch 0 taken 366972 times.
✓ Branch 1 taken 54121914 times.
54488886 if(p_dontSkipSpace){return;}
634
2/2
✓ Branch 2 taken 435016 times.
✓ Branch 3 taken 53686898 times.
54121914 if(p_listWhiteSpace.find(p_fileContent[p_currentChar])){
635 do{
636 637310 incrementCurrentChar();
637
5/6
✓ Branch 2 taken 202294 times.
✓ Branch 3 taken 435016 times.
✓ Branch 5 taken 202294 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 202294 times.
✓ Branch 8 taken 435016 times.
637310 }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 421097 void PFileParser::skipChars(const PString & chToSkip){
645
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 421097 times.
421097 if(chToSkip.find(p_fileContent[p_currentChar])){
646 do{
647 incrementCurrentChar();
648 }while(chToSkip.find(p_fileContent[p_currentChar]) && !isEndOfFile());
649 }
650 421097 }
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 55163 size_t PFileParser::getCurrentCharIdx() const{
709 55163 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 }
757
758 ///Increment the current line
759 3970128 void PFileParser::incrementCurrentLine(){
760 3970128 ++p_currentLine;
761 3970128 p_currentLineFirstColumn = p_currentChar + 1lu;
762 3970128 }
763
764 ///Increment the current caracter
765 /** @param nbChar : number of char to go ahead
766 */
767 77890923 void PFileParser::incrementCurrentChar(size_t nbChar){
768 77890923 bool currentCharEchaped(false);
769
4/4
✓ Branch 0 taken 99847523 times.
✓ Branch 1 taken 77891259 times.
✓ Branch 2 taken 336 times.
✓ Branch 3 taken 77890923 times.
177738782 for(size_t i(0lu); i < nbChar || currentCharEchaped; ++i){
770
2/2
✓ Branch 1 taken 3970128 times.
✓ Branch 2 taken 95877731 times.
99847859 if(p_fileContent[p_currentChar] == '\n'){
771 3970128 incrementCurrentLine();
772 }
773
8/8
✓ Branch 0 taken 99847523 times.
✓ Branch 1 taken 336 times.
✓ Branch 3 taken 337 times.
✓ Branch 4 taken 99847186 times.
✓ Branch 5 taken 336 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 336 times.
✓ Branch 8 taken 99847523 times.
99847859 if(!currentCharEchaped && p_fileContent[p_currentChar] == p_echapChar && p_echapChar != '\0'){
774 336 currentCharEchaped = true;
775 }else{
776 99847523 currentCharEchaped = false;
777 }
778
2/2
✓ Branch 0 taken 99847858 times.
✓ Branch 1 taken 1 times.
99847859 if(p_currentChar < p_nbTotalChar){
779 99847858 ++p_currentChar;
780 }
781 }
782 77890923 }
783
784
785