|
||||
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_DOMNODEFILTER_HPP) 0023 #define XERCESC_INCLUDE_GUARD_DOMNODEFILTER_HPP 0024 0025 #include <xercesc/dom/DOMNode.hpp> 0026 0027 XERCES_CPP_NAMESPACE_BEGIN 0028 0029 0030 /** 0031 * Filters are objects that know how to "filter out" nodes. If a 0032 * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> is given a 0033 * <code>DOMNodeFilter</code>, it applies the filter before it returns the next 0034 * node. If the filter says to accept the node, the traversal logic returns 0035 * it; otherwise, traversal looks for the next node and pretends that the 0036 * node that was rejected was not there. 0037 * <p>The DOM does not provide any filters. <code>DOMNodeFilter</code> is just an 0038 * interface that users can implement to provide their own filters. 0039 * <p><code>DOMNodeFilters</code> do not need to know how to traverse from node 0040 * to node, nor do they need to know anything about the data structure that 0041 * is being traversed. This makes it very easy to write filters, since the 0042 * only thing they have to know how to do is evaluate a single node. One 0043 * filter may be used with a number of different kinds of traversals, 0044 * encouraging code reuse. 0045 * <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>. 0046 * @since DOM Level 2 0047 */ 0048 0049 class CDOM_EXPORT DOMNodeFilter 0050 { 0051 protected: 0052 // ----------------------------------------------------------------------- 0053 // Hidden constructors 0054 // ----------------------------------------------------------------------- 0055 /** @name Hidden constructors */ 0056 //@{ 0057 DOMNodeFilter() {}; 0058 //@} 0059 0060 private: 0061 // ----------------------------------------------------------------------- 0062 // Unimplemented constructors and operators 0063 // ----------------------------------------------------------------------- 0064 /** @name Unimplemented constructors and operators */ 0065 //@{ 0066 DOMNodeFilter(const DOMNodeFilter &); 0067 DOMNodeFilter & operator = (const DOMNodeFilter &); 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 ~DOMNodeFilter() {}; 0081 //@} 0082 0083 // ----------------------------------------------------------------------- 0084 // Class Types 0085 // ----------------------------------------------------------------------- 0086 /** @name Public Constants */ 0087 //@{ 0088 /** 0089 * Constants returned by acceptNode. 0090 * 0091 * <p><code>FILTER_ACCEPT:</code> 0092 * Accept the node. Navigation methods defined for 0093 * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> will return this 0094 * node.</p> 0095 * 0096 * <p><code>FILTER_REJECT:</code> 0097 * Reject the node. Navigation methods defined for 0098 * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> will not return 0099 * this node. For <code>DOMTreeWalker</code>, the children of this node 0100 * will also be rejected. <code>DOMNodeIterators</code> treat this as a 0101 * synonym for <code>FILTER_SKIP.</code></p> 0102 * 0103 * <p><code>FILTER_SKIP:</code> 0104 * Skip this single node. Navigation methods defined for 0105 * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> will not return 0106 * this node. For both <code>DOMNodeIterator</code> and 0107 * <code>DOMTreeWalker</code>, the children of this node will still be 0108 * considered.</p> 0109 * 0110 * @since DOM Level 2 0111 */ 0112 enum FilterAction {FILTER_ACCEPT = 1, 0113 FILTER_REJECT = 2, 0114 FILTER_SKIP = 3}; 0115 0116 /** 0117 * Constants for whatToShow 0118 * 0119 * <p><code>SHOW_ALL:</code> 0120 * Show all <code>DOMNode(s)</code>.</p> 0121 * 0122 * <p><code>SHOW_ELEMENT:</code> 0123 * Show <code>DOMElement</code> nodes.</p> 0124 * 0125 * <p><code>SHOW_ATTRIBUTE:</code> 0126 * Show <code>DOMAttr</code> nodes. This is meaningful only when creating an 0127 * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> with an 0128 * attribute node as its <code>root</code>; in this case, it means that 0129 * the attribute node will appear in the first position of the iteration 0130 * or traversal. Since attributes are never children of other nodes, 0131 * they do not appear when traversing over the document tree.</p> 0132 * 0133 * <p><code>SHOW_TEXT:</code> 0134 * Show <code>DOMText</code> nodes.</p> 0135 * 0136 * <p><code>SHOW_CDATA_SECTION:</code> 0137 * Show <code>DOMCDATASection</code> nodes.</p> 0138 * 0139 * <p><code>SHOW_ENTITY_REFERENCE:</code> 0140 * Show <code>DOMEntityReference</code> nodes.</p> 0141 * 0142 * <p><code>SHOW_ENTITY:</code> 0143 * Show <code>DOMEntity</code> nodes. This is meaningful only when creating 0144 * an <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> with an 0145 * <code>DOMEntity</code> node as its <code>root</code>; in this case, it 0146 * means that the <code>DOMEntity</code> node will appear in the first 0147 * position of the traversal. Since entities are not part of the 0148 * document tree, they do not appear when traversing over the document 0149 * tree.</p> 0150 * 0151 * <p><code>SHOW_PROCESSING_INSTRUCTION:</code> 0152 * Show <code>DOMProcessingInstruction</code> nodes.</p> 0153 * 0154 * <p><code>SHOW_COMMENT:</code> 0155 * Show <code>DOMComment</code> nodes.</p> 0156 * 0157 * <p><code>SHOW_DOCUMENT:</code> 0158 * Show <code>DOMDocument</code> nodes.</p> 0159 * 0160 * <p><code>SHOW_DOCUMENT_TYPE:</code> 0161 * Show <code>DOMDocumentType</code> nodes.</p> 0162 * 0163 * <p><code>SHOW_DOCUMENT_FRAGMENT:</code> 0164 * Show <code>DOMDocumentFragment</code> nodes.</p> 0165 * 0166 * <p><code>SHOW_NOTATION:</code> 0167 * Show <code>DOMNotation</code> nodes. This is meaningful only when creating 0168 * an <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> with a 0169 * <code>DOMNotation</code> node as its <code>root</code>; in this case, it 0170 * means that the <code>DOMNotation</code> node will appear in the first 0171 * position of the traversal. Since notations are not part of the 0172 * document tree, they do not appear when traversing over the document 0173 * tree.</p> 0174 * 0175 * @since DOM Level 2 0176 */ 0177 enum ShowTypeMasks { 0178 SHOW_ALL = 0x0000FFFF, 0179 SHOW_ELEMENT = 0x00000001, 0180 SHOW_ATTRIBUTE = 0x00000002, 0181 SHOW_TEXT = 0x00000004, 0182 SHOW_CDATA_SECTION = 0x00000008, 0183 SHOW_ENTITY_REFERENCE = 0x00000010, 0184 SHOW_ENTITY = 0x00000020, 0185 SHOW_PROCESSING_INSTRUCTION = 0x00000040, 0186 SHOW_COMMENT = 0x00000080, 0187 SHOW_DOCUMENT = 0x00000100, 0188 SHOW_DOCUMENT_TYPE = 0x00000200, 0189 SHOW_DOCUMENT_FRAGMENT = 0x00000400, 0190 SHOW_NOTATION = 0x00000800 0191 }; 0192 0193 typedef unsigned long ShowType; 0194 0195 //@} 0196 0197 // ----------------------------------------------------------------------- 0198 // Virtual DOMNodeFilter interface 0199 // ----------------------------------------------------------------------- 0200 /** @name Functions introduced in DOM Level 2 */ 0201 //@{ 0202 /** 0203 * Test whether a specified node is visible in the logical view of a 0204 * <code>DOMTreeWalker</code> or <code>DOMNodeIterator</code>. This function 0205 * will be called by the implementation of <code>DOMTreeWalker</code> and 0206 * <code>DOMNodeIterator</code>; it is not normally called directly from 0207 * user code. (Though you could do so if you wanted to use the same 0208 * filter to guide your own application logic.) 0209 * @param node The node to check to see if it passes the filter or not. 0210 * @return A constant to determine whether the node is accepted, 0211 * rejected, or skipped, as defined above. 0212 * @since DOM Level 2 0213 */ 0214 virtual FilterAction acceptNode (const DOMNode* node) const =0; 0215 //@} 0216 0217 }; 0218 0219 XERCES_CPP_NAMESPACE_END 0220 0221 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |