DOMNode.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id$
*/
#if !defined(XERCESC_INCLUDE_GUARD_DOMNODE_HPP)
#define XERCESC_INCLUDE_GUARD_DOMNODE_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class DOMDocument;
class DOMNamedNodeMap;
class DOMNodeList;
class DOMUserDataHandler;
class CDOM_EXPORT DOMNode {
protected:
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
DOMNode() {}
DOMNode(const DOMNode &) {}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DOMNode & operator = (const DOMNode &);
public:
// -----------------------------------------------------------------------
// All constructors are hidden, just the destructor is available
// -----------------------------------------------------------------------
virtual ~DOMNode() {};
// -----------------------------------------------------------------------
// Class Types
// -----------------------------------------------------------------------
enum NodeType {
ELEMENT_NODE = 1,
ATTRIBUTE_NODE = 2,
TEXT_NODE = 3,
CDATA_SECTION_NODE = 4,
ENTITY_REFERENCE_NODE = 5,
ENTITY_NODE = 6,
PROCESSING_INSTRUCTION_NODE = 7,
COMMENT_NODE = 8,
DOCUMENT_NODE = 9,
DOCUMENT_TYPE_NODE = 10,
DOCUMENT_FRAGMENT_NODE = 11,
NOTATION_NODE = 12
};
enum DocumentPosition {
DOCUMENT_POSITION_DISCONNECTED = 0x01,
DOCUMENT_POSITION_PRECEDING = 0x02,
DOCUMENT_POSITION_FOLLOWING = 0x04,
DOCUMENT_POSITION_CONTAINS = 0x08,
DOCUMENT_POSITION_CONTAINED_BY = 0x10,
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
};
// -----------------------------------------------------------------------
// Virtual DOMNode interface
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
virtual const XMLCh * getNodeName() const = 0;
virtual const XMLCh * getNodeValue() const = 0;
virtual NodeType getNodeType() const = 0;
virtual DOMNode *getParentNode() const = 0;
virtual DOMNodeList *getChildNodes() const = 0;
virtual DOMNode *getFirstChild() const = 0;
virtual DOMNode *getLastChild() const = 0;
virtual DOMNode *getPreviousSibling() const = 0;
virtual DOMNode *getNextSibling() const = 0;
virtual DOMNamedNodeMap *getAttributes() const = 0;
virtual DOMDocument *getOwnerDocument() const = 0;
// -----------------------------------------------------------------------
// Node methods
// -----------------------------------------------------------------------
virtual DOMNode * cloneNode(bool deep) const = 0;
virtual DOMNode *insertBefore(DOMNode *newChild,
DOMNode *refChild) = 0;
virtual DOMNode *replaceChild(DOMNode *newChild,
DOMNode *oldChild) = 0;
virtual DOMNode *removeChild(DOMNode *oldChild) = 0;
virtual DOMNode *appendChild(DOMNode *newChild) = 0;
// -----------------------------------------------------------------------
// Query methods
// -----------------------------------------------------------------------
virtual bool hasChildNodes() const = 0;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
virtual void setNodeValue(const XMLCh *nodeValue) = 0;
virtual void normalize() = 0;
virtual bool isSupported(const XMLCh *feature,
const XMLCh *version) const = 0;
virtual const XMLCh * getNamespaceURI() const = 0;
virtual const XMLCh * getPrefix() const = 0;
virtual const XMLCh * getLocalName() const = 0;
virtual void setPrefix(const XMLCh * prefix) = 0;
virtual bool hasAttributes() const = 0;
virtual bool isSameNode(const DOMNode* other) const = 0;
virtual bool isEqualNode(const DOMNode* arg) const = 0;
virtual void* setUserData(const XMLCh* key,
void* data,
DOMUserDataHandler* handler) = 0;
virtual void* getUserData(const XMLCh* key) const = 0;
virtual const XMLCh* getBaseURI() const = 0;
virtual short compareDocumentPosition(const DOMNode* other) const = 0;
virtual const XMLCh* getTextContent() const = 0;
virtual void setTextContent(const XMLCh* textContent) = 0;
virtual const XMLCh* lookupPrefix(const XMLCh* namespaceURI) const = 0;
virtual bool isDefaultNamespace(const XMLCh* namespaceURI) const = 0;
virtual const XMLCh* lookupNamespaceURI(const XMLCh* prefix) const = 0;
virtual void* getFeature(const XMLCh* feature, const XMLCh* version) const = 0;
// -----------------------------------------------------------------------
// Non-standard Extension
// -----------------------------------------------------------------------
virtual void release() = 0;
#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
// -----------------------------------------------------------------------
// Non-standard Extension
// -----------------------------------------------------------------------
virtual void decRefCount() {}
// -----------------------------------------------------------------------
// Non-standard Extension
// -----------------------------------------------------------------------
virtual void incRefCount() {}
#endif
};
/***
* Utilities macros for getting memory manager within DOM
***/
#define GET_OWNER_DOCUMENT(ptr) \
((DOMDocumentImpl*)(ptr->getOwnerDocument()))
#define GET_DIRECT_MM(ptr) \
(ptr ? ((DOMDocumentImpl*)ptr)->getMemoryManager() : XMLPlatformUtils::fgMemoryManager)
#define GET_INDIRECT_MM(ptr) \
(!ptr ? XMLPlatformUtils::fgMemoryManager : \
GET_OWNER_DOCUMENT(ptr) ? GET_OWNER_DOCUMENT(ptr)->getMemoryManager() : \
XMLPlatformUtils::fgMemoryManager)
/***
* For DOMNode and its derivatives
***/
#define GetDOMNodeMemoryManager GET_INDIRECT_MM(this)
XERCES_CPP_NAMESPACE_END
#endif
XercesDefs.hpp
CDOM_EXPORT
#define CDOM_EXPORT
Definition: XercesDefs.hpp:166
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
DOMDocument
The DOMDocument interface represents the entire XML document.
Definition: DOMDocument.hpp:67
DOMNamedNodeMap
DOMNamedNodeMaps are used to represent collections of nodes that can be accessed by name.
Definition: DOMNamedNodeMap.hpp:45
DOMNodeList
The DOMNodeList interface provides the abstraction of an ordered collection of nodes.
Definition: DOMNodeList.hpp:45
DOMNode
The DOMNode interface is the primary datatype for the entire Document Object Model.
Definition: DOMNode.hpp:139
DOMNode::setPrefix
virtual void setPrefix(const XMLCh *prefix)=0
Set the namespace prefix of this node.
DOMNode::lookupPrefix
virtual const XMLCh * lookupPrefix(const XMLCh *namespaceURI) const =0
Look up the prefix associated to the given namespace URI, starting from this node.
DOMNode::DOMNode
DOMNode(const DOMNode &)
Definition: DOMNode.hpp:147
DOMNode::getUserData
virtual void * getUserData(const XMLCh *key) const =0
Retrieves the object associated to a key on a this node.
DOMNode::compareDocumentPosition
virtual short compareDocumentPosition(const DOMNode *other) const =0
Compares the reference node, i.e.
DOMNode::replaceChild
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...
DOMNode::getNextSibling
virtual DOMNode * getNextSibling() const =0
Gets the node immediately following this node.
DOMNode::lookupNamespaceURI
virtual const XMLCh * lookupNamespaceURI(const XMLCh *prefix) const =0
Look up the namespace URI associated to the given prefix, starting from this node.
DOMNode::getBaseURI
virtual const XMLCh * getBaseURI() const =0
The absolute base URI of this node or null if undefined.
DOMNode::hasAttributes
virtual bool hasAttributes() const =0
Returns whether this node (if it is an element) has any attributes.
DOMNode::cloneNode
virtual DOMNode * cloneNode(bool deep) const =0
Returns a duplicate of this node.
DOMNode::getAttributes
virtual DOMNamedNodeMap * getAttributes() const =0
Gets a DOMNamedNodeMap containing the attributes of this node (if it is an DOMElement) or null otherw...
DOMNode::insertBefore
virtual DOMNode * insertBefore(DOMNode *newChild, DOMNode *refChild)=0
Inserts the node newChild before the existing child node refChild.
DOMNode::getParentNode
virtual DOMNode * getParentNode() const =0
Gets the parent of this node.
DOMNode::getNamespaceURI
virtual const XMLCh * getNamespaceURI() const =0
Get the namespace URI of this node, or null if it is unspecified.
DOMNode::getPrefix
virtual const XMLCh * getPrefix() const =0
Get the namespace prefix of this node, or null if it is unspecified.
DOMNode::getLocalName
virtual const XMLCh * getLocalName() const =0
Returns the local part of the qualified name of this node.
DOMNode::getPreviousSibling
virtual DOMNode * getPreviousSibling() const =0
Gets the node immediately preceding this node.
DOMNode::getNodeType
virtual NodeType getNodeType() const =0
An enum value representing the type of the underlying object.
DOMNode::getTextContent
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...
DOMNode::NodeType
NodeType
NodeType.
Definition: DOMNode.hpp:182
DOMNode::release
virtual void release()=0
Called to indicate that this Node (and its associated children) is no longer in use and that the impl...
DOMNode::appendChild
virtual DOMNode * appendChild(DOMNode *newChild)=0
Adds the node newChild to the end of the list of children of this node.
DOMNode::getFirstChild
virtual DOMNode * getFirstChild() const =0
Gets the first child of this node.
DOMNode::setTextContent
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...
DOMNode::getFeature
virtual void * getFeature(const XMLCh *feature, const XMLCh *version) const =0
This method makes available a DOMNode's specialized interface.
DOMNode::~DOMNode
virtual ~DOMNode()
Destructor.
Definition: DOMNode.hpp:169
DOMNode::DOMNode
DOMNode()
Definition: DOMNode.hpp:146
DOMNode::DocumentPosition
DocumentPosition
DocumentPosition:
Definition: DOMNode.hpp:215
DOMNode::getChildNodes
virtual DOMNodeList * getChildNodes() const =0
Gets a DOMNodeList that contains all children of this node.
DOMNode::removeChild
virtual DOMNode * removeChild(DOMNode *oldChild)=0
Removes the child node indicated by oldChild from the list of children, and returns it.
DOMNode::getNodeName
virtual const XMLCh * getNodeName() const =0
The name of this node, depending on its type; see the table above.
DOMNode::isSameNode
virtual bool isSameNode(const DOMNode *other) const =0
Returns whether this node is the same node as the given one.
DOMNode::isDefaultNamespace
virtual bool isDefaultNamespace(const XMLCh *namespaceURI) const =0
This method checks if the specified namespaceURI is the default namespace or not.
DOMNode::setUserData
virtual void * setUserData(const XMLCh *key, void *data, DOMUserDataHandler *handler)=0
Associate an object to a key on this node.
DOMNode::setNodeValue
virtual void setNodeValue(const XMLCh *nodeValue)=0
Sets the value of the node.
DOMNode::hasChildNodes
virtual bool hasChildNodes() const =0
This is a convenience method to allow easy determination of whether a node has any children.
DOMNode::isEqualNode
virtual bool isEqualNode(const DOMNode *arg) const =0
Tests whether two nodes are equal.
DOMNode::isSupported
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...
DOMNode::getLastChild
virtual DOMNode * getLastChild() const =0
Gets the last child of this node.
DOMNode::getNodeValue
virtual const XMLCh * getNodeValue() const =0
Gets the value of this node, depending on its type.
DOMNode::normalize
virtual void normalize()=0
Puts all DOMText nodes in the full depth of the sub-tree underneath this DOMNode, including attribute...
DOMNode::getOwnerDocument
virtual DOMDocument * getOwnerDocument() const =0
Gets the DOMDocument object associated with this node.
DOMUserDataHandler
When associating an object to a key on a node using setUserData the application can provide a handler...
Definition: DOMUserDataHandler.hpp:40