CppUnit project page FAQ CppUnit home page

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

XmlElement.h

Go to the documentation of this file.
00001 #ifndef CPPUNIT_TOOLS_XMLELEMENT_H 00002 #define CPPUNIT_TOOLS_XMLELEMENT_H 00003 00004 #include <cppunit/Portability.h> 00005 00006 #if CPPUNIT_NEED_DLL_DECL 00007 #pragma warning( push ) 00008 #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z 00009 #endif 00010 00011 #include <cppunit/portability/CppUnitDeque.h> 00012 #include <string> 00013 00014 00015 CPPUNIT_NS_BEGIN 00016 00017 00018 class XmlElement; 00019 00020 #if CPPUNIT_NEED_DLL_DECL 00021 // template class CPPUNIT_API std::deque<XmlElement *>; 00022 #endif 00023 00024 00033 class CPPUNIT_API XmlElement 00034 { 00035 public: 00040 XmlElement( std::string elementName, 00041 std::string content ="" ); 00042 00047 XmlElement( std::string elementName, 00048 int numericContent ); 00049 00052 virtual ~XmlElement(); 00053 00057 std::string name() const; 00058 00062 std::string content() const; 00063 00067 void setName( const std::string &name ); 00068 00072 void setContent( const std::string &content ); 00073 00076 void setContent( int numericContent ); 00077 00082 void addAttribute( std::string attributeName, 00083 std::string value ); 00084 00089 void addAttribute( std::string attributeName, 00090 int numericValue ); 00091 00095 void addElement( XmlElement *element ); 00096 00100 int elementCount() const; 00101 00107 XmlElement *elementAt( int index ) const; 00108 00115 XmlElement *elementFor( const std::string &name ) const; 00116 00122 std::string toString( const std::string &indent = "" ) const; 00123 00124 private: 00125 typedef std::pair<std::string,std::string> Attribute; 00126 00127 std::string attributesAsString() const; 00128 std::string escape( std::string value ) const; 00129 00130 private: 00131 std::string m_name; 00132 std::string m_content; 00133 00134 typedef CppUnitDeque<Attribute> Attributes; 00135 Attributes m_attributes; 00136 00137 typedef CppUnitDeque<XmlElement *> Elements; 00138 Elements m_elements; 00139 }; 00140 00141 00142 CPPUNIT_NS_END 00143 00144 #if CPPUNIT_NEED_DLL_DECL 00145 #pragma warning( pop ) 00146 #endif 00147 00148 00149 #endif // CPPUNIT_TOOLS_XMLELEMENT_H

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers