1 #ifndef _ifmsxmldocument_
\r
2 #define _ifmsxmldocument_
\r
4 #include "stringfunctions.h"
\r
14 \brief Interface for objects that represent an XML document
\r
16 class IFMSXMLDocument
\r
21 \brief Returns xml document represented by this object
\r
23 \return xml document
\r
25 virtual std::string GetXML()=0;
\r
28 \brief Parses an xml document into this object
\r
30 \return true if the document was parsed successfully, false if it was not
\r
32 virtual const bool ParseXML(const std::string &xml)=0;
\r
36 \brief Creates and returns an element with a boolean value
\r
38 virtual TiXmlElement *XMLCreateBooleanElement(const std::string &name, const bool value)
\r
40 TiXmlText *txt=new TiXmlText(value ? "true" : "false");
\r
41 TiXmlElement *el=new TiXmlElement(name);
\r
42 el->LinkEndChild(txt);
\r
47 \brief Creates and returns an element with a CDATA value
\r
49 virtual TiXmlElement *XMLCreateCDATAElement(const std::string &name, const std::string &data)
\r
51 TiXmlText *txt=new TiXmlText(data);
\r
52 txt->SetCDATA(true);
\r
53 TiXmlElement *el=new TiXmlElement(name);
\r
54 el->LinkEndChild(txt);
\r
59 \brief Creates and returns a text element
\r
61 virtual TiXmlElement *XMLCreateTextElement(const std::string &name, const std::string &data)
\r
63 TiXmlText *txt=new TiXmlText(data);
\r
64 TiXmlElement *el=new TiXmlElement(name);
\r
65 el->LinkEndChild(txt);
\r
69 virtual TiXmlElement *XMLCreateTextElement(const std::string &name, const long data)
\r
71 std::string datastr;
\r
72 StringFunctions::Convert(data,datastr);
\r
73 return XMLCreateTextElement(name,datastr);
\r
76 virtual const bool XMLGetBooleanElement(TiXmlElement *parent, const std::string &name)
\r
78 TiXmlHandle hnd(parent);
\r
79 TiXmlText *txt=hnd.FirstChild(name).FirstChild().ToText();
\r
82 if(txt->ValueStr()=="true")
\r
94 const std::string SanitizeSingleString(const std::string &text)
\r
96 std::string returntext=text;
\r
97 // remove bogus chars from text string
\r
98 for(char i=1; i<32; i++)
\r
100 returntext=StringFunctions::Replace(returntext,std::string(1,i),"");
\r
107 #endif // _ifmsxmldocument_
\r