source: NonGTP/Xerces/xerces/include/xercesc/dom/deprecated/ParentNode.hpp @ 358

Revision 358, 4.2 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1#ifndef ParentNode_HEADER_GUARD_
2#define ParentNode_HEADER_GUARD_
3/*
4 * Copyright 1999-2002,2004 The Apache Software Foundation.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *      http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19//
20//  This file is part of the internal implementation of the C++ XML DOM.
21//  It should NOT be included or used directly by application programs.
22//
23//  Applications should include the file <xercesc/dom/deprecated/DOM.hpp> for the entire
24//  DOM API, or DOM_*.hpp for individual DOM classes, where the class
25//  name is substituded for the *.
26//
27
28/*
29 * $Id: ParentNode.hpp,v 1.5 2004/09/08 13:55:44 peiyongz Exp $
30 */
31
32/**
33 * ParentNode inherits from ChildImpl and adds the capability of having child
34 * nodes. Not every node in the DOM can have children, so only nodes that can
35 * should inherit from this class and pay the price for it.
36 * <P>
37 * ParentNode, just like NodeImpl, also implements NodeList, so it can
38 * return itself in response to the getChildNodes() query. This eliminiates
39 * the need for a separate ChildNodeList object. Note that this is an
40 * IMPLEMENTATION DETAIL; applications should _never_ assume that
41 * this identity exists.
42 * <P>
43 * While we have a direct reference to the first child, the last child is
44 * stored as the previous sibling of the first child. First child nodes are
45 * marked as being so, and getNextSibling hides this fact.
46 * <P>Note: Not all parent nodes actually need to also be a child. At some
47 * point we used to have ParentNode inheriting from NodeImpl and another class
48 * called ChildAndParentNode that inherited from ChildNode. But due to the lack
49 * of multiple inheritance a lot of code had to be duplicated which led to a
50 * maintenance nightmare. At the same time only a few nodes (Document,
51 * DocumentFragment, Entity, and Attribute) cannot be a child so the gain is
52 * memory wasn't really worth it. The only type for which this would be the
53 * case is Attribute, but we deal with there in another special way, so this is
54 * not applicable.
55 *
56 * <p><b>WARNING</b>: Some of the code here is partially duplicated in
57 * AttrImpl, be careful to keep these two classes in sync!
58 *
59 **/
60
61#include <xercesc/util/XercesDefs.hpp>
62#include "ChildNode.hpp"
63
64XERCES_CPP_NAMESPACE_BEGIN
65
66class DEPRECATED_DOM_EXPORT ParentNode: public ChildNode {
67public:
68    DocumentImpl            *ownerDocument; // Document this node belongs to
69
70    ChildNode                *firstChild;
71
72public:
73    ParentNode(DocumentImpl *ownerDocument);
74    ParentNode(const ParentNode &other);
75
76    virtual DocumentImpl * getOwnerDocument();
77    virtual void setOwnerDocument(DocumentImpl *doc);
78
79    virtual NodeListImpl *getChildNodes();
80    virtual NodeImpl * getFirstChild();
81    virtual NodeImpl * getLastChild();
82    virtual unsigned int getLength();
83    virtual bool        hasChildNodes();
84    virtual NodeImpl    *insertBefore(NodeImpl *newChild, NodeImpl *refChild);
85    virtual NodeImpl    *item(unsigned int index);
86    virtual NodeImpl    * removeChild(NodeImpl *oldChild);
87    virtual NodeImpl    *replaceChild(NodeImpl *newChild, NodeImpl *oldChild);
88    virtual void        setReadOnly(bool isReadOnly, bool deep);
89
90    //Introduced in DOM Level 2
91    virtual void        normalize();
92
93    // NON-DOM
94    // unlike getOwnerDocument this never returns null, even for Document nodes
95    virtual DocumentImpl * getDocument();
96protected:
97    void cloneChildren(const NodeImpl &other);
98    ChildNode * lastChild();
99    void lastChild(ChildNode *);
100
101    /** Cached node list length. */
102    int fCachedLength;
103
104    /** Last requested child. */
105    ChildNode * fCachedChild;
106
107    /** Last requested child index. */
108    int fCachedChildIndex;
109};
110
111XERCES_CPP_NAMESPACE_END
112
113#endif
Note: See TracBrowser for help on using the repository browser.