- Main Page
- Related Pages
- Classes
- Files

# DOMNode.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: DOMNode.hpp 932887 2010-04-11 13:04:59Z borisk $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_DOMNODE_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_DOMNODE_HPP
    00024
    00025 #include <xercesc/util/XercesDefs.hpp>
    00026
    00027 XERCES_CPP_NAMESPACE_BEGIN
    00028
    00029
    00030 class DOMDocument;
    00031 class DOMNamedNodeMap;
    00032 class DOMNodeList;
    00033 class DOMUserDataHandler;
    00034
    00139 class  CDOM_EXPORT DOMNode {
    00140 protected:
    00141     // -----------------------------------------------------------------------
    00142     //  Hidden constructors
    00143     // -----------------------------------------------------------------------
    00146     DOMNode() {}
    00147     DOMNode(const DOMNode &) {}
    00149
    00150 private:
    00151     // -----------------------------------------------------------------------
    00152     // Unimplemented constructors and operators
    00153     // -----------------------------------------------------------------------
    00156     DOMNode & operator = (const DOMNode &);
    00158
    00159 public:
    00160     // -----------------------------------------------------------------------
    00161     //  All constructors are hidden, just the destructor is available
    00162     // -----------------------------------------------------------------------
    00169     virtual ~DOMNode() {};
    00171
    00172     // -----------------------------------------------------------------------
    00173     //  Class Types
    00174     // -----------------------------------------------------------------------
    00182     enum NodeType {
    00183         ELEMENT_NODE                = 1,
    00184         ATTRIBUTE_NODE              = 2,
    00185         TEXT_NODE                   = 3,
    00186         CDATA_SECTION_NODE          = 4,
    00187         ENTITY_REFERENCE_NODE       = 5,
    00188         ENTITY_NODE                 = 6,
    00189         PROCESSING_INSTRUCTION_NODE = 7,
    00190         COMMENT_NODE                = 8,
    00191         DOCUMENT_NODE               = 9,
    00192         DOCUMENT_TYPE_NODE          = 10,
    00193         DOCUMENT_FRAGMENT_NODE      = 11,
    00194         NOTATION_NODE               = 12
    00195     };
    00196
    00215     enum DocumentPosition {
    00216         DOCUMENT_POSITION_DISCONNECTED            = 0x01,
    00217         DOCUMENT_POSITION_PRECEDING               = 0x02,
    00218         DOCUMENT_POSITION_FOLLOWING               = 0x04,
    00219         DOCUMENT_POSITION_CONTAINS                = 0x08,
    00220         DOCUMENT_POSITION_CONTAINED_BY            = 0x10,
    00221         DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
    00222     };
    00224
    00225     // -----------------------------------------------------------------------
    00226     //  Virtual DOMNode interface
    00227     // -----------------------------------------------------------------------
    00230     // -----------------------------------------------------------------------
    00231     //  Getter methods
    00232     // -----------------------------------------------------------------------
    00237     virtual const XMLCh *   getNodeName() const = 0;
    00238
    00246     virtual const XMLCh *       getNodeValue() const = 0;
    00247
    00252     virtual NodeType            getNodeType() const = 0;
    00253
    00264     virtual DOMNode        *getParentNode() const = 0;
    00265
    00280     virtual DOMNodeList    *getChildNodes() const = 0;
    00287     virtual DOMNode        *getFirstChild() const = 0;
    00288
    00295     virtual DOMNode        *getLastChild() const = 0;
    00296
    00303     virtual DOMNode        *getPreviousSibling() const = 0;
    00304
    00311     virtual DOMNode        *getNextSibling() const = 0;
    00312
    00318     virtual DOMNamedNodeMap  *getAttributes() const = 0;
    00319
    00331     virtual DOMDocument      *getOwnerDocument() const = 0;
    00332
    00333     // -----------------------------------------------------------------------
    00334     //  Node methods
    00335     // -----------------------------------------------------------------------
    00355     virtual DOMNode        * cloneNode(bool deep) const = 0;
    00356
    00384     virtual DOMNode       *insertBefore(DOMNode *newChild,
    00385                                           DOMNode *refChild) = 0;
    00386
    00387
    00411     virtual DOMNode  *replaceChild(DOMNode *newChild,
    00412                                      DOMNode *oldChild) = 0;
    00425     virtual DOMNode        *removeChild(DOMNode *oldChild) = 0;
    00426
    00447     virtual DOMNode        *appendChild(DOMNode *newChild) = 0;
    00448
    00449     // -----------------------------------------------------------------------
    00450     //  Query methods
    00451     // -----------------------------------------------------------------------
    00460     virtual bool             hasChildNodes() const = 0;
    00461
    00462     // -----------------------------------------------------------------------
    00463     //  Setter methods
    00464     // -----------------------------------------------------------------------
    00480     virtual void              setNodeValue(const XMLCh  *nodeValue) = 0;
    00482
    00505     virtual void              normalize() = 0;
    00506
    00522     virtual bool              isSupported(const XMLCh *feature,
    00523                                            const XMLCh *version) const = 0;
    00524
    00540     virtual const XMLCh *         getNamespaceURI() const = 0;
    00541
    00548     virtual const XMLCh *          getPrefix() const = 0;
    00549
    00559     virtual const XMLCh *          getLocalName() const = 0;
    00560
    00594     virtual void              setPrefix(const XMLCh * prefix) = 0;
    00595
    00602     virtual bool              hasAttributes() const = 0;
    00604
    00622     virtual bool              isSameNode(const DOMNode* other) const = 0;
    00623
    00664     virtual bool              isEqualNode(const DOMNode* arg) const = 0;
    00665
    00666
    00692     virtual void*             setUserData(const XMLCh* key,
    00693                                           void* data,
    00694                                           DOMUserDataHandler* handler) = 0;
    00695
    00707     virtual void*             getUserData(const XMLCh* key) const = 0;
    00708
    00709
    00726     virtual const XMLCh*      getBaseURI() const = 0;
    00727
    00738     virtual short             compareDocumentPosition(const DOMNode* other) const = 0;
    00739
    00781     virtual const XMLCh*      getTextContent() const = 0;
    00782
    00794     virtual void              setTextContent(const XMLCh* textContent) = 0;
    00795
    00807     virtual const XMLCh*      lookupPrefix(const XMLCh* namespaceURI) const = 0;
    00808
    00818     virtual bool              isDefaultNamespace(const XMLCh* namespaceURI) const = 0;
    00819
    00831     virtual const XMLCh*      lookupNamespaceURI(const XMLCh* prefix) const  = 0;
    00832
    00848     virtual void*             getFeature(const XMLCh* feature, const XMLCh* version) const = 0;
    00850
    00851     // -----------------------------------------------------------------------
    00852     //  Non-standard Extension
    00853     // -----------------------------------------------------------------------
    00869     virtual void              release() = 0;
    00871 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
    00872     // -----------------------------------------------------------------------
    00873     //  Non-standard Extension
    00874     // -----------------------------------------------------------------------
    00884     virtual void decRefCount() {}
    00886
    00887     // -----------------------------------------------------------------------
    00888     //  Non-standard Extension
    00889     // -----------------------------------------------------------------------
    00896     virtual void incRefCount() {}
    00898 #endif
    00899 };
    00900
    00901 /***
    00902  * Utilities macros for getting memory manager within DOM
    00903 ***/
    00904 #define GET_OWNER_DOCUMENT(ptr)      \
    00905         ((DOMDocumentImpl*)(ptr->getOwnerDocument()))
    00906
    00907 #define GET_DIRECT_MM(ptr)           \
    00908         (ptr ? ((DOMDocumentImpl*)ptr)->getMemoryManager() : XMLPlatformUtils::fgMemoryManager)
    00909
    00910 #define GET_INDIRECT_MM(ptr)                                                    \
    00911         (!ptr ? XMLPlatformUtils::fgMemoryManager :                              \
    00912         GET_OWNER_DOCUMENT(ptr) ? GET_OWNER_DOCUMENT(ptr)->getMemoryManager() : \
    00913         XMLPlatformUtils::fgMemoryManager)
    00914
    00915 /***
    00916  * For DOMNode and its derivatives
    00917 ***/
    00918 #define GetDOMNodeMemoryManager GET_INDIRECT_MM(this)
    00919
    00920 XERCES_CPP_NAMESPACE_END
    00921
    00922 #endif