Qt 4.8
qpullbridge.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 <QVariant>
43 
45 #include "qitemmappingiterator_p.h"
46 #include "qitem_p.h"
47 #include "qxmlname.h"
48 #include "qxmlquery_p.h"
49 
50 #include "qpullbridge_p.h"
51 
53 
54 using namespace QPatternist;
55 
74 {
75  m_index = m_iterators.top().second->next();
76 
77  if(!m_index.isNull())
78  {
79  Item item(m_index);
80 
81  if(item && item.isAtomicValue())
83  else
84  {
85  Q_ASSERT(item.isNode());
86 
87  switch(m_index.kind())
88  {
90  {
92  break;
93  }
95  {
97  break;
98  }
100  {
103  break;
104  }
106  {
109  break;
110  }
112  {
114  break;
115  }
117  {
119  break;
120  }
122  {
123  m_current = Text;
124  break;
125  }
126  }
127  }
128  }
129  else
130  {
131  if(m_iterators.isEmpty())
133  else
134  {
135  switch(m_iterators.top().first)
136  {
137  case StartOfInput:
138  {
140  break;
141  }
142  case StartElement:
143  {
145  m_iterators.pop();
146  break;
147  }
148  case StartDocument:
149  {
151  m_iterators.pop();
152  break;
153  }
154  default:
155  {
156  Q_ASSERT_X(false, Q_FUNC_INFO,
157  "Invalid value.");
159  }
160  }
161  }
162 
163  }
164 
165  return m_current;
166 }
167 
169 {
170  return m_current;
171 }
172 
174 {
175  return m_index;
176 }
177 
179 {
180  return m_index.model()->sourceLocation(m_index);
181 }
182 
184 {
185  return m_index.name();
186 }
187 
189 {
190  return QVariant();
191 }
192 
194 {
195  return QString();
196 }
197 
199 {
201 
203 
205  QXmlNodeModelIndex index = it->next();
206  while (!index.isNull()) {
207  const Item attribute(index);
208  attributes.insert(index.name(), index.stringValue());
209 
210  index = it->next();
211  }
212 
213  return attributes;
214 }
215 
217 {
219 
221 
223  QXmlNodeModelIndex index = it->next();
224  while (!index.isNull()) {
225  const Item attribute(index);
226  attributes.insert(index.name(), QXmlItem(index));
227 
228  index = it->next();
229  }
230 
231  return attributes;
232 }
233 
235 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
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
bool isNull() const
Returns true if this QXmlNodeModelIndex is a default constructed value, otherwise false...
#define it(className, varName)
QXmlNodeModelIndex index() const
Due to strong interdependencies, this file contains the definitions for the classes Item...
The QXmlItem class contains either an XML node or an atomic value.
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
QSourceLocation sourceLocation() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isNode() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:349
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
virtual QHash< QXmlName, QXmlItem > attributeItems()
T pop()
Removes the top item from the stack and returns it.
Definition: qstack.h:67
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Base class for all classes representing atomic values.
Definition: qitem_p.h:118
The namespace for the internal API of QtXmlPatterns.
The QSourceLocation class identifies a location in a resource by URI, line, and column.
virtual Event next()
Advances this AbstractXmlPullProvider, and returns the new event.
Definition: qpullbridge.cpp:73
IteratorStack m_iterators
Definition: qpullbridge_p.h:93
virtual QHash< QXmlName, QString > attributes()
If the current() is Element, the attributes of the element are returned, an empty list of attributes ...
const QAbstractXmlNodeModel * model() const
Returns the QAbstractXmlNodeModel that this node index refers to.
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
virtual QVariant atomicValue() const
QXmlName name() const
Definition: qitem_p.h:446
bool isAtomicValue() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:335
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
virtual QString stringValue() const
If current() is Text, the text node&#39;s value is returned.
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > iterate(const Axis axis) const
Definition: qitem_p.h:456
virtual QXmlName name() const
If the current event is StartElement, EndElement, ProcessingInstruction, Attribute, or Namespace, the node&#39;s name is returned.
QSourceLocation sourceLocation(const QXmlNodeModelIndex &index) const
Returns the source location for the object with the given index or a default constructed QSourceLocat...
virtual Event current() const
Returns the event that next() returned the last time it was called.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
QString stringValue() const
Definition: qitem_p.h:509
NodeKind kind() const
Definition: qitem_p.h:471
QXmlNodeModelIndex m_index
Definition: qpullbridge_p.h:94
T & top()
Returns a reference to the stack&#39;s top item.
Definition: qstack.h:72
#define Q_FUNC_INFO
Definition: qglobal.h:1871