Orcus
xml_namespace.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_NAMESPACE_MANAGER_HPP
9 #define INCLUDED_ORCUS_XML_NAMESPACE_MANAGER_HPP
10 
11 #include "types.hpp"
12 
13 #include <ostream>
14 #include <memory>
15 
16 namespace orcus {
17 
18 class xmlns_context;
19 struct xmlns_repository_impl;
20 struct xmlns_context_impl;
21 
29 class ORCUS_PSR_DLLPUBLIC xmlns_repository
30 {
31  friend class xmlns_context;
32 
33  struct impl;
34  std::unique_ptr<impl> mp_impl;
35 
36  xmlns_id_t intern(std::string_view uri);
37 
38  size_t get_index(xmlns_id_t ns_id) const;
39 
40 public:
41  xmlns_repository(const xmlns_repository&) = delete;
42  xmlns_repository& operator= (const xmlns_repository&) = delete;
43 
47 
48  xmlns_repository& operator= (xmlns_repository&&);
49 
62  void add_predefined_values(const xmlns_id_t* predefined_ns);
63 
74 
82  xmlns_id_t get_identifier(size_t index) const;
83 
88  std::string get_short_name(xmlns_id_t ns_id) const;
89 };
90 
99 class ORCUS_PSR_DLLPUBLIC xmlns_context
100 {
101  friend class xmlns_repository;
102 
103  struct impl;
104  std::unique_ptr<impl> mp_impl;
105 
107 public:
108  xmlns_context();
110  xmlns_context(const xmlns_context& r);
111  ~xmlns_context();
112 
113  xmlns_context& operator= (const xmlns_context& r);
114  xmlns_context& operator= (xmlns_context&& r);
115 
126  xmlns_id_t push(std::string_view alias, std::string_view uri);
127 
133  void pop(std::string_view alias);
134 
142  xmlns_id_t get(std::string_view alias) const;
143 
152  size_t get_index(xmlns_id_t ns_id) const;
153 
167  std::string get_short_name(xmlns_id_t ns_id) const;
168 
178  std::string_view get_alias(xmlns_id_t ns_id) const;
179 
180  std::vector<xmlns_id_t> get_all_namespaces() const;
181 
182  void dump(std::ostream& os) const;
183 
187  void dump_state(std::ostream& os) const;
188 
189  void swap(xmlns_context& other) noexcept;
190 };
191 
192 }
193 
194 #endif
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: xml_namespace.hpp:100
size_t get_index(xmlns_id_t ns_id) const
xmlns_id_t push(std::string_view alias, std::string_view uri)
std::string get_short_name(xmlns_id_t ns_id) const
xmlns_id_t get(std::string_view alias) const
void dump_state(std::ostream &os) const
std::string_view get_alias(xmlns_id_t ns_id) const
void pop(std::string_view alias)
Definition: xml_namespace.hpp:30
xmlns_context create_context()
std::string get_short_name(xmlns_id_t ns_id) const
void add_predefined_values(const xmlns_id_t *predefined_ns)
xmlns_id_t get_identifier(size_t index) const