KHTML
dom2_traversal.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _dom2_traversal_h_
00028 #define _dom2_traversal_h_
00029
00030 #include <khtml_export.h>
00031 #include <dom/dom_node.h>
00032 #include <dom/dom_misc.h>
00033
00034 namespace DOM {
00035 class Node;
00036 class NodeFilter;
00037 class NodeIteratorImpl;
00038 class NodeFilterImpl;
00039 class TreeWalkerImpl;
00040 class CustomNodeFilter;
00041 class CustomNodeFilterImpl;
00042
00059 class KHTML_EXPORT 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 KHTML_EXPORT 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 KHTML_EXPORT 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 KHTML_EXPORT 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 }
00532
00533 #endif