Qt 4.8
qacceliterators.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 <QtDebug>
43 
44 #include "qacceliterators_p.h"
45 
47 
48 using namespace QPatternist;
49 
51 {
52  return m_position;
53 }
54 
56 {
57  return m_current;
58 }
59 
61 {
62  /* "the following axis contains all nodes that are descendants
63  * of the root of the tree in which the context node is found,
64  * are not descendants of the context node, and occur after
65  * the context node in document order." */
66 
67  if(m_position == 0)
68  {
69  /* Skip the descendants. */
71  }
72 
74  return closedExit();
75 
77  {
78  ++m_currentPre;
80  return closedExit();
81  }
82 
84  ++m_position;
85  ++m_currentPre;
86  return m_current;
87 }
88 
90 {
91  if(m_currentPre == -1)
92  return closedExit();
93 
94  /* We skip ancestors and attributes and take into account that they can be intermixed. If one
95  * skips them in two separate loops, one can end up with skipping all the attributes to then
96  * be positioned at an ancestor(which will be accepted because the ancestor loop was before the
97  * attributes loop). */
99  m_document->postNumber(m_currentPre) > m_postNumber)
100  {
101  --m_currentPre;
102  if(m_currentPre == -1)
103  return closedExit();
104  }
105 
106  if(m_currentPre == -1)
107  {
108  m_currentPre = -1;
109  return closedExit();
110  }
111 
112  /* Phew, m_currentPre is now 1) not an ancestor; and
113  * 2) not an attribute; and 3) preceds the context node. */
114 
116  ++m_position;
117  --m_currentPre;
118 
119  return m_current;
120 }
121 
123 {
125 }
126 
128 {
130 }
131 
133 {
134  if(m_currentPre == -1)
135  return closedExit();
136 
137  ++m_position;
139 
140  /* We get the count of the descendants, and increment m_currentPre. After
141  * this, m_currentPre is the node after the descendants. */
143  ++m_currentPre;
144 
146  m_currentPre = -1;
147 
148  return m_current;
149 }
150 
152 {
154 }
155 
157 {
158  if(m_currentPre == -1)
159  return closedExit();
160  else
161  {
163  ++m_position;
164 
165  ++m_currentPre;
166 
169  m_currentPre = -1;
170 
171  return m_current;
172  }
173 }
174 
176 {
178 }
179 
181 
virtual QXmlNodeModelIndex next()
Returns the next item in the sequence, or a null object if the end has been reached.
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
Implements axis attribute for the AccelTree.
qint64 xsInteger
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
virtual QXmlNodeModelIndex::Iterator::Ptr copy() const
Copies this QAbstractXmlForwardIterator and returns the copy.
virtual QXmlNodeModelIndex::Iterator::Ptr copy() const
Copies this QAbstractXmlForwardIterator and returns the copy.
virtual QXmlNodeModelIndex next()
Returns the next item in the sequence, or a null object if the end has been reached.
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< T > > Ptr
A smart pointer wrapping an instance of a QAbstractXmlForwardIterator subclass.
virtual QXmlNodeModelIndex next()
Returns the next item in the sequence, or a null object if the end has been reached.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual QXmlNodeModelIndex next()
Returns the next item in the sequence, or a null object if the end has been reached.
The namespace for the internal API of QtXmlPatterns.
Implements axis following for the AccelTree.
QXmlNodeModelIndex m_current
Depth depth(const PreNumber pre) const
Definition: qacceltree_p.h:350
virtual QXmlNodeModelIndex::Iterator::Ptr copy() const
Copies this QAbstractXmlForwardIterator and returns the copy.
Implements axis preceding for the AccelTree.
virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &ni) const
Returns a value indicating the kind of node identified by ni.
Definition: qacceltree.cpp:214
const AccelTree::PreNumber m_preNumber
QXmlNodeModelIndex createIndex(qint64 data) const
Creates a node index with data as its internal data.
PostNumber postNumber(const PreNumber pre) const
Definition: qacceltree_p.h:322
virtual QXmlNodeModelIndex::Iterator::Ptr copy() const
Copies this QAbstractXmlForwardIterator and returns the copy.
Iterates along the child axis in an AccelTree.
AccelTree::PreNumber m_currentPre
PreNumber maximumPreNumber() const
Definition: qacceltree_p.h:333
PreNumber size(const PreNumber pre) const
Definition: qacceltree_p.h:343
virtual QXmlNodeModelIndex current() const
Returns the current item in the sequence.
QXmlNodeModelIndex closedExit()
virtual xsInteger position() const
Returns the current position in the sequence represented by this.
const AccelTree *const m_document