1bd7ae5a6ecca139f4390ab5eaed449ee35d0e9f
[profile/ivi/qtxmlpatterns.git] / src / xmlpatterns / type / qsequencetype_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 //
43 //  W A R N I N G
44 //  -------------
45 //
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.
49 //
50 // We mean it.
51
52 #ifndef Patternist_SequenceType_H
53 #define Patternist_SequenceType_H
54
55 template<typename T> class QList;
56
57 #include <QSharedData>
58
59 #include <private/qcardinality_p.h>
60 #include <private/qitemtype_p.h>
61
62 QT_BEGIN_HEADER
63
64 QT_BEGIN_NAMESPACE
65
66 namespace QPatternist
67 {
68     class ItemType;
69
70     /**
71      * @short A SequenceType instance represents the type of a sequence of Item
72      * instances.
73      *
74      * It carries a Cardinality and ItemType, and is hence conceptually
75      * identical to the SequenceType EBNF construct.
76      *
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>
81      */
82     class SequenceType : public virtual QSharedData
83     {
84     public:
85         inline SequenceType()
86         {
87         }
88
89         /**
90          * A smart pointer wrapping SequenceType instances.
91          */
92         typedef QExplicitlySharedDataPointer<const SequenceType> Ptr;
93
94         /**
95          * A list of SequenceType instances, each wrapped in a smart pointer.
96          */
97         typedef QList<SequenceType::Ptr> List;
98
99         virtual ~SequenceType();
100
101         /**
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?".
105          */
106         virtual QString displayName(const NamePool::Ptr &np) const = 0;
107
108         virtual Cardinality cardinality() const = 0;
109
110         virtual ItemType::Ptr itemType() const = 0;
111
112         /**
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>.
117          *
118          * The return values of cardinality() and itemType() used with ItemType::xdtTypeMatches
119          * and Cardinality::isWithinScope() is used for achieving this.
120          *
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>
123          */
124         bool matches(const SequenceType::Ptr other) const;
125
126         bool is(const SequenceType::Ptr &other) const;
127     private:
128         Q_DISABLE_COPY(SequenceType)
129     };
130 }
131
132 Q_DECLARE_TYPEINFO(QPatternist::SequenceType::Ptr, Q_MOVABLE_TYPE);
133
134 QT_END_NAMESPACE
135
136 QT_END_HEADER
137
138 #endif