XmlDocument.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef CPPUNIT_TOOLS_XMLDOCUMENT_H
  2. #define CPPUNIT_TOOLS_XMLDOCUMENT_H
  3. #include <cppunit/Portability.h>
  4. #if CPPUNIT_NEED_DLL_DECL
  5. #pragma warning( push )
  6. #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
  7. #endif
  8. #include <string>
  9. CPPUNIT_NS_BEGIN
  10. class XmlElement;
  11. /*! \brief A XML Document.
  12. *
  13. * A XmlDocument represents a XML file. It holds a pointer on the root XmlElement
  14. * of the document. It also holds the encoding and style sheet used.
  15. *
  16. * By default, the XML document is stand-alone and tagged with enconding "ISO-8859-1".
  17. */
  18. class CPPUNIT_API XmlDocument
  19. {
  20. public:
  21. /*! \brief Constructs a XmlDocument object.
  22. * \param encoding Encoding used in the XML file (default is Latin-1, ISO-8859-1 ).
  23. * \param styleSheet Name of the XSL style sheet file used. If empty then no
  24. * style sheet will be specified in the output.
  25. */
  26. XmlDocument( const std::string &encoding = "",
  27. const std::string &styleSheet = "" );
  28. /// Destructor.
  29. virtual ~XmlDocument();
  30. std::string encoding() const;
  31. void setEncoding( const std::string &encoding = "" );
  32. std::string styleSheet() const;
  33. void setStyleSheet( const std::string &styleSheet = "" );
  34. bool standalone() const;
  35. /*! \brief set the output document as standalone or not.
  36. *
  37. * For the output document, specify wether it's a standalone XML
  38. * document, or not.
  39. *
  40. * \param standalone if true, the output will be specified as standalone.
  41. * if false, it will be not.
  42. */
  43. void setStandalone( bool standalone );
  44. void setRootElement( XmlElement *rootElement );
  45. XmlElement &rootElement() const;
  46. std::string toString() const;
  47. private:
  48. /// Prevents the use of the copy constructor.
  49. XmlDocument( const XmlDocument &copy );
  50. /// Prevents the use of the copy operator.
  51. void operator =( const XmlDocument &copy );
  52. protected:
  53. std::string m_encoding;
  54. std::string m_styleSheet;
  55. XmlElement *m_rootElement;
  56. bool m_standalone;
  57. };
  58. #if CPPUNIT_NEED_DLL_DECL
  59. #pragma warning( pop )
  60. #endif
  61. CPPUNIT_NS_END
  62. #endif // CPPUNIT_TOOLS_XMLDOCUMENT_H