CppUnit - The Unit Testing Library

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
11 #include <deque>
12 #include <string>
13
14
15 CPPUNIT_NS_BEGIN
16
17
18 class XmlElement;
19
20 #if CPPUNIT_NEED_DLL_DECL
21 // template class CPPUNIT_API std::deque<XmlElement *>;
22 #endif
23
24
33 class CPPUNIT_API XmlElement
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 std::deque<Attribute> Attributes;
135 Attributes m_attributes;
136
137 typedef std::deque<XmlElement *> Elements;
138 Elements m_elements;
139 };
140
141
142 CPPUNIT_NS_END
143
144 #if CPPUNIT_NEED_DLL_DECL
145 #pragma warning( pop )
146 #endif
147
148
149 #endif // CPPUNIT_TOOLS_XMLELEMENT_H
XmlElement::m_content
std::string m_content
Definition: XmlElement.h:132
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
XmlElement::Attributes
std::deque< Attribute > Attributes
Definition: XmlElement.h:134
XmlElement::m_elements
Elements m_elements
Definition: XmlElement.h:138
XmlElement
A XML Element.
Definition: XmlElement.h:33
XmlElement::m_name
std::string m_name
Definition: XmlElement.h:131
XmlElement::Elements
std::deque< XmlElement * > Elements
Definition: XmlElement.h:137
XmlElement::Attribute
std::pair< std::string, std::string > Attribute
Definition: XmlElement.h:125
StringHelper::toString
std::enable_if<!std::is_enum< T >::value, std::string >::type toString(const T &x)
Definition: StringHelper.h:22
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:105
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:106
XmlElement::m_attributes
Attributes m_attributes
Definition: XmlElement.h:135
Portability.h

| Send comments to: CppUnit Developers