dom_node.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_core.h"
00035 #include "../System/sharedptr.h"
00036 #include "dom_string.h"
00037 
00038 class CL_DomElement;
00039 class CL_DomAttr;
00040 class CL_DomText;
00041 class CL_DomCDATASection;
00042 class CL_DomEntityReference;
00043 class CL_DomEntity;
00044 class CL_DomProcessingInstruction;
00045 class CL_DomComment;
00046 class CL_DomDocument;
00047 class CL_DomDocumentType;
00048 class CL_DomDocumentFragment;
00049 class CL_DomNotation;
00050 class CL_DomNodeList;
00051 class CL_DomNamedNodeMap;
00052 class CL_DomNode_Generic;
00053 
00069 class CL_API_CORE CL_DomNode
00070 {
00073 
00074 public:
00075         CL_DomNode();
00076 
00080         CL_DomNode(const CL_DomNode &copy);
00081 
00082         ~CL_DomNode();
00083 
00087 
00088 public:
00090         enum NodeType
00091         {
00092                 NULL_NODE                     = 0,
00093                 ELEMENT_NODE                  = 1,
00094                 ATTRIBUTE_NODE                = 2,
00095                 TEXT_NODE                     = 3,
00096                 CDATA_SECTION_NODE            = 4,
00097                 ENTITY_REFERENCE_NODE         = 5,
00098                 ENTITY_NODE                   = 6,
00099                 PROCESSING_INSTRUCTION_NODE   = 7,
00100                 COMMENT_NODE                  = 8,
00101                 DOCUMENT_NODE                 = 9,
00102                 DOCUMENT_TYPE_NODE            = 10,
00103                 DOCUMENT_FRAGMENT_NODE        = 11,
00104                 NOTATION_NODE                 = 12
00105         };
00106 
00108 
00123         CL_DomString get_node_name() const;
00124 
00126         CL_DomString get_namespace_uri() const;
00127 
00129 
00132         CL_DomString get_prefix() const;
00133 
00135 
00142         void set_prefix(const CL_DomString &prefix);
00143 
00145 
00148         CL_DomString get_local_name() const;
00149 
00151 
00166         CL_DomString get_node_value() const;
00167 
00169         void set_node_value(const CL_DomString &value);
00170 
00172         unsigned short get_node_type() const;
00173 
00175 
00178         CL_DomNode get_parent_node() const;
00179 
00181 
00187         CL_DomNodeList get_child_nodes() const;
00188 
00190 
00191         CL_DomNode get_first_child() const;
00192 
00194 
00195         CL_DomNode get_last_child() const;
00196 
00198 
00199         CL_DomNode get_previous_sibling() const;
00200 
00202 
00203         CL_DomNode get_next_sibling() const;
00204 
00206         CL_DomNamedNodeMap get_attributes() const;
00207 
00209 
00210         CL_DomDocument get_owner_document() const;
00211 
00213         bool is_null() const;
00214 
00216         bool is_element() const;
00217 
00219         bool is_attr() const;
00220 
00222         bool is_text() const;
00223 
00225         bool is_cdata_section() const;
00226 
00228         bool is_entity_reference() const;
00229 
00231         bool is_entity() const;
00232 
00234         bool is_processing_instruction() const;
00235 
00237         bool is_comment() const;
00238 
00240         bool is_document() const;
00241 
00243         bool is_document_type() const;
00244 
00246         bool is_document_fragment() const;
00247 
00249         bool is_notation() const;
00250 
00252         bool is_supported(const CL_DomString &feature, const CL_DomString &version) const;
00253 
00255         bool has_attributes() const;
00256 
00258         bool has_child_nodes() const;
00259 
00263 
00264 public:
00266 
00269         CL_DomNode &operator =(const CL_DomNode &copy);
00270 
00272         bool operator ==(const CL_DomNode &other) const;
00273 
00275         bool operator !=(const CL_DomNode &other) const;
00276 
00278 
00288         void normalize();
00289 
00291 
00297         CL_DomNode insert_before(CL_DomNode &new_child, CL_DomNode &ref_child);
00298 
00300 
00304         CL_DomNode replace_child(CL_DomNode &new_child, CL_DomNode &old_child);
00305 
00307         CL_DomNode remove_child(CL_DomNode &old_child);
00308 
00310 
00311         CL_DomNode append_child(CL_DomNode new_child);
00312 
00314 
00321         CL_DomNode clone_node(bool deep) const;
00322 
00324 
00325         CL_DomElement to_element() const;
00326 
00328 
00329         CL_DomAttr to_attr() const;
00330 
00332 
00333         CL_DomText to_text() const;
00334 
00336 
00337         CL_DomCDATASection to_cdata_section() const;
00338 
00340 
00341         CL_DomEntityReference to_entity_reference() const;
00342 
00344 
00345         CL_DomEntity to_entity() const;
00346 
00348 
00349         CL_DomProcessingInstruction to_processing_instruction() const;
00350 
00352 
00353         CL_DomComment to_comment() const;
00354 
00356 
00357         CL_DomDocument to_document() const;
00358 
00360 
00361         CL_DomDocumentType to_document_type() const;
00362 
00364 
00365         CL_DomDocumentFragment to_document_fragment() const;
00366 
00368 
00369         CL_DomNotation to_notation() const;
00370 
00372 
00373         CL_DomNode named_item(const CL_DomString &name) const;
00374 
00376         CL_DomNode named_item_ns(
00377                 const CL_DomString &namespace_uri,
00378                 const CL_DomString &local_name) const;
00379 
00381         CL_DomString find_namespace_uri(const CL_DomString &qualified_name) const;
00382 
00384         CL_DomString find_prefix(const CL_DomString &namespace_uri) const;
00385 
00387         std::vector<CL_DomNode> select_nodes(const CL_DomString &xpath_expression) const;
00388 
00390         CL_DomNode select_node(const CL_DomString &xpath_expression) const;
00391 
00393         CL_String select_string(const CL_DomString &xpath_expression) const;
00394 
00396         int select_int(const CL_DomString &xpath_expression) const;
00397 
00399         float select_float(const CL_DomString &xpath_expression) const;
00400 
00402         bool select_bool(const CL_DomString &xpath_expression) const;
00403 
00407 
00408 protected:
00409 
00414         CL_DomNode(CL_DomDocument doc, unsigned short node_type);
00415 
00419         CL_DomNode(const CL_SharedPtr<CL_DomNode_Generic> &impl);
00420 
00421         CL_SharedPtr<CL_DomNode_Generic> impl;
00422 
00423         friend class CL_DomDocument;
00424 
00425         friend class CL_DomNamedNodeMap;
00427 };
00428