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 
30 public:
31  class ORCUS_PSR_DLLPUBLIC scope
32  {
33  friend class xml_writer;
34 
35  struct impl;
36  std::unique_ptr<impl> mp_impl;
37 
38  scope(xml_writer* parent, const xml_name_t& name);
39  public:
40  scope(const scope&) = delete;
41  scope(scope&& other);
42  ~scope();
43 
44  scope& operator= (scope&& other);
45  };
46 
47  xml_writer(const xml_writer&) = delete;
48  xml_writer& operator= (const xml_writer&) = delete;
49 
50  xml_writer(xmlns_repository& ns_repo, std::ostream& os);
51  xml_writer(xml_writer&& other);
52 
53  xml_writer& operator= (xml_writer&& other);
54 
59  ~xml_writer();
60 
72  scope push_element_scope(const xml_name_t& name);
73 
80  void push_element(const xml_name_t& name);
81 
90  xmlns_id_t add_namespace(const pstring& alias, const pstring& value);
91 
98  void add_attribute(const xml_name_t& name, const pstring& value);
99 
106  void add_content(const pstring& content);
107 
114  xml_name_t pop_element();
115 };
116 
117 }
118 
119 #endif
120 
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: pstring.hpp:27
Definition: xml_writer.hpp:31
Definition: xml_namespace.hpp:27
Definition: xml_writer.hpp:23
Definition: types.hpp:47
Definition: base64.hpp:15