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.2 by ab11, Wed Jan 24 19:33:37 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 23 | Line 23 | XMLFormatter::XMLFormatter( string newHostInfo, string
23          // std::cout << "DEBUG: " << newHostInfo << ":" << attributes << "\n";
24          xmlData += "<";
25          xmlData += newHostInfo;
26 +        xmlData += " ";
27 +        xmlData += attributes;
28          xmlData += ">";
29          
30          hostInfo = newHostInfo;
# Line 32 | 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 59 | 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 87 | 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