1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
46 // This file is not part of the Qt API. It exists purely as an
47 // implementation detail. This header file may change from version to
48 // version without notice, or even be removed.
52 #ifndef Patternist_SequenceType_H
53 #define Patternist_SequenceType_H
55 template<typename T> class QList;
57 #include <QSharedData>
59 #include <private/qcardinality_p.h>
60 #include <private/qitemtype_p.h>
71 * @short A SequenceType instance represents the type of a sequence of Item
74 * It carries a Cardinality and ItemType, and is hence conceptually
75 * identical to the SequenceType EBNF construct.
77 * @ingroup Patternist_types
78 * @author Frans Englich <frans.englich@nokia.com>
79 * @see <a href="http://www.w3.org/TR/xpath20/#id-sequencetype-syntax">XML
80 * Path Language (XPath) 2.0, 2.5.3 SequenceType Syntax</a>
82 class SequenceType : public virtual QSharedData
90 * A smart pointer wrapping SequenceType instances.
92 typedef QExplicitlySharedDataPointer<const SequenceType> Ptr;
95 * A list of SequenceType instances, each wrapped in a smart pointer.
97 typedef QList<SequenceType::Ptr> List;
99 virtual ~SequenceType();
102 * Generates a name for the sequence type for display purposes. The
103 * prefix used for the QName identifying the schema type is conventional.
104 * An example of a display name for a SequenceType is "xs:integer?".
106 virtual QString displayName(const NamePool::Ptr &np) const = 0;
108 virtual Cardinality cardinality() const = 0;
110 virtual ItemType::Ptr itemType() const = 0;
113 * Determines whether @p other is identical to, or a sub-type
114 * of this SequenceType. For example, if this SequenceType is
115 * <tt>xs:anyAtomicType</tt>, @c false is returned if @p other is <tt>element()</tt>,
116 * but @c true if @p other is <tt>xs:string</tt>.
118 * The return values of cardinality() and itemType() used with ItemType::xdtTypeMatches
119 * and Cardinality::isWithinScope() is used for achieving this.
121 * @see <a href="http://www.w3.org/TR/xquery/#id-sequencetype-matching">XQuery 1.0:
122 * An XML Query Language, 2.5.4 SequenceType Matching</a>
124 bool matches(const SequenceType::Ptr other) const;
126 bool is(const SequenceType::Ptr &other) const;
128 Q_DISABLE_COPY(SequenceType)
132 Q_DECLARE_TYPEINFO(QPatternist::SequenceType::Ptr, Q_MOVABLE_TYPE);