Orcus
Loading...
Searching...
No Matches
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
16namespace orcus {
17
18class xmlns_context;
19struct xmlns_repository_impl;
20struct xmlns_context_impl;
21
26class ORCUS_PSR_DLLPUBLIC xmlns_repository
27{
28 friend class xmlns_context;
29
30 struct impl;
31 std::unique_ptr<impl> mp_impl;
32
33 xmlns_id_t intern(std::string_view uri);
34
35 xmlns_repository(const xmlns_repository&); // disabled
36 xmlns_repository& operator= (const xmlns_repository&); // disabled
37
38 size_t get_index(xmlns_id_t ns_id) const;
39
40public:
43
56 void add_predefined_values(const xmlns_id_t* predefined_ns);
57
58 xmlns_context create_context();
59
67 xmlns_id_t get_identifier(size_t index) const;
68
69 std::string get_short_name(xmlns_id_t ns_id) const;
70 std::string get_short_name(size_t index) const;
71};
72
81class ORCUS_PSR_DLLPUBLIC xmlns_context
82{
83 friend class xmlns_repository;
84
85 struct impl;
86 std::unique_ptr<impl> mp_impl;
87
89public:
94
95 xmlns_context& operator= (const xmlns_context& r);
96 xmlns_context& operator= (xmlns_context&& r);
97
98 xmlns_id_t push(std::string_view key, std::string_view uri);
99 void pop(std::string_view key);
100
108 xmlns_id_t get(std::string_view key) const;
109
118 size_t get_index(xmlns_id_t ns_id) const;
119
133 std::string get_short_name(xmlns_id_t ns_id) const;
134
144 std::string_view get_alias(xmlns_id_t ns_id) const;
145
146 std::vector<xmlns_id_t> get_all_namespaces() const;
147
148 void dump(std::ostream& os) const;
149
153 void dump_state(std::ostream& os) const;
154
155 void swap(xmlns_context& other) noexcept;
156};
157
158}
159
160#endif
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: xml_namespace.hpp:82
xmlns_id_t get(std::string_view key) const
size_t get_index(xmlns_id_t ns_id) const
std::string get_short_name(xmlns_id_t ns_id) const
void dump_state(std::ostream &os) const
std::string_view get_alias(xmlns_id_t ns_id) const
Definition: xml_namespace.hpp:27
void add_predefined_values(const xmlns_id_t *predefined_ns)
xmlns_id_t get_identifier(size_t index) const