source: NonGTP/Xerces/xercesc/dom/DOMNodeFilter.hpp @ 188

Revision 188, 10.8 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1#ifndef DOMNodeFilter_HEADER_GUARD_
2#define DOMNodeFilter_HEADER_GUARD_
3
4/*
5 * The Apache Software License, Version 1.1
6 *
7 * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
8 * reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in
19 *    the documentation and/or other materials provided with the
20 *    distribution.
21 *
22 * 3. The end-user documentation included with the redistribution,
23 *    if any, must include the following acknowledgment:
24 *       "This product includes software developed by the
25 *        Apache Software Foundation (http://www.apache.org/)."
26 *    Alternately, this acknowledgment may appear in the software itself,
27 *    if and wherever such third-party acknowledgments normally appear.
28 *
29 * 4. The names "Xerces" and "Apache Software Foundation" must
30 *    not be used to endorse or promote products derived from this
31 *    software without prior written permission. For written
32 *    permission, please contact apache\@apache.org.
33 *
34 * 5. Products derived from this software may not be called "Apache",
35 *    nor may "Apache" appear in their name, without prior written
36 *    permission of the Apache Software Foundation.
37 *
38 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 * SUCH DAMAGE.
50 * ====================================================================
51 *
52 * This software consists of voluntary contributions made by many
53 * individuals on behalf of the Apache Software Foundation, and was
54 * originally based on software copyright (c) 2001, International
55 * Business Machines, Inc., http://www.ibm.com .  For more information
56 * on the Apache Software Foundation, please see
57 * <http://www.apache.org/>.
58 */
59
60/*
61 * $Id: DOMNodeFilter.hpp,v 1.6 2003/03/07 19:59:06 tng Exp $
62 */
63
64#include "DOMNode.hpp"
65
66XERCES_CPP_NAMESPACE_BEGIN
67
68
69/**
70 * Filters are objects that know how to "filter out" nodes. If a
71 * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> is given a
72 * <code>DOMNodeFilter</code>, it applies the filter before it returns the next
73 * node. If the filter says to accept the node, the traversal logic returns
74 * it; otherwise, traversal looks for the next node and pretends that the
75 * node that was rejected was not there.
76 * <p>The DOM does not provide any filters. <code>DOMNodeFilter</code> is just an
77 * interface that users can implement to provide their own filters.
78 * <p><code>DOMNodeFilters</code> do not need to know how to traverse from node
79 * to node, nor do they need to know anything about the data structure that
80 * is being traversed. This makes it very easy to write filters, since the
81 * only thing they have to know how to do is evaluate a single node. One
82 * filter may be used with a number of different kinds of traversals,
83 * encouraging code reuse.
84 * <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>.
85 * @since DOM Level 2
86 */
87
88class CDOM_EXPORT DOMNodeFilter
89{
90protected:
91    // -----------------------------------------------------------------------
92    //  Hidden constructors
93    // -----------------------------------------------------------------------
94    /** @name Hidden constructors */
95    //@{   
96    DOMNodeFilter() {};
97    //@}   
98
99private:
100    // -----------------------------------------------------------------------
101    // Unimplemented constructors and operators
102    // -----------------------------------------------------------------------
103    /** @name Unimplemented constructors and operators */
104    //@{
105    DOMNodeFilter(const DOMNodeFilter &);
106    DOMNodeFilter & operator = (const DOMNodeFilter &);
107    //@}
108
109public:
110    // -----------------------------------------------------------------------
111    //  All constructors are hidden, just the destructor is available
112    // -----------------------------------------------------------------------
113    /** @name Destructor */
114    //@{
115    /**
116     * Destructor
117     *
118     */
119    virtual ~DOMNodeFilter() {};
120    //@}
121
122    // -----------------------------------------------------------------------
123    //  Class Types
124    // -----------------------------------------------------------------------
125    /** @name Public Contants */
126    //@{
127    /**
128     * Constants returned by acceptNode.
129     *
130     * <p><code>FILTER_ACCEPT:</code>
131     * Accept the node. Navigation methods defined for
132     * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> will return this
133     * node.</p>
134     *
135     * <p><code>FILTER_REJECT:</code>
136     * Reject the node. Navigation methods defined for
137     * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> will not return
138     * this node. For <code>DOMTreeWalker</code>, the children of this node
139     * will also be rejected. <code>DOMNodeIterators</code> treat this as a
140     * synonym for <code>FILTER_SKIP.</code></p>
141     *
142     * <p><code>FILTER_SKIP:</code>
143     * Skip this single node. Navigation methods defined for
144     * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> will not return
145     * this node. For both <code>DOMNodeIterator</code> and
146     * <code>DOMTreeWalker</code>, the children of this node will still be
147     * considered.</p>
148     *
149     * @since DOM Level 2
150     */
151    enum FilterAction {FILTER_ACCEPT = 1,
152                       FILTER_REJECT = 2,
153                       FILTER_SKIP   = 3};
154
155    /**
156     * Constants for whatToShow
157     *
158     * <p><code>SHOW_ALL:</code>
159     * Show all <code>DOMNode(s)</code>.</p>
160     *
161     * <p><code>SHOW_ELEMENT:</code>
162     * Show <code>DOMElement</code> nodes.</p>
163     *
164     * <p><code>SHOW_ATTRIBUTE:</code>
165     * Show <code>DOMAttr</code> nodes. This is meaningful only when creating an
166     * <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> with an
167     * attribute node as its <code>root</code>; in this case, it means that
168     * the attribute node will appear in the first position of the iteration
169     * or traversal. Since attributes are never children of other nodes,
170     * they do not appear when traversing over the document tree.</p>
171     *
172     * <p><code>SHOW_TEXT:</code>
173     * Show <code>DOMText</code> nodes.</p>
174     *
175     * <p><code>SHOW_CDATA_SECTION:</code>
176     * Show <code>DOMCDATASection</code> nodes.</p>
177     *
178     * <p><code>SHOW_ENTITY_REFERENCE:</code>
179     * Show <code>DOMEntityReference</code> nodes.</p>
180     *
181     * <p><code>SHOW_ENTITY:</code>
182     * Show <code>DOMEntity</code> nodes. This is meaningful only when creating
183     * an <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> with an
184     * <code>DOMEntity</code> node as its <code>root</code>; in this case, it
185     * means that the <code>DOMEntity</code> node will appear in the first
186     * position of the traversal. Since entities are not part of the
187     * document tree, they do not appear when traversing over the document
188     * tree.</p>
189     *
190     * <p><code>SHOW_PROCESSING_INSTRUCTION:</code>
191     * Show <code>DOMProcessingInstruction</code> nodes.</p>
192     *
193     * <p><code>SHOW_COMMENT:</code>
194     * Show <code>DOMComment</code> nodes.</p>
195     *
196     * <p><code>SHOW_DOCUMENT:</code>
197     * Show <code>DOMDocument</code> nodes.</p>
198     *
199     * <p><code>SHOW_DOCUMENT_TYPE:</code>
200     * Show <code>DOMDocumentType</code> nodes.</p>
201     *
202     * <p><code>SHOW_DOCUMENT_FRAGMENT:</code>
203     * Show <code>DOMDocumentFragment</code> nodes.</p>
204     *
205     * <p><code>SHOW_NOTATION:</code>
206     * Show <code>DOMNotation</code> nodes. This is meaningful only when creating
207     * an <code>DOMNodeIterator</code> or <code>DOMTreeWalker</code> with a
208     * <code>DOMNotation</code> node as its <code>root</code>; in this case, it
209     * means that the <code>DOMNotation</code> node will appear in the first
210     * position of the traversal. Since notations are not part of the
211     * document tree, they do not appear when traversing over the document
212     * tree.</p>
213     *
214     * @since DOM Level 2
215     */
216    enum ShowType {
217        SHOW_ALL                       = 0x0000FFFF,
218        SHOW_ELEMENT                   = 0x00000001,
219        SHOW_ATTRIBUTE                 = 0x00000002,
220        SHOW_TEXT                      = 0x00000004,
221        SHOW_CDATA_SECTION             = 0x00000008,
222        SHOW_ENTITY_REFERENCE          = 0x00000010,
223        SHOW_ENTITY                    = 0x00000020,
224        SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
225        SHOW_COMMENT                   = 0x00000080,
226        SHOW_DOCUMENT                  = 0x00000100,
227        SHOW_DOCUMENT_TYPE             = 0x00000200,
228        SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
229        SHOW_NOTATION                  = 0x00000800
230    };
231    //@}
232
233    // -----------------------------------------------------------------------
234    //  Virtual DOMNodeFilter interface
235    // -----------------------------------------------------------------------
236    /** @name Functions introduced in DOM Level 2 */
237    //@{
238    /**
239     * Test whether a specified node is visible in the logical view of a
240     * <code>DOMTreeWalker</code> or <code>DOMNodeIterator</code>. This function
241     * will be called by the implementation of <code>DOMTreeWalker</code> and
242     * <code>DOMNodeIterator</code>; it is not normally called directly from
243     * user code. (Though you could do so if you wanted to use the same
244     * filter to guide your own application logic.)
245     * @param node The node to check to see if it passes the filter or not.
246     * @return A constant to determine whether the node is accepted,
247     *   rejected, or skipped, as defined above.
248     * @since DOM Level 2
249     */
250    virtual short acceptNode (const DOMNode* node) const =0;
251    //@}
252
253};
254
255XERCES_CPP_NAMESPACE_END
256
257#endif
Note: See TracBrowser for help on using the repository browser.