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
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
16
17
18class XmlElement;
19
20#if CPPUNIT_NEED_DLL_DECL
21// template class CPPUNIT_API std::deque<XmlElement *>;
22#endif
23
24
34{
35public:
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
124private:
125 typedef std::pair<std::string,std::string> Attribute;
126
127 std::string attributesAsString() const;
128 std::string escape( std::string value ) const;
129
130private:
131 std::string m_name;
132 std::string m_content;
133
134 typedef std::deque<Attribute> Attributes;
136
137 typedef std::deque<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
#define CPPUNIT_API
Definition CppUnitApi.h:27
#define CPPUNIT_NS_END
Definition Portability.h:106
#define CPPUNIT_NS_BEGIN
Definition Portability.h:105
A XML Element.
Definition XmlElement.h:34
std::pair< std::string, std::string > Attribute
Definition XmlElement.h:125
Attributes m_attributes
Definition XmlElement.h:135
std::string m_name
Definition XmlElement.h:131
std::deque< XmlElement * > Elements
Definition XmlElement.h:137
std::string m_content
Definition XmlElement.h:132
Elements m_elements
Definition XmlElement.h:138
std::deque< Attribute > Attributes
Definition XmlElement.h:134

Send comments to:
CppUnit Developers