Orcus
|
#include <xml_writer.hpp>
Classes | |
class | scope |
Public Member Functions | |
xml_writer (const xml_writer &)=delete | |
xml_writer & | operator= (const xml_writer &)=delete |
xml_writer (xmlns_repository &ns_repo, std::ostream &os) | |
xml_writer (xml_writer &&other) | |
xml_writer & | operator= (xml_writer &&other) |
~xml_writer () | |
scope | push_element_scope (const xml_name_t &name) |
void | push_element (const xml_name_t &name) |
xmlns_id_t | add_namespace (std::string_view alias, std::string_view value) |
void | add_attribute (const xml_name_t &name, std::string_view value) |
void | add_content (std::string_view content) |
xml_name_t | pop_element () |
This class lets you produce XML contents from scratch. It writes its content to any object supporting the std::ostream interface.
orcus::xml_writer::~xml_writer | ( | ) |
Destructor. Any remaining element(s) on the stack will get popped when the destructor is called.
void orcus::xml_writer::add_attribute | ( | const xml_name_t & | name, |
std::string_view | value ) |
Add a new attribute for the next element to be pushed.
name | name of the attribute to be added. |
value | value of the attribute to be added. |
void orcus::xml_writer::add_content | ( | std::string_view | content | ) |
Add a content to the current element on the stack. The content will be properly encoded.
content | content to be added to the current element. |
xmlns_id_t orcus::xml_writer::add_namespace | ( | std::string_view | alias, |
std::string_view | value ) |
Add a namespace definition for the next element to be pushed.
alias | alias for the namespace. |
value | value of the namespace definition. |
xml_name_t orcus::xml_writer::pop_element | ( | ) |
Pop the current element from the stack, and write a closing element to the output stream.
void orcus::xml_writer::push_element | ( | const xml_name_t & | name | ) |
Push a new element to the stack, and write an opening element to the output stream.
name | name of the element. |
scope orcus::xml_writer::push_element_scope | ( | const xml_name_t & | name | ) |
Push a new element to the stack, and write an opening element to the output stream. It differs from the push_element
method in that the new element will be automatically popped when the returned object goes out of scope.
name | name of the new element. |