source: NonGTP/Xerces/xercesc/dom/deprecated/NodeImpl.hpp @ 188

Revision 188, 10.7 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1#ifndef NodeImpl_HEADER_GUARD_
2#define NodeImpl_HEADER_GUARD_
3
4/*
5 * The Apache Software License, Version 1.1
6 *
7 * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
8 * reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in
19 *    the documentation and/or other materials provided with the
20 *    distribution.
21 *
22 * 3. The end-user documentation included with the redistribution,
23 *    if any, must include the following acknowledgment:
24 *       "This product includes software developed by the
25 *        Apache Software Foundation (http://www.apache.org/)."
26 *    Alternately, this acknowledgment may appear in the software itself,
27 *    if and wherever such third-party acknowledgments normally appear.
28 *
29 * 4. The names "Xerces" and "Apache Software Foundation" must
30 *    not be used to endorse or promote products derived from this
31 *    software without prior written permission. For written
32 *    permission, please contact apache\@apache.org.
33 *
34 * 5. Products derived from this software may not be called "Apache",
35 *    nor may "Apache" appear in their name, without prior written
36 *    permission of the Apache Software Foundation.
37 *
38 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 * SUCH DAMAGE.
50 * ====================================================================
51 *
52 * This software consists of voluntary contributions made by many
53 * individuals on behalf of the Apache Software Foundation, and was
54 * originally based on software copyright (c) 1999, International
55 * Business Machines, Inc., http://www.ibm.com .  For more information
56 * on the Apache Software Foundation, please see
57 * <http://www.apache.org/>.
58 */
59
60/*
61 * $Id: NodeImpl.hpp,v 1.4 2003/05/15 18:25:53 knoaman Exp $
62 */
63
64//
65//  This file is part of the internal implementation of the C++ XML DOM.
66//  It should NOT be included or used directly by application programs.
67//
68//  Applications should include the file <xercesc/dom/deprecated/DOM.hpp> for the entire
69//  DOM API, or DOM_*.hpp for individual DOM classes, where the class
70//  name is substituded for the *.
71//
72
73/**
74 * A NodeImpl doesn't have any children, and can therefore only be directly
75 * inherited by classes of nodes that never have any, such as Text nodes. For
76 * other types, such as Element, classes must inherit from ParentNode.
77 * <P>
78 * All nodes in a single document must originate
79 * in that document. (Note that this is much tighter than "must be
80 * same implementation") Nodes are all aware of their ownerDocument,
81 * and attempts to mismatch will throw WRONG_DOCUMENT_ERR.
82 * <P>
83 * However, to save memory not all nodes always have a direct reference
84 * to their ownerDocument. When a node is owned by another node it relies
85 * on its owner to store its ownerDocument. Parent nodes always store it
86 * though, so there is never more than one level of indirection.
87 * And when a node doesn't have an owner, ownerNode refers to its
88 * ownerDocument.
89 **/
90
91#include <xercesc/util/XMemory.hpp>
92#include "NodeListImpl.hpp"
93#include "DOMString.hpp"
94
95XERCES_CPP_NAMESPACE_BEGIN
96
97
98class NamedNodeMapImpl;
99class NodeListImpl;
100class DocumentImpl;
101
102//  define 'null' is used extensively in the DOM implementation code,
103//  as a consequence of its Java origins.
104//  MSVC 5.0 compiler has problems with overloaded function resolution
105//      when using the const int definition.
106//
107#if defined(XML_CSET)
108const int null = 0;
109#else
110#define null 0
111#endif
112
113
114class CDOM_EXPORT NodeImpl: public NodeListImpl {
115public:
116    NodeImpl                *ownerNode; // typically the parent but not always!
117
118    // data
119
120    unsigned short flags;
121
122    static const unsigned short READONLY;
123    static const unsigned short SYNCDATA;
124    static const unsigned short SYNCCHILDREN;
125    static const unsigned short OWNED;
126    static const unsigned short FIRSTCHILD;
127    static const unsigned short SPECIFIED;
128    static const unsigned short IGNORABLEWS;
129    static const unsigned short SETVALUE;
130    static const unsigned short ID_ATTR;
131    static const unsigned short USERDATA;
132    static const unsigned short HASSTRING;
133
134    static int              gLiveNodeImpls; // Counters for debug & tuning.
135    static int              gTotalNodeImpls;
136
137public:
138    NodeImpl(DocumentImpl *ownerDocument);
139    NodeImpl(const NodeImpl &other);
140    virtual ~NodeImpl();
141
142    // Dynamic Cast replacement functions.
143    virtual bool isAttrImpl();
144    virtual bool isCDATASectionImpl();
145    virtual bool isDocumentFragmentImpl();
146    virtual bool isDocumentImpl();
147    virtual bool isDocumentTypeImpl();
148    virtual bool isElementImpl();
149    virtual bool isEntityReference();
150    virtual bool isTextImpl();
151
152    virtual void changed();
153    virtual int changes();
154
155    virtual NodeImpl *appendChild(NodeImpl *newChild);
156    virtual NodeImpl * cloneNode(bool deep) = 0;
157    static void deleteIf(NodeImpl *thisNode);
158    virtual NamedNodeMapImpl * getAttributes();
159    virtual NodeListImpl *getChildNodes();
160    virtual NodeImpl * getFirstChild();
161    virtual NodeImpl * getLastChild();
162    virtual unsigned int getLength();
163    virtual NodeImpl * getNextSibling();
164    virtual DOMString getNodeName() = 0;
165    virtual short getNodeType() = 0;
166    virtual DOMString getNodeValue();
167    virtual DocumentImpl * getOwnerDocument();
168    virtual NodeImpl * getParentNode();
169    virtual NodeImpl*  getPreviousSibling();
170    virtual void *getUserData();
171    virtual bool        hasChildNodes();
172    virtual NodeImpl    *insertBefore(NodeImpl *newChild, NodeImpl *refChild);
173    static  bool        isKidOK(NodeImpl *parent, NodeImpl *child);
174    virtual NodeImpl    *item(unsigned int index);
175    virtual void        referenced();
176    virtual NodeImpl    * removeChild(NodeImpl *oldChild);
177    virtual NodeImpl    *replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
178    virtual void        setNodeValue(const DOMString &value);
179    virtual void        setReadOnly(bool readOnly, bool deep);
180    virtual void        setUserData(void *value);
181    virtual DOMString   toString();
182    virtual void        unreferenced();
183
184    //Introduced in DOM Level 2
185    virtual void        normalize();
186    virtual bool        isSupported(const DOMString &feature, const DOMString &version);
187    virtual DOMString   getNamespaceURI();
188    virtual DOMString   getPrefix();
189    virtual DOMString   getLocalName();
190    virtual void        setPrefix(const DOMString &prefix);
191    virtual bool        hasAttributes();
192
193protected:
194    //Utility, not part of DOM Level 2 API
195    static const DOMString&     mapPrefix(const DOMString &prefix,
196        const DOMString &namespaceURI, short nType);
197    static DOMString getXmlnsString();
198    static DOMString getXmlnsURIString();
199    static DOMString getXmlString();
200    static DOMString getXmlURIString();
201
202public: // should really be protected - ALH
203
204    virtual void setOwnerDocument(DocumentImpl *doc);
205    // NON-DOM
206    // unlike getOwnerDocument this never returns null, even for Document nodes
207    virtual DocumentImpl * getDocument();
208
209    /*
210     * Flags setters and getters
211     */
212
213    inline bool isReadOnly() const {
214        return (flags & READONLY) != 0;
215    }
216
217    inline void isReadOnly(bool value) {
218        flags = (value ? flags | READONLY : flags & ~READONLY);
219    }
220
221    inline bool needsSyncData() const {
222        return (flags & SYNCDATA) != 0;
223    }
224
225    inline void needsSyncData(bool value) {
226        flags = (value ? flags | SYNCDATA : flags & ~SYNCDATA);
227    }
228
229    inline bool needsSyncChildren() const {
230        return (flags & SYNCCHILDREN) != 0;
231    }
232
233    inline void needsSyncChildren(bool value) {
234        flags = (value ? flags | SYNCCHILDREN : flags & ~SYNCCHILDREN);
235    }
236
237    inline bool isOwned() const {
238        return (flags & OWNED) != 0;
239    }
240
241    inline void isOwned(bool value) {
242        flags = (value ? flags | OWNED : flags & ~OWNED);
243    }
244
245    inline bool isFirstChild() const {
246        return (flags & FIRSTCHILD) != 0;
247    }
248
249    inline void isFirstChild(bool value) {
250        flags = (value ? flags | FIRSTCHILD : flags & ~FIRSTCHILD);
251    }
252
253    inline bool isSpecified() const {
254        return (flags & SPECIFIED) != 0;
255    }
256
257    inline void isSpecified(bool value) {
258        flags = (value ? flags | SPECIFIED : flags & ~SPECIFIED);
259    }
260
261    inline bool ignorableWhitespace() const {
262        return (flags & IGNORABLEWS) != 0;
263    }
264
265    inline void ignorableWhitespace(bool value) {
266        flags = (value ? flags | IGNORABLEWS : flags & ~IGNORABLEWS);
267    }
268
269    inline bool setValueCalled() const {
270        return (flags & SETVALUE) != 0;
271    }
272
273    inline void setValueCalled(bool value) {
274        flags = (value ? flags | SETVALUE : flags & ~SETVALUE);
275    }
276
277    inline bool isIdAttr() const {
278        return (flags & ID_ATTR) != 0;
279    }
280
281    inline void isIdAttr(bool value) {
282        flags = (value ? flags | ID_ATTR : flags & ~ID_ATTR);
283    }
284
285    inline bool hasUserData() const {
286        return (flags & USERDATA) != 0;
287    }
288
289    inline void hasUserData(bool value) {
290        flags = (value ? flags | USERDATA : flags & ~USERDATA);
291    }
292
293    inline bool hasStringValue() const {
294        return (flags & HASSTRING) != 0;
295    }
296
297    inline void hasStringValue(bool value) {
298        flags = (value ? flags | HASSTRING : flags & ~HASSTRING);
299    }
300
301    // -----------------------------------------------------------------------
302    //  Notification that lazy data has been deleted
303    // -----------------------------------------------------------------------
304        static void reinitNodeImpl();
305
306};
307
308
309XERCES_CPP_NAMESPACE_END
310
311#endif
Note: See TracBrowser for help on using the repository browser.