MCPcopy Create free account
hub / github.com/FidoProject/Fido / XmlWriter

Class XmlWriter

tests/catch.h:8909–9064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8907 };
8908
8909 class XmlWriter {
8910 public:
8911
8912 class ScopedElement {
8913 public:
8914 ScopedElement( XmlWriter* writer )
8915 : m_writer( writer )
8916 {}
8917
8918 ScopedElement( ScopedElement const& other )
8919 : m_writer( other.m_writer ){
8920 other.m_writer = CATCH_NULL;
8921 }
8922
8923 ~ScopedElement() {
8924 if( m_writer )
8925 m_writer->endElement();
8926 }
8927
8928 ScopedElement& writeText( std::string const& text, bool indent = true ) {
8929 m_writer->writeText( text, indent );
8930 return *this;
8931 }
8932
8933 template<typename T>
8934 ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
8935 m_writer->writeAttribute( name, attribute );
8936 return *this;
8937 }
8938
8939 private:
8940 mutable XmlWriter* m_writer;
8941 };
8942
8943 XmlWriter()
8944 : m_tagIsOpen( false ),
8945 m_needsNewline( false ),
8946 m_os( &Catch::cout() )
8947 {}
8948
8949 XmlWriter( std::ostream& os )
8950 : m_tagIsOpen( false ),
8951 m_needsNewline( false ),
8952 m_os( &os )
8953 {}
8954
8955 ~XmlWriter() {
8956 while( !m_tags.empty() )
8957 endElement();
8958 }
8959
8960 XmlWriter& startElement( std::string const& name ) {
8961 ensureTagClosed();
8962 newlineIfNecessary();
8963 stream() << m_indent << "<" << name;
8964 m_tags.push_back( name );
8965 m_indent += " ";
8966 m_tagIsOpen = true;

Callers

nothing calls this directly

Calls 3

XmlEncodeClass · 0.85
emptyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected