Orcus
xml_writer.hpp
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_ORCUS_XML_WRITER_HPP
9 #define INCLUDED_ORCUS_XML_WRITER_HPP
10 
11 #include "orcus/types.hpp"
12 
13 #include <memory>
14 
15 namespace orcus {
16 
17 class xmlns_repository;
18 
23 class ORCUS_PSR_DLLPUBLIC xml_writer
24 {
25  struct impl;
26  std::unique_ptr<impl> mp_impl;
27 
28  void close_current_element();
29  void pop_elements();
30 
31 public:
32  class ORCUS_PSR_DLLPUBLIC scope
33  {
34  friend class xml_writer;
35 
36  struct impl;
37  std::unique_ptr<impl> mp_impl;
38 
39  scope(xml_writer* parent, const xml_name_t& name);
40  public:
41  scope(const scope&) = delete;
42  scope(scope&& other);
43  ~scope();
44 
45  scope& operator= (scope&& other);
46  };
47 
48  xml_writer(const xml_writer&) = delete;
49  xml_writer& operator= (const xml_writer&) = delete;
50 
51  xml_writer(xmlns_repository& ns_repo, std::ostream& os);
52  xml_writer(xml_writer&& other);
53 
54  xml_writer& operator= (xml_writer&& other);
55 
61 
74 
81  void push_element(const xml_name_t& name);
82 
91  xmlns_id_t add_namespace(std::string_view alias, std::string_view value);
92 
99  void add_attribute(const xml_name_t& name, std::string_view value);
100 
107  void add_content(std::string_view content);
108 
116 };
117 
118 }
119 
120 #endif
121 
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: xml_writer.hpp:33
Definition: xml_writer.hpp:24
void push_element(const xml_name_t &name)
xml_name_t pop_element()
void add_content(std::string_view content)
scope push_element_scope(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)
Definition: xml_namespace.hpp:27
Definition: types.hpp:59