12 |
|
stackPointer = 0; |
13 |
|
} |
14 |
|
|
15 |
< |
XMLFormatter::XMLFormatter( ){ |
15 |
> |
XMLFormatter::XMLFormatter(){ |
16 |
|
// std::cout << "DEBUG: " << "No Root info" << "\n"; |
17 |
|
hostInfo = ""; // null |
18 |
< |
xmlData = hostInfo; |
18 |
> |
xmlData = ""; |
19 |
|
stackPointer = 0; |
20 |
|
} |
21 |
|
|
34 |
|
|
35 |
|
void XMLFormatter::closeNest(){ |
36 |
|
// std::cout << "DEBUG: Closing Nest: " << stackPointer << ":" << stack[stackPointer] << "\n"; |
37 |
< |
stackPointer--; |
38 |
< |
xmlData += "</"; |
39 |
< |
xmlData += stack[stackPointer]; |
40 |
< |
xmlData += ">"; |
37 |
> |
if ( stackPointer >= 0 ){ |
38 |
> |
|
39 |
> |
stackPointer--; |
40 |
> |
xmlData += "</"; |
41 |
> |
xmlData += stack[stackPointer]; |
42 |
> |
xmlData += ">"; |
43 |
> |
} |
44 |
|
|
45 |
|
return; |
46 |
|
} |
64 |
|
xmlData += " "; |
65 |
|
xmlData += attributes; |
66 |
|
xmlData += ">"; |
67 |
< |
xmlData += value; |
68 |
< |
xmlData += "</"; |
69 |
< |
xmlData += element; |
70 |
< |
xmlData += ">"; |
71 |
< |
return; |
67 |
> |
if ( value != "" ){ |
68 |
> |
xmlData += value; |
69 |
> |
xmlData += "</"; |
70 |
> |
xmlData += element; |
71 |
> |
xmlData += ">"; |
72 |
> |
} // if |
73 |
> |
return; |
74 |
|
} |
75 |
|
|
76 |
|
void XMLFormatter::addElement(string element, string value){ |
94 |
|
closeNest(); |
95 |
|
} |
96 |
|
|
97 |
< |
if ( hostInfo.length() != 0 ){ |
98 |
< |
xmlData += "</"; |
97 |
> |
if ( hostInfo.length() > 0 ){ |
98 |
> |
xmlData += "</"; |
99 |
|
xmlData += hostInfo; |
100 |
|
xmlData += ">"; |
101 |
|
} |
102 |
+ |
|
103 |
+ |
stackPointer = 0; |
104 |
|
|
105 |
|
// std::cout << "DEBUG: returning XML: " << xmlData; |
106 |
|
return xmlData; |