source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/dom/deprecated/ParentNode.hpp @ 2674

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