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

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

xerces added

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