source: trunk/src/xmlpatterns/acceltree/qacceltree.cpp@ 447

Last change on this file since 447 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 24.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <QStack>
43
44#include "qabstractxmlreceiver.h"
45#include "qacceliterators_p.h"
46#include "qacceltree_p.h"
47#include "qatomicstring_p.h"
48#include "qcommonvalues_p.h"
49#include "qcompressedwhitespace_p.h"
50#include "qdebug_p.h"
51#include "quntypedatomic_p.h"
52#include "qxpathhelper_p.h"
53
54QT_BEGIN_NAMESPACE
55
56using namespace QPatternist;
57
58void AccelTree::printStats(const NamePool::Ptr &np) const
59{
60 Q_ASSERT(np);
61#ifdef QT_NO_DEBUG
62 Q_UNUSED(np); /* Needed when compiling in release mode. */
63#else
64 const int len = basicData.count();
65
66 pDebug() << "AccelTree stats for" << (m_documentURI.isEmpty() ? QString::fromLatin1("<empty URI>") : m_documentURI.toString());
67 pDebug() << "Maximum pre number:" << maximumPreNumber();
68 pDebug() << "+---------------+-------+-------+---------------+-------+--------------+-------+";
69 pDebug() << "| Pre number | Depth | Size | Post Number | Kind | Name | Value |";
70 pDebug() << "+---------------+-------+-------+---------------+-------+--------------+-------+";
71 for(int i = 0; i < len; ++i)
72 {
73 const BasicNodeData &v = basicData.at(i);
74 pDebug() << "|" << i
75 << "\t\t|" << v.depth()
76 << "\t|" << v.size()
77 << "\t|" << postNumber(i)
78 << "\t|" << v.kind()
79 << "\t\t|" << (v.name().isNull() ? QString::fromLatin1("(none)") : np->displayName(v.name()))
80 << "\t\t|" << ((v.kind() == QXmlNodeModelIndex::Text && isCompressed(i)) ? CompressedWhitespace::decompress(data.value(i))
81 : data.value(i))
82 << "\t|";
83 /*
84 pDebug() << "|" << QString().arg(i, 14)
85 << "|" << QString().arg(v.depth(), 6)
86 << "|" << QString().arg(v.size(), 6)
87 << "|" << QString().arg(postNumber(i), 14)
88 << "|" << QString().arg(v.kind(), 6)
89 << "|";
90 */
91 }
92 pDebug() << "+---------------+-------+-------+---------------+-------+--------------+";
93 pDebug() << "Namespaces(" << namespaces.count() << "):";
94
95 QHashIterator<PreNumber, QVector<QXmlName> > it(namespaces);
96 while(it.hasNext())
97 {
98 it.next();
99
100 pDebug() << "PreNumber: " << QString::number(it.key());
101 for(int i = 0; i < it.value().count(); ++i)
102 pDebug() << "\t\t" << np->stringForPrefix(it.value().at(i).prefix()) << " = " << np->stringForNamespace(it.value().at(i).namespaceURI());
103 }
104
105#endif
106}
107
108QUrl AccelTree::baseUri(const QXmlNodeModelIndex &ni) const
109{
110 switch(kind(toPreNumber(ni)))
111 {
112 case QXmlNodeModelIndex::Document:
113 return baseUri();
114 case QXmlNodeModelIndex::Element:
115 {
116 const QXmlNodeModelIndex::Iterator::Ptr it(iterate(ni, QXmlNodeModelIndex::AxisAttribute));
117 QXmlNodeModelIndex next(it->next());
118
119 while(!next.isNull())
120 {
121 if(next.name() == QXmlName(StandardNamespaces::xml, StandardLocalNames::base))
122 {
123 const QUrl candidate(next.stringValue());
124 // TODO. The xml:base spec says to do URI escaping here.
125
126 if(!candidate.isValid())
127 return QUrl();
128 else if(candidate.isRelative())
129 {
130 const QXmlNodeModelIndex par(parent(ni));
131
132 if(par.isNull())
133 return baseUri().resolved(candidate);
134 else
135 return par.baseUri().resolved(candidate);
136 }
137 else
138 return candidate;
139 }
140
141 next = it->next();
142 }
143
144 /* We have no xml:base-attribute. Can any parent supply us a base URI? */
145 const QXmlNodeModelIndex par(parent(ni));
146
147 if(par.isNull())
148 return baseUri();
149 else
150 return par.baseUri();
151 }
152 case QXmlNodeModelIndex::ProcessingInstruction:
153 /* Fallthrough. */
154 case QXmlNodeModelIndex::Comment:
155 /* Fallthrough. */
156 case QXmlNodeModelIndex::Attribute:
157 /* Fallthrough. */
158 case QXmlNodeModelIndex::Text:
159 {
160 const QXmlNodeModelIndex par(ni.iterate(QXmlNodeModelIndex::AxisParent)->next());
161 if(par.isNull())
162 return QUrl();
163 else
164 return par.baseUri();
165 }
166 case QXmlNodeModelIndex::Namespace:
167 return QUrl();
168 }
169
170 Q_ASSERT_X(false, Q_FUNC_INFO, "This line is never supposed to be reached.");
171 return QUrl();
172}
173
174QUrl AccelTree::documentUri(const QXmlNodeModelIndex &ni) const
175{
176 if(kind(toPreNumber(ni)) == QXmlNodeModelIndex::Document)
177 return documentUri();
178 else
179 return QUrl();
180}
181
182QXmlNodeModelIndex::NodeKind AccelTree::kind(const QXmlNodeModelIndex &ni) const
183{
184 return kind(toPreNumber(ni));
185}
186
187QXmlNodeModelIndex::DocumentOrder AccelTree::compareOrder(const QXmlNodeModelIndex &ni1,
188 const QXmlNodeModelIndex &ni2) const
189{
190 Q_ASSERT_X(ni1.model() == ni2.model(), Q_FUNC_INFO,
191 "The API docs guarantees the two nodes are from the same model");
192
193 const PreNumber p1 = ni1.data();
194 const PreNumber p2 = ni2.data();
195
196 if(p1 == p2)
197 return QXmlNodeModelIndex::Is;
198 else if(p1 < p2)
199 return QXmlNodeModelIndex::Precedes;
200 else
201 return QXmlNodeModelIndex::Follows;
202}
203
204QXmlNodeModelIndex AccelTree::root(const QXmlNodeModelIndex &) const
205{
206 return createIndex(qint64(0));
207}
208
209QXmlNodeModelIndex AccelTree::parent(const QXmlNodeModelIndex &ni) const
210{
211 const AccelTree::PreNumber p = basicData.at(toPreNumber(ni)).parent();
212
213 if(p == -1)
214 return QXmlNodeModelIndex();
215 else
216 return createIndex(p);
217}
218
219QXmlNodeModelIndex::Iterator::Ptr AccelTree::iterate(const QXmlNodeModelIndex &ni,
220 QXmlNodeModelIndex::Axis axis) const
221{
222 const PreNumber preNumber = toPreNumber(ni);
223
224 switch(axis)
225 {
226 case QXmlNodeModelIndex::AxisChildOrTop:
227 {
228 if(!hasParent(preNumber))
229 {
230 switch(kind(preNumber))
231 {
232 case QXmlNodeModelIndex::Comment:
233 /* Fallthrough. */
234 case QXmlNodeModelIndex::ProcessingInstruction:
235 /* Fallthrough. */
236 case QXmlNodeModelIndex::Element:
237 /* Fallthrough. */
238 case QXmlNodeModelIndex::Text:
239 return makeSingletonIterator(ni);
240 case QXmlNodeModelIndex::Attribute:
241 /* Fallthrough. */
242 case QXmlNodeModelIndex::Document:
243 /* Fallthrough. */
244 case QXmlNodeModelIndex::Namespace:
245 /* Do nothing. */;
246 }
247 }
248 /* Else, fallthrough to AxisChild. */
249 }
250 case QXmlNodeModelIndex::AxisChild:
251 {
252 if(hasChildren(preNumber))
253 return QXmlNodeModelIndex::Iterator::Ptr(new ChildIterator(this, preNumber));
254 else
255 return makeEmptyIterator<QXmlNodeModelIndex>();
256 }
257 case QXmlNodeModelIndex::AxisAncestor:
258 {
259 if(hasParent(preNumber))
260 return QXmlNodeModelIndex::Iterator::Ptr(new AncestorIterator<false>(this, preNumber));
261 else
262 return makeEmptyIterator<QXmlNodeModelIndex>();
263 }
264 case QXmlNodeModelIndex::AxisAncestorOrSelf:
265 return QXmlNodeModelIndex::Iterator::Ptr(new AncestorIterator<true>(this, preNumber));
266 case QXmlNodeModelIndex::AxisParent:
267 {
268 if(hasParent(preNumber))
269 return makeSingletonIterator(createIndex(parent(preNumber)));
270 else
271 return makeEmptyIterator<QXmlNodeModelIndex>();
272 }
273 case QXmlNodeModelIndex::AxisDescendant:
274 {
275 if(hasChildren(preNumber))
276 return QXmlNodeModelIndex::Iterator::Ptr(new DescendantIterator<false>(this, preNumber));
277 else
278 return makeEmptyIterator<QXmlNodeModelIndex>();
279 }
280 case QXmlNodeModelIndex::AxisDescendantOrSelf:
281 return QXmlNodeModelIndex::Iterator::Ptr(new DescendantIterator<true>(this, preNumber));
282 case QXmlNodeModelIndex::AxisFollowing:
283 {
284 if(preNumber == maximumPreNumber())
285 return makeEmptyIterator<QXmlNodeModelIndex>();
286 else
287 return QXmlNodeModelIndex::Iterator::Ptr(new FollowingIterator(this, preNumber));
288 }
289 case QXmlNodeModelIndex::AxisAttributeOrTop:
290 {
291 if(!hasParent(preNumber) && kind(preNumber) == QXmlNodeModelIndex::Attribute)
292 return makeSingletonIterator(ni);
293 /* Else, falthrough to AxisAttribute. */
294 }
295 case QXmlNodeModelIndex::AxisAttribute:
296 {
297 if(hasChildren(preNumber) && kind(preNumber + 1) == QXmlNodeModelIndex::Attribute)
298 return QXmlNodeModelIndex::Iterator::Ptr(new AttributeIterator(this, preNumber));
299 else
300 return makeEmptyIterator<QXmlNodeModelIndex>();
301 }
302 case QXmlNodeModelIndex::AxisPreceding:
303 {
304 if(preNumber == 0)
305 return makeEmptyIterator<QXmlNodeModelIndex>();
306 else
307 return QXmlNodeModelIndex::Iterator::Ptr(new PrecedingIterator(this, preNumber));
308 }
309 case QXmlNodeModelIndex::AxisSelf:
310 return makeSingletonIterator(createIndex(toPreNumber(ni)));
311 case QXmlNodeModelIndex::AxisFollowingSibling:
312 {
313 if(preNumber == maximumPreNumber())
314 return makeEmptyIterator<QXmlNodeModelIndex>();
315 else
316 return QXmlNodeModelIndex::Iterator::Ptr(new SiblingIterator<true>(this, preNumber));
317 }
318 case QXmlNodeModelIndex::AxisPrecedingSibling:
319 {
320 if(preNumber == 0)
321 return makeEmptyIterator<QXmlNodeModelIndex>();
322 else
323 return QXmlNodeModelIndex::Iterator::Ptr(new SiblingIterator<false>(this, preNumber));
324 }
325 case QXmlNodeModelIndex::AxisNamespace:
326 return makeEmptyIterator<QXmlNodeModelIndex>();
327 }
328
329 Q_ASSERT(false);
330 return QXmlNodeModelIndex::Iterator::Ptr();
331}
332
333QXmlNodeModelIndex AccelTree::nextFromSimpleAxis(QAbstractXmlNodeModel::SimpleAxis,
334 const QXmlNodeModelIndex&) const
335{
336 Q_ASSERT_X(false, Q_FUNC_INFO, "This function is not supposed to be called.");
337 return QXmlNodeModelIndex();
338}
339
340QVector<QXmlNodeModelIndex> AccelTree::attributes(const QXmlNodeModelIndex &element) const
341{
342 Q_ASSERT_X(false, Q_FUNC_INFO, "This function is not supposed to be called.");
343 Q_UNUSED(element);
344 return QVector<QXmlNodeModelIndex>();
345}
346
347QXmlName AccelTree::name(const QXmlNodeModelIndex &ni) const
348{
349 /* If this node type does not have a name(for instance, it's a comment)
350 * we will return the default constructed value, which is conformant with
351 * this function's contract. */
352 return name(toPreNumber(ni));
353}
354
355QVector<QXmlName> AccelTree::namespaceBindings(const QXmlNodeModelIndex &ni) const
356{
357 /* We get a hold of the ancestor, and loop them in reverse document
358 * order(first the parent, then the parent's parent, etc). As soon
359 * we find a binding that hasn't already been added, we add it to the
360 * result list. In that way, declarations appearing further down override
361 * those further up. */
362
363 const PreNumber preNumber = toPreNumber(ni);
364
365 const QXmlNodeModelIndex::Iterator::Ptr it(new AncestorIterator<true>(this, preNumber));
366 QVector<QXmlName> result;
367 QXmlNodeModelIndex n(it->next());
368
369 /* Whether xmlns="" has been encountered. */
370 bool hasUndeclaration = false;
371
372 while(!n.isNull())
373 {
374 const QVector<QXmlName> &forNode = namespaces.value(toPreNumber(n));
375 const int len = forNode.size();
376 bool stopInheritance = false;
377
378 for(int i = 0; i < len; ++i)
379 {
380 const QXmlName &nsb = forNode.at(i);
381
382 if(nsb.namespaceURI() == StandardNamespaces::StopNamespaceInheritance)
383 {
384 stopInheritance = true;
385 continue;
386 }
387
388 if(nsb.prefix() == StandardPrefixes::empty &&
389 nsb.namespaceURI() == StandardNamespaces::empty)
390 {
391 hasUndeclaration = true;
392 continue;
393 }
394
395 if(!hasPrefix(result, nsb.prefix()))
396 {
397 /* We've already encountered an undeclaration, so we're supposed to skip
398 * them. */
399 if(hasUndeclaration && nsb.prefix() == StandardPrefixes::empty)
400 continue;
401 else
402 result.append(nsb);
403 }
404 }
405
406 if(stopInheritance)
407 break;
408 else
409 n = it->next();
410 }
411
412 result.append(QXmlName(StandardNamespaces::xml, StandardLocalNames::empty, StandardPrefixes::xml));
413
414 return result;
415}
416
417void AccelTree::sendNamespaces(const QXmlNodeModelIndex &n,
418 QAbstractXmlReceiver *const receiver) const
419{
420 Q_ASSERT(n.kind() == QXmlNodeModelIndex::Element);
421
422 const QXmlNodeModelIndex::Iterator::Ptr it(iterate(n, QXmlNodeModelIndex::AxisAncestorOrSelf));
423 QXmlNodeModelIndex next(it->next());
424 QVector<QXmlName::PrefixCode> alreadySent;
425
426 while(!next.isNull())
427 {
428 const PreNumber preNumber = toPreNumber(next);
429
430 const QVector<QXmlName> &nss = namespaces.value(preNumber);
431
432 /* This is by far the most common case. */
433 if(nss.isEmpty())
434 {
435 next = it->next();
436 continue;
437 }
438
439 const int len = nss.count();
440 bool stopInheritance = false;
441
442 for(int i = 0; i < len; ++i)
443 {
444 const QXmlName &name = nss.at(i);
445
446 if(name.namespaceURI() == StandardNamespaces::StopNamespaceInheritance)
447 {
448 stopInheritance = true;
449 continue;
450 }
451
452 if(!alreadySent.contains(name.prefix()))
453 {
454 alreadySent.append(name.prefix());
455 receiver->namespaceBinding(name);
456 }
457 }
458
459 if(stopInheritance)
460 break;
461 else
462 next = it->next();
463 }
464}
465
466QString AccelTree::stringValue(const QXmlNodeModelIndex &ni) const
467{
468 const PreNumber preNumber = toPreNumber(ni);
469
470 switch(kind(preNumber))
471 {
472 case QXmlNodeModelIndex::Element:
473 {
474 /* Concatenate all text nodes that are descendants of this node. */
475 if(!hasChildren(preNumber))
476 return QString();
477
478 const AccelTree::PreNumber stop = preNumber + size(preNumber);
479 AccelTree::PreNumber pn = preNumber + 1; /* Jump over ourselves. */
480 QString result;
481
482 for(; pn <= stop; ++pn)
483 {
484 if(kind(pn) == QXmlNodeModelIndex::Text)
485 {
486 if(isCompressed(pn))
487 result += CompressedWhitespace::decompress(data.value(pn));
488 else
489 result += data.value(pn);
490 }
491 }
492
493 return result;
494 }
495 case QXmlNodeModelIndex::Text:
496 {
497 if(isCompressed(preNumber))
498 return CompressedWhitespace::decompress(data.value(preNumber));
499 /* Else, fallthrough. It's not compressed so use it as it is. */
500 }
501 case QXmlNodeModelIndex::Attribute:
502 /* Fallthrough */
503 case QXmlNodeModelIndex::ProcessingInstruction:
504 /* Fallthrough */
505 case QXmlNodeModelIndex::Comment:
506 return data.value(preNumber);
507 case QXmlNodeModelIndex::Document:
508 {
509 /* Concatenate all text nodes in the whole document. */
510
511 QString result;
512 // Perhaps we can QString::reserve() the result based on the size?
513 const AccelTree::PreNumber max = maximumPreNumber();
514
515 for(AccelTree::PreNumber i = 0; i <= max; ++i)
516 {
517 if(kind(i) == QXmlNodeModelIndex::Text)
518 {
519 if(isCompressed(i))
520 result += CompressedWhitespace::decompress(data.value(i));
521 else
522 result += data.value(i);
523 }
524 }
525
526 return result;
527 }
528 default:
529 {
530 Q_ASSERT_X(false, Q_FUNC_INFO,
531 "A node type that doesn't exist in the XPath Data Model was encountered.");
532 return QString(); /* Dummy, silence compiler warning. */
533 }
534 }
535}
536
537QVariant AccelTree::typedValue(const QXmlNodeModelIndex &n) const
538{
539 return stringValue(n);
540}
541
542bool AccelTree::hasPrefix(const QVector<QXmlName> &nbs, const QXmlName::PrefixCode prefix)
543{
544 const int size = nbs.size();
545
546 for(int i = 0; i < size; ++i)
547 {
548 if(nbs.at(i).prefix() == prefix)
549 return true;
550 }
551
552 return false;
553}
554
555ItemType::Ptr AccelTree::type(const QXmlNodeModelIndex &ni) const
556{
557 /* kind() is manually inlined here to avoid a virtual call. */
558 return XPathHelper::typeFromKind(basicData.at(toPreNumber(ni)).kind());
559}
560
561Item::Iterator::Ptr AccelTree::sequencedTypedValue(const QXmlNodeModelIndex &n) const
562{
563 const PreNumber preNumber = toPreNumber(n);
564
565 switch(kind(preNumber))
566 {
567 case QXmlNodeModelIndex::Element:
568 /* Fallthrough. */
569 case QXmlNodeModelIndex::Document:
570 /* Fallthrough. */
571 case QXmlNodeModelIndex::Attribute:
572 return makeSingletonIterator(Item(UntypedAtomic::fromValue(stringValue(n))));
573
574 case QXmlNodeModelIndex::Text:
575 /* Fallthrough. */
576 case QXmlNodeModelIndex::ProcessingInstruction:
577 /* Fallthrough. */
578 case QXmlNodeModelIndex::Comment:
579 return makeSingletonIterator(Item(AtomicString::fromValue(stringValue(n))));
580 default:
581 {
582 Q_ASSERT_X(false, Q_FUNC_INFO,
583 qPrintable(QString::fromLatin1("A node type that doesn't exist "
584 "in the XPath Data Model was encountered.").arg(kind(preNumber))));
585 return Item::Iterator::Ptr(); /* Dummy, silence compiler warning. */
586 }
587 }
588}
589
590void AccelTree::copyNodeTo(const QXmlNodeModelIndex &node,
591 QAbstractXmlReceiver *const receiver,
592 const NodeCopySettings &settings) const
593{
594 /* This code piece can be seen as a customized version of
595 * QAbstractXmlReceiver::item/sendAsNode(). */
596 Q_ASSERT(receiver);
597 Q_ASSERT(!node.isNull());
598
599 typedef QHash<QXmlName::PrefixCode, QXmlName::NamespaceCode> Binding;
600 QStack<Binding> outputted;
601
602 switch(node.kind())
603 {
604 case QXmlNodeModelIndex::Element:
605 {
606 outputted.push(Binding());
607
608 /* Add the namespace for our element name. */
609 const QXmlName elementName(node.name());
610
611 receiver->startElement(elementName);
612
613 if(!settings.testFlag(InheritNamespaces))
614 receiver->namespaceBinding(QXmlName(StandardNamespaces::StopNamespaceInheritance, 0,
615 StandardPrefixes::StopNamespaceInheritance));
616
617 if(settings.testFlag(PreserveNamespaces))
618 node.sendNamespaces(receiver);
619 else
620 {
621 /* Find the namespaces that we actually use and add them to outputted. These are drawn
622 * from the element name, and the node's attributes. */
623 outputted.top().insert(elementName.prefix(), elementName.namespaceURI());
624
625 const QXmlNodeModelIndex::Iterator::Ptr attributes(iterate(node, QXmlNodeModelIndex::AxisAttribute));
626 QXmlNodeModelIndex attr(attributes->next());
627
628 while(!attr.isNull())
629 {
630 const QXmlName &attrName = attr.name();
631 outputted.top().insert(attrName.prefix(), attrName.namespaceURI());
632 attr = attributes->next();
633 }
634
635 Binding::const_iterator it(outputted.top().constBegin());
636 const Binding::const_iterator end(outputted.top().constEnd());
637
638 for(; it != end; ++it)
639 receiver->namespaceBinding(QXmlName(it.value(), 0, it.key()));
640 }
641
642 /* Send the attributes of the element. */
643 {
644 QXmlNodeModelIndex::Iterator::Ptr attributes(node.iterate(QXmlNodeModelIndex::AxisAttribute));
645 QXmlNodeModelIndex attribute(attributes->next());
646
647 while(!attribute.isNull())
648 {
649 const QString &v = attribute.stringValue();
650 receiver->attribute(attribute.name(), QStringRef(&v));
651 attribute = attributes->next();
652 }
653 }
654
655 /* Send the children of the element. */
656 copyChildren(node, receiver, settings);
657
658 receiver->endElement();
659 outputted.pop();
660 break;
661 }
662 case QXmlNodeModelIndex::Document:
663 {
664 /* We need to intercept and grab the elements of the document node, such
665 * that we preserve/inherit preference applies to them. */
666 receiver->startDocument();
667 copyChildren(node, receiver, settings);
668 receiver->endDocument();
669 break;
670 }
671 default:
672 receiver->item(node);
673 }
674
675}
676
677void AccelTree::copyChildren(const QXmlNodeModelIndex &node,
678 QAbstractXmlReceiver *const receiver,
679 const NodeCopySettings &settings) const
680{
681 QXmlNodeModelIndex::Iterator::Ptr children(node.iterate(QXmlNodeModelIndex::AxisChild));
682 QXmlNodeModelIndex child(children->next());
683
684 while(!child.isNull())
685 {
686 copyNodeTo(child, receiver, settings);
687 child = children->next();
688 }
689}
690
691QXmlNodeModelIndex AccelTree::elementById(const QXmlName &id) const
692{
693 const PreNumber pre = m_IDs.value(id.localName(), -1);
694 if(pre == -1)
695 return QXmlNodeModelIndex();
696 else
697 return createIndex(pre);
698}
699
700QVector<QXmlNodeModelIndex> AccelTree::nodesByIdref(const QXmlName &) const
701{
702 return QVector<QXmlNodeModelIndex>();
703}
704
705QT_END_NAMESPACE
706
Note: See TracBrowser for help on using the repository browser.