Orcus
Loading...
Searching...
No Matches
include
orcus
xml_structure_tree.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_STRUCTURE_TREE_HPP
9
#define INCLUDED_ORCUS_XML_STRUCTURE_TREE_HPP
10
11
#include "env.hpp"
12
#include "types.hpp"
13
14
#include <ostream>
15
#include <memory>
16
#include <functional>
17
18
namespace
orcus {
19
20
class
xmlns_context;
21
22
struct
ORCUS_DLLPUBLIC
xml_table_range_t
23
{
24
std::vector<std::string> paths;
25
std::vector<std::string> row_groups;
26
27
xml_table_range_t
();
28
~xml_table_range_t
();
29
};
30
37
class
ORCUS_DLLPUBLIC
xml_structure_tree
38
{
39
struct
impl;
40
std::unique_ptr<impl> mp_impl;
41
42
public
:
43
xml_structure_tree
() =
delete
;
44
xml_structure_tree
(
const
xml_structure_tree
&) =
delete
;
45
xml_structure_tree
& operator= (
const
xml_structure_tree
&) =
delete
;
46
47
struct
ORCUS_DLLPUBLIC
entity_name
48
{
49
xmlns_id_t ns;
50
std::string_view name;
51
52
entity_name
();
53
entity_name
(xmlns_id_t _ns, std::string_view _name);
54
55
bool
operator< (
const
entity_name
& r)
const
;
56
bool
operator== (
const
entity_name
& r)
const
;
57
58
struct
ORCUS_DLLPUBLIC
hash
59
{
60
size_t
operator ()(
const
entity_name
& val)
const
;
61
};
62
};
63
64
typedef
std::vector<entity_name> entity_names_type;
65
66
struct
ORCUS_DLLPUBLIC
element
67
{
68
entity_name
name;
69
bool
repeat;
70
bool
has_content;
71
72
element
();
73
element
(
const
entity_name
& _name,
bool
_repeat,
bool
_has_content);
74
};
75
76
struct
walker_impl;
77
81
class
ORCUS_DLLPUBLIC
walker
82
{
83
friend
class
xml_structure_tree
;
84
85
std::unique_ptr<walker_impl> mp_impl;
86
87
walker
(
const
xml_structure_tree::impl& parent_impl);
88
public
:
89
walker
() =
delete
;
90
walker
(
const
walker
& r);
91
~walker
();
92
walker
& operator= (
const
walker
& r);
93
100
element
root
();
101
112
element
descend
(
const
entity_name
& name);
113
117
element
ascend
();
118
128
element
move_to
(
const
std::string& path);
129
136
entity_names_type
get_children
();
137
144
entity_names_type
get_attributes
();
145
155
size_t
get_xmlns_index
(xmlns_id_t ns)
const
;
156
157
std::string get_xmlns_short_name(xmlns_id_t ns)
const
;
158
167
std::string
to_string
(
const
entity_name
& name)
const
;
168
173
std::string
get_path
()
const
;
174
};
175
176
xml_structure_tree
(
xmlns_context
& xmlns_cxt);
177
xml_structure_tree
(
xml_structure_tree
&& other);
178
~xml_structure_tree
();
179
180
void
parse(std::string_view s);
181
182
void
dump_compact(std::ostream& os)
const
;
183
184
walker
get_walker()
const
;
185
186
using
range_handler_type = std::function<void(
xml_table_range_t
&&)>;
187
188
void
process_ranges(range_handler_type rh)
const
;
189
190
void
swap(
xml_structure_tree
& other);
191
};
192
193
}
194
195
196
197
#endif
198
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
orcus::xml_structure_tree::walker
Definition
xml_structure_tree.hpp:82
orcus::xml_structure_tree::walker::ascend
element ascend()
orcus::xml_structure_tree::walker::root
element root()
orcus::xml_structure_tree::walker::get_attributes
entity_names_type get_attributes()
orcus::xml_structure_tree::walker::move_to
element move_to(const std::string &path)
orcus::xml_structure_tree::walker::descend
element descend(const entity_name &name)
orcus::xml_structure_tree::walker::get_children
entity_names_type get_children()
orcus::xml_structure_tree::walker::get_path
std::string get_path() const
orcus::xml_structure_tree::walker::get_xmlns_index
size_t get_xmlns_index(xmlns_id_t ns) const
orcus::xml_structure_tree::walker::to_string
std::string to_string(const entity_name &name) const
orcus::xml_structure_tree
Definition
xml_structure_tree.hpp:38
orcus::xmlns_context
Definition
xml_namespace.hpp:100
orcus::xml_structure_tree::element
Definition
xml_structure_tree.hpp:67
orcus::xml_structure_tree::entity_name::hash
Definition
xml_structure_tree.hpp:59
orcus::xml_structure_tree::entity_name
Definition
xml_structure_tree.hpp:48
orcus::xml_table_range_t
Definition
xml_structure_tree.hpp:23
Generated on Sun Mar 24 2024 00:00:00 for Orcus by
1.10.0