Orcus
include
orcus
dom_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_DOM_TREE_HPP
9
#define INCLUDED_ORCUS_DOM_TREE_HPP
10
11
#include "pstring.hpp"
12
#include "types.hpp"
13
14
#include <vector>
15
#include <ostream>
16
#include <memory>
17
18
namespace
orcus {
19
20
class
xmlns_context;
21
struct
dom_tree_impl;
22
23
namespace
sax {
24
25
struct
doctype_declaration;
26
27
}
28
32
class
ORCUS_DLLPUBLIC
dom_tree
33
{
34
dom_tree
(
const
dom_tree
&) =
delete
;
35
dom_tree
& operator= (
const
dom_tree
&) =
delete
;
36
37
public
:
38
39
struct
entity_name
40
{
41
xmlns_id_t ns;
42
pstring
name;
43
44
entity_name
();
45
entity_name
(xmlns_id_t _ns,
const
pstring
& _name);
46
47
void
print(std::ostream& os,
const
xmlns_context
& cxt)
const
;
48
};
49
50
struct
attr
51
{
52
entity_name
name;
53
pstring
value;
54
55
attr
(xmlns_id_t _ns,
const
pstring
& _name,
const
pstring
& _value);
56
57
void
print(std::ostream& os,
const
xmlns_context
& cxt)
const
;
58
};
59
60
typedef
std::vector<attr> attrs_type;
61
62
enum class
node_type {
element
,
content
};
63
64
struct
node
65
{
66
node_type type;
67
68
node
(node_type _type) : type(_type) {}
69
70
virtual
~
node
() = 0;
71
virtual
void
print(std::ostream& os,
const
xmlns_context
& cxt)
const
= 0;
72
};
73
74
typedef
std::vector<std::unique_ptr<node>> nodes_type;
75
76
struct
element
:
public
node
77
{
78
entity_name
name;
79
attrs_type attrs;
80
nodes_type child_nodes;
81
82
element
(xmlns_id_t _ns,
const
pstring
& _name);
83
virtual
void
print(std::ostream& os,
const
xmlns_context
& cxt)
const
;
84
virtual
~
element
();
85
};
86
87
typedef
std::vector<element*> element_stack_type;
88
89
struct
content
:
public
node
90
{
91
pstring
value;
92
93
content
(
const
pstring
& _value);
94
virtual
void
print(std::ostream& os,
const
xmlns_context
& cxt)
const
;
95
virtual
~
content
();
96
};
97
98
dom_tree
(
xmlns_context
& cxt);
99
~
dom_tree
();
100
106
void
load(
const
std::string& strm);
107
113
void
swap(
dom_tree
& other);
114
115
void
start_declaration(
const
pstring
& name);
116
void
end_declaration(
const
pstring
& name);
117
void
start_element(xmlns_id_t ns,
const
pstring
& name);
118
void
end_element(xmlns_id_t ns,
const
pstring
& name);
119
void
set_characters(
const
pstring
& val);
120
void
set_attribute(xmlns_id_t ns,
const
pstring
& name,
const
pstring
& val);
121
122
void
set_doctype(
const
sax::doctype_declaration
& dtd);
123
const
sax::doctype_declaration
* get_doctype()
const
;
124
125
const
attrs_type* get_declaration_attributes(
const
pstring
& name)
const
;
126
127
void
dump_compact(std::ostream& os)
const
;
128
129
private
:
130
std::unique_ptr<dom_tree_impl> mp_impl;
131
};
132
133
}
134
135
#endif
136
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
orcus::dom_tree::attr
Definition:
dom_tree.hpp:50
orcus::dom_tree::node
Definition:
dom_tree.hpp:64
orcus::sax::doctype_declaration
Definition:
sax_parser_base.hpp:45
orcus::xmlns_context
Definition:
xml_namespace.hpp:80
orcus::dom_tree::entity_name
Definition:
dom_tree.hpp:39
orcus::dom_tree::element
Definition:
dom_tree.hpp:76
orcus::pstring
Definition:
pstring.hpp:24
orcus::dom_tree
Definition:
dom_tree.hpp:32
orcus::dom_tree::content
Definition:
dom_tree.hpp:89
Generated on Sat Sep 11 2021 07:46:52 for Orcus by
1.8.17