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.1 by ab11, Thu Nov 30 21:58:30 2000 UTC vs.
Revision 1.4 by ab11, Mon Feb 26 14:54:13 2001 UTC

# Line 1 | Line 1
1 < #include <XMLFormatter.h>
1 > #include "XMLFormatter.h"
2  
3 < void XMLFormatter::XMLFormatter( char* newHostInfo ){
4 <        hostInfo = "<"+newHostInfo+">";
3 > XMLFormatter::XMLFormatter( string newHostInfo ){
4 >        // std::cout << "DEBUG: " << newHostInfo << "\n";
5 >        xmlData += "<";
6 >        xmlData += newHostInfo;
7 >        xmlData += ">";
8 >        
9 >        hostInfo = newHostInfo;
10 >        // std::cout << "DEBUG: xmldata: " << xmlData << "\n";
11 >        
12 >        stackPointer = 0;
13   }
14  
15 + XMLFormatter::XMLFormatter( ){
16 +        // std::cout << "DEBUG: " << "No Root info" << "\n";
17 +        hostInfo = ""; // null
18 +        xmlData = hostInfo;
19 +        stackPointer = 0;
20 + }
21 +
22 + XMLFormatter::XMLFormatter( string newHostInfo, string attributes){
23 +        // std::cout << "DEBUG: " << newHostInfo << ":" << attributes << "\n";
24 +        xmlData += "<";
25 +        xmlData += newHostInfo;
26 +        xmlData += " ";
27 +        xmlData += attributes;
28 +        xmlData += ">";
29 +        
30 +        hostInfo = newHostInfo;
31 +        
32 +        stackPointer = 0;
33 + }
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 += ">";
41 +        
42          return;
43   }
44  
45 < void XMLFormatter::addNest(char* nest){
45 > void XMLFormatter::addNest(string nest){
46 >        // std::cout << "DEBUG: Adding Nest: " << nest << "\n";
47 >        xmlData += "<";
48 >        xmlData += nest;
49 >        xmlData += ">";
50 >        
51 >        // now add the nest to the stack
52 >        stack[stackPointer] = nest;
53 >        stackPointer++;
54          return;
55   }
56  
57 < void XMLFormatter::addElement(char* element){
57 > void XMLFormatter::addElement(string element, string attributes, string value){
58 >        // std::cout << "DEBUG: Add Element: " << element << ":" << attributes << ":" << value << "\n";
59 >        xmlData += "<";
60 >        xmlData += element;
61 >        xmlData += " ";
62 >        xmlData += attributes;
63 >        xmlData += ">";
64 >        xmlData += value;
65 >        xmlData += "</";
66 >        xmlData += element;
67 >        xmlData += ">";
68          return;
69   }
70  
71 < char* XMLFormatter::returnXML(){
72 <        return "hellO";
71 > void XMLFormatter::addElement(string element, string value){
72 >        // std::cout << "DEBUG: Add Element: " << element << ":" << value << "\n";
73 >        xmlData += "<";
74 >        xmlData += element;
75 >        xmlData += ">";
76 >        xmlData += value;
77 >        xmlData += "</";
78 >        xmlData += element;
79 >        xmlData += ">";
80 >        return;
81 > }
82 >
83 >
84 > string XMLFormatter::returnXML(){
85 >        // close as many nests as we have open, could (but shouldn't) cause
86 >        // some arraylist out of bounds errors.
87 >        for ( int count= stackPointer; count > 0; count-- ){
88 >                // close nest
89 >                closeNest();    
90 >        }
91 >        
92 >        if ( hostInfo.length() != 0 ){
93 >                xmlData += "</";
94 >                xmlData += hostInfo;
95 >                xmlData += ">";
96 >        }
97 >        
98 >        // std::cout << "DEBUG: returning XML: " << xmlData;
99 >        return xmlData;
100   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines