Change copyrights from Nokia to Digia
[profile/ivi/qtxmlpatterns.git] / src / xmlpatterns / type / qsequencetype_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 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 //
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