Menu

[r315]: / trunk / cppunit / src / cppunit / XmlDocument.cpp  Maximize  Restore  History

Download this file

90 lines (59 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <cppunit/tools/XmlDocument.h>
#include <cppunit/tools/XmlElement.h>
namespace CppUnit
{
XmlDocument::XmlDocument( const std::string &encoding,
const std::string &styleSheet )
: m_rootElement( new XmlElement( "DummyRoot" ) )
, m_styleSheet( styleSheet )
{
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() ? "ISO-8859-1" : encoding;
}
std::string
XmlDocument::styleSheet() const
{
return m_styleSheet;
}
void
XmlDocument::setStyleSheet( const std::string &styleSheet )
{
m_styleSheet = styleSheet;
}
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 + "' standalone='yes' ?>\n";
if ( !m_styleSheet.empty() )
asString += "<?xml-stylesheet type=\"text/xsl\" href="/?originalUrl=https%3A%2F%2Fsourceforge.net%2F%253C%2Fspan">\"" + m_styleSheet + "\"?>\n";
asString += m_rootElement->toString();
return asString;
}
} // namespace CppUnit
MongoDB Logo MongoDB