Qt 4.8
qmultiitemtype.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 "qatomictype_p.h"
43 
44 #include "qmultiitemtype_p.h"
45 
47 
48 using namespace QPatternist;
49 
50 MultiItemType::MultiItemType(const ItemType::List &list) : m_types(list),
51  m_end(list.constEnd())
52 {
53  Q_ASSERT_X(list.count() >= 2, Q_FUNC_INFO,
54  "It makes no sense to use MultiItemType for types less than two.");
56  "No member in the list can be null.");
57 }
58 
60 {
61  QString result;
63 
64  while(true)
65  {
66  result += (*it)->displayName(np);
67  ++it;
68 
69  if(it != m_end)
70  result += QLatin1String(" | ");
71  else
72  break;
73  }
74 
75  return result;
76 }
77 
78 bool MultiItemType::itemMatches(const Item &item) const
79 {
81  if((*it)->itemMatches(item))
82  return true;
83 
84  return false;
85 }
86 
88 {
90  if((*it)->xdtTypeMatches(type))
91  return true;
92 
93  return false;
94 }
95 
97 {
99  if((*it)->isNodeType())
100  return true;
101 
102  return false;
103 }
104 
106 {
108  if((*it)->isAtomicType())
109  return true;
110 
111  return false;
112 }
113 
115 {
117  /* Load the first one, and jump over it in the loop. */
118  ItemType::Ptr result((*it)->xdtSuperType());
119  ++it;
120 
121  for(; it != m_end; ++it)
122  result |= (*it)->xdtSuperType();
123 
124  return result;
125 }
126 
128 {
130  /* Load the first one, and jump over it in the loop. */
131  ItemType::Ptr result((*it)->atomizedType());
132  ++it;
133 
134  for(; it != m_end; ++it)
135  result |= (*it)->atomizedType();
136 
137  return result;
138 }
139 
const ItemType::List m_types
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
virtual ItemType::Ptr atomizedType() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool isNodeType() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The namespace for the internal API of QtXmlPatterns.
virtual QString displayName(const NamePool::Ptr &np) const
MultiItemType(const ItemType::List &typeList)
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
virtual bool isAtomicType() const
virtual bool xdtTypeMatches(const ItemType::Ptr &other) const
virtual ItemType::Ptr xdtSuperType() const
virtual bool itemMatches(const Item &item) const
const ItemType::List::const_iterator m_end
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
#define Q_FUNC_INFO
Definition: qglobal.h:1871