00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(TREEWALKER_HEADER_GUARD_1357924680) 00019 #define TREEWALKER_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/DOMSupport/DOMSupportDefinitions.hpp> 00025 00026 00027 00028 XALAN_CPP_NAMESPACE_BEGIN 00029 00030 00031 00032 class XalanNode; 00033 00034 00035 00036 class XALAN_DOMSUPPORT_EXPORT TreeWalker 00037 { 00038 public: 00039 00040 /** 00041 * Constructor. 00042 */ 00043 TreeWalker(); 00044 00045 virtual 00046 ~TreeWalker(); 00047 00048 /** 00049 * Perform a document-order traversal. 00050 * 00051 * Derived classes and stop the traversal by returning 00052 * true from startNode() or endNode(). If that happens, 00053 * the function will return the next node in document 00054 * order. If desired, the caller can start traversing 00055 * the tree again from that point. Note that terminal 00056 * nodes will always have startNode() and endNode() 00057 * called before the traversal terminates. 00058 * 00059 * @param pos The node in the tree with which to start the walk 00060 * 00061 * @return 0 if the traversal completes, or the next node if the traversal doesn't complete. 00062 */ 00063 const XalanNode* 00064 traverse(const XalanNode* pos); 00065 00066 /** 00067 * Perform a document-order traversal. 00068 * 00069 * Derived classes and stop the traversal by returning 00070 * true from startNode() or endNode(). If that happens, 00071 * the function will return the next node in document 00072 * order. If desired, the caller can start traversing 00073 * the tree again from that point. Note that terminal 00074 * nodes will always have startNode() and endNode() 00075 * called before the traversal terminates. 00076 * 00077 * @param pos The node in the tree with which to start the walk 00078 * 00079 * @return 0 if the traversal completes, or the next node if the traversal doesn't complete. 00080 */ 00081 XalanNode* 00082 traverse(XalanNode* pos); 00083 00084 /** 00085 * Perform a document-order traversal stopping at the 00086 * provided parent node. 00087 * 00088 * Derived classes and stop the traversal by returning 00089 * true from startNode() or endNode(). If that happens, 00090 * the function will return the next node in document 00091 * order. If desired, the caller can start traversing 00092 * the tree again from that point. Note that terminal 00093 * nodes will always have startNode() and endNode() 00094 * called before the traversal terminates. 00095 * 00096 * @param pos The node in the tree with which to start the walk 00097 * @param parent The parent of pos. Note that for multiple calls that continue the traversal, this node must remain the same. 00098 * 00099 * @return parent if the traversal completes, or the next node if the traversal doesn't complete. 00100 */ 00101 const XalanNode* 00102 traverse( 00103 const XalanNode* pos, 00104 const XalanNode* parent); 00105 00106 /** 00107 * Perform a document-order traversal stopping at the 00108 * provided parent node. 00109 * 00110 * Derived classes and stop the traversal by returning 00111 * true from startNode() or endNode(). If that happens, 00112 * the function will return the next node in document 00113 * order. If desired, the caller can start traversing 00114 * the tree again from that point. Note that terminal 00115 * nodes will always have startNode() and endNode() 00116 * called before the traversal terminates. 00117 * 00118 * @param pos The node in the tree with which to start the walk 00119 * @param parent The parent of pos. Note that for multiple calls that continue the traversal, this node must remain the same. 00120 * 00121 * @return parent if the traversal completes, or the next node if the traversal doesn't complete. 00122 */ 00123 XalanNode* 00124 traverse( 00125 XalanNode* pos, 00126 XalanNode* parent); 00127 00128 /** 00129 * Perform a pre-order traversal. 00130 * 00131 * @param pos starting node 00132 */ 00133 virtual void 00134 traverseSubtree(const XalanNode* pos); 00135 00136 /** 00137 * Perform a pre-order traversal. 00138 * 00139 * @param pos starting node 00140 */ 00141 virtual void 00142 traverseSubtree(XalanNode* pos); 00143 00144 protected: 00145 00146 /** 00147 * Called when first walking a node 00148 * 00149 * @param node The node 00150 * 00151 * @return return false if the walk should continue, or true if it should not. 00152 */ 00153 virtual bool 00154 startNode(const XalanNode* node) = 0; 00155 00156 /** 00157 * Called when first walking a node 00158 * 00159 * @param node The node 00160 * 00161 * @return return false if the walk should continue, or true if it should not. 00162 */ 00163 virtual bool 00164 startNode(XalanNode* node) = 0; 00165 00166 /** 00167 * Called when leaving a node 00168 * 00169 * @param node The node 00170 * 00171 * @return return false if the walk should continue, or true if it should not. 00172 */ 00173 virtual bool 00174 endNode(const XalanNode* node) = 0; 00175 00176 /** 00177 * Called when leaving a node 00178 * 00179 * @param node The node 00180 * 00181 * @return return false if the walk should continue, or true if it should not. 00182 */ 00183 virtual bool 00184 endNode(XalanNode* node) = 0; 00185 00186 private: 00187 }; 00188 00189 00190 00191 XALAN_CPP_NAMESPACE_END 00192 00193 00194 00195 #endif // TREEWALKER_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|