MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / XmlWriter

Class XmlWriter

extlibs/catch/include/catch/catch.hpp:6036–6104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6034 };
6035
6036 class XmlWriter {
6037 public:
6038
6039 class ScopedElement {
6040 public:
6041 ScopedElement( XmlWriter* writer );
6042
6043 ScopedElement( ScopedElement&& other ) noexcept;
6044 ScopedElement& operator=( ScopedElement&& other ) noexcept;
6045
6046 ~ScopedElement();
6047
6048 ScopedElement& writeText( std::string const& text, bool indent = true );
6049
6050 template<typename T>
6051 ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
6052 m_writer->writeAttribute( name, attribute );
6053 return *this;
6054 }
6055
6056 private:
6057 mutable XmlWriter* m_writer = nullptr;
6058 };
6059
6060 XmlWriter( std::ostream& os = Catch::cout() );
6061 ~XmlWriter();
6062
6063 XmlWriter( XmlWriter const& ) = delete;
6064 XmlWriter& operator=( XmlWriter const& ) = delete;
6065
6066 XmlWriter& startElement( std::string const& name );
6067
6068 ScopedElement scopedElement( std::string const& name );
6069
6070 XmlWriter& endElement();
6071
6072 XmlWriter& writeAttribute( std::string const& name, std::string const& attribute );
6073
6074 XmlWriter& writeAttribute( std::string const& name, bool attribute );
6075
6076 template<typename T>
6077 XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
6078 ReusableStringStream rss;
6079 rss << attribute;
6080 return writeAttribute( name, rss.str() );
6081 }
6082
6083 XmlWriter& writeText( std::string const& text, bool indent = true );
6084
6085 XmlWriter& writeComment( std::string const& text );
6086
6087 void writeStylesheetRef( std::string const& url );
6088
6089 XmlWriter& writeBlankLine();
6090
6091 void ensureTagClosed();
6092
6093 private:

Callers

nothing calls this directly

Calls 1

strMethod · 0.45

Tested by

no test coverage detected