Qt 4.8
qacceltree.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include <QStack>
43 
44 #include "qabstractxmlreceiver.h"
46 #include "qacceliterators_p.h"
47 #include "qacceltree_p.h"
48 #include "qatomicstring_p.h"
49 #include "qcommonvalues_p.h"
51 #include "qdebug_p.h"
52 #include "quntypedatomic_p.h"
53 #include "qxpathhelper_p.h"
54 
56 
57 using namespace QPatternist;
58 
59 namespace QPatternist {
60 
62  {
63  public:
65  : m_accelTree(accelTree)
66  {
67  }
68 
70  {
71  return m_accelTree->sourceLocation(index);
72  }
73 
74  private:
76  };
77 }
78 
79 AccelTree::AccelTree(const QUrl &docURI, const QUrl &bURI)
81  , m_documentURI(docURI)
82  , m_baseURI(bURI)
83 {
84  /* Pre-allocate at least a little bit. */
85  // TODO. Do it according to what an average 4 KB doc contains.
86  basicData.reserve(100);
87  data.reserve(30);
88 }
89 
90 void AccelTree::printStats(const NamePool::Ptr &np) const
91 {
92  Q_ASSERT(np);
93 #ifdef QT_NO_DEBUG
94  Q_UNUSED(np); /* Needed when compiling in release mode. */
95 #else
96  const int len = basicData.count();
97 
98  pDebug() << "AccelTree stats for" << (m_documentURI.isEmpty() ? QString::fromLatin1("<empty URI>") : m_documentURI.toString());
99  pDebug() << "Maximum pre number:" << maximumPreNumber();
100  pDebug() << "+---------------+-------+-------+---------------+-------+--------------+-------+";
101  pDebug() << "| Pre number | Depth | Size | Post Number | Kind | Name | Value |";
102  pDebug() << "+---------------+-------+-------+---------------+-------+--------------+-------+";
103  for(int i = 0; i < len; ++i)
104  {
105  const BasicNodeData &v = basicData.at(i);
106  pDebug() << '|' << i
107  << "\t\t|" << v.depth()
108  << "\t|" << v.size()
109  << "\t|" << postNumber(i)
110  << "\t|" << v.kind()
111  << "\t\t|" << (v.name().isNull() ? QString::fromLatin1("(none)") : np->displayName(v.name()))
113  : data.value(i))
114  << "\t|";
115  /*
116  pDebug() << '|' << QString().arg(i, 14)
117  << '|' << QString().arg(v.depth(), 6)
118  << '|' << QString().arg(v.size(), 6)
119  << '|' << QString().arg(postNumber(i), 14)
120  << '|' << QString().arg(v.kind(), 6)
121  << '|';
122  */
123  }
124  pDebug() << "+---------------+-------+-------+---------------+-------+--------------+";
125  pDebug() << "Namespaces(" << namespaces.count() << "):";
126 
127  QHashIterator<PreNumber, QVector<QXmlName> > it(namespaces);
128  while(it.hasNext())
129  {
130  it.next();
131 
132  pDebug() << "PreNumber: " << QString::number(it.key());
133  for(int i = 0; i < it.value().count(); ++i)
134  pDebug() << "\t\t" << np->stringForPrefix(it.value().at(i).prefix()) << " = " << np->stringForNamespace(it.value().at(i).namespaceURI());
135  }
136 
137 #endif
138 }
139 
141 {
142  switch(kind(toPreNumber(ni)))
143  {
145  return baseUri();
147  {
149  QXmlNodeModelIndex next(it->next());
150 
151  while(!next.isNull())
152  {
154  {
155  const QUrl candidate(next.stringValue());
156  // TODO. The xml:base spec says to do URI escaping here.
157 
158  if(!candidate.isValid())
159  return QUrl();
160  else if(candidate.isRelative())
161  {
162  const QXmlNodeModelIndex par(parent(ni));
163 
164  if(par.isNull())
165  return baseUri().resolved(candidate);
166  else
167  return par.baseUri().resolved(candidate);
168  }
169  else
170  return candidate;
171  }
172 
173  next = it->next();
174  }
175 
176  /* We have no xml:base-attribute. Can any parent supply us a base URI? */
177  const QXmlNodeModelIndex par(parent(ni));
178 
179  if(par.isNull())
180  return baseUri();
181  else
182  return par.baseUri();
183  }
185  /* Fallthrough. */
187  /* Fallthrough. */
189  /* Fallthrough. */
191  {
193  if(par.isNull())
194  return QUrl();
195  else
196  return par.baseUri();
197  }
199  return QUrl();
200  }
201 
202  Q_ASSERT_X(false, Q_FUNC_INFO, "This line is never supposed to be reached.");
203  return QUrl();
204 }
205 
207 {
209  return documentUri();
210  else
211  return QUrl();
212 }
213 
215 {
216  return kind(toPreNumber(ni));
217 }
218 
220  const QXmlNodeModelIndex &ni2) const
221 {
222  Q_ASSERT_X(ni1.model() == ni2.model(), Q_FUNC_INFO,
223  "The API docs guarantees the two nodes are from the same model");
224 
225  const PreNumber p1 = ni1.data();
226  const PreNumber p2 = ni2.data();
227 
228  if(p1 == p2)
229  return QXmlNodeModelIndex::Is;
230  else if(p1 < p2)
232  else
234 }
235 
237 {
238  return createIndex(qint64(0));
239 }
240 
242 {
243  const AccelTree::PreNumber p = basicData.at(toPreNumber(ni)).parent();
244 
245  if(p == -1)
246  return QXmlNodeModelIndex();
247  else
248  return createIndex(p);
249 }
250 
252  QXmlNodeModelIndex::Axis axis) const
253 {
254  const PreNumber preNumber = toPreNumber(ni);
255 
256  switch(axis)
257  {
259  {
260  if(!hasParent(preNumber))
261  {
262  switch(kind(preNumber))
263  {
265  /* Fallthrough. */
267  /* Fallthrough. */
269  /* Fallthrough. */
271  return makeSingletonIterator(ni);
273  /* Fallthrough. */
275  /* Fallthrough. */
277  /* Do nothing. */;
278  }
279  }
280  /* Else, fallthrough to AxisChild. */
281  }
283  {
284  if(hasChildren(preNumber))
285  return QXmlNodeModelIndex::Iterator::Ptr(new ChildIterator(this, preNumber));
286  else
287  return makeEmptyIterator<QXmlNodeModelIndex>();
288  }
290  {
291  if(hasParent(preNumber))
292  return QXmlNodeModelIndex::Iterator::Ptr(new AncestorIterator<false>(this, preNumber));
293  else
294  return makeEmptyIterator<QXmlNodeModelIndex>();
295  }
297  return QXmlNodeModelIndex::Iterator::Ptr(new AncestorIterator<true>(this, preNumber));
299  {
300  if(hasParent(preNumber))
301  return makeSingletonIterator(createIndex(parent(preNumber)));
302  else
303  return makeEmptyIterator<QXmlNodeModelIndex>();
304  }
306  {
307  if(hasChildren(preNumber))
309  else
310  return makeEmptyIterator<QXmlNodeModelIndex>();
311  }
313  return QXmlNodeModelIndex::Iterator::Ptr(new DescendantIterator<true>(this, preNumber));
315  {
316  if(preNumber == maximumPreNumber())
317  return makeEmptyIterator<QXmlNodeModelIndex>();
318  else
319  return QXmlNodeModelIndex::Iterator::Ptr(new FollowingIterator(this, preNumber));
320  }
322  {
323  if(!hasParent(preNumber) && kind(preNumber) == QXmlNodeModelIndex::Attribute)
324  return makeSingletonIterator(ni);
325  /* Else, falthrough to AxisAttribute. */
326  }
328  {
329  if(hasChildren(preNumber) && kind(preNumber + 1) == QXmlNodeModelIndex::Attribute)
330  return QXmlNodeModelIndex::Iterator::Ptr(new AttributeIterator(this, preNumber));
331  else
332  return makeEmptyIterator<QXmlNodeModelIndex>();
333  }
335  {
336  if(preNumber == 0)
337  return makeEmptyIterator<QXmlNodeModelIndex>();
338  else
339  return QXmlNodeModelIndex::Iterator::Ptr(new PrecedingIterator(this, preNumber));
340  }
342  return makeSingletonIterator(createIndex(toPreNumber(ni)));
344  {
345  if(preNumber == maximumPreNumber())
346  return makeEmptyIterator<QXmlNodeModelIndex>();
347  else
348  return QXmlNodeModelIndex::Iterator::Ptr(new SiblingIterator<true>(this, preNumber));
349  }
351  {
352  if(preNumber == 0)
353  return makeEmptyIterator<QXmlNodeModelIndex>();
354  else
355  return QXmlNodeModelIndex::Iterator::Ptr(new SiblingIterator<false>(this, preNumber));
356  }
358  return makeEmptyIterator<QXmlNodeModelIndex>();
359  }
360 
361  Q_ASSERT(false);
363 }
364 
366  const QXmlNodeModelIndex&) const
367 {
368  Q_ASSERT_X(false, Q_FUNC_INFO, "This function is not supposed to be called.");
369  return QXmlNodeModelIndex();
370 }
371 
373 {
374  Q_ASSERT_X(false, Q_FUNC_INFO, "This function is not supposed to be called.");
375  Q_UNUSED(element);
377 }
378 
380 {
381  /* If this node type does not have a name(for instance, it's a comment)
382  * we will return the default constructed value, which is conformant with
383  * this function's contract. */
384  return name(toPreNumber(ni));
385 }
386 
388 {
389  /* We get a hold of the ancestor, and loop them in reverse document
390  * order(first the parent, then the parent's parent, etc). As soon
391  * we find a binding that hasn't already been added, we add it to the
392  * result list. In that way, declarations appearing further down override
393  * those further up. */
394 
395  const PreNumber preNumber = toPreNumber(ni);
396 
397  const QXmlNodeModelIndex::Iterator::Ptr it(new AncestorIterator<true>(this, preNumber));
398  QVector<QXmlName> result;
399  QXmlNodeModelIndex n(it->next());
400 
401  /* Whether xmlns="" has been encountered. */
402  bool hasUndeclaration = false;
403 
404  while(!n.isNull())
405  {
406  const QVector<QXmlName> &forNode = namespaces.value(toPreNumber(n));
407  const int len = forNode.size();
408  bool stopInheritance = false;
409 
410  for(int i = 0; i < len; ++i)
411  {
412  const QXmlName &nsb = forNode.at(i);
413 
415  {
416  stopInheritance = true;
417  continue;
418  }
419 
420  if(nsb.prefix() == StandardPrefixes::empty &&
422  {
423  hasUndeclaration = true;
424  continue;
425  }
426 
427  if(!hasPrefix(result, nsb.prefix()))
428  {
429  /* We've already encountered an undeclaration, so we're supposed to skip
430  * them. */
431  if(hasUndeclaration && nsb.prefix() == StandardPrefixes::empty)
432  continue;
433  else
434  result.append(nsb);
435  }
436  }
437 
438  if(stopInheritance)
439  break;
440  else
441  n = it->next();
442  }
443 
445 
446  return result;
447 }
448 
450  QAbstractXmlReceiver *const receiver) const
451 {
453 
455  QXmlNodeModelIndex next(it->next());
456  QVector<QXmlName::PrefixCode> alreadySent;
457 
458  while(!next.isNull())
459  {
460  const PreNumber preNumber = toPreNumber(next);
461 
462  const QVector<QXmlName> &nss = namespaces.value(preNumber);
463 
464  /* This is by far the most common case. */
465  if(nss.isEmpty())
466  {
467  next = it->next();
468  continue;
469  }
470 
471  const int len = nss.count();
472  bool stopInheritance = false;
473 
474  for(int i = 0; i < len; ++i)
475  {
476  const QXmlName &name = nss.at(i);
477 
479  {
480  stopInheritance = true;
481  continue;
482  }
483 
484  if(!alreadySent.contains(name.prefix()))
485  {
486  alreadySent.append(name.prefix());
487  receiver->namespaceBinding(name);
488  }
489  }
490 
491  if(stopInheritance)
492  break;
493  else
494  next = it->next();
495  }
496 }
497 
499 {
500  const PreNumber preNumber = toPreNumber(ni);
501 
502  switch(kind(preNumber))
503  {
505  {
506  /* Concatenate all text nodes that are descendants of this node. */
507  if(!hasChildren(preNumber))
508  return QString();
509 
510  const AccelTree::PreNumber stop = preNumber + size(preNumber);
511  AccelTree::PreNumber pn = preNumber + 1; /* Jump over ourselves. */
512  QString result;
513 
514  for(; pn <= stop; ++pn)
515  {
516  if(kind(pn) == QXmlNodeModelIndex::Text)
517  {
518  if(isCompressed(pn))
520  else
521  result += data.value(pn);
522  }
523  }
524 
525  return result;
526  }
528  {
529  if(isCompressed(preNumber))
530  return CompressedWhitespace::decompress(data.value(preNumber));
531  /* Else, fallthrough. It's not compressed so use it as it is. */
532  }
534  /* Fallthrough */
536  /* Fallthrough */
538  return data.value(preNumber);
540  {
541  /* Concatenate all text nodes in the whole document. */
542 
543  QString result;
544  // Perhaps we can QString::reserve() the result based on the size?
546 
547  for(AccelTree::PreNumber i = 0; i <= max; ++i)
548  {
550  {
551  if(isCompressed(i))
553  else
554  result += data.value(i);
555  }
556  }
557 
558  return result;
559  }
560  default:
561  {
562  Q_ASSERT_X(false, Q_FUNC_INFO,
563  "A node type that doesn't exist in the XPath Data Model was encountered.");
564  return QString(); /* Dummy, silence compiler warning. */
565  }
566  }
567 }
568 
570 {
571  return stringValue(n);
572 }
573 
575 {
576  const int size = nbs.size();
577 
578  for(int i = 0; i < size; ++i)
579  {
580  if(nbs.at(i).prefix() == prefix)
581  return true;
582  }
583 
584  return false;
585 }
586 
588 {
589  /* kind() is manually inlined here to avoid a virtual call. */
590  return XPathHelper::typeFromKind(basicData.at(toPreNumber(ni)).kind());
591 }
592 
594 {
595  const PreNumber preNumber = toPreNumber(n);
596 
597  switch(kind(preNumber))
598  {
600  /* Fallthrough. */
602  /* Fallthrough. */
604  return makeSingletonIterator(Item(UntypedAtomic::fromValue(stringValue(n))));
605 
607  /* Fallthrough. */
609  /* Fallthrough. */
611  return makeSingletonIterator(Item(AtomicString::fromValue(stringValue(n))));
612  default:
613  {
614  Q_ASSERT_X(false, Q_FUNC_INFO,
615  qPrintable(QString::fromLatin1("A node type that doesn't exist "
616  "in the XPath Data Model was encountered.").arg(kind(preNumber))));
617  return Item::Iterator::Ptr(); /* Dummy, silence compiler warning. */
618  }
619  }
620 }
621 
623  QAbstractXmlReceiver *const receiver,
624  const NodeCopySettings &settings) const
625 {
626  /* This code piece can be seen as a customized version of
627  * QAbstractXmlReceiver::item/sendAsNode(). */
628  Q_ASSERT(receiver);
629  Q_ASSERT(!node.isNull());
630 
632  QStack<Binding> outputted;
633 
634  switch(node.kind())
635  {
637  {
638  outputted.push(Binding());
639 
640  /* Add the namespace for our element name. */
641  const QXmlName elementName(node.name());
642 
643  receiver->startElement(elementName);
644 
645  if(!settings.testFlag(InheritNamespaces))
648 
649  if(settings.testFlag(PreserveNamespaces))
650  node.sendNamespaces(receiver);
651  else
652  {
653  /* Find the namespaces that we actually use and add them to outputted. These are drawn
654  * from the element name, and the node's attributes. */
655  outputted.top().insert(elementName.prefix(), elementName.namespaceURI());
656 
658  QXmlNodeModelIndex attr(attributes->next());
659 
660  while(!attr.isNull())
661  {
662  const QXmlName &attrName = attr.name();
663  outputted.top().insert(attrName.prefix(), attrName.namespaceURI());
664  attr = attributes->next();
665  }
666 
667  Binding::const_iterator it(outputted.top().constBegin());
668  const Binding::const_iterator end(outputted.top().constEnd());
669 
670  for(; it != end; ++it)
671  receiver->namespaceBinding(QXmlName(it.value(), 0, it.key()));
672  }
673 
674  /* Send the attributes of the element. */
675  {
677  QXmlNodeModelIndex attribute(attributes->next());
678 
679  while(!attribute.isNull())
680  {
681  const QString &v = attribute.stringValue();
682  receiver->attribute(attribute.name(), QStringRef(&v));
683  attribute = attributes->next();
684  }
685  }
686 
687  /* Send the children of the element. */
688  copyChildren(node, receiver, settings);
689 
690  receiver->endElement();
691  outputted.pop();
692  break;
693  }
695  {
696  /* We need to intercept and grab the elements of the document node, such
697  * that we preserve/inherit preference applies to them. */
698  receiver->startDocument();
699  copyChildren(node, receiver, settings);
700  receiver->endDocument();
701  break;
702  }
703  default:
704  receiver->item(node);
705  }
706 
707 }
708 
710 {
711  const PreNumber key = toPreNumber(index);
712  if (sourcePositions.contains(key)) {
714  return QSourceLocation(m_documentURI, position.first, position.second);
715  } else {
716  return QSourceLocation();
717  }
718 }
719 
721  QAbstractXmlReceiver *const receiver,
722  const NodeCopySettings &settings) const
723 {
725  QXmlNodeModelIndex child(children->next());
726 
727  while(!child.isNull())
728  {
729  copyNodeTo(child, receiver, settings);
730  child = children->next();
731  }
732 }
733 
735 {
736  const PreNumber pre = m_IDs.value(id.localName(), -1);
737  if(pre == -1)
738  return QXmlNodeModelIndex();
739  else
740  return createIndex(pre);
741 }
742 
744 {
746 }
747 
749 
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QString displayName(const QXmlName qName) const
Definition: qnamepool.cpp:347
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
A push interface for the XPath Data Model. Similar to SAX&#39;s ContentHandler.
Iterates along the ancestor or ancestor-or-self axis in an AccelTree.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
bool isNull() const
Returns true if this QXmlNodeModelIndex is a default constructed value, otherwise false...
virtual void namespaceBinding(const QXmlName &nb)=0
Signals the presence of the namespace declaration nb.
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
#define it(className, varName)
Implements axis attribute for the AccelTree.
static bool hasPrefix(const QVector< QXmlName > &nbs, const QXmlName::PrefixCode prefix)
Definition: qacceltree.cpp:574
Iterates along the sibling axes in an AccelTree.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition: qurl.cpp:4317
virtual QXmlNodeModelIndex::DocumentOrder compareOrder(const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const
This function returns the relative document order for the nodes indexed by ni1 and ni2...
Definition: qacceltree.cpp:219
T1 first
Definition: qpair.h:65
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
T2 second
Definition: qpair.h:66
virtual void copyNodeTo(const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &settings) const
Definition: qacceltree.cpp:622
AccelTreePrivate(AccelTree *accelTree)
Definition: qacceltree.cpp:64
virtual QXmlNodeModelIndex::Iterator::Ptr iterate(const QXmlNodeModelIndex &ni, QXmlNodeModelIndex::Axis axis) const
Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes...
Definition: qacceltree.cpp:251
bool testFlag(Enum f) const
Returns true if the flag is set, otherwise false.
Definition: qglobal.h:2345
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63
virtual void startElement(const QXmlName name)=0
Signals the start of an element by name name.
Contains macros for debugging.
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual void sendNamespaces(const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const
Definition: qacceltree.cpp:449
virtual void endElement()=0
Signals the end of the current element.
QHash< PreNumber, QVector< QXmlName > > namespaces
Definition: qacceltree_p.h:268
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
static UntypedAtomic::Ptr fromValue(const QString &value)
bool isCompressed(const PreNumber pre) const
Definition: qacceltree_p.h:362
static AtomicString::Ptr fromValue(const QString &value)
QString prefix(const QXmlNamePool &query) const
Returns the prefix.
Definition: qxmlname.cpp:370
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
virtual QXmlNodeModelIndex root(const QXmlNodeModelIndex &n) const
Returns the root node.
Definition: qacceltree.cpp:236
PreNumber toPreNumber(const QXmlNodeModelIndex n) const
Definition: qacceltree_p.h:338
void reserve(int size)
Ensures that the QHash&#39;s internal hash table consists of at least size buckets.
Definition: qhash.h:846
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< T > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.
T pop()
Removes the top item from the stack and returns it.
Definition: qstack.h:67
const QString & stringForPrefix(const QXmlName::PrefixCode code) const
Definition: qnamepool_p.h:174
bool hasParent(const PreNumber pre) const
Definition: qacceltree_p.h:312
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
qint64 data() const
Returns the first data value.
QVector< BasicNodeData > basicData
Definition: qacceltree_p.h:276
The QAbstractXmlNodeModel class is an abstract base class for modeling non-XML data to look like XML ...
DocumentOrder
Identifies the specific node comparison operator that should be used.
The namespace for the internal API of QtXmlPatterns.
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
Implements axis following for the AccelTree.
virtual QVector< QXmlName > namespaceBindings(const QXmlNodeModelIndex &n) const
Returns the in-scope namespaces of n.
Definition: qacceltree.cpp:387
bool hasChildren(const PreNumber pre) const
Returns true if the node identified by pre has child nodes(in the sense of the XDM), but also if it has namespace nodes, or attribute nodes.
Definition: qacceltree_p.h:294
The QSourceLocation class identifies a location in a resource by URI, line, and column.
virtual void item(const Item &item)=0
Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an AtomicValue...
__int64 qint64
Definition: qglobal.h:942
QHash< PreNumber, QString > data
Definition: qacceltree_p.h:274
const QAbstractXmlNodeModel * model() const
Returns the QAbstractXmlNodeModel that this node index refers to.
The Binding element allows arbitrary property bindings to be created.
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
Implements axis preceding for the AccelTree.
virtual QXmlNodeModelIndex elementById(const QXmlName &id) const
Returns the index of the element identified as id.
Definition: qacceltree.cpp:734
QXmlName name() const
Definition: qitem_p.h:446
NamespaceCode namespaceURI() const
Definition: qnamepool_p.h:503
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
Implements axis descendant and descendant-or-self for the AccelTree.
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &ni) const
Returns a value indicating the kind of node identified by ni.
Definition: qacceltree.cpp:214
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
Stores an XML document using the XPath Accelerator scheme, also known as pre/post numbering...
Definition: qacceltree_p.h:92
NodeKind
Identifies a kind of node.
void sendNamespaces(QAbstractXmlReceiver *const receiver) const
Definition: qitem_p.h:494
QXmlNodeModelIndex createIndex(qint64 data) const
Creates a node index with data as its internal data.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
SimpleAxis
Four axes that each contain one node only.
virtual QVariant typedValue(const QXmlNodeModelIndex &n) const
Returns the typed value for node node.
Definition: qacceltree.cpp:569
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > iterate(const Axis axis) const
Definition: qitem_p.h:456
int key
void printStats(const NamePool::Ptr &np) const
Definition: qacceltree.cpp:90
const QString & stringForNamespace(const QXmlName::NamespaceCode code) const
Definition: qnamepool_p.h:180
virtual QString stringValue(const QXmlNodeModelIndex &n) const
Returns the string value for node n.
Definition: qacceltree.cpp:498
PostNumber postNumber(const PreNumber pre) const
Definition: qacceltree_p.h:322
QUrl baseUri() const
Definition: qitem_p.h:466
AccelTree(const QUrl &docURI, const QUrl &bURI)
Definition: qacceltree.cpp:79
virtual QVector< QXmlNodeModelIndex > attributes(const QXmlNodeModelIndex &element) const
Returns the attributes of element.
Definition: qacceltree.cpp:372
virtual QVector< QXmlNodeModelIndex > nodesByIdref(const QXmlName &idref) const
Returns the elements and/or attributes that have an IDREF value equal to idref.
Definition: qacceltree.cpp:743
quint16 index
Axis
Identify the axes emanating from a node.
int count(const Key &key) const
Returns the number of items associated with the key.
Definition: qhash.h:719
virtual QXmlName name(const QXmlNodeModelIndex &ni) const
Returns the name of ni.
Definition: qacceltree.cpp:379
virtual QXmlNodeModelIndex parent(const QXmlNodeModelIndex &ni) const
Definition: qacceltree.cpp:241
Iterates along the child axis in an AccelTree.
QUrl documentUri() const
Definition: qacceltree_p.h:279
Houses data for a node, and that all node kinds have.
Definition: qacceltree_p.h:121
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
The QFlags class provides a type-safe way of storing OR-combinations of enum values.
Definition: qglobal.h:2313
PreNumber maximumPreNumber() const
Definition: qacceltree_p.h:333
void copyChildren(const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &settings) const
Definition: qacceltree.cpp:720
static QPatternist::ItemTypePtr typeFromKind(const QXmlNodeModelIndex::NodeKind nodeKind)
PreNumber size(const PreNumber pre) const
Definition: qacceltree_p.h:343
static QString decompress(const QString &input)
Decompresses input into a usual QString.
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition: qurl.cpp:5819
virtual void attribute(const QXmlName name, const QString &value)=0
Signals the presence of an attribute node.
static const KeyPair *const end
#define qPrintable(string)
Definition: qglobal.h:1750
virtual QXmlNodeModelIndex nextFromSimpleAxis(QAbstractXmlNodeModel::SimpleAxis, const QXmlNodeModelIndex &) const
When QtXmlPatterns evaluate path expressions, it emulate them through a combination of calls with QSi...
Definition: qacceltree.cpp:365
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
virtual QSourceLocation sourceLocation(const QXmlNodeModelIndex &index) const
Definition: qacceltree.cpp:69
virtual Item::Iterator::Ptr sequencedTypedValue(const QXmlNodeModelIndex &n) const
Definition: qacceltree.cpp:593
QSourceLocation sourceLocation(const QXmlNodeModelIndex &index) const
Definition: qacceltree.cpp:709
NodeKind kind() const
Definition: qitem_p.h:471
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224
QHash< QXmlName::LocalNameCode, PreNumber > m_IDs
Definition: qacceltree_p.h:394
T & top()
Returns a reference to the stack&#39;s top item.
Definition: qstack.h:72
QHash< PreNumber, QPair< qint64, qint64 > > sourcePositions
Definition: qacceltree_p.h:277
QXmlNodeModelIndex::NodeKind kind() const
Definition: qacceltree_p.h:169
QNoDebug pDebug()
Definition: qdebug_p.h:99
virtual ItemType::Ptr type(const QXmlNodeModelIndex &ni) const
Definition: qacceltree.cpp:587
#define Q_FUNC_INFO
Definition: qglobal.h:1871
NamespaceCode PrefixCode
Definition: qxmlname.h:83