diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-05-23 17:38:39 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-05-23 17:38:39 +0000 |
| commit | 5ad4640702a80078748b38ebaeda37e69dce1189 (patch) | |
| tree | 9d1ecf8d28f0e9397c2f90565d96ccda6d08b98e /include/cppunit/tools | |
| parent | 7edd0684368ed3c43fe2707d1d34d6b7590d9fd6 (diff) | |
| download | cppunit-5ad4640702a80078748b38ebaeda37e69dce1189.tar.gz | |
Include/cppunit/XmlOutputter.
include/cppunit/XmlOutputter.h:
* src/cppunit/XmlOutputter.cpp: extracted class XmlOutputter::Node to
XmlElement. Extracted xml 'prolog' generation to XmlDocument.
* include/cppunit/tools/XmlElement.h:
* src/cppunit/tools/XmlElement.cpp: added, extracted from XmlOutputter::Node.
* include/cppunit/tools/XmlDocument.h:
* src/cppunit/tools/XmlDocument.cpp: added, extracted from XmlOutputter. Handle
XML document prolog (encoding & style-sheet) and manage the root element.
* src/DllPlugInTester/DllPlugInTester.cpp: bug fix, flag --xsl was ignored.
* examples/cppunittest/XmlOutputterTest.h:
* examples/cppunittest/XmlOutputterTest.cpp: updated for XmlOuputter changes.
extracted tests for XmlOutputter::Node to XmlElementTest
* examples/cppunittest/XmlElementTest.h:
* examples/cppunittest/XmlElementTest.cpp: added, tests extracted from
XmlOutputterTest.
Diffstat (limited to 'include/cppunit/tools')
| -rw-r--r-- | include/cppunit/tools/Makefile.am | 5 | ||||
| -rw-r--r-- | include/cppunit/tools/XmlDocument.h | 67 | ||||
| -rw-r--r-- | include/cppunit/tools/XmlElement.h | 72 |
3 files changed, 144 insertions, 0 deletions
diff --git a/include/cppunit/tools/Makefile.am b/include/cppunit/tools/Makefile.am new file mode 100644 index 0000000..7035ef7 --- /dev/null +++ b/include/cppunit/tools/Makefile.am @@ -0,0 +1,5 @@ +libcppunitincludedir = $(includedir)/cppunit/tools + +libcppunitinclude_HEADERS = \ + XmlElement.h \ + XmlDocument.h
\ No newline at end of file diff --git a/include/cppunit/tools/XmlDocument.h b/include/cppunit/tools/XmlDocument.h new file mode 100644 index 0000000..3ed4107 --- /dev/null +++ b/include/cppunit/tools/XmlDocument.h @@ -0,0 +1,67 @@ +#ifndef CPPUNIT_TOOLS_XMLDOCUMENT_H +#define CPPUNIT_TOOLS_XMLDOCUMENT_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include <string> + + +namespace CppUnit +{ + +class XmlElement; + + +/*! A XML Document. + */ +class CPPUNIT_API XmlDocument +{ +public: + /*! Constructs a XmlDocument object. + * \param encoding Encoding used in the XML file (default is Latin-1, ISO-8859-1 ). + */ + XmlDocument( const std::string &encoding = "", + const std::string &styleSheet = "" ); + + /// Destructor. + virtual ~XmlDocument(); + + std::string encoding() const; + void setEncoding( const std::string &encoding = "" ); + + std::string styleSheet() const; + void setStyleSheet( const std::string &styleSheet = "" ); + + void setRootElement( XmlElement *rootElement ); + XmlElement &rootElement() const; + + std::string toString() const; + +private: + /// Prevents the use of the copy constructor. + XmlDocument( const XmlDocument © ); + + /// Prevents the use of the copy operator. + void operator =( const XmlDocument © ); + +protected: + std::string m_encoding; + std::string m_styleSheet; + XmlElement *m_rootElement; +}; + + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +} // namespace CppUnit + + +#endif // CPPUNIT_TOOLS_XMLDOCUMENT_H diff --git a/include/cppunit/tools/XmlElement.h b/include/cppunit/tools/XmlElement.h new file mode 100644 index 0000000..9b033f4 --- /dev/null +++ b/include/cppunit/tools/XmlElement.h @@ -0,0 +1,72 @@ +#ifndef CPPUNIT_TOOLS_XMLELEMENT_H +#define CPPUNIT_TOOLS_XMLELEMENT_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include <deque> +#include <string> + + +namespace CppUnit +{ + +class XmlElement; + +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::deque<XmlElement *>; +#endif + + +/*! A XML Element. + */ +class CPPUNIT_API XmlElement +{ +public: + XmlElement( std::string elementName, + std::string content ="" ); + XmlElement( std::string elementName, + int numericContent ); + virtual ~XmlElement(); + + void addAttribute( std::string attributeName, + std::string value ); + void addAttribute( std::string attributeName, + int numericValue ); + void addNode( XmlElement *element ); + + std::string toString( const std::string &indent = "" ) const; + +private: + typedef std::pair<std::string,std::string> Attribute; + + std::string attributesAsString() const; + std::string escape( std::string value ) const; + static std::string asString( int value ); + +private: + std::string m_name; + std::string m_content; + + typedef std::deque<Attribute> Attributes; + Attributes m_attributes; + + typedef std::deque<XmlElement *> Elements; + Elements m_elements; +}; + + + +} // namespace CppUnit + + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +#endif // CPPUNIT_TOOLS_XMLELEMENT_H |
