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.2 by ab11, Wed Jan 24 19:33:37 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 +        
28 +        hostInfo = newHostInfo;
29 +        
30 +        stackPointer = 0;
31 + }
32 +
33   void XMLFormatter::closeNest(){
34 +        // std::cout << "DEBUG: Closing Nest: " << stackPointer << ":" << stack[stackPointer] << "\n";
35 +        stackPointer--;
36 +        xmlData += "</";
37 +        xmlData += stack[stackPointer];
38 +        xmlData += ">";
39 +        
40          return;
41   }
42  
43 < void XMLFormatter::addNest(char* nest){
43 > void XMLFormatter::addNest(string nest){
44 >        // std::cout << "DEBUG: Adding Nest: " << nest << "\n";
45 >        xmlData += "<";
46 >        xmlData += nest;
47 >        xmlData += ">";
48 >        
49 >        // now add the nest to the stack
50 >        stack[stackPointer] = nest;
51 >        stackPointer++;
52          return;
53   }
54  
55 < void XMLFormatter::addElement(char* element){
55 > void XMLFormatter::addElement(string element, string attributes, string value){
56 >        // std::cout << "DEBUG: Add Element: " << element << ":" << attributes << ":" << value << "\n";
57 >        xmlData += "<";
58 >        xmlData += element;
59 >        xmlData += " ";
60 >        xmlData += attributes;
61 >        xmlData += ">";
62 >        xmlData += value;
63 >        xmlData += "</";
64 >        xmlData += element;
65 >        xmlData += ">";
66          return;
67   }
68  
69 < char* XMLFormatter::returnXML(){
70 <        return "hellO";
69 > void XMLFormatter::addElement(string element, string value){
70 >        // std::cout << "DEBUG: Add Element: " << element << ":" << value << "\n";
71 >        xmlData += "<";
72 >        xmlData += element;
73 >        xmlData += ">";
74 >        xmlData += value;
75 >        xmlData += "</";
76 >        xmlData += element;
77 >        xmlData += ">";
78 >        return;
79 > }
80 >
81 >
82 > string XMLFormatter::returnXML(){
83 >        // close as many nests as we have open, could (but shouldn't) cause
84 >        // some arraylist out of bounds errors.
85 >        for ( int count= stackPointer; count > 0; count-- ){
86 >                // close nest
87 >                closeNest();    
88 >        }
89 >        
90 >        if ( hostInfo.length() != 0 ){
91 >                xmlData += "</";
92 >                xmlData += hostInfo;
93 >                xmlData += ">";
94 >        }
95 >        
96 >        // std::cout << "DEBUG: returning XML: " << xmlData;
97 >        return xmlData;
98   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines