CppUnit project page FAQ

XmlElement.h
Go to the documentation of this file.
1 #ifndef CPPUNIT_TOOLS_XMLELEMENT_H
2 #define CPPUNIT_TOOLS_XMLELEMENT_H
3 
4 #include <cppunit/Portability.h>
5 
6 #if CPPUNIT_NEED_DLL_DECL
7 #pragma warning( push )
8 #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
9 #endif
10 
12 #include <string>
13 
14 
16 
17 
18 class XmlElement;
19 
20 #if CPPUNIT_NEED_DLL_DECL
21 // template class CPPUNIT_API std::deque<XmlElement *>;
22 #endif
23 
24 
34 {
35 public:
40  XmlElement( std::string elementName,
41  std::string content ="" );
42 
47  XmlElement( std::string elementName,
48  int numericContent );
49 
52  virtual ~XmlElement();
53 
57  std::string name() const;
58 
62  std::string content() const;
63 
67  void setName( const std::string &name );
68 
72  void setContent( const std::string &content );
73 
76  void setContent( int numericContent );
77 
82  void addAttribute( std::string attributeName,
83  std::string value );
84 
89  void addAttribute( std::string attributeName,
90  int numericValue );
91 
95  void addElement( XmlElement *element );
96 
100  int elementCount() const;
101 
107  XmlElement *elementAt( int index ) const;
108 
115  XmlElement *elementFor( const std::string &name ) const;
116 
122  std::string toString( const std::string &indent = "" ) const;
123 
124 private:
125  typedef std::pair<std::string,std::string> Attribute;
126 
127  std::string attributesAsString() const;
128  std::string escape( std::string value ) const;
129 
130 private:
131  std::string m_name;
132  std::string m_content;
133 
134  typedef CppUnitDeque<Attribute> Attributes;
136 
137  typedef CppUnitDeque<XmlElement *> Elements;
139 };
140 
141 
143 
144 #if CPPUNIT_NEED_DLL_DECL
145 #pragma warning( pop )
146 #endif
147 
148 
149 #endif // CPPUNIT_TOOLS_XMLELEMENT_H

Send comments to:
CppUnit Developers