dom_node.h Source File - ClanLib SDK
Description: dom_node.h Source File

dom_node.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** arising from the use of this software.
8**
9** Permission is granted to anyone to use this software for any purpose,
10** including commercial applications, and to alter it and redistribute it
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Magnus Norddahl
27*/
28
29
30#pragma once
31
32#include <memory>
33#include "dom_string.h"
34
35namespace clan
36{
39
40 class DomElement;
41 class DomAttr;
42 class DomText;
43 class DomCDATASection;
44 class DomEntityReference;
45 class DomEntity;
46 class DomProcessingInstruction;
47 class DomComment;
48 class DomDocument;
49 class DomDocumentType;
50 class DomDocumentFragment;
51 class DomNotation;
52 class DomNodeList;
53 class DomNamedNodeMap;
54 class DomNode_Impl;
55
70 class DomNode
71 {
72 public:
73 DomNode();
74
78 DomNode(const DomNode &copy);
79
80 ~DomNode();
81
83 enum NodeType
84 {
85 NULL_NODE = 0,
86 ELEMENT_NODE = 1,
87 ATTRIBUTE_NODE = 2,
88 TEXT_NODE = 3,
89 CDATA_SECTION_NODE = 4,
90 ENTITY_REFERENCE_NODE = 5,
91 ENTITY_NODE = 6,
92 PROCESSING_INSTRUCTION_NODE = 7,
93 COMMENT_NODE = 8,
94 DOCUMENT_NODE = 9,
95 DOCUMENT_TYPE_NODE = 10,
96 DOCUMENT_FRAGMENT_NODE = 11,
97 NOTATION_NODE = 12
98 };
99
101
116 DomString get_node_name() const;
117
119 DomString get_namespace_uri() const;
120
122
125 DomString get_prefix() const;
126
128
135 void set_prefix(const DomString &prefix);
136
138
141 DomString get_local_name() const;
142
144
159 DomString get_node_value() const;
160
162 void set_node_value(const DomString &value);
163
165 unsigned short get_node_type() const;
166
168
171 DomNode get_parent_node() const;
172
174
180 DomNodeList get_child_nodes() const;
181
183
184 DomNode get_first_child() const;
185
187
188 DomNode get_last_child() const;
189
191
192 DomNode get_previous_sibling() const;
193
195
196 DomNode get_next_sibling() const;
197
199 DomNamedNodeMap get_attributes() const;
200
202
203 DomDocument get_owner_document() const;
204
206 bool is_null() const;
207
209 bool is_element() const;
210
212 bool is_attr() const;
213
215 bool is_text() const;
216
218 bool is_cdata_section() const;
219
221 bool is_entity_reference() const;
222
224 bool is_entity() const;
225
227 bool is_processing_instruction() const;
228
230 bool is_comment() const;
231
233 bool is_document() const;
234
236 bool is_document_type() const;
237
239 bool is_document_fragment() const;
240
242 bool is_notation() const;
243
245 bool is_supported(const DomString &feature, const DomString &version) const;
246
248 bool has_attributes() const;
249
251 bool has_child_nodes() const;
252
254
257 DomNode &operator =(const DomNode &copy);
258
260 bool operator ==(const DomNode &other) const;
261
263 bool operator !=(const DomNode &other) const;
264
266
276 void normalize();
277
279
285 DomNode insert_before(DomNode &new_child, DomNode &ref_child);
286
288
292 DomNode replace_child(DomNode &new_child, DomNode &old_child);
293
295 DomNode remove_child(DomNode &old_child);
296
298
299 DomNode append_child(DomNode new_child);
300
302
309 DomNode clone_node(bool deep) const;
310
312
313 DomElement to_element() const;
314
316
317 DomAttr to_attr() const;
318
320
321 DomText to_text() const;
322
324
325 DomCDATASection to_cdata_section() const;
326
328
329 DomEntityReference to_entity_reference() const;
330
332
333 DomEntity to_entity() const;
334
336
337 DomProcessingInstruction to_processing_instruction() const;
338
340
341 DomComment to_comment() const;
342
344
345 DomDocument to_document() const;
346
348
349 DomDocumentType to_document_type() const;
350
352
353 DomDocumentFragment to_document_fragment() const;
354
356
357 DomNotation to_notation() const;
358
360
361 DomNode named_item(const DomString &name) const;
362
364 DomNode named_item_ns(
365 const DomString &namespace_uri,
366 const DomString &local_name) const;
367
369 DomString find_namespace_uri(const DomString &qualified_name) const;
370
372 DomString find_prefix(const DomString &namespace_uri) const;
373
375 std::vector<DomNode> select_nodes(const DomString &xpath_expression) const;
376
378 DomNode select_node(const DomString &xpath_expression) const;
379
381 std::string select_string(const DomString &xpath_expression) const;
382
384 int select_int(const DomString &xpath_expression) const;
385
387 float select_float(const DomString &xpath_expression) const;
388
390 bool select_bool(const DomString &xpath_expression) const;
391
392 protected:
393 DomNode(DomDocument doc, unsigned short node_type);
394 DomNode(const std::shared_ptr<DomNode_Impl> &impl);
395
396 std::shared_ptr<DomNode_Impl> impl;
397
398 friend class DomDocument;
399 friend class DomNamedNodeMap;
400 };
401
403}
clan::DomAttr
DOM Attribute class.
Definition dom_attr.h:67
clan::DomCDATASection
DOM CDATA Section.
Definition dom_cdata_section.h:55
clan::DomComment
DOM Comment class.
Definition dom_comment.h:45
clan::DomDocumentFragment
DOM Document Fragment class.
Definition dom_document_fragment.h:71
clan::DomDocumentType
DOM Document Type class.
Definition dom_document_type.h:51
clan::DomDocument
DOM Document class.
Definition dom_document.h:65
clan::DomElement
DOM Element class.
Definition dom_element.h:60
clan::DomEntityReference
DOM Entity Reference class.
Definition dom_entity_reference.h:52
clan::DomEntity
DOM Entity class.
Definition dom_entity.h:46
clan::DomNamedNodeMap
DOM Named Node Map class.
Definition dom_named_node_map.h:52
clan::DomNodeList
DOM Node List class.
Definition dom_node_list.h:51
clan::DomNode::to_entity_reference
DomEntityReference to_entity_reference() const
Returns the Entity Reference interface to this node.
clan::DomNode::get_attributes
DomNamedNodeMap get_attributes() const
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
clan::DomNode::set_node_value
void set_node_value(const DomString &value)
Sets the node value.
clan::DomNode::get_previous_sibling
DomNode get_previous_sibling() const
The node immediately preceding this node.
clan::DomNode::select_string
std::string select_string(const DomString &xpath_expression) const
Returns the first node value matching the specified xpath expression using this node as the context n...
clan::DomNode::named_item_ns
DomNode named_item_ns(const DomString &namespace_uri, const DomString &local_name) const
Retrieves the first child node with the specified namespace URI and local name.
clan::DomNode::find_prefix
DomString find_prefix(const DomString &namespace_uri) const
Searches the node tree upwards for the prefix name for the namespace URI.
clan::DomNode::to_notation
DomNotation to_notation() const
Returns the Notation interface to this node.
clan::DomNode::select_nodes
std::vector< DomNode > select_nodes(const DomString &xpath_expression) const
Returns all the nodes matching the specified xpath expression using this node as the context node.
clan::DomNode::is_null
bool is_null() const
Returns true if this is a null node.
clan::DomNode::get_owner_document
DomDocument get_owner_document() const
The Document object associated with this node.
clan::DomNode::get_node_name
DomString get_node_name() const
Returns the node name.
clan::DomNode::to_text
DomText to_text() const
Returns the Text interface to this node.
clan::DomNode::is_document_type
bool is_document_type() const
Returns true if this is a document type node.
clan::DomNode::is_processing_instruction
bool is_processing_instruction() const
Returns true if this is a processing instruction node.
clan::DomNode::select_node
DomNode select_node(const DomString &xpath_expression) const
Returns the first node matching the specified xpath expression using this node as the context node.
clan::DomNode::select_int
int select_int(const DomString &xpath_expression) const
Returns the first node value (as integer) matching the specified xpath expression using this node as ...
clan::DomNode::clone_node
DomNode clone_node(bool deep) const
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
clan::DomNode::append_child
DomNode append_child(DomNode new_child)
Adds the node new_child to the end of the list of children of this node.
clan::DomNode::to_comment
DomComment to_comment() const
Returns the Comment interface to this node.
clan::DomNode::get_last_child
DomNode get_last_child() const
The last child of this node.
clan::DomNode::get_next_sibling
DomNode get_next_sibling() const
The node immediately following this node.
clan::DomNode::to_attr
DomAttr to_attr() const
Returns the Attribute interface to this node.
clan::DomNode::to_cdata_section
DomCDATASection to_cdata_section() const
Returns the CDATA Section interface to this node.
clan::DomNode::select_float
float select_float(const DomString &xpath_expression) const
Returns the first node value (as float) matching the specified xpath expression using this node as th...
clan::DomNode::is_cdata_section
bool is_cdata_section() const
Returns true if this is a CDATA section node.
clan::DomNode::has_child_nodes
bool has_child_nodes() const
Returns true if this node has any children.
clan::DomNode::find_namespace_uri
DomString find_namespace_uri(const DomString &qualified_name) const
Searches the node tree upwards for the namespace URI of the given qualified name.
clan::DomNode::get_first_child
DomNode get_first_child() const
The first child of this node.
clan::DomNode::remove_child
DomNode remove_child(DomNode &old_child)
Removes the child node indicated by old_child from the list of children, and returns it.
clan::DomNode::get_parent_node
DomNode get_parent_node() const
Returns the parent of this node.
clan::DomNode::to_document_fragment
DomDocumentFragment to_document_fragment() const
Returns the Document Fragment interface to this node.
clan::DomNode::DomNode
DomNode()
clan::DomNode::DomDocument
friend class DomDocument
Definition dom_node.h:398
clan::DomNode::~DomNode
~DomNode()
clan::DomNode::operator=
DomNode & operator=(const DomNode &copy)
Copy assignment operator.
clan::DomNode::insert_before
DomNode insert_before(DomNode &new_child, DomNode &ref_child)
Inserts the node new_child before the existing child node ref_child.
clan::DomNode::get_node_type
unsigned short get_node_type() const
Returns the node type (one of those in the NodeType enum).
clan::DomNode::is_supported
bool is_supported(const DomString &feature, const DomString &version) const
Tests whether the DOM implementation implements a specific feature and that feature is supported by t...
clan::DomNode::set_prefix
void set_prefix(const DomString &prefix)
Sets the namespace prefix of the node.
clan::DomNode::get_prefix
DomString get_prefix() const
Returns the namespace prefix of the node.
clan::DomNode::is_entity_reference
bool is_entity_reference() const
Returns true if this is an entity reference node.
clan::DomNode::operator==
bool operator==(const DomNode &other) const
Compare operator.
clan::DomNode::get_local_name
DomString get_local_name() const
Returns local part of the qualified name of this node.
clan::DomNode::is_document
bool is_document() const
Returns true if this is a document node.
clan::DomNode::is_entity
bool is_entity() const
Returns true if this is an entity node.
clan::DomNode::to_entity
DomEntity to_entity() const
Returns the Entity interface to this node.
clan::DomNode::is_text
bool is_text() const
Returns true if this is a text node.
clan::DomNode::is_element
bool is_element() const
Returns true if this is an element node.
clan::DomNode::is_document_fragment
bool is_document_fragment() const
Returns true if this is a document fragment node.
clan::DomNode::replace_child
DomNode replace_child(DomNode &new_child, DomNode &old_child)
Replaces the child node old_child with new_child in the list of children.
clan::DomNode::get_child_nodes
DomNodeList get_child_nodes() const
Returns a NodeList that contains all children of this node.
clan::DomNode::DomNode
DomNode(const std::shared_ptr< DomNode_Impl > &impl)
clan::DomNode::impl
std::shared_ptr< DomNode_Impl > impl
Definition dom_node.h:396
clan::DomNode::operator!=
bool operator!=(const DomNode &other) const
Compare operator.
clan::DomNode::NodeType
NodeType
An integer indicating which type of node this is.
Definition dom_node.h:84
clan::DomNode::ENTITY_REFERENCE_NODE
@ ENTITY_REFERENCE_NODE
Definition dom_node.h:90
clan::DomNode::NOTATION_NODE
@ NOTATION_NODE
Definition dom_node.h:97
clan::DomNode::ELEMENT_NODE
@ ELEMENT_NODE
Definition dom_node.h:86
clan::DomNode::DOCUMENT_NODE
@ DOCUMENT_NODE
Definition dom_node.h:94
clan::DomNode::COMMENT_NODE
@ COMMENT_NODE
Definition dom_node.h:93
clan::DomNode::PROCESSING_INSTRUCTION_NODE
@ PROCESSING_INSTRUCTION_NODE
Definition dom_node.h:92
clan::DomNode::ENTITY_NODE
@ ENTITY_NODE
Definition dom_node.h:91
clan::DomNode::NULL_NODE
@ NULL_NODE
Definition dom_node.h:85
clan::DomNode::DOCUMENT_FRAGMENT_NODE
@ DOCUMENT_FRAGMENT_NODE
Definition dom_node.h:96
clan::DomNode::ATTRIBUTE_NODE
@ ATTRIBUTE_NODE
Definition dom_node.h:87
clan::DomNode::CDATA_SECTION_NODE
@ CDATA_SECTION_NODE
Definition dom_node.h:89
clan::DomNode::DOCUMENT_TYPE_NODE
@ DOCUMENT_TYPE_NODE
Definition dom_node.h:95
clan::DomNode::TEXT_NODE
@ TEXT_NODE
Definition dom_node.h:88
clan::DomNode::to_document_type
DomDocumentType to_document_type() const
Returns the Document Type interface to this node.
clan::DomNode::is_comment
bool is_comment() const
Returns true if this is a comment node.
clan::DomNode::is_attr
bool is_attr() const
Returns true if this is an attribute node.
clan::DomNode::named_item
DomNode named_item(const DomString &name) const
Returns the first child node with the specified node name.
clan::DomNode::DomNamedNodeMap
friend class DomNamedNodeMap
Definition dom_node.h:399
clan::DomNode::select_bool
bool select_bool(const DomString &xpath_expression) const
Returns the first node value (as boolean) matching the specified xpath expression using this node as ...
clan::DomNode::to_processing_instruction
DomProcessingInstruction to_processing_instruction() const
Returns the Processing Instruction interface to this node.
clan::DomNode::get_node_value
DomString get_node_value() const
Returns the node value.
clan::DomNode::to_document
DomDocument to_document() const
Returns the Document interface to this node.
clan::DomNode::is_notation
bool is_notation() const
Returns true if this is a notation node.
clan::DomNode::DomNode
DomNode(const DomNode &copy)
Constructs a DomNode.
clan::DomNode::get_namespace_uri
DomString get_namespace_uri() const
Returns the namespace URI of this node.
clan::DomNode::to_element
DomElement to_element() const
Returns the Element interface to this node.
clan::DomNode::has_attributes
bool has_attributes() const
Returns true if this node (if its an element) has any attributes.
clan::DomNode::DomNode
DomNode(DomDocument doc, unsigned short node_type)
clan::DomNode::normalize
void normalize()
Merges any adjacent Text nodes.
clan::DomNotation
DOM Notation class.
Definition dom_notation.h:49
clan::DomProcessingInstruction
DOM Processing Instruction class.
Definition dom_processing_instruction.h:44
clan::DomText
DOM Text class.
Definition dom_text.h:55
clan::DomString
std::string DomString
Definition dom_string.h:37
clan
Definition clanapp.h:36