ClanLib  2.3.7
dom_node.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 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 
31 
32 #pragma once
33 
34 #include "../api_core.h"
35 #include "../System/sharedptr.h"
36 #include "dom_string.h"
37 
38 class CL_DomElement;
39 class CL_DomAttr;
40 class CL_DomText;
41 class CL_DomCDATASection;
43 class CL_DomEntity;
45 class CL_DomComment;
46 class CL_DomDocument;
47 class CL_DomDocumentType;
49 class CL_DomNotation;
50 class CL_DomNodeList;
51 class CL_DomNamedNodeMap;
52 class CL_DomNode_Generic;
53 
70 {
73 
74 public:
75  CL_DomNode();
76 
80  CL_DomNode(const CL_DomNode &copy);
81 
82  ~CL_DomNode();
83 
87 
88 public:
90  enum NodeType
91  {
92  NULL_NODE = 0,
93  ELEMENT_NODE = 1,
94  ATTRIBUTE_NODE = 2,
95  TEXT_NODE = 3,
96  CDATA_SECTION_NODE = 4,
97  ENTITY_REFERENCE_NODE = 5,
98  ENTITY_NODE = 6,
99  PROCESSING_INSTRUCTION_NODE = 7,
100  COMMENT_NODE = 8,
101  DOCUMENT_NODE = 9,
102  DOCUMENT_TYPE_NODE = 10,
103  DOCUMENT_FRAGMENT_NODE = 11,
104  NOTATION_NODE = 12
105  };
106 
108 
123  CL_DomString get_node_name() const;
124 
126  CL_DomString get_namespace_uri() const;
127 
129 
132  CL_DomString get_prefix() const;
133 
135 
142  void set_prefix(const CL_DomString &prefix);
143 
145 
148  CL_DomString get_local_name() const;
149 
151 
166  CL_DomString get_node_value() const;
167 
169  void set_node_value(const CL_DomString &value);
170 
172  unsigned short get_node_type() const;
173 
175 
178  CL_DomNode get_parent_node() const;
179 
181 
187  CL_DomNodeList get_child_nodes() const;
188 
190 
191  CL_DomNode get_first_child() const;
192 
194 
195  CL_DomNode get_last_child() const;
196 
198 
199  CL_DomNode get_previous_sibling() const;
200 
202 
203  CL_DomNode get_next_sibling() const;
204 
206  CL_DomNamedNodeMap get_attributes() const;
207 
209 
210  CL_DomDocument get_owner_document() const;
211 
213  bool is_null() const;
214 
216  bool is_element() const;
217 
219  bool is_attr() const;
220 
222  bool is_text() const;
223 
225  bool is_cdata_section() const;
226 
228  bool is_entity_reference() const;
229 
231  bool is_entity() const;
232 
234  bool is_processing_instruction() const;
235 
237  bool is_comment() const;
238 
240  bool is_document() const;
241 
243  bool is_document_type() const;
244 
246  bool is_document_fragment() const;
247 
249  bool is_notation() const;
250 
252  bool is_supported(const CL_DomString &feature, const CL_DomString &version) const;
253 
255  bool has_attributes() const;
256 
258  bool has_child_nodes() const;
259 
263 
264 public:
266 
269  CL_DomNode &operator =(const CL_DomNode &copy);
270 
272  bool operator ==(const CL_DomNode &other) const;
273 
275  bool operator !=(const CL_DomNode &other) const;
276 
278 
288  void normalize();
289 
291 
297  CL_DomNode insert_before(CL_DomNode &new_child, CL_DomNode &ref_child);
298 
300 
304  CL_DomNode replace_child(CL_DomNode &new_child, CL_DomNode &old_child);
305 
307  CL_DomNode remove_child(CL_DomNode &old_child);
308 
310 
311  CL_DomNode append_child(CL_DomNode new_child);
312 
314 
321  CL_DomNode clone_node(bool deep) const;
322 
324 
325  CL_DomElement to_element() const;
326 
328 
329  CL_DomAttr to_attr() const;
330 
332 
333  CL_DomText to_text() const;
334 
336 
337  CL_DomCDATASection to_cdata_section() const;
338 
340 
341  CL_DomEntityReference to_entity_reference() const;
342 
344 
345  CL_DomEntity to_entity() const;
346 
348 
349  CL_DomProcessingInstruction to_processing_instruction() const;
350 
352 
353  CL_DomComment to_comment() const;
354 
356 
357  CL_DomDocument to_document() const;
358 
360 
361  CL_DomDocumentType to_document_type() const;
362 
364 
365  CL_DomDocumentFragment to_document_fragment() const;
366 
368 
369  CL_DomNotation to_notation() const;
370 
372 
373  CL_DomNode named_item(const CL_DomString &name) const;
374 
376  CL_DomNode named_item_ns(
377  const CL_DomString &namespace_uri,
378  const CL_DomString &local_name) const;
379 
381  CL_DomString find_namespace_uri(const CL_DomString &qualified_name) const;
382 
384  CL_DomString find_prefix(const CL_DomString &namespace_uri) const;
385 
387  std::vector<CL_DomNode> select_nodes(const CL_DomString &xpath_expression) const;
388 
390  CL_DomNode select_node(const CL_DomString &xpath_expression) const;
391 
393  CL_String select_string(const CL_DomString &xpath_expression) const;
394 
396  int select_int(const CL_DomString &xpath_expression) const;
397 
399  float select_float(const CL_DomString &xpath_expression) const;
400 
402  bool select_bool(const CL_DomString &xpath_expression) const;
403 
407 
408 protected:
409 
414  CL_DomNode(CL_DomDocument doc, unsigned short node_type);
415 
419  CL_DomNode(const CL_SharedPtr<CL_DomNode_Generic> &impl);
420 
421  CL_SharedPtr<CL_DomNode_Generic> impl;
422 
423  friend class CL_DomDocument;
424 
425  friend class CL_DomNamedNodeMap;
427 };
428