• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • dom
dom2_traversal.cpp
Go to the documentation of this file.
1 
23 #include "dom/dom_exception.h"
24 #include "dom/dom_string.h"
25 #include "xml/dom_nodeimpl.h"
26 #include "xml/dom2_traversalimpl.h"
27 
28 using namespace DOM;
29 
30 
31 NodeIterator::NodeIterator()
32 {
33  impl = 0;
34 }
35 
36 NodeIterator::NodeIterator(const NodeIterator &other)
37 {
38  impl = other.impl;
39  if (impl) impl->ref();
40 }
41 
42 NodeIterator::NodeIterator(NodeIteratorImpl *i)
43 {
44  impl = i;
45  if (impl) impl->ref();
46 }
47 
48 NodeIterator &NodeIterator::operator = (const NodeIterator &other)
49 {
50  if ( impl != other.impl ) {
51  if (impl) impl->deref();
52  impl = other.impl;
53  if (impl) impl->ref();
54  }
55  return *this;
56 }
57 
58 NodeIterator::~NodeIterator()
59 {
60  if (impl) impl->deref();
61 }
62 
63 Node NodeIterator::root()
64 {
65  if (impl) return impl->root();
66  return 0;
67 }
68 
69 unsigned long NodeIterator::whatToShow()
70 {
71  if (impl) return impl->whatToShow();
72  return 0;
73 }
74 
75 NodeFilter NodeIterator::filter()
76 {
77  if (impl) return impl->filter();
78  return 0;
79 }
80 
81 bool NodeIterator::expandEntityReferences()
82 {
83  if (impl) return impl->expandEntityReferences();
84  return 0;
85 }
86 
87 Node NodeIterator::nextNode( )
88 {
89  void* dummy;
90  if (!impl)
91  throw DOMException(DOMException::INVALID_STATE_ERR);
92 
93  int exceptioncode = 0;
94  SharedPtr<NodeImpl> r = impl->nextNode(exceptioncode, dummy);
95  if (exceptioncode)
96  throw DOMException(exceptioncode);
97  return r.get();
98 }
99 
100 Node NodeIterator::previousNode( )
101 {
102  void* dummy; // ### rely on C++ exception propagation --- might not be safe
103  // we could probably proxy the DOM exceptions at the very least
104  if (!impl)
105  throw DOMException(DOMException::INVALID_STATE_ERR);
106 
107  int exceptioncode = 0;
108  SharedPtr<NodeImpl> r = impl->previousNode(exceptioncode, dummy);
109  if (exceptioncode)
110  throw DOMException(exceptioncode);
111  return r.get();
112 }
113 
114 void NodeIterator::detach()
115 {
116  if (!impl)
117  throw DOMException(DOMException::INVALID_STATE_ERR);
118 
119  int exceptioncode = 0;
120  impl->detach(exceptioncode);
121  if (exceptioncode)
122  throw DOMException(exceptioncode);
123 }
124 
125 NodeIteratorImpl *NodeIterator::handle() const
126 {
127  return impl;
128 }
129 
130 bool NodeIterator::isNull() const
131 {
132  return (impl == 0);
133 }
134 
135 // -----------------------------------------------------------
136 
137 NodeFilter::NodeFilter()
138 {
139  impl = 0;
140 }
141 
142 NodeFilter::NodeFilter(const NodeFilter &other)
143 {
144  impl = other.impl;
145  if (impl) impl->ref();
146 }
147 
148 NodeFilter::NodeFilter(NodeFilterImpl *i)
149 {
150  impl = i;
151  if (impl) impl->ref();
152 }
153 
154 NodeFilter &NodeFilter::operator = (const NodeFilter &other)
155 {
156  if ( impl != other.impl ) {
157  if (impl) impl->deref();
158  impl = other.impl;
159  if (impl) impl->ref();
160  }
161  return *this;
162 }
163 
164 NodeFilter::~NodeFilter()
165 {
166  if (impl) impl->deref();
167 }
168 
169 short NodeFilter::acceptNode(const Node &n)
170 {
171  void* dummy;
172  if (impl) return impl->acceptNode(n, dummy);
173  return 0;
174 }
175 
176 void NodeFilter::setCustomNodeFilter(CustomNodeFilter *custom)
177 {
178  if (impl) impl->setCustomNodeFilter(custom);
179 }
180 
181 CustomNodeFilter *NodeFilter::customNodeFilter()
182 {
183  if (impl) return impl->customNodeFilter();
184  return 0;
185 }
186 
187 NodeFilterImpl *NodeFilter::handle() const
188 {
189  return impl;
190 }
191 
192 bool NodeFilter::isNull() const
193 {
194  return (impl == 0);
195 }
196 
197 NodeFilter NodeFilter::createCustom(CustomNodeFilter *custom)
198 {
199  NodeFilterImpl *i = new NodeFilterImpl();
200  i->setCustomNodeFilter(custom);
201  return i;
202 }
203 
204 // --------------------------------------------------------------
205 CustomNodeFilter::CustomNodeFilter()
206 {
207  impl = 0;
208 }
209 
210 CustomNodeFilter::~CustomNodeFilter()
211 {
212 }
213 
214 short CustomNodeFilter::acceptNode (const Node &/*n*/)
215 {
216  return NodeFilter::FILTER_ACCEPT;
217 }
218 
219 bool CustomNodeFilter::isNull()
220 {
221  return false;
222 }
223 
224 DOMString CustomNodeFilter::customNodeFilterType()
225 {
226  return "";
227 }
228 
229 // --------------------------------------------------------------
230 
231 TreeWalker::TreeWalker()
232 {
233  impl = 0;
234 }
235 
236 TreeWalker::TreeWalker(const TreeWalker &other)
237 {
238  impl = other.impl;
239  if (impl) impl->ref();
240 }
241 
242 TreeWalker::TreeWalker(TreeWalkerImpl *i)
243 {
244  impl = i;
245  if (impl) impl->ref();
246 }
247 
248 TreeWalker & TreeWalker::operator = (const TreeWalker &other)
249 {
250  if ( impl != other.impl ) {
251  if (impl) impl->deref();
252  impl = other.impl;
253  if (impl) impl->ref();
254  }
255 
256  return *this;
257 }
258 
259 TreeWalker::~TreeWalker()
260 {
261  if (impl) impl->deref();
262 }
263 
264 Node TreeWalker::root()
265 {
266  if (impl) return impl->getRoot();
267  return 0;
268 }
269 
270 unsigned long TreeWalker::whatToShow()
271 {
272  if (impl) return impl->getWhatToShow();
273  return 0;
274 }
275 
276 NodeFilter TreeWalker::filter()
277 {
278  if (impl) return impl->getFilter();
279  return 0;
280 }
281 
282 bool TreeWalker::expandEntityReferences()
283 {
284  if (impl) return impl->getExpandEntityReferences();
285  return false;
286 }
287 
288 Node TreeWalker::currentNode()
289 {
290  if (impl) return impl->getCurrentNode();
291  return 0;
292 }
293 
294 void TreeWalker::setCurrentNode(const Node& _currentNode)
295 {
296  int exceptionCode = 0;
297  if (impl) impl->setCurrentNode(_currentNode.handle(), exceptionCode);
298  if (exceptionCode)
299  throw DOMException(exceptionCode);
300 }
301 
302 Node TreeWalker::parentNode()
303 {
304  void *dummy;
305  if (impl) return impl->parentNode(dummy);
306  return 0;
307 }
308 
309 Node TreeWalker::firstChild()
310 {
311  void *dummy;
312  if (impl) return impl->firstChild(dummy);
313  return 0;
314 }
315 
316 Node TreeWalker::lastChild()
317 {
318  void *dummy;
319  if (impl) return impl->lastChild(dummy);
320  return 0;
321 }
322 
323 Node TreeWalker::previousSibling()
324 {
325  void *dummy;
326  if (impl) return impl->previousSibling(dummy);
327  return 0;
328 }
329 
330 Node TreeWalker::nextSibling()
331 {
332  void *dummy;
333  if (impl) return impl->nextSibling(dummy);
334  return 0;
335 }
336 
337 Node TreeWalker::previousNode()
338 {
339  void *dummy;
340  if (impl) return impl->previousNode(dummy);
341  return 0;
342 }
343 
344 Node TreeWalker::nextNode()
345 {
346  void *dummy;
347  if (impl) return impl->nextNode(dummy);
348  return 0;
349 }
350 
351 TreeWalkerImpl *TreeWalker::handle() const
352 {
353  return impl;
354 }
355 
356 bool TreeWalker::isNull() const
357 {
358  return (impl == 0);
359 }
360 
dom_string.h
DOM::CustomNodeFilter
CustomNodeFilter can be used to define your own NodeFilter for use with NodeIterators and TreeWalkers...
Definition: dom2_traversal.h:294
DOM::NodeFilter::NodeFilterImpl
friend class NodeFilterImpl
Definition: dom2_traversal.h:189
DOM::NodeFilter::customNodeFilter
CustomNodeFilter * customNodeFilter()
Definition: dom2_traversal.cpp:181
DOM::CustomNodeFilter::isNull
virtual bool isNull()
Definition: dom2_traversal.cpp:219
DOM::NodeIterator::handle
NodeIteratorImpl * handle() const
Definition: dom2_traversal.cpp:125
DOM::TreeWalker::root
Node root()
The root node of the TreeWalker, as specified when it was created.
Definition: dom2_traversal.cpp:264
DOM::NodeFilter::~NodeFilter
virtual ~NodeFilter()
Definition: dom2_traversal.cpp:164
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:270
DOM::TreeWalker::filter
NodeFilter filter()
The filter used to screen nodes.
Definition: dom2_traversal.cpp:276
DOM::TreeWalker::previousSibling
Node previousSibling()
Moves the TreeWalker to the previous sibling of the current node, and returns the new node...
Definition: dom2_traversal.cpp:323
DOM::NodeFilter::operator=
virtual NodeFilter & operator=(const NodeFilter &other)
Definition: dom2_traversal.cpp:154
DOM::TreeWalker::nextSibling
Node nextSibling()
Moves the TreeWalker to the next sibling of the current node, and returns the new node...
Definition: dom2_traversal.cpp:330
DOM::TreeWalker::impl
TreeWalkerImpl * impl
Definition: dom2_traversal.h:527
DOM::TreeWalker::whatToShow
unsigned long whatToShow()
This attribute determines which node types are presented via the TreeWalker.
Definition: dom2_traversal.cpp:270
DOM::CustomNodeFilter::customNodeFilterType
virtual DOMString customNodeFilterType()
Definition: dom2_traversal.cpp:224
DOM::TreeWalker::previousNode
Node previousNode()
Moves the TreeWalker to the previous node in document order relative to the current node...
Definition: dom2_traversal.cpp:337
DOM::NodeFilter::isNull
virtual bool isNull() const
Definition: dom2_traversal.cpp:192
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:58
DOM::NodeIterator::NodeIterator
NodeIterator()
Definition: dom2_traversal.cpp:31
DOM::NodeFilter::setCustomNodeFilter
void setCustomNodeFilter(CustomNodeFilter *custom)
Definition: dom2_traversal.cpp:176
DOM::NodeIterator::whatToShow
unsigned long whatToShow()
This attribute determines which node types are presented via the iterator.
Definition: dom2_traversal.cpp:69
DOM::NodeIterator::nextNode
Node nextNode()
Returns the next node in the set and advances the position of the Iterator in the set...
Definition: dom2_traversal.cpp:87
DOM::CustomNodeFilter::CustomNodeFilter
CustomNodeFilter()
Definition: dom2_traversal.cpp:205
DOM::TreeWalker
TreeWalker objects are used to navigate a document tree or subtree using the view of the document def...
Definition: dom2_traversal.h:338
DOM::NodeFilter::acceptNode
virtual short acceptNode(const Node &n)
Test whether a specified node is visible in the logical view of a TreeWalker or NodeIterator.
Definition: dom2_traversal.cpp:169
DOM::NodeIterator::filter
NodeFilter filter()
The NodeFilter used to screen nodes.
Definition: dom2_traversal.cpp:75
DOM::TreeWalker::currentNode
Node currentNode()
The node at which the TreeWalker is currently positioned.
Definition: dom2_traversal.cpp:288
DOM::NodeFilter::FILTER_ACCEPT
Definition: dom2_traversal.h:204
DOM::NodeIterator::isNull
bool isNull() const
Definition: dom2_traversal.cpp:130
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
DOM::TreeWalker::firstChild
Node firstChild()
Moves the TreeWalker to the first child of the current node, and returns the new node.
Definition: dom2_traversal.cpp:309
dom_exception.h
DOM::NodeFilter::createCustom
static NodeFilter createCustom(CustomNodeFilter *custom)
Definition: dom2_traversal.cpp:197
DOM::NodeIterator::root
Node root()
The root node of the NodeIterator, as specified when it was created.
Definition: dom2_traversal.cpp:63
DOM::NodeIterator::previousNode
Node previousNode()
Returns the previous node in the set and moves the position of the Iterator backwards in the set...
Definition: dom2_traversal.cpp:100
DOM::NodeFilter::NodeFilter
NodeFilter()
Definition: dom2_traversal.cpp:137
DOM::NodeFilter
Filters are objects that know how to "filter out" nodes.
Definition: dom2_traversal.h:183
DOM::TreeWalker::isNull
bool isNull() const
Definition: dom2_traversal.cpp:356
DOM::TreeWalker::handle
TreeWalkerImpl * handle() const
Definition: dom2_traversal.cpp:351
DOM::NodeFilter::impl
NodeFilterImpl * impl
Definition: dom2_traversal.h:260
DOM::CustomNodeFilter::impl
CustomNodeFilterImpl * impl
Definition: dom2_traversal.h:316
DOM::TreeWalker::setCurrentNode
void setCurrentNode(const Node &_currentNode)
see currentNode
Definition: dom2_traversal.cpp:294
DOM::TreeWalker::operator=
TreeWalker & operator=(const TreeWalker &other)
Definition: dom2_traversal.cpp:248
DOM::TreeWalker::expandEntityReferences
bool expandEntityReferences()
The value of this flag determines whether the children of entity reference nodes are visible to the T...
Definition: dom2_traversal.cpp:282
DOM::NodeIterator::~NodeIterator
~NodeIterator()
Definition: dom2_traversal.cpp:58
DOM::NodeIterator::impl
NodeIteratorImpl * impl
Definition: dom2_traversal.h:155
DOM::NodeFilter::handle
virtual NodeFilterImpl * handle() const
Definition: dom2_traversal.cpp:187
DOM::TreeWalker::TreeWalker
TreeWalker()
Definition: dom2_traversal.cpp:231
DOM::NodeIterator
NodeIterators are used to step through a set of nodes, e.g.
Definition: dom2_traversal.h:59
DOM::NodeIterator::operator=
NodeIterator & operator=(const NodeIterator &other)
Definition: dom2_traversal.cpp:48
DOM::TreeWalker::lastChild
Node lastChild()
Moves the TreeWalker to the last child of the current node, and returns the new node.
Definition: dom2_traversal.cpp:316
DOM::NodeIterator::detach
void detach()
Detaches the NodeIterator from the set which it iterated over, releasing any computational resources ...
Definition: dom2_traversal.cpp:114
DOM::NodeIterator::expandEntityReferences
bool expandEntityReferences()
The value of this flag determines whether the children of entity reference nodes are visible to the i...
Definition: dom2_traversal.cpp:81
DOM::DOMException::INVALID_STATE_ERR
Definition: dom_exception.h:83
DOM::TreeWalker::~TreeWalker
~TreeWalker()
Definition: dom2_traversal.cpp:259
DOM::Node::handle
NodeImpl * handle() const
Definition: dom_node.h:925
DOM::TreeWalker::nextNode
Node nextNode()
Moves the TreeWalker to the next node in document order relative to the current node, and returns the new node.
Definition: dom2_traversal.cpp:344
DOM::TreeWalker::parentNode
Node parentNode()
Moves to and returns the parent node of the current node.
Definition: dom2_traversal.cpp:302
DOM::CustomNodeFilter::~CustomNodeFilter
virtual ~CustomNodeFilter()
Definition: dom2_traversal.cpp:210
DOM::CustomNodeFilter::acceptNode
virtual short acceptNode(const Node &n)
Definition: dom2_traversal.cpp:214
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal