Qt 4.8
qbuiltinnodetype.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 
48 template <const QXmlNodeModelIndex::NodeKind kind>
50 {
51 }
52 
53 template <const QXmlNodeModelIndex::NodeKind kind>
55 {
56  if(!other->isNodeType())
57  return false;
58 
59  return *static_cast<const BuiltinNodeType *>(other.data()) == *this
60  ? true
61  : xdtTypeMatches(other->xdtSuperType());
62 }
63 
64 template <const QXmlNodeModelIndex::NodeKind kind>
66 {
67  Q_ASSERT(item);
68 
69  return item.isNode() &&
70  item.asNode().kind() == kind;
71 }
72 
73 template <const QXmlNodeModelIndex::NodeKind kind>
75 {
76  switch(kind)
77  {
78  /* Fallthrough all these. */
83  return BuiltinTypes::xsUntypedAtomic;
85  /* Fallthrough. */
87  return BuiltinTypes::xsString;
88  default:
89  {
90  Q_ASSERT_X(false, Q_FUNC_INFO,
91  "Encountered invalid XPath Data Model node type.");
92  return BuiltinTypes::xsUntypedAtomic;
93  }
94  }
95 }
96 
97 template <const QXmlNodeModelIndex::NodeKind kind>
99 {
100  switch(kind)
101  {
103  return QLatin1String("element()");
105  return QLatin1String("document()");
107  return QLatin1String("attribute()");
109  return QLatin1String("text()");
111  return QLatin1String("processing-instruction()");
113  return QLatin1String("comment()");
114  default:
115  {
116  Q_ASSERT_X(false, Q_FUNC_INFO,
117  "Encountered invalid XPath Data Model node type.");
118  return QString();
119  }
120  }
121 }
122 
123 template <const QXmlNodeModelIndex::NodeKind kind>
125 {
126  return BuiltinTypes::node;
127 }
128 
129 template <const QXmlNodeModelIndex::NodeKind kind>
131 {
132  return kind;
133 }
134 
135 template <const QXmlNodeModelIndex::NodeKind kind>
137 {
138  /* See XSL Transformations (XSLT) Version 2.0, 6.4 Conflict Resolution for
139  * Template Rules */
140  switch(kind)
141  {
143  /* Fallthrough. */
145  /* Fallthrough. */
147  /* "If the pattern is any other NodeTest, optionally preceded by a
148  * PatternAxis, then the priority is 0.5."
149  * Fallthrough. */
151  /* Fallthrough. */
153  /* Fallthrough. */
155  /* "If the pattern has the form /, then the priority is -0.5.". */
156  return -0.5;
157  default:
158  {
159  Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown node type");
160  return 0;
161  }
162  }
163 
164 }
165 
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
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
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
const QXmlNodeModelIndex & asNode() const
Definition: qitem_p.h:379
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
NodeKind
Identifies a kind of node.
Instances of this class represents types that are sub-classes of node(), such as processing-instructi...
xsDouble PatternPriority
NodeKind kind() const
Definition: qitem_p.h:471
#define Q_FUNC_INFO
Definition: qglobal.h:1871