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

Revision 2674, 7.9 KB checked in by mattausch, 16 years ago (diff)
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: DOM_TreeWalker.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22#ifndef DOM_TreeWalker_HEADER_GUARD_
23#define DOM_TreeWalker_HEADER_GUARD_
24
25#include "DOM_Node.hpp"
26#include "DOM_NodeFilter.hpp"
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30
31class TreeWalkerImpl;
32
33
34/**
35 * <code>DOM_TreeWalker</code> objects are used to navigate a document tree or
36 * subtree using the view of the document defined by its <code>whatToShow</code>
37 * flags and any filters that are defined for the <code>DOM_TreeWalker</code>. Any
38 * function which performs navigation using a <code>DOM_TreeWalker</code> will
39 * automatically support any view defined by a <code>DOM_TreeWalker</code>.
40 *
41 * Omitting nodes from the logical view of a subtree can result in a structure that is
42 * substantially different from the same subtree in the complete, unfiltered document. Nodes
43 * that are siblings in the DOM_TreeWalker view may be children of different, widely separated
44 * nodes in the original view. For instance, consider a Filter that skips all nodes except for
45 * Text nodes and the root node of a document. In the logical view that results, all text
46 * nodes will be siblings and appear as direct children of the root node, no matter how
47 * deeply nested the structure of the original document.
48 *
49 */
50class DEPRECATED_DOM_EXPORT DOM_TreeWalker {
51    public:
52        /** @name Constructors and assignment operator */
53        //@{
54        /**
55          * Default constructor.
56          */
57        DOM_TreeWalker();
58
59        /**
60          * Copy constructor.
61          *
62          * @param other The object to be copied.
63          */
64        DOM_TreeWalker(const DOM_TreeWalker &other);
65
66        /**
67          * Assignment operator.
68          *
69          * @param other The object to be copied.
70          */
71        DOM_TreeWalker & operator = (const DOM_TreeWalker &other);
72
73        /**
74          * Assignment operator.  This overloaded variant is provided for
75          *   the sole purpose of setting a DOM_NodeIterator to null.
76          *
77          * @param val  Only a value of 0, or null, is allowed.
78          */
79        DOM_TreeWalker & operator = (const DOM_NullPtr *val);
80        //@}
81
82        /** @name Destructor. */
83        //@{
84        /**
85          * Destructor for DOM_TreeWalker.
86          */
87        ~DOM_TreeWalker();
88        //@}
89
90        /** @name Equality and Inequality operators. */
91        //@{
92        /**
93         * The equality operator.
94         *
95         * @param other The object reference with which <code>this</code> object is compared
96         * @returns True if both <code>DOM_TreeWalker</code>s refer to the same
97         *  actual node, or are both null; return false otherwise.
98         */
99        bool operator == (const DOM_TreeWalker & other)const;
100
101        /**
102          *  Compare with a pointer.  Intended only to allow a convenient
103          *    comparison with null.
104          */
105        bool operator == (const DOM_NullPtr *other) const;
106
107        /**
108         * The inequality operator.  See operator ==.
109         */
110        bool operator != (const DOM_TreeWalker & other) const;
111
112         /**
113          *  Compare with a pointer.  Intended only to allow a convenient
114          *    comparison with null.
115          *
116          */
117        bool operator != (const DOM_NullPtr * other) const;
118        //@}
119
120        /** @name Get functions. */
121        //@{
122        /**
123         * The <code>root</code> node of the <code>TreeWalker</code>, as specified
124         * when it was created.
125         */
126        DOM_Node          getRoot();
127
128        /**
129          * Return which node types are presented via the DOM_TreeWalker.
130          * These constants are defined in the DOM_NodeFilter interface.
131          *
132          */
133        unsigned long           getWhatToShow();
134
135        /**
136          * Return The filter used to screen nodes.
137          *
138          */
139        DOM_NodeFilter*         getFilter();
140
141        /**
142          * Return the expandEntityReferences flag.
143          * The value of this flag determines whether the children of entity reference
144          * nodes are visible to the DOM_TreeWalker. If false, they will be skipped over.
145          *
146          */
147        bool getExpandEntityReferences();
148
149        /**
150          * Return the node at which the DOM_TreeWalker is currently positioned.
151          *
152          */
153        DOM_Node                getCurrentNode();
154
155        /**
156          * Moves to and returns the closest visible ancestor node of the current node.
157          * If the search for parentNode attempts to step upward from the DOM_TreeWalker's root
158          * node, or if it fails to find a visible ancestor node, this method retains the
159          * current position and returns null.
160          *
161          */
162        DOM_Node                parentNode();
163
164        /**
165          * Moves the <code>DOM_TreeWalker</code> to the first child of the current node,
166          * and returns the new node. If the current node has no children, returns
167          * <code>null</code>, and retains the current node.
168          *
169          */
170        DOM_Node                firstChild();
171
172        /**
173          * Moves the <code>DOM_TreeWalker</code> to the last child of the current node, and
174          * returns the new node. If the current node has no children, returns
175          * <code>null</code>, and retains the current node.
176          *
177          */
178        DOM_Node                lastChild();
179
180        /**
181          * Moves the <code>DOM_TreeWalker</code> to the previous sibling of the current
182          * node, and returns the new node. If the current node has no previous sibling,
183          * returns <code>null</code>, and retains the current node.
184          *
185          */
186        DOM_Node                previousSibling();
187
188        /**
189          * Moves the <code>DOM_TreeWalker</code> to the next sibling of the current node,
190          * and returns the new node. If the current node has no next sibling, returns
191          * <code>null</code>, and retains the current node.
192          *
193          */
194        DOM_Node                nextSibling();
195
196        /**
197          * Moves the <code>DOM_TreeWalker</code> to the previous visible node in document
198          * order relative to the current node, and returns the new node. If the current
199          * node has no previous node,
200          * or if the search for previousNode attempts to step upward from the DOM_TreeWalker's
201          * root node, returns <code>null</code>, and retains the current node.
202          *
203          */
204        DOM_Node                previousNode();
205
206        /**
207          * Moves the <code>DOM_TreeWalker</code> to the next visible node in document order
208          * relative to the current node, and returns the new node. If the current node has
209          * no next node,
210          * or if the search for nextNode attempts to step upward from the DOM_TreeWalker's
211          * root node, returns <code>null</code>, and retains the current node.
212          *
213          */
214        DOM_Node                nextNode();
215        //@}
216
217        /** @name Set functions. */
218        //@{
219        /**
220          * Set the node at which the DOM_TreeWalker is currently positioned.
221          *
222          */
223        void                    setCurrentNode(DOM_Node currentNode);
224        //@}
225
226
227    protected:
228        DOM_TreeWalker(TreeWalkerImpl* impl);
229
230        friend class DOM_Document;
231
232    private:
233        TreeWalkerImpl*         fImpl;
234};
235
236XERCES_CPP_NAMESPACE_END
237
238#endif
Note: See TracBrowser for help on using the repository browser.