author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtXmlPatterns module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
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_SchemaType_H |
|
53 |
#define Patternist_SchemaType_H |
|
54 |
||
55 |
#include "qnamepool_p.h" |
|
56 |
#include "qschemacomponent_p.h" |
|
57 |
#include "qxmlname.h" |
|
58 |
||
59 |
template<typename N, typename M> class QHash; |
|
60 |
template<typename N> class QList; |
|
61 |
||
62 |
QT_BEGIN_HEADER |
|
63 |
||
64 |
QT_BEGIN_NAMESPACE |
|
65 |
||
66 |
namespace QPatternist |
|
67 |
{ |
|
68 |
class AtomicType; |
|
69 |
||
70 |
/** |
|
71 |
* @short Base class for W3C XML Schema types. |
|
72 |
* |
|
73 |
* This is the base class of all data types in a W3C XML Schema. |
|
74 |
* |
|
75 |
* @ingroup Patternist_types |
|
76 |
* @author Frans Englich <frans.englich@nokia.com> |
|
77 |
*/ |
|
78 |
class SchemaType : public SchemaComponent |
|
79 |
{ |
|
80 |
public: |
|
81 |
||
82 |
typedef QExplicitlySharedDataPointer<SchemaType> Ptr; |
|
83 |
typedef QHash<QXmlName, SchemaType::Ptr> Hash; |
|
84 |
typedef QList<SchemaType::Ptr> List; |
|
85 |
||
86 |
/** |
|
87 |
* Schema types are divided into different categories such as |
|
88 |
* complex type, atomic imple type, union simple type, and so forth. This |
|
89 |
* enumerator, which category() returns a value of, identifies what |
|
90 |
* category the type belong to. |
|
91 |
* |
|
92 |
* @todo Add docs & links for the enums |
|
93 |
*/ |
|
94 |
enum TypeCategory |
|
95 |
{ |
|
96 |
None = 0, |
|
97 |
/** |
|
98 |
* A simple atomic type. These are also sometimes |
|
99 |
* referred to as primitive types. An example of this type is |
|
100 |
* xs:string. |
|
101 |
* |
|
102 |
* Formally speaking, a simple type with variety atomic. |
|
103 |
*/ |
|
104 |
SimpleTypeAtomic, |
|
105 |
SimpleTypeList, |
|
106 |
SimpleTypeUnion, |
|
107 |
ComplexType |
|
108 |
}; |
|
109 |
||
110 |
enum DerivationMethod |
|
111 |
{ |
|
112 |
DerivationRestriction = 1, |
|
113 |
DerivationExtension = 2, |
|
114 |
DerivationUnion = 4, |
|
115 |
DerivationList = 8, |
|
116 |
/** |
|
117 |
* Used for <tt>xs:anyType</tt>. |
|
118 |
*/ |
|
119 |
NoDerivation = 16 |
|
120 |
}; |
|
121 |
||
122 |
/** |
|
123 |
* Describes the derivation constraints that are given by the 'final' or 'block' attributes. |
|
124 |
*/ |
|
125 |
enum DerivationConstraint |
|
126 |
{ |
|
127 |
RestrictionConstraint = 1, |
|
128 |
ExtensionConstraint = 2, |
|
129 |
ListConstraint = 4, |
|
130 |
UnionConstraint = 8 |
|
131 |
}; |
|
132 |
Q_DECLARE_FLAGS(DerivationConstraints, DerivationConstraint) |
|
133 |
||
134 |
SchemaType(); |
|
135 |
virtual ~SchemaType(); |
|
136 |
||
137 |
/** |
|
138 |
* Determines how this SchemaType is derived from its super type. |
|
139 |
* |
|
140 |
* @note Despite that DerivationMethod is designed for being |
|
141 |
* used for bitwise OR'd value, this function may only return one enum |
|
142 |
* value. If the type does not derive from any type, which is the case of |
|
143 |
* <tt>xs:anyType</tt>, this function returns NoDerivation. |
|
144 |
* |
|
145 |
* @see SchemaType::wxsSuperType() |
|
146 |
* @see <a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-DerivationMethods">Document |
|
147 |
* Object Model (DOM) Level 3 Core Specification, Definition group DerivationMethods</a> |
|
148 |
* @returns a DerivationMethod enumerator signifiying how |
|
149 |
* this SchemaType is derived from its base type |
|
150 |
*/ |
|
151 |
virtual DerivationMethod derivationMethod() const = 0; |
|
152 |
||
153 |
/** |
|
154 |
* Determines what derivation constraints exists for the type. |
|
155 |
*/ |
|
156 |
virtual DerivationConstraints derivationConstraints() const = 0; |
|
157 |
||
158 |
/** |
|
159 |
* Determines whether the type is an abstract type. |
|
160 |
* |
|
161 |
* @note It is important a correct value is returned, since |
|
162 |
* abstract types must not be instantiated. |
|
163 |
*/ |
|
164 |
virtual bool isAbstract() const = 0; |
|
165 |
||
166 |
/** |
|
167 |
* @short Returns the name of the type. |
|
168 |
* |
|
169 |
* The reason to why we take the name pool argument, is that the basic |
|
170 |
* types, @c xs:anySimpleType and so on, are stored globally in |
|
171 |
* BuiltinTypes and ComonSequenceTypes, and therefore cannot be tied to |
|
172 |
* a certain name pool. Type instances that knows they always will be |
|
173 |
* used with a certain name pool, can therefore ignore @p np and return |
|
174 |
* a QXmlName instance stored as a member. |
|
175 |
* |
|
176 |
* If the type code was refactored to not be store globally and |
|
177 |
* therfore by design would be tied to a name pool, this argument could |
|
178 |
* be removed. |
|
179 |
*/ |
|
180 |
virtual QXmlName name(const NamePool::Ptr &np) const = 0; |
|
181 |
||
182 |
/** |
|
183 |
* @short Returns a suitable display name for this type. |
|
184 |
* |
|
185 |
* See name() for an explanation to why we take a NamePool as argument. |
|
186 |
*/ |
|
187 |
virtual QString displayName(const NamePool::Ptr &np) const = 0; |
|
188 |
||
189 |
/** |
|
190 |
* @returns the W3C XML Schema base type that this type derives from. All types |
|
191 |
* returns an instance, except for the xs:anyType since it |
|
192 |
* is the very base type of all types, and it returns 0. Hence, |
|
193 |
* one can walk the hierarchy of a schema type by recursively calling |
|
194 |
* wxsSuperType, until zero is returned. |
|
195 |
* |
|
196 |
* This function walks the Schema hierarchy. Some simple types, the atomic types, |
|
197 |
* is also part of the XPath Data Model hierarchy, and their super type in that |
|
198 |
* hierarchy can be introspected with xdtSuperType(). |
|
199 |
* |
|
200 |
* wxsSuperType() can be said to correspond to the {base type definition} property |
|
201 |
* in the Post Schema Valid Infoset(PSVI). |
|
202 |
* |
|
203 |
* @see ItemType::xdtSuperType() |
|
204 |
*/ |
|
205 |
virtual SchemaType::Ptr wxsSuperType() const = 0; |
|
206 |
||
207 |
/** |
|
208 |
* @returns @c true if @p other is identical to 'this' schema type or if @p other |
|
209 |
* is either directly or indirectly a base type of 'this'. Hence, calling |
|
210 |
* AnyType::wxsTypeMatches() with @p other as argument returns @c true for all types, |
|
211 |
* since all types have @c xs:anyType as super type. |
|
212 |
*/ |
|
213 |
virtual bool wxsTypeMatches(const SchemaType::Ptr &other) const = 0; |
|
214 |
||
215 |
virtual TypeCategory category() const = 0; |
|
216 |
||
217 |
/** |
|
218 |
* Determines whether the type is a simple type, by introspecting |
|
219 |
* the result of category(). |
|
220 |
* |
|
221 |
* @note Do not re-implement this function, but instead override category() |
|
222 |
* and let it return an appropriate value. |
|
223 |
*/ |
|
224 |
virtual bool isSimpleType() const; |
|
225 |
||
226 |
/** |
|
227 |
* Determines whether the type is a complex type, by introspecting |
|
228 |
* the result of category(). |
|
229 |
* |
|
230 |
* @note Do not re-implement this function, but instead override category() |
|
231 |
* and let it return an appropriate value. |
|
232 |
*/ |
|
233 |
virtual bool isComplexType() const; |
|
234 |
||
235 |
/** |
|
236 |
* Returns whether the value has been defined by a schema (is not a built in type). |
|
237 |
*/ |
|
238 |
virtual bool isDefinedBySchema() const; |
|
239 |
}; |
|
240 |
||
241 |
Q_DECLARE_OPERATORS_FOR_FLAGS(SchemaType::DerivationConstraints) |
|
242 |
} |
|
243 |
||
244 |
QT_END_NAMESPACE |
|
245 |
||
246 |
QT_END_HEADER |
|
247 |
||
248 |
#endif |