ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/XMLFormatter.cpp
Revision: 1.3
Committed: Mon Feb 26 14:42:43 2001 UTC (23 years, 8 months ago) by ab11
Branch: MAIN
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
DELETED

File Contents

# Content
1 #include "XMLFormatter.h"
2
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(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(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 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 }