ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/XMLFormatter.cpp
(Generate patch)

Comparing projects/cms/source/host/c++/XMLFormatter.cpp (file contents):
Revision 1.4 by ab11, Mon Feb 26 14:54:13 2001 UTC vs.
Revision 1.5 by ab11, Fri Mar 23 14:07:11 2001 UTC

# Line 12 | Line 12 | XMLFormatter::XMLFormatter( string newHostInfo ){
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  
# Line 34 | Line 34 | XMLFormatter::XMLFormatter( string newHostInfo, string
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   }
# Line 61 | Line 64 | void XMLFormatter::addElement(string element, string a
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){
# Line 89 | Line 94 | string XMLFormatter::returnXML(){
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines