khtml Library API Documentation

dom2_traversal.h

00001 /*
00002  * This file is part of the DOM implementation for KDE.
00003  *
00004  * (C) 1999 Lars Knoll (knoll@kde.org)
00005  * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  *
00021  * This file includes excerpts from the Document Object Model (DOM)
00022  * Level 2 Specification (Candidate Recommendation)
00023  * http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/
00024  * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
00025  *
00026  */
00027 #ifndef _dom2_traversal_h_
00028 #define _dom2_traversal_h_
00029 #include <dom/dom_node.h>
00030 #include <dom/dom_misc.h>
00031 
00032 
00033 namespace DOM {
00034 class Node;
00035 class NodeFilter;
00036 class NodeImpl;
00037 class NodeIteratorImpl;
00038 class NodeFilterImpl;
00039 class TreeWalkerImpl;
00040 class CustomNodeFilter;
00041 class CustomNodeFilterImpl;
00042 
00059 class NodeIterator
00060 {
00061     friend class NodeIteratorImpl;
00062     friend class Document;
00063 public:
00064     NodeIterator();
00065     NodeIterator(const NodeIterator &other);
00066 
00067     NodeIterator & operator = (const NodeIterator &other);
00068 
00069     ~NodeIterator();
00070 
00074     Node root();
00075 
00083     unsigned long whatToShow();
00084 
00088     NodeFilter filter();
00089 
00106     bool expandEntityReferences();
00107 
00122     Node nextNode();
00123 
00137     Node previousNode();
00138 
00145     void detach();
00146 
00151     NodeIteratorImpl *handle() const;
00152     bool isNull() const;
00153 
00154 protected:
00155     NodeIteratorImpl *impl;
00156     NodeIterator(NodeIteratorImpl *i);
00157 };
00158 
00159 
00183 class NodeFilter
00184 {
00185     friend class NodeIterator;
00186     friend class NodeIteratorImpl;
00187     friend class TreeWalker;
00188     friend class TreeWalkerImpl;
00189     friend class NodeFilterImpl;
00190 public:
00191     NodeFilter();
00192     NodeFilter(const NodeFilter &other);
00193     NodeFilter(NodeFilterImpl *i);
00194 
00195     virtual NodeFilter & operator = (const NodeFilter &other);
00196 
00197     virtual ~NodeFilter();
00203     enum AcceptCode {
00204         FILTER_ACCEPT = 1,
00205         FILTER_REJECT = 2,
00206         FILTER_SKIP   = 3
00207     };
00208 
00216     enum ShowCode {
00217         SHOW_ALL                       = 0xFFFFFFFF,
00218         SHOW_ELEMENT                   = 0x00000001,
00219         SHOW_ATTRIBUTE                 = 0x00000002,
00220         SHOW_TEXT                      = 0x00000004,
00221         SHOW_CDATA_SECTION             = 0x00000008,
00222         SHOW_ENTITY_REFERENCE          = 0x00000010,
00223         SHOW_ENTITY                    = 0x00000020,
00224         SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
00225         SHOW_COMMENT                   = 0x00000080,
00226         SHOW_DOCUMENT                  = 0x00000100,
00227         SHOW_DOCUMENT_TYPE             = 0x00000200,
00228         SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
00229         SHOW_NOTATION                  = 0x00000800
00230     };
00231 
00246     virtual short acceptNode (const Node &n);
00247 
00252     virtual NodeFilterImpl *handle() const;
00253     virtual bool isNull() const;
00254 
00255     void setCustomNodeFilter(CustomNodeFilter *custom);
00256     CustomNodeFilter *customNodeFilter();
00257     static NodeFilter createCustom(CustomNodeFilter *custom);
00258 
00259 protected:
00260     NodeFilterImpl *impl;
00261 };
00262 
00294 class CustomNodeFilter : public DomShared {
00295 public:
00296     CustomNodeFilter();
00297     virtual ~CustomNodeFilter();
00298     virtual short acceptNode (const Node &n);
00299     virtual bool isNull();
00300 
00309     virtual DOMString customNodeFilterType();
00310 
00311 protected:
00316     CustomNodeFilterImpl *impl;
00317 };
00318 
00338 class TreeWalker
00339 {
00340     friend class Document;
00341     friend class TreeWalkerImpl;
00342 public:
00343     TreeWalker();
00344     TreeWalker(const TreeWalker &other);
00345 
00346     TreeWalker & operator = (const TreeWalker &other);
00347 
00348     ~TreeWalker();
00349 
00350 
00354     Node root();
00355 
00363     unsigned long whatToShow();
00364 
00368     NodeFilter filter();
00369 
00384     bool expandEntityReferences();
00385 
00399     Node currentNode();
00400 
00404     void setCurrentNode(const Node &_currentNode);
00405 
00420     Node parentNode();
00421 
00436     Node firstChild();
00437 
00452     Node lastChild();
00453 
00468     Node previousSibling();
00469 
00484     Node nextSibling();
00485 
00500     Node previousNode();
00501 
00516     Node nextNode();
00517 
00522     TreeWalkerImpl *handle() const;
00523     bool isNull() const;
00524 
00525 protected:
00526     TreeWalker(TreeWalkerImpl *i);
00527     TreeWalkerImpl *impl;
00528 };
00529 
00530 
00531 // ### not sure if this this class is really needed - both methods are in
00532 // Document
00533 
00614 } // namespace
00615 
00616 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:45:39 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003