diff options
| author | Remko Tronçon <git@el-tramo.be> | 2009-06-01 08:48:42 (GMT) | 
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2009-06-01 09:24:28 (GMT) | 
| commit | 2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch) | |
| tree | d46294f35150c4f0f43deaf2d31fceaf945ae715 /3rdParty/CppUnit/src/XmlDocument.cpp | |
| download | swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2  | |
Import.
Diffstat (limited to '3rdParty/CppUnit/src/XmlDocument.cpp')
| -rw-r--r-- | 3rdParty/CppUnit/src/XmlDocument.cpp | 106 | 
1 files changed, 106 insertions, 0 deletions
diff --git a/3rdParty/CppUnit/src/XmlDocument.cpp b/3rdParty/CppUnit/src/XmlDocument.cpp new file mode 100644 index 0000000..31f9115 --- /dev/null +++ b/3rdParty/CppUnit/src/XmlDocument.cpp @@ -0,0 +1,106 @@ +#include <cppunit/config/SourcePrefix.h> +#include <cppunit/tools/XmlDocument.h> +#include <cppunit/tools/XmlElement.h> + + +CPPUNIT_NS_BEGIN + + +XmlDocument::XmlDocument( const std::string &encoding, +                          const std::string &styleSheet ) +  : m_styleSheet( styleSheet ) +  , m_rootElement( new XmlElement( "DummyRoot" ) ) +  , m_standalone( true ) +{ +  setEncoding( encoding ); +} + + +XmlDocument::~XmlDocument() +{ +  delete m_rootElement; +} + + + +std::string  +XmlDocument::encoding() const +{ +  return m_encoding; +} + + +void  +XmlDocument::setEncoding( const std::string &encoding ) +{ +  m_encoding = encoding.empty() ? std::string("ISO-8859-1") : encoding; +} + + +std::string  +XmlDocument::styleSheet() const +{ +  return m_styleSheet; +} + + +void  +XmlDocument::setStyleSheet( const std::string &styleSheet ) +{ +  m_styleSheet = styleSheet; +} + + +bool +XmlDocument::standalone() const +{ +  return m_standalone; +} + + +void +XmlDocument::setStandalone( bool standalone ) +{ +  m_standalone = standalone; +} + + +void  +XmlDocument::setRootElement( XmlElement *rootElement ) +{ +  if ( rootElement == m_rootElement ) +    return; + +  delete m_rootElement; +  m_rootElement = rootElement; +} + + +XmlElement & +XmlDocument::rootElement() const +{ +  return *m_rootElement; +} + + +std::string  +XmlDocument::toString() const +{ +  std::string asString = "<?xml version=\"1.0\" " +                         "encoding='" + m_encoding + "'"; +  if ( m_standalone ) +      asString += " standalone='yes'"; + +  asString += " ?>\n";  + +  if ( !m_styleSheet.empty() ) +    asString += "<?xml-stylesheet type=\"text/xsl\" href=\"" + m_styleSheet + "\"?>\n"; + +  asString += m_rootElement->toString(); + +  return asString; +} + + +CPPUNIT_NS_END +  | 
 Swift