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

KHTML

  • 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 
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon May 5 2014 18:19:18 by doxygen 1.8.3.1 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-4.11.5 API Reference

Skip menu "kdelibs-4.11.5 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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