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
16namespace orcus {
17
18class xmlns_context;
19class pstring;
20struct xmlns_repository_impl;
21struct xmlns_context_impl;
22
27class ORCUS_PSR_DLLPUBLIC xmlns_repository
28{
29 friend class xmlns_context;
30
31 struct impl;
32 std::unique_ptr<impl> mp_impl;
33
34 xmlns_id_t intern(const pstring& uri);
35
36 xmlns_repository(const xmlns_repository&); // disabled
37 xmlns_repository& operator= (const xmlns_repository&); // disabled
38
39 size_t get_index(xmlns_id_t ns_id) const;
40
41public:
44
57 void add_predefined_values(const xmlns_id_t* predefined_ns);
58
59 xmlns_context create_context();
60
68 xmlns_id_t get_identifier(size_t index) const;
69
70 std::string get_short_name(xmlns_id_t ns_id) const;
71 std::string get_short_name(size_t index) const;
72};
73
82class ORCUS_PSR_DLLPUBLIC xmlns_context
83{
84 friend class xmlns_repository;
85
86 struct impl;
87 std::unique_ptr<impl> mp_impl;
88
89 xmlns_context(); // disabled
91public:
94
95 xmlns_id_t push(const pstring& key, const pstring& uri);
96 void pop(const pstring& key);
97
105 xmlns_id_t get(const pstring& key) const;
106
115 size_t get_index(xmlns_id_t ns_id) const;
116
130 std::string get_short_name(xmlns_id_t ns_id) const;
131
141 pstring get_alias(xmlns_id_t ns_id) const;
142
143 std::vector<xmlns_id_t> get_all_namespaces() const;
144
145 void dump(std::ostream& os) const;
146};
147
148}
149
150#endif
151/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: pstring.hpp:28
Definition: xml_namespace.hpp:83
size_t get_index(xmlns_id_t ns_id) const
xmlns_id_t get(const pstring &key) const
std::string get_short_name(xmlns_id_t ns_id) const
pstring get_alias(xmlns_id_t ns_id) const
Definition: xml_namespace.hpp:28
void add_predefined_values(const xmlns_id_t *predefined_ns)
xmlns_id_t get_identifier(size_t index) const