GCC Code Coverage Report


Directory: ./
File: tmp_project/PhoenixXml/src/pxml_utils.cpp
Date: 2025-03-14 12:04:36
Exec Total Coverage
Lines: 188 203 92.6%
Branches: 265 369 71.8%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 ///List of allowed char as balise name
8 #define ALLOWED_BALISE_CHAR "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:?!-"
9
10 ///List of allowed char as attribute name
11 #define ALLOWED_ATTRIBUTE_CHAR "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:-"
12
13 #include "pxml_utils.h"
14
15 ///Set the PFileParser for xml
16 /** @param fileContent : content to be parsed
17 * @param isSvg : true if the parsed file is a svg
18 * @return PFileParser
19 */
20 22 PFileParser pxml_setXmlParser(const PString & fileContent, bool isSvg){
21 22 PFileParser parser;
22
2/2
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
22 parser.setSeparator("<>\"=");
23
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 14 times.
22 if(isSvg){
24
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 parser.setWhiteSpace("");
25 }else{
26
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 parser.setWhiteSpace("\t\n ");
27 }
28
1/1
✓ Branch 1 taken 22 times.
22 parser.setFileContent(fileContent);
29 22 return parser;
30 }
31
32 ///Parse a PXml with a file
33 /** @param[out] xml : PXml to be initialised
34 * @param fileName : name of the intialisation file
35 * @param isSvg : true if the parsed file is a svg
36 * @return true on success, false otherwise
37 */
38 10 bool pxml_parserFile(PXml & xml, const PPath & fileName, bool isSvg){
39
1/1
✓ Branch 2 taken 10 times.
10 return pxml_parserContent(xml, fileName.loadFileContent(), isSvg);
40 }
41
42 ///Parse a PXml with a file content
43 /** @param[out] xml : PXml to be initialised
44 * @param fileContent : file content
45 * @param isSvg : true if the parsed file is a svg
46 * @return true on success, false otherwise
47 */
48 22 bool pxml_parserContent(PXml & xml, const PString & fileContent, bool isSvg){
49
1/1
✓ Branch 1 taken 22 times.
22 PFileParser parser(pxml_setXmlParser(fileContent, isSvg));
50
2/2
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
22 xml.setName("root");
51
52
1/1
✓ Branch 1 taken 22 times.
44 return pxml_parserXmlContent(xml, parser, true);
53
54 // return pxml_parserVecXml(xml.getVecChild(), parser, isSvg);
55 22 }
56
57 ///Say if it is the end of the attribute definition of the current balise
58 /** @param[out] parent : xml parent in wich to set the isCompact attribute
59 * @param[out] parser : parser to be used
60 * @return true if the attribute end is reached, false if not
61 */
62 26859 bool pxml_isAttributeEnd(PXml & parent, PFileParser & parser){
63
3/3
✓ Branch 2 taken 26859 times.
✓ Branch 5 taken 4600 times.
✓ Branch 6 taken 22259 times.
26859 if(parser.isMatch("/>")){
64 4600 parent.setIsCompact(true);
65 4600 return true;
66
3/3
✓ Branch 2 taken 22259 times.
✓ Branch 5 taken 392 times.
✓ Branch 6 taken 21867 times.
22259 }else if(parser.isMatch(">")){
67 392 parent.setIsCompact(false);
68 392 return true;
69 }else{
70 21867 return false;
71 }
72 }
73
74 ///Parse the attribute of a xml balise
75 /** @param[out] parent : xml parent in wich to put the attribute
76 * @param[out] parser : parser to be used
77 * @return true on success, false otherwise
78 */
79 4992 bool pxml_parserXmlAttribute(PXml & parent, PFileParser & parser){
80
1/1
✓ Branch 2 taken 4992 times.
4992 parser.setWhiteSpace(" \t\n");
81
5/6
✓ Branch 1 taken 21867 times.
✓ Branch 2 taken 4992 times.
✓ Branch 4 taken 21867 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21867 times.
✓ Branch 7 taken 4992 times.
26859 while(!pxml_isAttributeEnd(parent, parser) && !parser.isEndOfFile()){
82
2/2
✓ Branch 1 taken 21867 times.
✓ Branch 4 taken 21867 times.
21867 PString attributeName(parser.getStrComposedOf(ALLOWED_ATTRIBUTE_CHAR));
83
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 21867 times.
21867 if(attributeName == ""){
84 std::cerr << "pxml_parserXmlAttribute : error at : " << parser.getLocation() << std::endl;
85 std::cerr << "\tcannot parse the attributes name as '"<<parser.getNextToken()<<"'" << std::endl;
86 return false;
87 }
88
3/4
✓ Branch 1 taken 21867 times.
✓ Branch 4 taken 21867 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21867 times.
21867 if(!parser.isMatch("=")){
89 std::cerr << "pxml_parserXmlAttribute : error at : " << parser.getLocation() << std::endl;
90 std::cerr << "\texpected '=' after attribute '"<<attributeName<<"'" << std::endl;
91 return false;
92 }
93
3/4
✓ Branch 1 taken 21867 times.
✓ Branch 4 taken 21867 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21867 times.
21867 if(!parser.isMatch("\"")){
94 std::cerr << "pxml_parserXmlAttribute : error at : " << parser.getLocation() << std::endl;
95 std::cerr << "\texpected '\"' after attribute '"<<attributeName<<"='" << std::endl;
96 return false;
97 }
98
2/2
✓ Branch 1 taken 21867 times.
✓ Branch 4 taken 21867 times.
21867 PString attributeValue(parser.getUntilKeyWithoutPatern("\""));
99
1/1
✓ Branch 1 taken 21867 times.
21867 PXmlAttr tmpAttribute;
100
1/1
✓ Branch 1 taken 21867 times.
21867 tmpAttribute.setName(attributeName);
101
1/1
✓ Branch 1 taken 21867 times.
21867 tmpAttribute.setValue(attributeValue);
102
2/2
✓ Branch 1 taken 21867 times.
✓ Branch 4 taken 21867 times.
21867 parent.getVecAttr().push_back(tmpAttribute);
103
1/2
✓ Branch 3 taken 21867 times.
✗ Branch 4 not taken.
21867 }
104
1/1
✓ Branch 2 taken 4992 times.
4992 parser.setWhiteSpace("");
105 4992 return true;
106 }
107
108
109 ///Parse the content of an xml balise
110 /** @param[out] parent : xml parent in wich to put the content
111 * @param[out] parser : parser to be used
112 * @param isMainBalise : true if the parent balise if the main one, false otherwise
113 * @return true on success, false otherwise
114 */
115 414 bool pxml_parserXmlContent(PXml & parent, PFileParser & parser, bool isMainBalise){
116
2/2
✓ Branch 1 taken 414 times.
✓ Branch 4 taken 414 times.
414 parser.setSeparator("<>\"=");
117
2/2
✓ Branch 1 taken 414 times.
✓ Branch 4 taken 414 times.
414 parser.setWhiteSpace("");
118
4/4
✓ Branch 1 taken 414 times.
✓ Branch 4 taken 414 times.
✓ Branch 7 taken 414 times.
✓ Branch 10 taken 414 times.
828 PString balisePartialEnd("/" + parent.getName() + ">");
119
2/2
✓ Branch 1 taken 414 times.
✓ Branch 4 taken 414 times.
414 PString baliseEnd("<" + balisePartialEnd);
120
1/1
✓ Branch 1 taken 414 times.
414 PXml text;
121
1/1
✓ Branch 1 taken 414 times.
414 text.setIsText(true);
122
8/8
✓ Branch 1 taken 5409 times.
✓ Branch 3 taken 5364 times.
✓ Branch 4 taken 45 times.
✓ Branch 6 taken 5364 times.
✓ Branch 8 taken 5357 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 5357 times.
✓ Branch 11 taken 52 times.
5409 while(!parser.isMatch(baliseEnd) && !parser.isEndOfFile()){
123
2/2
✓ Branch 1 taken 5357 times.
✓ Branch 4 taken 5357 times.
5357 PString textString(parser.getUntilKeyWithoutPatern("<"));
124
2/2
✓ Branch 1 taken 5245 times.
✓ Branch 2 taken 112 times.
5357 if(textString != ""){ //If the next token is not a < it is a text
125
2/2
✓ Branch 1 taken 5245 times.
✓ Branch 4 taken 5245 times.
5245 text.getValue() += textString;
126
3/3
✓ Branch 1 taken 5245 times.
✓ Branch 4 taken 354 times.
✓ Branch 5 taken 4891 times.
5245 if(parent.getVecChild().size() == 0lu){
127
3/3
✓ Branch 1 taken 354 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 279 times.
354 if(parser.isMatch(balisePartialEnd)){
128
2/2
✓ Branch 1 taken 75 times.
✓ Branch 4 taken 75 times.
75 parent.setValue(text.getValue());
129 75 return true;
130 }else{
131
2/2
✓ Branch 1 taken 279 times.
✓ Branch 4 taken 279 times.
279 parent.getVecChild().push_back(text);
132 }
133 }else{
134
2/2
✓ Branch 1 taken 4891 times.
✓ Branch 4 taken 4891 times.
4891 parent.getVecChild().push_back(text);
135 }
136
2/2
✓ Branch 1 taken 5170 times.
✓ Branch 4 taken 5170 times.
5170 text.setValue(""); //Reset value for next one
137 }
138
3/3
✓ Branch 1 taken 5282 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 5267 times.
5282 if(parser.isEndOfFile()){
139
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(isMainBalise){
140 14 return true;
141 }else{
142
4/4
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
1 std::cerr << "pxml_parserXmlContent : error at : " << parser.getLocation() << std::endl;
143
5/5
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
1 std::cerr << "\tunexpected end of file. We are supposed to be in the balise '"<<parent.getName()<<"'" << std::endl;
144 1 return false;
145 }
146 }
147
3/3
✓ Branch 1 taken 5267 times.
✓ Branch 3 taken 271 times.
✓ Branch 4 taken 4996 times.
5267 if(parser.isMatch(balisePartialEnd)){ //We find the end of the balise
148 271 return true;
149 }else{ //Or it can be another balise
150
2/2
✓ Branch 1 taken 4996 times.
✓ Branch 4 taken 4996 times.
4996 PString childBaliseName(parser.getStrComposedOf(ALLOWED_BALISE_CHAR));
151
1/2
✓ Branch 1 taken 4996 times.
✗ Branch 2 not taken.
4996 if(childBaliseName != ""){ //We find a new balise
152
1/1
✓ Branch 1 taken 4996 times.
4996 PXml xml;
153
1/1
✓ Branch 1 taken 4996 times.
4996 xml.setName(childBaliseName);
154
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4994 times.
4996 if(childBaliseName == "!--"){
155
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 parser.getUntilKeyWithoutPatern("-->"); //Skip the comment
156
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4992 times.
4994 }else if(childBaliseName == "?xml"){
157
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 parser.getUntilKeyWithoutPatern("?>"); //Skip the svg balise
158 }else{
159
2/3
✓ Branch 1 taken 4992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4992 times.
4992 if(!pxml_parserXmlAttribute(xml, parser)){ //Let's parse the attribute
160 std::cerr << "pxml_parserXmlContent : error at : " << parser.getLocation() << std::endl;
161 std::cerr << "\tcannot parse the attributes of balise '"<<childBaliseName<<"'" << std::endl;
162 return false;
163 }
164
3/3
✓ Branch 1 taken 4992 times.
✓ Branch 3 taken 392 times.
✓ Branch 4 taken 4600 times.
4992 if(!xml.getIsCompact()){
165 //Let's parse the content
166
3/3
✓ Branch 1 taken 392 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 391 times.
392 if(!pxml_parserXmlContent(xml, parser, false)){
167
4/4
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
1 std::cerr << "pxml_parserXmlContent : error at : " << parser.getLocation() << std::endl;
168
4/4
✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
1 std::cerr << "\tcannot parse balise '"<<childBaliseName<<"'" << std::endl;
169 1 return false;
170 }
171 }
172
2/2
✓ Branch 1 taken 4991 times.
✓ Branch 4 taken 4991 times.
4991 parent.getVecChild().push_back(xml);
173 }
174
2/8
✓ Branch 1 taken 4995 times.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4996 }else if(parser.isMatch("/")){
175 std::cerr << "pxml_parserXmlContent : in balise '"<<parent.getName()<<"' unexpected '</' at : " << parser.getLocation() << std::endl;
176 return false;
177 }else{ //It was just a text <
178 text.getValue() += "<";
179 }
180
2/2
✓ Branch 1 taken 4995 times.
✓ Branch 2 taken 1 times.
4996 }
181
2/2
✓ Branch 1 taken 4995 times.
✓ Branch 2 taken 362 times.
5357 }
182 52 return true;
183 414 }
184
185
186
187
188
189
190
191 ///Get the vector of childs with given name if exist
192 /** @param[out] vecMatch : vector of matched childs
193 * @param xml : xml input
194 * @param childName : name of the searched childs
195 * @return true if the childs exist, false otherwise
196 */
197 8 bool pxml_getVecChildIfExist(PVecXml & vecMatch, const PXml & xml, const PString & childName){
198 8 bool isFound(false);
199 8 const PVecXml & vecChild = xml.getVecChild();
200
2/2
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 8 times.
80 for(PVecXml::const_iterator it(vecChild.begin()); it != vecChild.end(); ++it){
201
3/3
✓ Branch 2 taken 72 times.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 43 times.
72 if(it->getName() == childName){
202
1/1
✓ Branch 2 taken 29 times.
29 vecMatch.push_back(*it);
203 29 isFound = true;
204 }
205 }
206 8 return isFound;
207 }
208
209 ///Get the child with given name if exist
210 /** @param[out] match : matched child
211 * @param xml : xml input
212 * @param childName : name of the searched child
213 * @return true if the child exist, false otherwise
214 */
215 12 bool pxml_getChildIfExist(PXml & match, const PXml & xml, const PString & childName){
216 12 bool isSearched(true);
217
1/1
✓ Branch 1 taken 12 times.
12 const PVecXml & vecChild = xml.getVecChild();
218 12 PVecXml::const_iterator it(vecChild.begin());
219
6/6
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 12 times.
33 while(it != vecChild.end() && isSearched){
220
3/3
✓ Branch 2 taken 21 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 18 times.
21 if(it->getName() == childName){
221
1/1
✓ Branch 2 taken 3 times.
3 match = *it;
222 3 isSearched = false;
223 }
224 21 ++it;
225 }
226 12 return !isSearched;
227 }
228
229 ///Get the child with given name if exist
230 /** @param xml : xml input
231 * @param childName : name of the searched child
232 * @return pointer to the existing child, NULL otherwise
233 */
234 17 PXml * pxml_getChildPtr(PXml & xml, const PString & childName){
235 17 PXml * out = NULL;
236 17 PVecXml & vecChild = xml.getVecChild();
237
5/6
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 37 times.
✓ Branch 9 taken 17 times.
54 for(PVecXml::iterator it(vecChild.begin()); it != vecChild.end() && out == NULL; ++it){
238
3/3
✓ Branch 2 taken 37 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 20 times.
37 if(it->getName() == childName){
239 17 out = &(*it);
240 }
241 }
242 17 return out;
243 }
244
245 ///Get the attribute with given name if exist
246 /** @param[out] attr : vector of matched child
247 * @param xml : xml input
248 * @param attrName : name of the searched child
249 * @return true if the attribute exists, false otherwise
250 */
251 29 bool pxml_getAttrIfExist(PXmlAttr & attr, const PXml & xml, const PString & attrName){
252 29 bool isSearched(true);
253
1/1
✓ Branch 1 taken 29 times.
29 const PVecXmlAttr & vecAttr = xml.getVecAttr();
254 29 PVecXmlAttr::const_iterator it(vecAttr.begin());
255
6/6
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 40 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 40 times.
✓ Branch 7 taken 29 times.
69 while(it != vecAttr.end() && isSearched){
256
3/3
✓ Branch 2 taken 40 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 23 times.
40 if(it->getName() == attrName){
257
1/1
✓ Branch 2 taken 17 times.
17 attr = *it;
258 17 isSearched = false;
259 }
260 40 ++it;
261 }
262 29 return !isSearched;
263 }
264
265 ///Set a value to an attribute
266 /** @param[out] xml : xml to be modified
267 * @param nameAttr : name of the attribute
268 * @param valueAttr : value of the attribute
269 */
270 65 void pxml_setAttr(PXml & xml, const PString & nameAttr, const PString & valueAttr){
271 65 bool isSearched(true);
272
1/1
✓ Branch 1 taken 65 times.
65 PVecXmlAttr & vecAttr = xml.getVecAttr();
273 65 PVecXmlAttr::iterator it(vecAttr.begin());
274
6/6
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 241 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 65 times.
306 while(it != vecAttr.end() && isSearched){
275
3/3
✓ Branch 2 taken 241 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 180 times.
241 if(it->getName() == nameAttr){
276
1/1
✓ Branch 2 taken 61 times.
61 it->setValue(valueAttr);
277 61 isSearched = false;
278 }
279 241 ++it;
280 }
281 65 }
282
283 ///Erase the childs of the current xml if it has childName as name
284 /** @param xml : current input
285 * @param childName : name of the childs to be erased
286 * @return output xml without childs named childName
287 */
288 2 PXml pxml_eraseVecChild(const PXml & xml, const PString & childName){
289 2 PXml out;
290
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 out.setName(xml.getName());
291
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 out.setValue(xml.getValue());
292
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 out.setVecAttr(xml.getVecAttr());
293
1/1
✓ Branch 1 taken 2 times.
2 const PVecXml & vecXml = xml.getVecChild();
294
2/2
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 2 times.
39 for(PVecXml::const_iterator it(vecXml.begin()); it != vecXml.end(); ++it){
295
3/3
✓ Branch 2 taken 37 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 18 times.
37 if(it->getName() != childName){
296
2/2
✓ Branch 1 taken 19 times.
✓ Branch 5 taken 19 times.
19 out.getVecChild().push_back(*it);
297 }
298 }
299 2 return out;
300 }
301
302 ///Save a xml in a file
303 /** @param fileName : name of the output file
304 * @param xml : xml to be saved
305 * @param isSvg : say if the output xml has to be SVG like (with no space between chevron and newline between attribute
306 * @return true on success, false otherwise
307 */
308 4 bool pxml_saveFile(const PPath & fileName, const PXml & xml, bool isSvg){
309
1/1
✓ Branch 1 taken 4 times.
4 PString body(pxml_baliseStr(xml, isSvg));
310
1/1
✓ Branch 1 taken 4 times.
8 return fileName.saveFileContent(body);
311 4 }
312
313 ///Convert xml in string
314 /** @param xml : xml to be converted into string
315 * @param isSvg : say if the output xml has to be SVG like (with no space between chevron and newline between attribute
316 * @return output string
317 */
318 89193 PString pxml_baliseStr(const PXml & xml, bool isSvg){
319
3/3
✓ Branch 1 taken 89193 times.
✓ Branch 4 taken 89193 times.
✓ Branch 7 taken 89193 times.
89193 PString body(""), name(xml.getName());
320
1/1
✓ Branch 1 taken 89193 times.
89193 PString baseXmlNewLine("\n");
321
2/2
✓ Branch 0 taken 89059 times.
✓ Branch 1 taken 134 times.
89193 if(isSvg){
322
1/1
✓ Branch 1 taken 89059 times.
89059 baseXmlNewLine = "";
323 }
324
3/3
✓ Branch 1 taken 89193 times.
✓ Branch 3 taken 45440 times.
✓ Branch 4 taken 43753 times.
89193 if(xml.getIsText()){
325
2/2
✓ Branch 1 taken 45440 times.
✓ Branch 4 taken 45440 times.
45440 body += xml.getValue();
326 }else{
327
2/2
✓ Branch 1 taken 43740 times.
✓ Branch 2 taken 13 times.
43753 if(name != ""){
328
1/1
✓ Branch 1 taken 43740 times.
43740 body += "<";
329
1/1
✓ Branch 1 taken 43740 times.
43740 body += name;
330
3/3
✓ Branch 1 taken 43740 times.
✓ Branch 4 taken 43740 times.
✓ Branch 7 taken 43740 times.
43740 body += pxml_vecAttrStr(xml.getVecAttr(), isSvg);
331
332
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 43740 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
43740 if(name == "?xml"){body += " ?>\n";}
333
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 43740 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
43740 else if(name == "!--"){body += " -->\n";}
334
3/3
✓ Branch 1 taken 43740 times.
✓ Branch 3 taken 41090 times.
✓ Branch 4 taken 2650 times.
43740 else if(xml.getIsCompact()){
335
2/2
✓ Branch 1 taken 41090 times.
✓ Branch 4 taken 41090 times.
41090 body += " />"+baseXmlNewLine;
336 }else{
337
2/2
✓ Branch 1 taken 2650 times.
✓ Branch 4 taken 2650 times.
2650 body += ">"+baseXmlNewLine;
338
3/3
✓ Branch 1 taken 2650 times.
✓ Branch 4 taken 2650 times.
✓ Branch 7 taken 2650 times.
2650 body += pxml_vecXmlStr(xml.getVecChild(), isSvg);
339
2/2
✓ Branch 1 taken 2650 times.
✓ Branch 4 taken 2650 times.
2650 body += xml.getValue();
340
4/4
✓ Branch 1 taken 2650 times.
✓ Branch 4 taken 2650 times.
✓ Branch 7 taken 2650 times.
✓ Branch 10 taken 2650 times.
2650 body += "</"+ name + ">" + baseXmlNewLine;
341 }
342 }else{
343
344
3/3
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
13 body += pxml_vecXmlStr(xml.getVecChild(), isSvg);
345 }
346 }
347 178386 return body;
348 89193 }
349
350 ///Convert a vecto of xml in string
351 /** @param vecXml : vecor of xml to be converted into string
352 * @param isSvg : say if the output xml has to be SVG like (with no space between chevron and newline between attribute
353 * @return output string
354 */
355 2670 PString pxml_vecXmlStr(const PVecXml & vecXml, bool isSvg){
356 2670 PString body("");
357
2/2
✓ Branch 3 taken 89167 times.
✓ Branch 4 taken 2670 times.
91837 for(PVecXml::const_iterator it(vecXml.begin()); it != vecXml.end(); ++it){
358
2/2
✓ Branch 2 taken 89167 times.
✓ Branch 5 taken 89167 times.
89167 body += pxml_baliseStr(*it, isSvg);
359 }
360 2670 return body;
361 }
362
363 ///Convert attribute in string
364 /** @param xmlAttr : xml attribute to be converted into string
365 * @param isSvg : say if the output xml has to be SVG like (with no space between chevron and newline between attribute
366 * @return output string
367 */
368 194165 PString pxml_attrStr(const PXmlAttr & xmlAttr, bool isSvg){
369 194165 PString body(" ");
370
6/6
✓ Branch 1 taken 194165 times.
✓ Branch 4 taken 194165 times.
✓ Branch 7 taken 194165 times.
✓ Branch 10 taken 194165 times.
✓ Branch 13 taken 194165 times.
✓ Branch 16 taken 194165 times.
194165 body += xmlAttr.getName() + "=\"" + xmlAttr.getValue() + "\"";
371
2/2
✓ Branch 0 taken 194158 times.
✓ Branch 1 taken 7 times.
194165 if(isSvg){
372
1/1
✓ Branch 1 taken 194158 times.
194158 body += "\n\t";
373 }
374 194165 return body;
375 }
376
377 ///Convert attributes in string
378 /** @param vecXmlAttr : xml attributes to be converted into string
379 * @param isSvg : say if the output xml has to be SVG like (with no space between chevron and newline between attribute
380 * @return output string
381 */
382 43740 PString pxml_vecAttrStr(const PVecXmlAttr & vecXmlAttr, bool isSvg){
383
3/3
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 43639 times.
✓ Branch 4 taken 101 times.
43740 if(vecXmlAttr.size() == 0lu){return "";}
384
1/1
✓ Branch 1 taken 43639 times.
43639 PString body("");
385
2/2
✓ Branch 3 taken 194165 times.
✓ Branch 4 taken 43639 times.
237804 for(PVecXmlAttr::const_iterator it(vecXmlAttr.begin()); it != vecXmlAttr.end(); ++it){
386
2/2
✓ Branch 2 taken 194165 times.
✓ Branch 5 taken 194165 times.
194165 body += pxml_attrStr(*it, isSvg);
387 }
388
1/1
✓ Branch 1 taken 43639 times.
43639 return body;
389 43639 }
390
391 ///Get the content of the PXml (children or value)
392 /** @param xml : PXml to be used
393 * @return content of the PXml (children or value)
394 */
395 58 PString pxml_getFullContent(const PXml & xml){
396 58 const PVecXml & vecXml = xml.getVecChild();
397
2/2
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 51 times.
58 if(vecXml.size() != 0lu){
398 7 return pxml_vecXmlStr(vecXml);
399 }else{
400 51 return xml.getValue();
401 }
402 }
403
404
405