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  * $Id: dom2_traversal.h,v 1.15.6.1 2003/05/18 12:34:37 mueller Exp $
00027  */
00028 #ifndef _dom2_traversal_h_
00029 #define _dom2_traversal_h_
00030 #include <dom/dom_node.h>
00031 #include <dom/dom_misc.h>
00032 
00033 
00034 namespace DOM {
00035 class Node;
00036 class NodeFilter;
00037 class NodeImpl;
00038 class NodeIteratorImpl;
00039 class NodeFilterImpl;
00040 class TreeWalkerImpl;
00041 class CustomNodeFilter;
00042 class CustomNodeFilterImpl;
00043 
00060 class NodeIterator
00061 {
00062     friend class NodeIteratorImpl;
00063     friend class Document;
00064 public:
00065     NodeIterator();
00066     NodeIterator(const NodeIterator &other);
00067 
00068     NodeIterator & operator = (const NodeIterator &other);
00069 
00070     ~NodeIterator();
00071 
00075     Node root();
00076 
00084     unsigned long whatToShow();
00085 
00089     NodeFilter filter();
00090 
00107     bool expandEntityReferences();
00108 
00123     Node nextNode();
00124 
00138     Node previousNode();
00139 
00146     void detach();
00147 
00152     NodeIteratorImpl *handle() const;
00153     bool isNull() const;
00154 
00155 protected:
00156     NodeIteratorImpl *impl;
00157     NodeIterator(NodeIteratorImpl *i);
00158 };
00159 
00160 
00184 class NodeFilter
00185 {
00186     friend class NodeIterator;
00187     friend class NodeIteratorImpl;
00188     friend class TreeWalker;
00189     friend class TreeWalkerImpl;
00190     friend class NodeFilterImpl;
00191 public:
00192     NodeFilter();
00193     NodeFilter(const NodeFilter &other);
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     NodeFilter(NodeFilterImpl *i);
00261     NodeFilterImpl *impl;
00262 };
00263 
00295 class CustomNodeFilter : public DomShared {
00296 public:
00297     CustomNodeFilter();
00298     virtual ~CustomNodeFilter();
00299     virtual short acceptNode (const Node &n);
00300     virtual bool isNull();
00301 
00310     virtual DOMString customNodeFilterType();
00311 
00312 protected:
00317     CustomNodeFilterImpl *impl;
00318 };
00319 
00339 class TreeWalker
00340 {
00341     friend class Document;
00342     friend class TreeWalkerImpl;
00343 public:
00344     TreeWalker();
00345     TreeWalker(const TreeWalker &other);
00346 
00347     TreeWalker & operator = (const TreeWalker &other);
00348 
00349     ~TreeWalker();
00350 
00351 
00355     Node root();
00356 
00364     unsigned long whatToShow();
00365 
00369     NodeFilter filter();
00370 
00385     bool expandEntityReferences();
00386 
00400     Node currentNode();
00401 
00405     void setCurrentNode(const Node _currentNode);
00406 
00421     Node parentNode();
00422 
00437     Node firstChild();
00438 
00453     Node lastChild();
00454 
00469     Node previousSibling();
00470 
00485     Node nextSibling();
00486 
00501     Node previousNode();
00502 
00517     Node nextNode();
00518 
00523     TreeWalkerImpl *handle() const;
00524     bool isNull() const;
00525 
00526 protected:
00527     TreeWalker(TreeWalkerImpl *i);
00528     TreeWalkerImpl *impl;
00529 };
00530 
00531 
00532 // ### not sure if this this class is really needed - both methods are in
00533 // Document
00534 
00615 } // namespace
00616 
00617 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:33:38 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001