| 6181 | }; |
| 6182 | |
| 6183 | class XmlWriter { |
| 6184 | public: |
| 6185 | |
| 6186 | class ScopedElement { |
| 6187 | public: |
| 6188 | ScopedElement( XmlWriter* writer, XmlFormatting fmt ); |
| 6189 | |
| 6190 | ScopedElement( ScopedElement&& other ) noexcept; |
| 6191 | ScopedElement& operator=( ScopedElement&& other ) noexcept; |
| 6192 | |
| 6193 | ~ScopedElement(); |
| 6194 | |
| 6195 | ScopedElement& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent ); |
| 6196 | |
| 6197 | template<typename T> |
| 6198 | ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { |
| 6199 | m_writer->writeAttribute( name, attribute ); |
| 6200 | return *this; |
| 6201 | } |
| 6202 | |
| 6203 | private: |
| 6204 | mutable XmlWriter* m_writer = nullptr; |
| 6205 | XmlFormatting m_fmt; |
| 6206 | }; |
| 6207 | |
| 6208 | XmlWriter( std::ostream& os = Catch::cout() ); |
| 6209 | ~XmlWriter(); |
| 6210 | |
| 6211 | XmlWriter( XmlWriter const& ) = delete; |
| 6212 | XmlWriter& operator=( XmlWriter const& ) = delete; |
| 6213 | |
| 6214 | XmlWriter& startElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 6215 | |
| 6216 | ScopedElement scopedElement( std::string const& name, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 6217 | |
| 6218 | XmlWriter& endElement(XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 6219 | |
| 6220 | XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); |
| 6221 | |
| 6222 | XmlWriter& writeAttribute( std::string const& name, bool attribute ); |
| 6223 | |
| 6224 | template<typename T> |
| 6225 | XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { |
| 6226 | ReusableStringStream rss; |
| 6227 | rss << attribute; |
| 6228 | return writeAttribute( name, rss.str() ); |
| 6229 | } |
| 6230 | |
| 6231 | XmlWriter& writeText( std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 6232 | |
| 6233 | XmlWriter& writeComment(std::string const& text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); |
| 6234 | |
| 6235 | void writeStylesheetRef( std::string const& url ); |
| 6236 | |
| 6237 | XmlWriter& writeBlankLine(); |
| 6238 | |
| 6239 | void ensureTagClosed(); |
| 6240 | |