--- projects/cms/source/host/c++/XMLFormatter.cpp 2001/03/23 16:38:34 1.6 +++ projects/cms/source/host/c++/XMLFormatter.cpp 2002/05/18 18:15:56 1.8 @@ -1,28 +1,48 @@ +/* + * i-scream central monitoring system + * Copyright (C) 2000-2002 i-scream + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + #include "XMLFormatter.h" XMLFormatter::XMLFormatter( string newHostInfo ){ - // std::cout << "DEBUG: " << newHostInfo << "\n"; + if ( newHostInfo != "" ){ xmlData += "<"; xmlData += newHostInfo; xmlData += ">"; - hostInfo = newHostInfo; - // std::cout << "DEBUG: xmldata: " << xmlData << "\n"; - } + + } // if stackPointer = 0; -} + +} // XMLFormatter XMLFormatter::XMLFormatter(){ - // std::cout << "DEBUG: " << "No Root info" << "\n"; + hostInfo = ""; // null xmlData = ""; stackPointer = 0; -} + +} // XMLFormatter XMLFormatter::XMLFormatter( string newHostInfo, string attributes){ - // std::cout << "DEBUG: " << newHostInfo << ":" << attributes << "\n"; + xmlData += "<"; xmlData += newHostInfo; xmlData += " "; @@ -32,24 +52,23 @@ XMLFormatter::XMLFormatter( string newHostInfo, string hostInfo = newHostInfo; stackPointer = 0; -} +} // XMLFormatter void XMLFormatter::closeNest(){ - // std::cout << "DEBUG: Closing Nest: " << stackPointer << ":" << stack[stackPointer] << "\n"; + if ( stackPointer >= 0 ){ stackPointer--; xmlData += ""; - } + } // if return; -} +} // closeNest void XMLFormatter::addNest(string nest){ - // std::cout << "DEBUG: Adding Nest: " << nest << "\n"; - + // check it is not empty if ( nest != "" ){ xmlData += "<"; @@ -62,10 +81,10 @@ void XMLFormatter::addNest(string nest){ } // if return; -} +} // addNest void XMLFormatter::addElement(string element, string attributes, string value){ - // std::cout << "DEBUG: Add Element: " << element << ":" << attributes << ":" << value << "\n"; + xmlData += "<"; xmlData += element; xmlData += " "; @@ -77,11 +96,10 @@ void XMLFormatter::addElement(string element, string a xmlData += ">"; return; -} +} // addElement void XMLFormatter::addElement(string element, string value){ - // std::cout << "DEBUG: Add Element: " << element << ":" << value << "\n"; - + if (( element != "" ) && ( value != "" )){ xmlData += "<"; xmlData += element; @@ -92,7 +110,8 @@ void XMLFormatter::addElement(string element, string v xmlData += ">"; } // if return; -} + +} // addElement string XMLFormatter::returnXML(){ @@ -101,16 +120,16 @@ string XMLFormatter::returnXML(){ for ( int count= stackPointer; count > 0; count-- ){ // close nest closeNest(); - } + } // if if ( hostInfo.length() > 0 ){ xmlData += ""; - } + } // if stackPointer = 0; - // std::cout << "DEBUG: returning XML: " << xmlData; return xmlData; -} \ No newline at end of file + +} // returnXML \ No newline at end of file