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
#include <dom/dom_node.h>
00030
#include <dom/dom_misc.h>
00031
00032
#include <kdelibs_export.h>
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 KHTML_EXPORT 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 KHTML_EXPORT 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 NodeFilter(NodeFilterImpl *i);
00195
00196
virtual NodeFilter & operator = (
const NodeFilter &other);
00197
00198
virtual ~NodeFilter();
00204 enum AcceptCode {
00205 FILTER_ACCEPT = 1,
00206 FILTER_REJECT = 2,
00207 FILTER_SKIP = 3
00208 };
00209
00217 enum ShowCode {
00218 SHOW_ALL = 0xFFFFFFFF,
00219 SHOW_ELEMENT = 0x00000001,
00220 SHOW_ATTRIBUTE = 0x00000002,
00221 SHOW_TEXT = 0x00000004,
00222 SHOW_CDATA_SECTION = 0x00000008,
00223 SHOW_ENTITY_REFERENCE = 0x00000010,
00224 SHOW_ENTITY = 0x00000020,
00225 SHOW_PROCESSING_INSTRUCTION = 0x00000040,
00226 SHOW_COMMENT = 0x00000080,
00227 SHOW_DOCUMENT = 0x00000100,
00228 SHOW_DOCUMENT_TYPE = 0x00000200,
00229 SHOW_DOCUMENT_FRAGMENT = 0x00000400,
00230 SHOW_NOTATION = 0x00000800
00231 };
00232
00247
virtual short acceptNode (
const Node &n);
00248
00253
virtual NodeFilterImpl *handle() const;
00254 virtual
bool isNull() const;
00255
00256
void setCustomNodeFilter(
CustomNodeFilter *custom);
00257
CustomNodeFilter *customNodeFilter();
00258 static NodeFilter createCustom(
CustomNodeFilter *custom);
00259
00260 protected:
00261 NodeFilterImpl *impl;
00262 };
00263
00295 class KHTML_EXPORT
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 KHTML_EXPORT 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
00533
00534
00615 }
00616
00617
#endif