Xalan-C++ API Reference 1.12.0
TreeWalker.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you 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#if !defined(TREEWALKER_HEADER_GUARD_1357924680)
19#define TREEWALKER_HEADER_GUARD_1357924680
20
21
22
23// Base include file. Must be first.
25
26
27
28namespace XALAN_CPP_NAMESPACE {
29
30
31
32class XalanNode;
33
34
35
37{
38public:
39
40 /**
41 * Constructor.
42 */
44
45 virtual
47
48 /**
49 * Perform a document-order traversal.
50 *
51 * Derived classes and stop the traversal by returning
52 * true from startNode() or endNode(). If that happens,
53 * the function will return the next node in document
54 * order. If desired, the caller can start traversing
55 * the tree again from that point. Note that terminal
56 * nodes will always have startNode() and endNode()
57 * called before the traversal terminates.
58 *
59 * @param pos The node in the tree with which to start the walk
60 *
61 * @return 0 if the traversal completes, or the next node if the traversal doesn't complete.
62 */
63 const XalanNode*
64 traverse(const XalanNode* pos);
65
66 /**
67 * Perform a document-order traversal.
68 *
69 * Derived classes and stop the traversal by returning
70 * true from startNode() or endNode(). If that happens,
71 * the function will return the next node in document
72 * order. If desired, the caller can start traversing
73 * the tree again from that point. Note that terminal
74 * nodes will always have startNode() and endNode()
75 * called before the traversal terminates.
76 *
77 * @param pos The node in the tree with which to start the walk
78 *
79 * @return 0 if the traversal completes, or the next node if the traversal doesn't complete.
80 */
83
84 /**
85 * Perform a document-order traversal stopping at the
86 * provided parent node.
87 *
88 * Derived classes and stop the traversal by returning
89 * true from startNode() or endNode(). If that happens,
90 * the function will return the next node in document
91 * order. If desired, the caller can start traversing
92 * the tree again from that point. Note that terminal
93 * nodes will always have startNode() and endNode()
94 * called before the traversal terminates.
95 *
96 * @param pos The node in the tree with which to start the walk
97 * @param parent The parent of pos. Note that for multiple calls that continue the traversal, this node must remain the same.
98 *
99 * @return parent if the traversal completes, or the next node if the traversal doesn't complete.
100 */
101 const XalanNode*
103 const XalanNode* pos,
104 const XalanNode* parent);
105
106 /**
107 * Perform a document-order traversal stopping at the
108 * provided parent node.
109 *
110 * Derived classes and stop the traversal by returning
111 * true from startNode() or endNode(). If that happens,
112 * the function will return the next node in document
113 * order. If desired, the caller can start traversing
114 * the tree again from that point. Note that terminal
115 * nodes will always have startNode() and endNode()
116 * called before the traversal terminates.
117 *
118 * @param pos The node in the tree with which to start the walk
119 * @param parent The parent of pos. Note that for multiple calls that continue the traversal, this node must remain the same.
120 *
121 * @return parent if the traversal completes, or the next node if the traversal doesn't complete.
122 */
123 XalanNode*
125 XalanNode* pos,
126 XalanNode* parent);
127
128 /**
129 * Perform a pre-order traversal.
130 *
131 * @param pos starting node
132 */
133 virtual void
135
136 /**
137 * Perform a pre-order traversal.
138 *
139 * @param pos starting node
140 */
141 virtual void
143
144protected:
145
146 /**
147 * Called when first walking a node
148 *
149 * @param node The node
150 *
151 * @return return false if the walk should continue, or true if it should not.
152 */
153 virtual bool
154 startNode(const XalanNode* node) = 0;
155
156 /**
157 * Called when first walking a node
158 *
159 * @param node The node
160 *
161 * @return return false if the walk should continue, or true if it should not.
162 */
163 virtual bool
165
166 /**
167 * Called when leaving a node
168 *
169 * @param node The node
170 *
171 * @return return false if the walk should continue, or true if it should not.
172 */
173 virtual bool
174 endNode(const XalanNode* node) = 0;
175
176 /**
177 * Called when leaving a node
178 *
179 * @param node The node
180 *
181 * @return return false if the walk should continue, or true if it should not.
182 */
183 virtual bool
184 endNode(XalanNode* node) = 0;
185
186private:
187};
188
189
190
191}
192
193
194
195#endif // TREEWALKER_HEADER_GUARD_1357924680
#define XALAN_DOMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
XalanNode * traverse(XalanNode *pos)
Perform a document-order traversal.
virtual bool endNode(const XalanNode *node)=0
Called when leaving a node.
virtual bool startNode(XalanNode *node)=0
Called when first walking a node.
const XalanNode * traverse(const XalanNode *pos, const XalanNode *parent)
Perform a document-order traversal stopping at the provided parent node.
virtual void traverseSubtree(XalanNode *pos)
Perform a pre-order traversal.
virtual bool endNode(XalanNode *node)=0
Called when leaving a node.
XalanNode * traverse(XalanNode *pos, XalanNode *parent)
Perform a document-order traversal stopping at the provided parent node.
TreeWalker()
Constructor.
const XalanNode * traverse(const XalanNode *pos)
Perform a document-order traversal.
virtual void traverseSubtree(const XalanNode *pos)
Perform a pre-order traversal.
virtual ~TreeWalker()
virtual bool startNode(const XalanNode *node)=0
Called when first walking a node.