Main Page   Class Hierarchy   Compound List   File List   Compound Members  

NodeImpl.hpp

00001 #ifndef NodeImpl_HEADER_GUARD_
00002 #define NodeImpl_HEADER_GUARD_
00003 
00004 /*
00005  * The Apache Software License, Version 1.1
00006  *
00007  * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
00008  * reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  *
00014  * 1. Redistributions of source code must retain the above copyright
00015  *    notice, this list of conditions and the following disclaimer.
00016  *
00017  * 2. Redistributions in binary form must reproduce the above copyright
00018  *    notice, this list of conditions and the following disclaimer in
00019  *    the documentation and/or other materials provided with the
00020  *    distribution.
00021  *
00022  * 3. The end-user documentation included with the redistribution,
00023  *    if any, must include the following acknowledgment:
00024  *       "This product includes software developed by the
00025  *        Apache Software Foundation (http://www.apache.org/)."
00026  *    Alternately, this acknowledgment may appear in the software itself,
00027  *    if and wherever such third-party acknowledgments normally appear.
00028  *
00029  * 4. The names "Xerces" and "Apache Software Foundation" must
00030  *    not be used to endorse or promote products derived from this
00031  *    software without prior written permission. For written
00032  *    permission, please contact apache\@apache.org.
00033  *
00034  * 5. Products derived from this software may not be called "Apache",
00035  *    nor may "Apache" appear in their name, without prior written
00036  *    permission of the Apache Software Foundation.
00037  *
00038  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00039  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00040  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00041  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00042  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00043  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00044  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00045  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00046  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00047  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00048  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00049  * SUCH DAMAGE.
00050  * ====================================================================
00051  *
00052  * This software consists of voluntary contributions made by many
00053  * individuals on behalf of the Apache Software Foundation, and was
00054  * originally based on software copyright (c) 1999, International
00055  * Business Machines, Inc., http://www.ibm.com .  For more information
00056  * on the Apache Software Foundation, please see
00057  * <http://www.apache.org/>.
00058  */
00059 
00060 /*
00061  * $Id: NodeImpl.hpp,v 1.1 2002/05/11 19:55:57 bhavani Exp $
00062  */
00063 
00064 //
00065 //  This file is part of the internal implementation of the C++ XML DOM.
00066 //  It should NOT be included or used directly by application programs.
00067 //
00068 //  Applications should include the file <dom/DOM.hpp> for the entire
00069 //  DOM API, or DOM_*.hpp for individual DOM classes, where the class
00070 //  name is substituded for the *.
00071 //
00072 
00091 #include <xercesc/util/XercesDefs.hpp>
00092 #include "NodeListImpl.hpp"
00093 #include "DOMString.hpp"
00094 
00095 
00096 class NamedNodeMapImpl;
00097 class NodeListImpl;
00098 class DocumentImpl;
00099 
00100 //  define 'null' is used extensively in the DOM implementation code,
00101 //  as a consequence of its Java origins.
00102 //  MSVC 5.0 compiler has problems with overloaded function resolution
00103 //      when using the const int definition.
00104 //
00105 #if defined(XML_CSET)
00106 const int null = 0;
00107 #else
00108 #define null 0
00109 #endif
00110 
00111 
00112 class CDOM_EXPORT NodeImpl: public NodeListImpl {
00113 public:
00114     NodeImpl                *ownerNode; // typically the parent but not always!
00115 
00116     // data
00117 
00118     unsigned short flags;
00119 
00120     static const unsigned short READONLY;
00121     static const unsigned short SYNCDATA;
00122     static const unsigned short SYNCCHILDREN;
00123     static const unsigned short OWNED;
00124     static const unsigned short FIRSTCHILD;
00125     static const unsigned short SPECIFIED;
00126     static const unsigned short IGNORABLEWS;
00127     static const unsigned short SETVALUE;
00128     static const unsigned short ID_ATTR;
00129     static const unsigned short USERDATA;
00130     static const unsigned short HASSTRING;
00131 
00132     static int              gLiveNodeImpls; // Counters for debug & tuning.
00133     static int              gTotalNodeImpls;
00134 
00135 public:
00136     NodeImpl(DocumentImpl *ownerDocument);
00137     NodeImpl(const NodeImpl &other);
00138     virtual ~NodeImpl();
00139 
00140     // Dynamic Cast replacement functions.
00141     virtual bool isAttrImpl();
00142     virtual bool isCDATASectionImpl();
00143     virtual bool isDocumentFragmentImpl();
00144     virtual bool isDocumentImpl();
00145     virtual bool isDocumentTypeImpl();
00146     virtual bool isElementImpl();
00147     virtual bool isEntityReference();
00148     virtual bool isTextImpl();
00149 
00150     virtual void changed();
00151     virtual int changes();
00152 
00153     virtual NodeImpl *appendChild(NodeImpl *newChild);
00154     virtual NodeImpl * cloneNode(bool deep) = 0;
00155     static void deleteIf(NodeImpl *thisNode);
00156     virtual NamedNodeMapImpl * getAttributes();
00157     virtual NodeListImpl *getChildNodes();
00158     virtual NodeImpl * getFirstChild();
00159     virtual NodeImpl * getLastChild();
00160     virtual unsigned int getLength();
00161     virtual NodeImpl * getNextSibling();
00162     virtual DOMString getNodeName() = 0;
00163     virtual short getNodeType() = 0;
00164     virtual DOMString getNodeValue();
00165     virtual DocumentImpl * getOwnerDocument();
00166     virtual NodeImpl * getParentNode();
00167     virtual NodeImpl*  getPreviousSibling();
00168     virtual void *getUserData();
00169     virtual bool        hasChildNodes();
00170     virtual NodeImpl    *insertBefore(NodeImpl *newChild, NodeImpl *refChild);
00171     static  bool        isKidOK(NodeImpl *parent, NodeImpl *child);
00172     virtual NodeImpl    *item(unsigned int index);
00173     virtual void        referenced();
00174     virtual NodeImpl    * removeChild(NodeImpl *oldChild);
00175     virtual NodeImpl    *replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
00176     virtual void        setNodeValue(const DOMString &value);
00177     virtual void        setReadOnly(bool readOnly, bool deep);
00178     virtual void        setUserData(void *value);
00179     virtual DOMString   toString();
00180     virtual void        unreferenced();
00181 
00182     //Introduced in DOM Level 2
00183     virtual void        normalize();
00184     virtual bool        isSupported(const DOMString &feature, const DOMString &version);
00185     virtual DOMString   getNamespaceURI();
00186     virtual DOMString   getPrefix();
00187     virtual DOMString   getLocalName();
00188     virtual void        setPrefix(const DOMString &prefix);
00189     virtual bool        hasAttributes();
00190 
00191 protected:
00192     //Utility, not part of DOM Level 2 API
00193     static const DOMString&     mapPrefix(const DOMString &prefix,
00194         const DOMString &namespaceURI, short nType);
00195     static DOMString getXmlnsString();
00196     static DOMString getXmlnsURIString();
00197     static DOMString getXmlString();
00198     static DOMString getXmlURIString();
00199 
00200 public: // should really be protected - ALH
00201 
00202     virtual void setOwnerDocument(DocumentImpl *doc);
00203     // NON-DOM
00204     // unlike getOwnerDocument this never returns null, even for Document nodes
00205     virtual DocumentImpl * getDocument();
00206 
00207     /*
00208      * Flags setters and getters
00209      */
00210 
00211     inline bool isReadOnly() const {
00212         return (flags & READONLY) != 0;
00213     }
00214 
00215     inline void isReadOnly(bool value) {
00216         flags = (value ? flags | READONLY : flags & ~READONLY);
00217     }
00218 
00219     inline bool needsSyncData() const {
00220         return (flags & SYNCDATA) != 0;
00221     }
00222 
00223     inline void needsSyncData(bool value) {
00224         flags = (value ? flags | SYNCDATA : flags & ~SYNCDATA);
00225     }
00226 
00227     inline bool needsSyncChildren() const {
00228         return (flags & SYNCCHILDREN) != 0;
00229     }
00230 
00231     inline void needsSyncChildren(bool value) {
00232         flags = (value ? flags | SYNCCHILDREN : flags & ~SYNCCHILDREN);
00233     }
00234 
00235     inline bool isOwned() const {
00236         return (flags & OWNED) != 0;
00237     }
00238 
00239     inline void isOwned(bool value) {
00240         flags = (value ? flags | OWNED : flags & ~OWNED);
00241     }
00242 
00243     inline bool isFirstChild() const {
00244         return (flags & FIRSTCHILD) != 0;
00245     }
00246 
00247     inline void isFirstChild(bool value) {
00248         flags = (value ? flags | FIRSTCHILD : flags & ~FIRSTCHILD);
00249     }
00250 
00251     inline bool isSpecified() const {
00252         return (flags & SPECIFIED) != 0;
00253     }
00254 
00255     inline void isSpecified(bool value) {
00256         flags = (value ? flags | SPECIFIED : flags & ~SPECIFIED);
00257     }
00258 
00259     inline bool ignorableWhitespace() const {
00260         return (flags & IGNORABLEWS) != 0;
00261     }
00262 
00263     inline void ignorableWhitespace(bool value) {
00264         flags = (value ? flags | IGNORABLEWS : flags & ~IGNORABLEWS);
00265     }
00266 
00267     inline bool setValueCalled() const {
00268         return (flags & SETVALUE) != 0;
00269     }
00270 
00271     inline void setValueCalled(bool value) {
00272         flags = (value ? flags | SETVALUE : flags & ~SETVALUE);
00273     }
00274 
00275     inline bool isIdAttr() const {
00276         return (flags & ID_ATTR) != 0;
00277     }
00278 
00279     inline void isIdAttr(bool value) {
00280         flags = (value ? flags | ID_ATTR : flags & ~ID_ATTR);
00281     }
00282 
00283     inline bool hasUserData() const {
00284         return (flags & USERDATA) != 0;
00285     }
00286 
00287     inline void hasUserData(bool value) {
00288         flags = (value ? flags | USERDATA : flags & ~USERDATA);
00289     }
00290 
00291     inline bool hasStringValue() const {
00292         return (flags & HASSTRING) != 0;
00293     }
00294 
00295     inline void hasStringValue(bool value) {
00296         flags = (value ? flags | HASSTRING : flags & ~HASSTRING);
00297     }
00298 
00299     // -----------------------------------------------------------------------
00300     //  Notification that lazy data has been deleted
00301     // -----------------------------------------------------------------------
00302         static void reinitNodeImpl();
00303 
00304 };
00305 
00306 
00307 #endif

Generated on Tue Nov 19 09:36:32 2002 by doxygen1.3-rc1