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 __ORCUS_XML_NAMESPACE_MANAGER_HPP__
9 #define __ORCUS_XML_NAMESPACE_MANAGER_HPP__
10 
11 #include "types.hpp"
12 
13 #include <ostream>
14 
15 namespace orcus {
16 
17 class xmlns_context;
18 class pstring;
19 struct xmlns_repository_impl;
20 struct xmlns_context_impl;
21 
27 {
28  friend class xmlns_context;
29  xmlns_id_t intern(const pstring& uri);
30 
31  xmlns_repository(const xmlns_repository&); // disabled
32  xmlns_repository& operator= (const xmlns_repository&); // disabled
33 
34  size_t get_index(xmlns_id_t ns_id) const;
35 
36 public:
37  ORCUS_PSR_DLLPUBLIC xmlns_repository();
38  ORCUS_PSR_DLLPUBLIC ~xmlns_repository();
39 
52  ORCUS_PSR_DLLPUBLIC void add_predefined_values(const xmlns_id_t* predefined_ns);
53 
54  ORCUS_PSR_DLLPUBLIC xmlns_context create_context();
55 
63  ORCUS_PSR_DLLPUBLIC xmlns_id_t get_identifier(size_t index) const;
64 
65  ORCUS_PSR_DLLPUBLIC std::string get_short_name(xmlns_id_t ns_id) const;
66  ORCUS_PSR_DLLPUBLIC std::string get_short_name(size_t index) const;
67 
68 private:
69  xmlns_repository_impl* mp_impl;
70 };
71 
80 class ORCUS_PSR_DLLPUBLIC xmlns_context
81 {
82  friend class xmlns_repository;
83 
84  xmlns_context(); // disabled
85  xmlns_context(xmlns_repository& repo);
86 public:
87  xmlns_context(const xmlns_context& r);
88  ~xmlns_context();
89 
90  xmlns_id_t push(const pstring& key, const pstring& uri);
91  void pop(const pstring& key);
92  xmlns_id_t get(const pstring& key) const;
93  size_t get_index(xmlns_id_t ns_id) const;
94  std::string get_short_name(xmlns_id_t ns_id) const;
95 
105  pstring get_alias(xmlns_id_t ns_id) const;
106 
107  void get_all_namespaces(std::vector<xmlns_id_t>& nslist) const;
108 
109  void dump(std::ostream& os) const;
110 
111 private:
112  xmlns_context_impl* mp_impl;
113 };
114 
115 }
116 
117 #endif
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: pstring.hpp:24
ORCUS_PSR_DLLPUBLIC xmlns_id_t get_identifier(size_t index) const
Definition: xml_namespace.hpp:80
ORCUS_PSR_DLLPUBLIC void add_predefined_values(const xmlns_id_t *predefined_ns)
Definition: xml_namespace.hpp:26
Definition: base64.hpp:15