|
||||
File indexing completed on 2025-01-18 10:14:51
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_DOMTREEWALKER_HPP) 0023 #define XERCESC_INCLUDE_GUARD_DOMTREEWALKER_HPP 0024 0025 #include <xercesc/dom/DOMNode.hpp> 0026 #include <xercesc/dom/DOMNodeFilter.hpp> 0027 0028 XERCES_CPP_NAMESPACE_BEGIN 0029 0030 0031 /** 0032 * <code>DOMTreeWalker</code> objects are used to navigate a document tree or 0033 * subtree using the view of the document defined by their 0034 * <code>whatToShow</code> flags and filter (if any). Any function which 0035 * performs navigation using a <code>DOMTreeWalker</code> will automatically 0036 * support any view defined by a <code>DOMTreeWalker</code>. 0037 * <p>Omitting nodes from the logical view of a subtree can result in a 0038 * structure that is substantially different from the same subtree in the 0039 * complete, unfiltered document. Nodes that are siblings in the 0040 * <code>DOMTreeWalker</code> view may be children of different, widely 0041 * separated nodes in the original view. For instance, consider a 0042 * <code>DOMNodeFilter</code> that skips all nodes except for DOMText nodes and 0043 * the root node of a document. In the logical view that results, all text 0044 * nodes will be siblings and appear as direct children of the root node, no 0045 * matter how deeply nested the structure of the original document. 0046 * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>. 0047 * 0048 * @since DOM Level 2 0049 */ 0050 class CDOM_EXPORT DOMTreeWalker { 0051 protected: 0052 // ----------------------------------------------------------------------- 0053 // Hidden constructors 0054 // ----------------------------------------------------------------------- 0055 /** @name Hidden constructors */ 0056 //@{ 0057 DOMTreeWalker() {} 0058 DOMTreeWalker(const DOMTreeWalker &) {} 0059 //@} 0060 0061 private: 0062 // ----------------------------------------------------------------------- 0063 // Unimplemented constructors and operators 0064 // ----------------------------------------------------------------------- 0065 /** @name Unimplemented constructors and operators */ 0066 //@{ 0067 DOMTreeWalker & operator = (const DOMTreeWalker &); 0068 //@} 0069 0070 public: 0071 // ----------------------------------------------------------------------- 0072 // All constructors are hidden, just the destructor is available 0073 // ----------------------------------------------------------------------- 0074 /** @name Destructor */ 0075 //@{ 0076 /** 0077 * Destructor 0078 * 0079 */ 0080 virtual ~DOMTreeWalker() {}; 0081 //@} 0082 0083 // ----------------------------------------------------------------------- 0084 // Virtual DOMTreeWalker interface 0085 // ----------------------------------------------------------------------- 0086 /** @name Functions introduced in DOM Level 2 */ 0087 //@{ 0088 // ----------------------------------------------------------------------- 0089 // Getter methods 0090 // ----------------------------------------------------------------------- 0091 0092 /** 0093 * The <code>root</code> node of the <code>DOMTreeWalker</code>, as specified 0094 * when it was created. 0095 * 0096 * @since DOM Level 2 0097 */ 0098 virtual DOMNode* getRoot() = 0; 0099 /** 0100 * This attribute determines which node types are presented via the 0101 * <code>DOMTreeWalker</code>. The available set of constants is defined in 0102 * the <code>DOMNodeFilter</code> interface. Nodes not accepted by 0103 * <code>whatToShow</code> will be skipped, but their children may still 0104 * be considered. Note that this skip takes precedence over the filter, 0105 * if any. 0106 * 0107 * @since DOM Level 2 0108 */ 0109 virtual DOMNodeFilter::ShowType getWhatToShow()= 0; 0110 0111 /** 0112 * Return The filter used to screen nodes. 0113 * 0114 * @since DOM Level 2 0115 */ 0116 virtual DOMNodeFilter* getFilter()= 0; 0117 0118 /** 0119 * The value of this flag determines whether the children of entity 0120 * reference nodes are visible to the <code>DOMTreeWalker</code>. If false, 0121 * these children and their descendants will be rejected. Note that 0122 * this rejection takes precedence over <code>whatToShow</code> and the 0123 * filter, if any. 0124 * <br> To produce a view of the document that has entity references 0125 * expanded and does not expose the entity reference node itself, use 0126 * the <code>whatToShow</code> flags to hide the entity reference node 0127 * and set <code>expandEntityReferences</code> to true when creating the 0128 * <code>DOMTreeWalker</code>. To produce a view of the document that has 0129 * entity reference nodes but no entity expansion, use the 0130 * <code>whatToShow</code> flags to show the entity reference node and 0131 * set <code>expandEntityReferences</code> to false. 0132 * 0133 * @since DOM Level 2 0134 */ 0135 virtual bool getExpandEntityReferences()= 0; 0136 0137 /** 0138 * Return the node at which the DOMTreeWalker is currently positioned. 0139 * 0140 * @since DOM Level 2 0141 */ 0142 virtual DOMNode* getCurrentNode()= 0; 0143 0144 // ----------------------------------------------------------------------- 0145 // Query methods 0146 // ----------------------------------------------------------------------- 0147 /** 0148 * Moves to and returns the closest visible ancestor node of the current 0149 * node. If the search for <code>parentNode</code> attempts to step 0150 * upward from the <code>DOMTreeWalker</code>'s <code>root</code> node, or 0151 * if it fails to find a visible ancestor node, this method retains the 0152 * current position and returns <code>null</code>. 0153 * @return The new parent node, or <code>null</code> if the current node 0154 * has no parent in the <code>DOMTreeWalker</code>'s logical view. 0155 * 0156 * @since DOM Level 2 0157 */ 0158 virtual DOMNode* parentNode()= 0; 0159 0160 /** 0161 * Moves the <code>DOMTreeWalker</code> to the first visible child of the 0162 * current node, and returns the new node. If the current node has no 0163 * visible children, returns <code>null</code>, and retains the current 0164 * node. 0165 * @return The new node, or <code>null</code> if the current node has no 0166 * visible children in the <code>DOMTreeWalker</code>'s logical view. 0167 * 0168 * @since DOM Level 2 0169 */ 0170 virtual DOMNode* firstChild()= 0; 0171 0172 /** 0173 * Moves the <code>DOMTreeWalker</code> to the last visible child of the 0174 * current node, and returns the new node. If the current node has no 0175 * visible children, returns <code>null</code>, and retains the current 0176 * node. 0177 * @return The new node, or <code>null</code> if the current node has no 0178 * children in the <code>DOMTreeWalker</code>'s logical view. 0179 * 0180 * @since DOM Level 2 0181 */ 0182 virtual DOMNode* lastChild()= 0; 0183 0184 /** 0185 * Moves the <code>DOMTreeWalker</code> to the previous sibling of the 0186 * current node, and returns the new node. If the current node has no 0187 * visible previous sibling, returns <code>null</code>, and retains the 0188 * current node. 0189 * @return The new node, or <code>null</code> if the current node has no 0190 * previous sibling. in the <code>DOMTreeWalker</code>'s logical view. 0191 * 0192 * @since DOM Level 2 0193 */ 0194 virtual DOMNode* previousSibling()= 0; 0195 0196 /** 0197 * Moves the <code>DOMTreeWalker</code> to the next sibling of the current 0198 * node, and returns the new node. If the current node has no visible 0199 * next sibling, returns <code>null</code>, and retains the current node. 0200 * @return The new node, or <code>null</code> if the current node has no 0201 * next sibling. in the <code>DOMTreeWalker</code>'s logical view. 0202 * 0203 * @since DOM Level 2 0204 */ 0205 virtual DOMNode* nextSibling()= 0; 0206 0207 /** 0208 * Moves the <code>DOMTreeWalker</code> to the previous visible node in 0209 * document order relative to the current node, and returns the new 0210 * node. If the current node has no previous node, or if the search for 0211 * <code>previousNode</code> attempts to step upward from the 0212 * <code>DOMTreeWalker</code>'s <code>root</code> node, returns 0213 * <code>null</code>, and retains the current node. 0214 * @return The new node, or <code>null</code> if the current node has no 0215 * previous node in the <code>DOMTreeWalker</code>'s logical view. 0216 * 0217 * @since DOM Level 2 0218 */ 0219 virtual DOMNode* previousNode()= 0; 0220 0221 /** 0222 * Moves the <code>DOMTreeWalker</code> to the next visible node in document 0223 * order relative to the current node, and returns the new node. If the 0224 * current node has no next node, or if the search for nextNode attempts 0225 * to step upward from the <code>DOMTreeWalker</code>'s <code>root</code> 0226 * node, returns <code>null</code>, and retains the current node. 0227 * @return The new node, or <code>null</code> if the current node has no 0228 * next node in the <code>DOMTreeWalker</code>'s logical view. 0229 * 0230 * @since DOM Level 2 0231 */ 0232 virtual DOMNode* nextNode()= 0; 0233 0234 // ----------------------------------------------------------------------- 0235 // Setter methods 0236 // ----------------------------------------------------------------------- 0237 /** 0238 * The node at which the <code>DOMTreeWalker</code> is currently positioned. 0239 * <br>Alterations to the DOM tree may cause the current node to no longer 0240 * be accepted by the <code>DOMTreeWalker</code>'s associated filter. 0241 * <code>currentNode</code> may also be explicitly set to any node, 0242 * whether or not it is within the subtree specified by the 0243 * <code>root</code> node or would be accepted by the filter and 0244 * <code>whatToShow</code> flags. Further traversal occurs relative to 0245 * <code>currentNode</code> even if it is not part of the current view, 0246 * by applying the filters in the requested direction; if no traversal 0247 * is possible, <code>currentNode</code> is not changed. 0248 * @exception DOMException 0249 * NOT_SUPPORTED_ERR: Raised if an attempt is made to set 0250 * <code>currentNode</code> to <code>null</code>. 0251 * 0252 * @since DOM Level 2 0253 */ 0254 virtual void setCurrentNode(DOMNode* currentNode)= 0; 0255 //@} 0256 0257 // ----------------------------------------------------------------------- 0258 // Non-standard Extension 0259 // ----------------------------------------------------------------------- 0260 /** @name Non-standard Extension */ 0261 //@{ 0262 /** 0263 * Called to indicate that this TreeWalker is no longer in use 0264 * and that the implementation may relinquish any resources associated with it. 0265 * 0266 * Access to a released object will lead to unexpected result. 0267 */ 0268 virtual void release() = 0; 0269 //@} 0270 }; 0271 0272 #define GetDOMTreeWalkerMemoryManager GET_INDIRECT_MM(fCurrentNode) 0273 0274 XERCES_CPP_NAMESPACE_END 0275 0276 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |