http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

DOMNode.hpp

Go to the documentation of this file.
00001 #ifndef DOMNode_HEADER_GUARD_
00002 #define DOMNode_HEADER_GUARD_
00003 
00004 /*
00005  * Copyright 2001-2002,2004 The Apache Software Foundation.
00006  * 
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  * 
00011  *      http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 
00020 /*
00021  * $Id: DOMNode.hpp,v 1.17 2004/09/08 13:55:39 peiyongz Exp $
00022  */
00023 
00024 #include <xercesc/util/XercesDefs.hpp>
00025 
00026 XERCES_CPP_NAMESPACE_BEGIN
00027 
00028 
00029 class DOMDocument;
00030 class DOMNamedNodeMap;
00031 class DOMNodeList;
00032 class DOMUserDataHandler;
00033 
00145 class   DOMNode {
00146 protected:
00147     // -----------------------------------------------------------------------
00148     //  Hidden constructors
00149     // -----------------------------------------------------------------------
00152     DOMNode() {};
00154 
00155 private:    
00156     // -----------------------------------------------------------------------
00157     // Unimplemented constructors and operators
00158     // -----------------------------------------------------------------------
00161     DOMNode(const DOMNode &);
00162     DOMNode & operator = (const DOMNode &);
00164 
00165 public:
00166     // -----------------------------------------------------------------------
00167     //  All constructors are hidden, just the destructor is available
00168     // -----------------------------------------------------------------------
00175     virtual ~DOMNode() {};
00177 
00178     // -----------------------------------------------------------------------
00179     //  Class Types
00180     // -----------------------------------------------------------------------
00188     enum NodeType {
00189         ELEMENT_NODE                = 1,
00190         ATTRIBUTE_NODE              = 2,
00191         TEXT_NODE                   = 3,
00192         CDATA_SECTION_NODE          = 4,
00193         ENTITY_REFERENCE_NODE       = 5,
00194         ENTITY_NODE                 = 6,
00195         PROCESSING_INSTRUCTION_NODE = 7,
00196         COMMENT_NODE                = 8,
00197         DOCUMENT_NODE               = 9,
00198         DOCUMENT_TYPE_NODE          = 10,
00199         DOCUMENT_FRAGMENT_NODE      = 11,
00200         NOTATION_NODE               = 12
00201     };
00202 
00229     enum DOMTreePosition {
00230         TREE_POSITION_PRECEDING   = 0x01,
00231         TREE_POSITION_FOLLOWING   = 0x02,
00232         TREE_POSITION_ANCESTOR    = 0x04,
00233         TREE_POSITION_DESCENDANT  = 0x08,
00234         TREE_POSITION_EQUIVALENT  = 0x10,
00235         TREE_POSITION_SAME_NODE   = 0x20,
00236         TREE_POSITION_DISCONNECTED = 0x00
00237     };
00239 
00240     // -----------------------------------------------------------------------
00241     //  Virtual DOMNode interface
00242     // -----------------------------------------------------------------------
00245     // -----------------------------------------------------------------------
00246     //  Getter methods
00247     // -----------------------------------------------------------------------
00252     virtual const XMLCh *   getNodeName() const = 0;
00253 
00261     virtual const XMLCh *       getNodeValue() const = 0;
00262 
00267     virtual short           getNodeType() const = 0;
00268 
00279     virtual DOMNode        *getParentNode() const = 0;
00280 
00295     virtual DOMNodeList    *getChildNodes() const = 0;
00302     virtual DOMNode        *getFirstChild() const = 0;
00303 
00310     virtual DOMNode        *getLastChild() const = 0;
00311 
00318     virtual DOMNode        *getPreviousSibling() const = 0;
00319 
00326     virtual DOMNode        *getNextSibling() const = 0;
00327 
00333     virtual DOMNamedNodeMap  *getAttributes() const = 0;
00334 
00346     virtual DOMDocument      *getOwnerDocument() const = 0;
00347 
00348     // -----------------------------------------------------------------------
00349     //  Node methods
00350     // -----------------------------------------------------------------------
00370     virtual DOMNode        * cloneNode(bool deep) const = 0;
00371 
00399     virtual DOMNode       *insertBefore(DOMNode *newChild,
00400                                           DOMNode *refChild) = 0;
00401 
00402 
00426     virtual DOMNode  *replaceChild(DOMNode *newChild,
00427                                      DOMNode *oldChild) = 0;
00440     virtual DOMNode        *removeChild(DOMNode *oldChild) = 0;
00441 
00462     virtual DOMNode        *appendChild(DOMNode *newChild) = 0;
00463 
00464     // -----------------------------------------------------------------------
00465     //  Query methods
00466     // -----------------------------------------------------------------------
00475     virtual bool             hasChildNodes() const = 0;
00476 
00477     // -----------------------------------------------------------------------
00478     //  Setter methods
00479     // -----------------------------------------------------------------------
00494     virtual void              setNodeValue(const XMLCh  *nodeValue) = 0;
00496 
00519     virtual void              normalize() = 0;
00520 
00536     virtual bool              isSupported(const XMLCh *feature,
00537                                            const XMLCh *version) const = 0;
00538 
00554     virtual const XMLCh *         getNamespaceURI() const = 0;
00555 
00562     virtual const XMLCh *          getPrefix() const = 0;
00563 
00573     virtual const XMLCh *          getLocalName() const = 0;
00574 
00608     virtual void              setPrefix(const XMLCh * prefix) = 0;
00609 
00616     virtual bool              hasAttributes() const = 0;
00618 
00638     virtual bool              isSameNode(const DOMNode* other) const = 0;
00639 
00682     virtual bool              isEqualNode(const DOMNode* arg) const = 0;
00683 
00684 
00712     virtual void*             setUserData(const XMLCh* key,
00713                                           void* data,
00714                                           DOMUserDataHandler* handler) = 0;
00715 
00729     virtual void*             getUserData(const XMLCh* key) const = 0;
00730 
00731 
00750     virtual const XMLCh*           getBaseURI() const = 0;
00751 
00764     virtual short                  compareTreePosition(const DOMNode* other) const = 0;
00765 
00814     virtual const XMLCh*           getTextContent() const = 0;
00815 
00864     virtual void                   setTextContent(const XMLCh* textContent) = 0;
00865 
00883     virtual const XMLCh*           lookupNamespacePrefix(const XMLCh* namespaceURI,
00884                                                          bool useDefault) const = 0;
00885 
00897     virtual bool                   isDefaultNamespace(const XMLCh* namespaceURI) const = 0;
00898 
00912     virtual const XMLCh*           lookupNamespaceURI(const XMLCh* prefix) const  = 0;
00913 
00930     virtual DOMNode*               getInterface(const XMLCh* feature) = 0;
00932 
00933     // -----------------------------------------------------------------------
00934     //  Non-standard Extension
00935     // -----------------------------------------------------------------------
00951     virtual void              release() = 0;
00953 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
00954     // -----------------------------------------------------------------------
00955     //  Non-standard Extension
00956     // -----------------------------------------------------------------------
00966     virtual void decRefCount() {}
00968 
00969     // -----------------------------------------------------------------------
00970     //  Non-standard Extension
00971     // -----------------------------------------------------------------------
00978     virtual void incRefCount() {}
00980 #endif
00981 };
00982 
00983 /***
00984  * Utilities macros for getting memory manager within DOM
00985 ***/
00986 #define GET_OWNER_DOCUMENT(ptr)      \
00987         ((DOMDocumentImpl*)(ptr->getOwnerDocument()))
00988 
00989 #define GET_DIRECT_MM(ptr)           \
00990         ptr ? ((DOMDocumentImpl*)ptr)->getMemoryManager() : XMLPlatformUtils::fgMemoryManager        
00991 
00992 #define GET_INDIRECT_MM(ptr)                                                    \
00993         !ptr ? XMLPlatformUtils::fgMemoryManager :                              \
00994         GET_OWNER_DOCUMENT(ptr) ? GET_OWNER_DOCUMENT(ptr)->getMemoryManager() : \
00995         XMLPlatformUtils::fgMemoryManager
00996 
00997 /***
00998  * For DOMNode and its derivatives
00999 ***/
01000 #define GetDOMNodeMemoryManager GET_INDIRECT_MM(this)
01001 
01002 XERCES_CPP_NAMESPACE_END
01003 
01004 #endif
01005 


Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.