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

Class XmlWriter

unittests/catch.hpp:4249–4317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4247 };
4248
4249 class XmlWriter {
4250 public:
4251
4252 class ScopedElement {
4253 public:
4254 ScopedElement( XmlWriter* writer );
4255
4256 ScopedElement( ScopedElement&& other ) noexcept;
4257 ScopedElement& operator=( ScopedElement&& other ) noexcept;
4258
4259 ~ScopedElement();
4260
4261 ScopedElement& writeText( std::string const& text, bool indent = true );
4262
4263 template<typename T>
4264 ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
4265 m_writer->writeAttribute( name, attribute );
4266 return *this;
4267 }
4268
4269 private:
4270 mutable XmlWriter* m_writer = nullptr;
4271 };
4272
4273 XmlWriter( std::ostream& os = Catch::cout() );
4274 ~XmlWriter();
4275
4276 XmlWriter( XmlWriter const& ) = delete;
4277 XmlWriter& operator=( XmlWriter const& ) = delete;
4278
4279 XmlWriter& startElement( std::string const& name );
4280
4281 ScopedElement scopedElement( std::string const& name );
4282
4283 XmlWriter& endElement();
4284
4285 XmlWriter& writeAttribute( std::string const& name, std::string const& attribute );
4286
4287 XmlWriter& writeAttribute( std::string const& name, bool attribute );
4288
4289 template<typename T>
4290 XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
4291 ReusableStringStream rss;
4292 rss << attribute;
4293 return writeAttribute( name, rss.str() );
4294 }
4295
4296 XmlWriter& writeText( std::string const& text, bool indent = true );
4297
4298 XmlWriter& writeComment( std::string const& text );
4299
4300 void writeStylesheetRef( std::string const& url );
4301
4302 XmlWriter& writeBlankLine();
4303
4304 void ensureTagClosed();
4305
4306 private:

Callers

nothing calls this directly

Calls 1

strMethod · 0.45

Tested by

no test coverage detected