1 | /* |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | * contributor license agreements. See the NOTICE file distributed with |
---|
4 | * this work for additional information regarding copyright ownership. |
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | * (the "License"); you may not use this file except in compliance with |
---|
7 | * the License. You may obtain a copy of the License at |
---|
8 | * |
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | * |
---|
11 | * Unless required by applicable law or agreed to in writing, software |
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | * See the License for the specific language governing permissions and |
---|
15 | * limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | * $Id: DOM_NodeFilter.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | // DOM_NodeFilter.h: interface for the DOM_NodeFilter class. |
---|
23 | // |
---|
24 | ////////////////////////////////////////////////////////////////////// |
---|
25 | |
---|
26 | #ifndef DOM_NodeFilter_HEADER_GUARD_ |
---|
27 | #define DOM_NodeFilter_HEADER_GUARD_ |
---|
28 | |
---|
29 | #include "DOM_Node.hpp" |
---|
30 | |
---|
31 | XERCES_CPP_NAMESPACE_BEGIN |
---|
32 | |
---|
33 | |
---|
34 | class NodeFilterImpl; |
---|
35 | |
---|
36 | |
---|
37 | /** |
---|
38 | * Filters are objects that know how to "filter out" nodes. If a |
---|
39 | * <code>DOM_NodeIterator</code> or <code>DOM_TreeWalker</code> is given a |
---|
40 | * filter, it applies the filter before it returns the next node. |
---|
41 | * |
---|
42 | * If the filter says to accept the node, the iterator returns it; otherwise, the |
---|
43 | * iterator looks for the next node and pretends that the node that was rejected |
---|
44 | * was not there. |
---|
45 | * |
---|
46 | * The DOM does not provide any filters. Filter is just an interface that users can |
---|
47 | * implement to provide their own filters. |
---|
48 | * |
---|
49 | * Filters do not need to know how to iterate, nor do they need to know anything |
---|
50 | * about the data structure that is being iterated. This makes it very easy to write |
---|
51 | * filters, since the only thing they have to know how to do is evaluate a single node. |
---|
52 | * One filter may be used with a number of different kinds of iterators, encouraging |
---|
53 | * code reuse. |
---|
54 | * |
---|
55 | */ |
---|
56 | class DEPRECATED_DOM_EXPORT DOM_NodeFilter |
---|
57 | { |
---|
58 | public: |
---|
59 | /** @name Enumerators for Node Filter */ |
---|
60 | //@{ |
---|
61 | /* |
---|
62 | * <table><tr><td>FILTER_ACCEPT</td> |
---|
63 | * <td>Accept the node. Navigation methods defined for |
---|
64 | * NodeIterator or TreeWalker will return this node.</td> |
---|
65 | * </tr> |
---|
66 | * <tr><td> |
---|
67 | * FILTER_REJECT</td> |
---|
68 | * <td>Reject the node. Navigation methods defined for |
---|
69 | * NodeIterator or TreeWalker will not return this |
---|
70 | * node. For TreeWalker, the children of this node will |
---|
71 | * also be rejected. Iterators treat this as a synonym |
---|
72 | * for FILTER_SKIP.</td> |
---|
73 | * </tr> |
---|
74 | * <tr><td>FILTER_SKIP</td> |
---|
75 | * <td>Reject the node. Navigation methods defined for |
---|
76 | * NodeIterator or TreeWalker will not return this |
---|
77 | * node. For both NodeIterator and Treewalker, the |
---|
78 | * children of this node will still be considered.</td> |
---|
79 | * </tr> |
---|
80 | * </table> |
---|
81 | * |
---|
82 | */ |
---|
83 | enum FilterAction {FILTER_ACCEPT = 1, |
---|
84 | FILTER_REJECT = 2, |
---|
85 | FILTER_SKIP = 3}; |
---|
86 | |
---|
87 | enum ShowType { |
---|
88 | SHOW_ALL = 0x0000FFFF, |
---|
89 | SHOW_ELEMENT = 0x00000001, |
---|
90 | SHOW_ATTRIBUTE = 0x00000002, |
---|
91 | SHOW_TEXT = 0x00000004, |
---|
92 | SHOW_CDATA_SECTION = 0x00000008, |
---|
93 | SHOW_ENTITY_REFERENCE = 0x00000010, |
---|
94 | SHOW_ENTITY = 0x00000020, |
---|
95 | SHOW_PROCESSING_INSTRUCTION = 0x00000040, |
---|
96 | SHOW_COMMENT = 0x00000080, |
---|
97 | SHOW_DOCUMENT = 0x00000100, |
---|
98 | SHOW_DOCUMENT_TYPE = 0x00000200, |
---|
99 | SHOW_DOCUMENT_FRAGMENT = 0x00000400, |
---|
100 | SHOW_NOTATION = 0x00000800 |
---|
101 | }; |
---|
102 | //@} |
---|
103 | |
---|
104 | /** @name Constructors */ |
---|
105 | //@{ |
---|
106 | /** |
---|
107 | * Default constructor for DOM_NodeFilter. |
---|
108 | */ |
---|
109 | DOM_NodeFilter(); |
---|
110 | //@} |
---|
111 | |
---|
112 | /** @name Destructor. */ |
---|
113 | //@{ |
---|
114 | /** |
---|
115 | * Destructor for DOM_NodeFilter. |
---|
116 | */ |
---|
117 | virtual ~DOM_NodeFilter(); |
---|
118 | //@} |
---|
119 | |
---|
120 | /** @name Test function. */ |
---|
121 | //@{ |
---|
122 | /** |
---|
123 | * Test whether a specified node is visible in the logical view of a DOM_TreeWalker |
---|
124 | * or DOM_NodeIterator. This function will be called by the implementation of |
---|
125 | * DOM_TreeWalker and DOM_NodeIterator; it is not intended to be called directly from user |
---|
126 | * code. |
---|
127 | * |
---|
128 | * @param node The node to check to see if it passes the filter or not. |
---|
129 | * @return A constant to determine whether the node is accepted, rejected, or skipped. |
---|
130 | */ |
---|
131 | virtual short acceptNode (const DOM_Node &node) const =0; |
---|
132 | //@} |
---|
133 | |
---|
134 | private: |
---|
135 | DOM_NodeFilter(const DOM_NodeFilter &other); |
---|
136 | DOM_NodeFilter & operator = (const DOM_NodeFilter &other); |
---|
137 | bool operator == (const DOM_NodeFilter &other) const; |
---|
138 | bool operator != (const DOM_NodeFilter &other) const; |
---|
139 | }; |
---|
140 | |
---|
141 | XERCES_CPP_NAMESPACE_END |
---|
142 | |
---|
143 | #endif |
---|