KHtml

dom2_traversal.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  * Copyright 2000 Frederik Holljen ([email protected])
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * This file includes excerpts from the Document Object Model (DOM)
22  * Level 2 Specification (Candidate Recommendation)
23  * https://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/
24  * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
25  *
26  */
27 #ifndef _dom2_traversal_h_
28 #define _dom2_traversal_h_
29 
30 #include <khtml_export.h>
31 #include <dom/dom_node.h>
32 #include <dom/dom_misc.h>
33 
34 namespace DOM
35 {
36 class Node;
37 class NodeFilter;
38 class NodeIteratorImpl;
39 class NodeFilterImpl;
40 class TreeWalkerImpl;
41 class CustomNodeFilter;
42 class CustomNodeFilterImpl;
43 
60 class KHTML_EXPORT NodeIterator
61 {
62  friend class NodeIteratorImpl;
63  friend class Document;
64 public:
65  NodeIterator();
66  NodeIterator(const NodeIterator &other);
67 
68  NodeIterator &operator = (const NodeIterator &other);
69 
70  ~NodeIterator();
71 
75  Node root();
76 
84  unsigned long whatToShow();
85 
89  NodeFilter filter();
90 
107  bool expandEntityReferences();
108 
123  Node nextNode();
124 
138  Node previousNode();
139 
146  void detach();
147 
152  NodeIteratorImpl *handle() const;
153  bool isNull() const;
154 
155 protected:
156  NodeIteratorImpl *impl;
157  NodeIterator(NodeIteratorImpl *i);
158 };
159 
183 class KHTML_EXPORT NodeFilter
184 {
185  friend class NodeIterator;
186  friend class NodeIteratorImpl;
187  friend class TreeWalker;
188  friend class TreeWalkerImpl;
189  friend class NodeFilterImpl;
190 public:
191  NodeFilter();
192  NodeFilter(const NodeFilter &other);
193  NodeFilter(NodeFilterImpl *i);
194 
195  virtual NodeFilter &operator = (const NodeFilter &other);
196 
197  virtual ~NodeFilter();
203  enum AcceptCode {
204  FILTER_ACCEPT = 1,
205  FILTER_REJECT = 2,
206  FILTER_SKIP = 3
207  };
208 
216  enum ShowCode {
217  SHOW_ALL = 0xFFFFFFFF,
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 
246  virtual short acceptNode(const Node &n);
247 
252  virtual NodeFilterImpl *handle() const;
253  virtual bool isNull() const;
254 
255  void setCustomNodeFilter(CustomNodeFilter *custom);
256  CustomNodeFilter *customNodeFilter();
257  static NodeFilter createCustom(CustomNodeFilter *custom);
258 
259 protected:
260  NodeFilterImpl *impl;
261 };
262 
294 class KHTML_EXPORT CustomNodeFilter : public DomShared
295 {
296 public:
298  virtual ~CustomNodeFilter();
299  virtual short acceptNode(const Node &n);
300  virtual bool isNull();
301 
310  virtual DOMString customNodeFilterType();
311 
312 protected:
317  CustomNodeFilterImpl *impl;
318 };
319 
339 class KHTML_EXPORT TreeWalker
340 {
341  friend class Document;
342  friend class TreeWalkerImpl;
343 public:
344  TreeWalker();
345  TreeWalker(const TreeWalker &other);
346 
347  TreeWalker &operator = (const TreeWalker &other);
348 
349  ~TreeWalker();
350 
354  Node root();
355 
363  unsigned long whatToShow();
364 
368  NodeFilter filter();
369 
384  bool expandEntityReferences();
385 
399  Node currentNode();
400 
404  void setCurrentNode(const Node &_currentNode);
405 
420  Node parentNode();
421 
436  Node firstChild();
437 
452  Node lastChild();
453 
468  Node previousSibling();
469 
484  Node nextSibling();
485 
500  Node previousNode();
501 
516  Node nextNode();
517 
522  TreeWalkerImpl *handle() const;
523  bool isNull() const;
524 
525 protected:
526  TreeWalker(TreeWalkerImpl *i);
527  TreeWalkerImpl *impl;
528 };
529 
530 } // namespace
531 
532 #endif
CustomNodeFilter can be used to define your own NodeFilter for use with NodeIterators and TreeWalkers...
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:278
AcceptCode
The following constants are returned by the acceptNode() method:
ShowCode
These are the available values for the whatToShow parameter.
TreeWalker objects are used to navigate a document tree or subtree using the view of the document def...
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:246
Filters are objects that know how to "filter out" nodes.
CustomNodeFilterImpl * impl
This library provides a full-featured HTML parser and widget.
NodeIterators are used to step through a set of nodes, e.g.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 10 2020 22:49:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.