DOM_NodeFilter.hpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:8k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 1999-2000 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.  * $Log: DOM_NodeFilter.hpp,v $
  58.  * Revision 1.10  2000/10/20 22:03:04  andyh
  59.  * DOM NodeFileter - define values for FilterAction enum to match those in the DOM spec.
  60.  *
  61.  * Revision 1.9  2000/05/11 00:07:38  abagchi
  62.  * Removed tables. It was confusing doxygen
  63.  *
  64.  * Revision 1.8  2000/03/11 03:19:13  chchou
  65.  * Fix bug # 19, add const keyword to API
  66.  *
  67.  * Revision 1.7  2000/02/24 20:11:28  abagchi
  68.  * Swat for removing Log from API docs
  69.  *
  70.  * Revision 1.6  2000/02/17 17:47:25  andyh
  71.  * Update Doc++ API comments
  72.  * NameSpace update to track W3C
  73.  * Changes were made by Chih Hsiang Chou
  74.  *
  75.  * Revision 1.5  2000/02/15 23:17:37  andyh
  76.  * Update Doc++ API comments
  77.  * NameSpace bugfix and update to track W3C
  78.  * Chih Hsiang Chou
  79.  *
  80.  * Revision 1.4  2000/02/10 21:47:12  abagchi
  81.  * Added API docs
  82.  *
  83.  * Revision 1.3  2000/02/06 07:47:30  rahulj
  84.  * Year 2K copyright swat.
  85.  *
  86.  * Revision 1.2  2000/02/04 01:49:28  aruna1
  87.  * TreeWalker and NodeIterator changes
  88.  *
  89.  * Revision 1.1.1.1  1999/11/09 01:09:00  twl
  90.  * Initial checkin
  91.  *
  92.  * Revision 1.2  1999/11/08 20:44:19  rahul
  93.  * Swat for adding in Product name and CVS comment log variable.
  94.  *
  95.  */
  96. // DOM_NodeFilter.h: interface for the DOM_NodeFilter class.
  97. //
  98. //////////////////////////////////////////////////////////////////////
  99. #ifndef DOM_NodeFilter_HEADER_GUARD_
  100. #define DOM_NodeFilter_HEADER_GUARD_
  101. #include "DOM_Node.hpp"
  102. class NodeFilterImpl;
  103. /**
  104.  * Filters are objects that know how to "filter out" nodes. If a
  105.  * <code>DOM_NodeIterator</code> or <code>DOM_TreeWalker</code> is given a
  106.  * filter, it applies the filter before it returns the next node.
  107.  *
  108.  * If the filter says to accept the node, the iterator returns it; otherwise, the
  109.  * iterator looks for the next node and pretends that the node that was rejected
  110.  * was not there.
  111.  *
  112.  *  The DOM does not provide any filters. Filter is just an interface that users can
  113.  *  implement to provide their own filters.
  114.  *
  115.  *  Filters do not need to know how to iterate, nor do they need to know anything
  116.  *  about the data structure that is being iterated. This makes it very easy to write
  117.  *  filters, since the only thing they have to know how to do is evaluate a single node.
  118.  *  One filter may be used with a number of different kinds of iterators, encouraging
  119.  *  code reuse.
  120.  *
  121.  * <p><b>"Experimental - subject to change"</b></p>
  122.  *
  123.  */
  124. class CDOM_EXPORT DOM_NodeFilter
  125. {
  126.     public:
  127. /** @name Enumerators for Node Filter */
  128.         //@{
  129. /*
  130.   * <table><tr><td>FILTER_ACCEPT</td>
  131.       *            <td>Accept the node. Navigation methods defined for
  132.       *                NodeIterator or TreeWalker will return this node.</td>
  133.   * </tr>
  134.   * <tr><td>
  135.       *               FILTER_REJECT</td>
  136.       *               <td>Reject the node. Navigation methods defined for
  137.       *               NodeIterator or TreeWalker will not return this
  138.       *               node. For TreeWalker, the children of this node will
  139.       *               also be rejected. Iterators treat this as a synonym
  140.       *               for FILTER_SKIP.</td>
  141.   * </tr>
  142.   * <tr><td>FILTER_SKIP</td>
  143.       *              <td>Reject the node. Navigation methods defined for
  144.       *                  NodeIterator or TreeWalker will not return this
  145.       *                  node. For both NodeIterator and Treewalker, the
  146.       *                  children of this node will still be considered.</td>
  147.     * </tr>
  148.   * </table>
  149.       *
  150.   */
  151.         enum FilterAction {FILTER_ACCEPT = 1,
  152.                            FILTER_REJECT = 2,
  153.                            FILTER_SKIP   = 3};
  154.         enum ShowType {
  155.             SHOW_ALL                       = 0x0000FFFF,
  156.             SHOW_ELEMENT                   = 0x00000001,
  157.             SHOW_ATTRIBUTE                 = 0x00000002,
  158.             SHOW_TEXT                      = 0x00000004,
  159.             SHOW_CDATA_SECTION             = 0x00000008,
  160.             SHOW_ENTITY_REFERENCE          = 0x00000010,
  161.             SHOW_ENTITY                    = 0x00000020,
  162.             SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
  163.             SHOW_COMMENT                   = 0x00000080,
  164.             SHOW_DOCUMENT                  = 0x00000100,
  165.             SHOW_DOCUMENT_TYPE             = 0x00000200,
  166.             SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
  167.             SHOW_NOTATION                  = 0x00000800
  168.         };
  169. //@}
  170.         /** @name Constructors */
  171.         //@{
  172.         /**
  173.           * Default constructor for DOM_NodeFilter.
  174.           */
  175.         DOM_NodeFilter();
  176.         //@}
  177.         /** @name Destructor. */
  178.         //@{
  179. /**
  180.   * Destructor for DOM_NodeFilter.
  181.   */
  182.         virtual ~DOM_NodeFilter();
  183.         //@}
  184.         /** @name Test function. */
  185.         //@{
  186. /**
  187.   * Test whether a specified node is visible in the logical view of a DOM_TreeWalker
  188.   * or DOM_NodeIterator. This function will be called by the implementation of
  189.   * DOM_TreeWalker and DOM_NodeIterator; it is not intended to be called directly from user
  190.   * code.
  191.           *
  192.           * <p><b>"Experimental - subject to change"</b></p>
  193.           *
  194.           * @param node The node to check to see if it passes the filter or not.
  195.           * @return A constant to determine whether the node is accepted, rejected, or skipped.
  196.   */
  197.         virtual short acceptNode (const DOM_Node &node) const =0;
  198.         //@}
  199.     private:
  200.         DOM_NodeFilter(const DOM_NodeFilter &other);
  201.         DOM_NodeFilter & operator = (const DOM_NodeFilter &other);
  202.         bool operator == (const DOM_NodeFilter &other) const;
  203.         bool operator != (const DOM_NodeFilter &other) const;
  204. };
  205. #endif