MCPcopy Create free account
hub / github.com/apache/thrift / XmlWriter

Class XmlWriter

compiler/cpp/tests/catch/catch.hpp:9868–10028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9866 };
9867
9868 class XmlWriter {
9869 public:
9870
9871 class ScopedElement {
9872 public:
9873 ScopedElement( XmlWriter* writer )
9874 : m_writer( writer )
9875 {}
9876
9877 ScopedElement( ScopedElement const& other )
9878 : m_writer( other.m_writer ){
9879 other.m_writer = CATCH_NULL;
9880 }
9881
9882 ~ScopedElement() {
9883 if( m_writer )
9884 m_writer->endElement();
9885 }
9886
9887 ScopedElement& writeText( std::string const& text, bool indent = true ) {
9888 m_writer->writeText( text, indent );
9889 return *this;
9890 }
9891
9892 template<typename T>
9893 ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
9894 m_writer->writeAttribute( name, attribute );
9895 return *this;
9896 }
9897
9898 private:
9899 mutable XmlWriter* m_writer;
9900 };
9901
9902 XmlWriter()
9903 : m_tagIsOpen( false ),
9904 m_needsNewline( false ),
9905 m_os( Catch::cout() )
9906 {
9907 writeDeclaration();
9908 }
9909
9910 XmlWriter( std::ostream& os )
9911 : m_tagIsOpen( false ),
9912 m_needsNewline( false ),
9913 m_os( os )
9914 {
9915 writeDeclaration();
9916 }
9917
9918 ~XmlWriter() {
9919 while( !m_tags.empty() )
9920 endElement();
9921 }
9922
9923 XmlWriter& startElement( std::string const& name ) {
9924 ensureTagClosed();
9925 newlineIfNecessary();

Callers

nothing calls this directly

Calls 5

XmlEncodeClass · 0.85
emptyMethod · 0.80
strMethod · 0.80
substrMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected