1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Id: DOM_NodeFilter.hpp,v 1.3 2002/11/04 15:04:44 tng Exp $
|
---|
59 | */
|
---|
60 |
|
---|
61 | // DOM_NodeFilter.h: interface for the DOM_NodeFilter class.
|
---|
62 | //
|
---|
63 | //////////////////////////////////////////////////////////////////////
|
---|
64 |
|
---|
65 | #ifndef DOM_NodeFilter_HEADER_GUARD_
|
---|
66 | #define DOM_NodeFilter_HEADER_GUARD_
|
---|
67 |
|
---|
68 | #include "DOM_Node.hpp"
|
---|
69 |
|
---|
70 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
71 |
|
---|
72 |
|
---|
73 | class NodeFilterImpl;
|
---|
74 |
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Filters are objects that know how to "filter out" nodes. If a
|
---|
78 | * <code>DOM_NodeIterator</code> or <code>DOM_TreeWalker</code> is given a
|
---|
79 | * filter, it applies the filter before it returns the next node.
|
---|
80 | *
|
---|
81 | * If the filter says to accept the node, the iterator returns it; otherwise, the
|
---|
82 | * iterator looks for the next node and pretends that the node that was rejected
|
---|
83 | * was not there.
|
---|
84 | *
|
---|
85 | * The DOM does not provide any filters. Filter is just an interface that users can
|
---|
86 | * implement to provide their own filters.
|
---|
87 | *
|
---|
88 | * Filters do not need to know how to iterate, nor do they need to know anything
|
---|
89 | * about the data structure that is being iterated. This makes it very easy to write
|
---|
90 | * filters, since the only thing they have to know how to do is evaluate a single node.
|
---|
91 | * One filter may be used with a number of different kinds of iterators, encouraging
|
---|
92 | * code reuse.
|
---|
93 | *
|
---|
94 | */
|
---|
95 | class CDOM_EXPORT DOM_NodeFilter
|
---|
96 | {
|
---|
97 | public:
|
---|
98 | /** @name Enumerators for Node Filter */
|
---|
99 | //@{
|
---|
100 | /*
|
---|
101 | * <table><tr><td>FILTER_ACCEPT</td>
|
---|
102 | * <td>Accept the node. Navigation methods defined for
|
---|
103 | * NodeIterator or TreeWalker will return this node.</td>
|
---|
104 | * </tr>
|
---|
105 | * <tr><td>
|
---|
106 | * FILTER_REJECT</td>
|
---|
107 | * <td>Reject the node. Navigation methods defined for
|
---|
108 | * NodeIterator or TreeWalker will not return this
|
---|
109 | * node. For TreeWalker, the children of this node will
|
---|
110 | * also be rejected. Iterators treat this as a synonym
|
---|
111 | * for FILTER_SKIP.</td>
|
---|
112 | * </tr>
|
---|
113 | * <tr><td>FILTER_SKIP</td>
|
---|
114 | * <td>Reject the node. Navigation methods defined for
|
---|
115 | * NodeIterator or TreeWalker will not return this
|
---|
116 | * node. For both NodeIterator and Treewalker, the
|
---|
117 | * children of this node will still be considered.</td>
|
---|
118 | * </tr>
|
---|
119 | * </table>
|
---|
120 | *
|
---|
121 | */
|
---|
122 | enum FilterAction {FILTER_ACCEPT = 1,
|
---|
123 | FILTER_REJECT = 2,
|
---|
124 | FILTER_SKIP = 3};
|
---|
125 |
|
---|
126 | enum ShowType {
|
---|
127 | SHOW_ALL = 0x0000FFFF,
|
---|
128 | SHOW_ELEMENT = 0x00000001,
|
---|
129 | SHOW_ATTRIBUTE = 0x00000002,
|
---|
130 | SHOW_TEXT = 0x00000004,
|
---|
131 | SHOW_CDATA_SECTION = 0x00000008,
|
---|
132 | SHOW_ENTITY_REFERENCE = 0x00000010,
|
---|
133 | SHOW_ENTITY = 0x00000020,
|
---|
134 | SHOW_PROCESSING_INSTRUCTION = 0x00000040,
|
---|
135 | SHOW_COMMENT = 0x00000080,
|
---|
136 | SHOW_DOCUMENT = 0x00000100,
|
---|
137 | SHOW_DOCUMENT_TYPE = 0x00000200,
|
---|
138 | SHOW_DOCUMENT_FRAGMENT = 0x00000400,
|
---|
139 | SHOW_NOTATION = 0x00000800
|
---|
140 | };
|
---|
141 | //@}
|
---|
142 |
|
---|
143 | /** @name Constructors */
|
---|
144 | //@{
|
---|
145 | /**
|
---|
146 | * Default constructor for DOM_NodeFilter.
|
---|
147 | */
|
---|
148 | DOM_NodeFilter();
|
---|
149 | //@}
|
---|
150 |
|
---|
151 | /** @name Destructor. */
|
---|
152 | //@{
|
---|
153 | /**
|
---|
154 | * Destructor for DOM_NodeFilter.
|
---|
155 | */
|
---|
156 | virtual ~DOM_NodeFilter();
|
---|
157 | //@}
|
---|
158 |
|
---|
159 | /** @name Test function. */
|
---|
160 | //@{
|
---|
161 | /**
|
---|
162 | * Test whether a specified node is visible in the logical view of a DOM_TreeWalker
|
---|
163 | * or DOM_NodeIterator. This function will be called by the implementation of
|
---|
164 | * DOM_TreeWalker and DOM_NodeIterator; it is not intended to be called directly from user
|
---|
165 | * code.
|
---|
166 | *
|
---|
167 | * @param node The node to check to see if it passes the filter or not.
|
---|
168 | * @return A constant to determine whether the node is accepted, rejected, or skipped.
|
---|
169 | */
|
---|
170 | virtual short acceptNode (const DOM_Node &node) const =0;
|
---|
171 | //@}
|
---|
172 |
|
---|
173 | private:
|
---|
174 | DOM_NodeFilter(const DOM_NodeFilter &other);
|
---|
175 | DOM_NodeFilter & operator = (const DOM_NodeFilter &other);
|
---|
176 | bool operator == (const DOM_NodeFilter &other) const;
|
---|
177 | bool operator != (const DOM_NodeFilter &other) const;
|
---|
178 | };
|
---|
179 |
|
---|
180 | XERCES_CPP_NAMESPACE_END
|
---|
181 |
|
---|
182 | #endif
|
---|