Xerces-C++ 3.2.5
DOMNode.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_DOMNODE_HPP)
23#define XERCESC_INCLUDE_GUARD_DOMNODE_HPP
24
26
28
29
30class DOMDocument;
31class DOMNamedNodeMap;
32class DOMNodeList;
34
140protected:
141 // -----------------------------------------------------------------------
142 // Hidden constructors
143 // -----------------------------------------------------------------------
147 DOMNode(const DOMNode &) {}
149
150private:
151 // -----------------------------------------------------------------------
152 // Unimplemented constructors and operators
153 // -----------------------------------------------------------------------
156 DOMNode & operator = (const DOMNode &);
158
159public:
160 // -----------------------------------------------------------------------
161 // All constructors are hidden, just the destructor is available
162 // -----------------------------------------------------------------------
169 virtual ~DOMNode() {};
171
172 // -----------------------------------------------------------------------
173 // Class Types
174 // -----------------------------------------------------------------------
182 enum NodeType {
183 ELEMENT_NODE = 1,
184 ATTRIBUTE_NODE = 2,
185 TEXT_NODE = 3,
186 CDATA_SECTION_NODE = 4,
187 ENTITY_REFERENCE_NODE = 5,
188 ENTITY_NODE = 6,
189 PROCESSING_INSTRUCTION_NODE = 7,
190 COMMENT_NODE = 8,
191 DOCUMENT_NODE = 9,
192 DOCUMENT_TYPE_NODE = 10,
193 DOCUMENT_FRAGMENT_NODE = 11,
194 NOTATION_NODE = 12
195 };
196
216 DOCUMENT_POSITION_DISCONNECTED = 0x01,
217 DOCUMENT_POSITION_PRECEDING = 0x02,
218 DOCUMENT_POSITION_FOLLOWING = 0x04,
219 DOCUMENT_POSITION_CONTAINS = 0x08,
220 DOCUMENT_POSITION_CONTAINED_BY = 0x10,
221 DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
222 };
224
225 // -----------------------------------------------------------------------
226 // Virtual DOMNode interface
227 // -----------------------------------------------------------------------
230 // -----------------------------------------------------------------------
231 // Getter methods
232 // -----------------------------------------------------------------------
237 virtual const XMLCh * getNodeName() const = 0;
238
246 virtual const XMLCh * getNodeValue() const = 0;
247
252 virtual NodeType getNodeType() const = 0;
253
264 virtual DOMNode *getParentNode() const = 0;
265
280 virtual DOMNodeList *getChildNodes() const = 0;
287 virtual DOMNode *getFirstChild() const = 0;
288
295 virtual DOMNode *getLastChild() const = 0;
296
303 virtual DOMNode *getPreviousSibling() const = 0;
304
311 virtual DOMNode *getNextSibling() const = 0;
312
318 virtual DOMNamedNodeMap *getAttributes() const = 0;
319
331 virtual DOMDocument *getOwnerDocument() const = 0;
332
333 // -----------------------------------------------------------------------
334 // Node methods
335 // -----------------------------------------------------------------------
355 virtual DOMNode * cloneNode(bool deep) const = 0;
356
384 virtual DOMNode *insertBefore(DOMNode *newChild,
385 DOMNode *refChild) = 0;
386
387
411 virtual DOMNode *replaceChild(DOMNode *newChild,
412 DOMNode *oldChild) = 0;
425 virtual DOMNode *removeChild(DOMNode *oldChild) = 0;
426
447 virtual DOMNode *appendChild(DOMNode *newChild) = 0;
448
449 // -----------------------------------------------------------------------
450 // Query methods
451 // -----------------------------------------------------------------------
460 virtual bool hasChildNodes() const = 0;
461
462 // -----------------------------------------------------------------------
463 // Setter methods
464 // -----------------------------------------------------------------------
480 virtual void setNodeValue(const XMLCh *nodeValue) = 0;
482
505 virtual void normalize() = 0;
506
522 virtual bool isSupported(const XMLCh *feature,
523 const XMLCh *version) const = 0;
524
540 virtual const XMLCh * getNamespaceURI() const = 0;
541
548 virtual const XMLCh * getPrefix() const = 0;
549
559 virtual const XMLCh * getLocalName() const = 0;
560
594 virtual void setPrefix(const XMLCh * prefix) = 0;
595
602 virtual bool hasAttributes() const = 0;
604
622 virtual bool isSameNode(const DOMNode* other) const = 0;
623
664 virtual bool isEqualNode(const DOMNode* arg) const = 0;
665
666
692 virtual void* setUserData(const XMLCh* key,
693 void* data,
694 DOMUserDataHandler* handler) = 0;
695
707 virtual void* getUserData(const XMLCh* key) const = 0;
708
709
726 virtual const XMLCh* getBaseURI() const = 0;
727
738 virtual short compareDocumentPosition(const DOMNode* other) const = 0;
739
784 virtual const XMLCh* getTextContent() const = 0;
785
797 virtual void setTextContent(const XMLCh* textContent) = 0;
798
810 virtual const XMLCh* lookupPrefix(const XMLCh* namespaceURI) const = 0;
811
821 virtual bool isDefaultNamespace(const XMLCh* namespaceURI) const = 0;
822
834 virtual const XMLCh* lookupNamespaceURI(const XMLCh* prefix) const = 0;
835
851 virtual void* getFeature(const XMLCh* feature, const XMLCh* version) const = 0;
853
854 // -----------------------------------------------------------------------
855 // Non-standard Extension
856 // -----------------------------------------------------------------------
872 virtual void release() = 0;
874#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
875 // -----------------------------------------------------------------------
876 // Non-standard Extension
877 // -----------------------------------------------------------------------
887 virtual void decRefCount() {}
889
890 // -----------------------------------------------------------------------
891 // Non-standard Extension
892 // -----------------------------------------------------------------------
899 virtual void incRefCount() {}
901#endif
902};
903
904/***
905 * Utilities macros for getting memory manager within DOM
906***/
907#define GET_OWNER_DOCUMENT(ptr) \
908 ((DOMDocumentImpl*)(ptr->getOwnerDocument()))
909
910#define GET_DIRECT_MM(ptr) \
911 (ptr ? ((DOMDocumentImpl*)ptr)->getMemoryManager() : XMLPlatformUtils::fgMemoryManager)
912
913#define GET_INDIRECT_MM(ptr) \
914 (!ptr ? XMLPlatformUtils::fgMemoryManager : \
915 GET_OWNER_DOCUMENT(ptr) ? GET_OWNER_DOCUMENT(ptr)->getMemoryManager() : \
916 XMLPlatformUtils::fgMemoryManager)
917
918/***
919 * For DOMNode and its derivatives
920***/
921#define GetDOMNodeMemoryManager GET_INDIRECT_MM(this)
922
924
925#endif
#define CDOM_EXPORT
Definition XercesDefs.hpp:166
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
uint16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
The DOMDocument interface represents the entire XML document.
Definition DOMDocument.hpp:67
DOMNamedNodeMaps are used to represent collections of nodes that can be accessed by name.
Definition DOMNamedNodeMap.hpp:45
The DOMNodeList interface provides the abstraction of an ordered collection of nodes.
Definition DOMNodeList.hpp:45
The DOMNode interface is the primary datatype for the entire Document Object Model.
Definition DOMNode.hpp:139
virtual void setPrefix(const XMLCh *prefix)=0
Set the namespace prefix of this node.
virtual const XMLCh * lookupPrefix(const XMLCh *namespaceURI) const =0
Look up the prefix associated to the given namespace URI, starting from this node.
DOMNode(const DOMNode &)
Definition DOMNode.hpp:147
virtual void * getUserData(const XMLCh *key) const =0
Retrieves the object associated to a key on a this node.
virtual short compareDocumentPosition(const DOMNode *other) const =0
Compares the reference node, i.e.
virtual DOMNode * replaceChild(DOMNode *newChild, DOMNode *oldChild)=0
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node...
virtual DOMNode * getNextSibling() const =0
Gets the node immediately following this node.
virtual const XMLCh * lookupNamespaceURI(const XMLCh *prefix) const =0
Look up the namespace URI associated to the given prefix, starting from this node.
virtual const XMLCh * getBaseURI() const =0
The absolute base URI of this node or null if undefined.
virtual bool hasAttributes() const =0
Returns whether this node (if it is an element) has any attributes.
virtual DOMNode * cloneNode(bool deep) const =0
Returns a duplicate of this node.
virtual DOMNamedNodeMap * getAttributes() const =0
Gets a DOMNamedNodeMap containing the attributes of this node (if it is an DOMElement) or null otherw...
virtual DOMNode * insertBefore(DOMNode *newChild, DOMNode *refChild)=0
Inserts the node newChild before the existing child node refChild.
virtual DOMNode * getParentNode() const =0
Gets the parent of this node.
virtual const XMLCh * getNamespaceURI() const =0
Get the namespace URI of this node, or null if it is unspecified.
virtual const XMLCh * getPrefix() const =0
Get the namespace prefix of this node, or null if it is unspecified.
virtual const XMLCh * getLocalName() const =0
Returns the local part of the qualified name of this node.
virtual DOMNode * getPreviousSibling() const =0
Gets the node immediately preceding this node.
virtual NodeType getNodeType() const =0
An enum value representing the type of the underlying object.
virtual const XMLCh * getTextContent() const =0
WARNING: This method is known to be buggy and does not produce accurate results under a variety of co...
NodeType
NodeType.
Definition DOMNode.hpp:182
virtual void release()=0
Called to indicate that this Node (and its associated children) is no longer in use and that the impl...
virtual DOMNode * appendChild(DOMNode *newChild)=0
Adds the node newChild to the end of the list of children of this node.
virtual DOMNode * getFirstChild() const =0
Gets the first child of this node.
virtual void setTextContent(const XMLCh *textContent)=0
This attribute removes any possible children this node may have and, if the new string is not empty o...
virtual void * getFeature(const XMLCh *feature, const XMLCh *version) const =0
This method makes available a DOMNode's specialized interface.
virtual ~DOMNode()
Destructor.
Definition DOMNode.hpp:169
DOMNode()
Definition DOMNode.hpp:146
DocumentPosition
DocumentPosition:
Definition DOMNode.hpp:215
virtual DOMNodeList * getChildNodes() const =0
Gets a DOMNodeList that contains all children of this node.
virtual DOMNode * removeChild(DOMNode *oldChild)=0
Removes the child node indicated by oldChild from the list of children, and returns it.
virtual const XMLCh * getNodeName() const =0
The name of this node, depending on its type; see the table above.
virtual bool isSameNode(const DOMNode *other) const =0
Returns whether this node is the same node as the given one.
virtual bool isDefaultNamespace(const XMLCh *namespaceURI) const =0
This method checks if the specified namespaceURI is the default namespace or not.
virtual void * setUserData(const XMLCh *key, void *data, DOMUserDataHandler *handler)=0
Associate an object to a key on this node.
virtual void setNodeValue(const XMLCh *nodeValue)=0
Sets the value of the node.
virtual bool hasChildNodes() const =0
This is a convenience method to allow easy determination of whether a node has any children.
virtual bool isEqualNode(const DOMNode *arg) const =0
Tests whether two nodes are equal.
virtual bool isSupported(const XMLCh *feature, const XMLCh *version) const =0
Tests whether the DOM implementation implements a specific feature and that feature is supported by t...
virtual DOMNode * getLastChild() const =0
Gets the last child of this node.
virtual const XMLCh * getNodeValue() const =0
Gets the value of this node, depending on its type.
virtual void normalize()=0
Puts all DOMText nodes in the full depth of the sub-tree underneath this DOMNode, including attribute...
virtual DOMDocument * getOwnerDocument() const =0
Gets the DOMDocument object associated with this node.
When associating an object to a key on a node using setUserData the application can provide a handler...
Definition DOMUserDataHandler.hpp:40