Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Catch::XmlWriter Class Reference

#include <catch_xmlwriter.h>

Classes

class  ScopedElement
 

Public Member Functions

 XmlWriter (std::ostream &os=Catch::cout())
 
 ~XmlWriter ()
 
 XmlWriter (XmlWriter const &)=delete
 
XmlWriteroperator= (XmlWriter const &)=delete
 
XmlWriterstartElement (std::string const &name)
 
ScopedElement scopedElement (std::string const &name)
 
XmlWriterendElement ()
 
XmlWriterwriteAttribute (std::string const &name, std::string const &attribute)
 
XmlWriterwriteAttribute (std::string const &name, bool attribute)
 
template<typename T >
XmlWriterwriteAttribute (std::string const &name, T const &attribute)
 
XmlWriterwriteText (std::string const &text, bool indent=true)
 
XmlWriterwriteComment (std::string const &text)
 
void writeStylesheetRef (std::string const &url)
 
XmlWriterwriteBlankLine ()
 
void ensureTagClosed ()
 

Detailed Description

Definition at line 33 of file catch_xmlwriter.h.

Constructor & Destructor Documentation

◆ XmlWriter() [1/2]

Catch::XmlWriter::XmlWriter ( std::ostream & os = Catch::cout())

Definition at line 188 of file catch_xmlwriter.cpp.

188 : m_os( os )
189 {
190 writeDeclaration();
191 }
os_t os

◆ ~XmlWriter()

Catch::XmlWriter::~XmlWriter ( )

Definition at line 193 of file catch_xmlwriter.cpp.

193 {
194 while( !m_tags.empty() )
195 endElement();
196 }
XmlWriter & endElement()
Here is the call graph for this function:

◆ XmlWriter() [2/2]

Catch::XmlWriter::XmlWriter ( XmlWriter const & )
delete

Member Function Documentation

◆ endElement()

XmlWriter & Catch::XmlWriter::endElement ( )

Definition at line 214 of file catch_xmlwriter.cpp.

214 {
215 newlineIfNecessary();
216 m_indent = m_indent.substr( 0, m_indent.size()-2 );
217 if( m_tagIsOpen ) {
218 m_os << "/>";
219 m_tagIsOpen = false;
220 }
221 else {
222 m_os << m_indent << "</" << m_tags.back() << ">";
223 }
224 m_os << std::endl;
225 m_tags.pop_back();
226 return *this;
227 }
Here is the caller graph for this function:

◆ ensureTagClosed()

void Catch::XmlWriter::ensureTagClosed ( )

Definition at line 269 of file catch_xmlwriter.cpp.

269 {
270 if( m_tagIsOpen ) {
271 m_os << ">" << std::endl;
272 m_tagIsOpen = false;
273 }
274 }
Here is the caller graph for this function:

◆ operator=()

XmlWriter & Catch::XmlWriter::operator= ( XmlWriter const & )
delete

◆ scopedElement()

XmlWriter::ScopedElement Catch::XmlWriter::scopedElement ( std::string const & name)

Definition at line 208 of file catch_xmlwriter.cpp.

208 {
209 ScopedElement scoped( this );
211 return scoped;
212 }
std::string name
XmlWriter & startElement(std::string const &name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startElement()

XmlWriter & Catch::XmlWriter::startElement ( std::string const & name)

Definition at line 198 of file catch_xmlwriter.cpp.

198 {
200 newlineIfNecessary();
201 m_os << m_indent << '<' << name;
202 m_tags.push_back( name );
203 m_indent += " ";
204 m_tagIsOpen = true;
205 return *this;
206 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeAttribute() [1/3]

XmlWriter & Catch::XmlWriter::writeAttribute ( std::string const & name,
bool attribute )

Definition at line 235 of file catch_xmlwriter.cpp.

235 {
236 m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"';
237 return *this;
238 }

◆ writeAttribute() [2/3]

XmlWriter & Catch::XmlWriter::writeAttribute ( std::string const & name,
std::string const & attribute )

Definition at line 229 of file catch_xmlwriter.cpp.

229 {
230 if( !name.empty() && !attribute.empty() )
231 m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"';
232 return *this;
233 }
Here is the caller graph for this function:

◆ writeAttribute() [3/3]

template<typename T >
XmlWriter & Catch::XmlWriter::writeAttribute ( std::string const & name,
T const & attribute )
inline

Definition at line 74 of file catch_xmlwriter.h.

74 {
75 ReusableStringStream rss;
76 rss << attribute;
77 return writeAttribute( name, rss.str() );
78 }
XmlWriter & writeAttribute(std::string const &name, std::string const &attribute)
Here is the call graph for this function:

◆ writeBlankLine()

XmlWriter & Catch::XmlWriter::writeBlankLine ( )

Definition at line 263 of file catch_xmlwriter.cpp.

263 {
265 m_os << '\n';
266 return *this;
267 }
Here is the call graph for this function:

◆ writeComment()

XmlWriter & Catch::XmlWriter::writeComment ( std::string const & text)

Definition at line 252 of file catch_xmlwriter.cpp.

252 {
254 m_os << m_indent << "<!--" << text << "-->";
255 m_needsNewline = true;
256 return *this;
257 }
Here is the call graph for this function:

◆ writeStylesheetRef()

void Catch::XmlWriter::writeStylesheetRef ( std::string const & url)

Definition at line 259 of file catch_xmlwriter.cpp.

259 {
260 m_os << "<?xml-stylesheet type=\"text/xsl\" href=\"" << url << "\"?>\n";
261 }
string url
Definition main.cpp:166
Here is the caller graph for this function:

◆ writeText()

XmlWriter & Catch::XmlWriter::writeText ( std::string const & text,
bool indent = true )

Definition at line 240 of file catch_xmlwriter.cpp.

240 {
241 if( !text.empty() ){
242 bool tagWasOpen = m_tagIsOpen;
244 if( tagWasOpen && indent )
245 m_os << m_indent;
246 m_os << XmlEncode( text );
247 m_needsNewline = true;
248 }
249 return *this;
250 }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: