Update obsolete contact address.
[profile/ivi/qtxmlpatterns.git] / src / xmlpatterns / type / qbuiltinatomictypes_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
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_BuiltinAtomicTypes_H
53 #define Patternist_BuiltinAtomicTypes_H
54
55 #include <private/qatomiccasterlocators_p.h>
56 #include <private/qatomiccomparatorlocators_p.h>
57 #include <private/qbuiltinatomictype_p.h>
58
59 QT_BEGIN_HEADER
60
61 QT_BEGIN_NAMESPACE
62
63 namespace QPatternist
64 {
65
66     /**
67      * @short Implements the type @c xs:anyAtomicType.
68      *
69      * @ingroup Patternist_types
70      * @author Frans Englich <frans.englich@nokia.com>
71      */
72     class AnyAtomicType : public BuiltinAtomicType
73     {
74     public:
75         typedef QExplicitlySharedDataPointer<AnyAtomicType> Ptr;
76
77         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
78                                                     const SourceLocationReflection *const reflection) const;
79         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
80                                                     const qint16 op,
81                                                     const SourceLocationReflection *const reflection) const;
82         virtual QXmlName name(const NamePool::Ptr &np) const;
83         virtual QString displayName(const NamePool::Ptr &np) const;
84
85         /**
86          * Overridden to return <tt>item()</tt>.
87          *
88          * @returns BuiltinTypes::item
89          */
90         virtual ItemType::Ptr xdtSuperType() const;
91
92         /**
93          * Overridden to return @c xs:anySimpleType.
94          *
95          * @returns BuiltinTypes::xsAnySimpleType
96          */
97         virtual SchemaType::Ptr wxsSuperType() const;
98
99         /**
100          * Overridden to return @c true, @c xs:anyAtomicType is abstract.
101          *
102          * @returns always @c true
103          */
104         virtual bool isAbstract() const;
105
106     protected:
107         friend class BuiltinTypes;
108         AnyAtomicType();
109     };
110
111     /**
112      * @short Implements the type @c xs:untypedAtomic.
113      *
114      * @ingroup Patternist_types
115      * @author Frans Englich <frans.englich@nokia.com>
116      */
117     class UntypedAtomicType : public BuiltinAtomicType
118     {
119     public:
120         typedef QExplicitlySharedDataPointer<UntypedAtomicType> Ptr;
121
122         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
123                                                     const SourceLocationReflection *const reflection) const;
124         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
125                                                     const qint16 op,
126                                                     const SourceLocationReflection *const reflection) const;
127         virtual QXmlName name(const NamePool::Ptr &np) const;
128         virtual QString displayName(const NamePool::Ptr &np) const;
129
130     protected:
131         friend class BuiltinTypes;
132         UntypedAtomicType();
133     };
134
135     /**
136      * @short Implements the type @c xs:dateTime.
137      *
138      * @ingroup Patternist_types
139      * @author Frans Englich <frans.englich@nokia.com>
140      */
141     class DateTimeType : public BuiltinAtomicType
142     {
143     public:
144         typedef QExplicitlySharedDataPointer<DateTimeType> Ptr;
145
146         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
147                                                     const SourceLocationReflection *const reflection) const;
148         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
149                                                     const qint16 op,
150                                                     const SourceLocationReflection *const reflection) const;
151
152         virtual QXmlName name(const NamePool::Ptr &np) const;
153         virtual QString displayName(const NamePool::Ptr &np) const;
154     protected:
155         friend class BuiltinTypes;
156         DateTimeType();
157     };
158
159     /**
160      * @short Implements the type @c xs:date.
161      *
162      * @ingroup Patternist_types
163      * @author Frans Englich <frans.englich@nokia.com>
164      */
165     class DateType : public BuiltinAtomicType
166     {
167     public:
168         typedef QExplicitlySharedDataPointer<DateType> Ptr;
169
170         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
171                                                     const SourceLocationReflection *const reflection) const;
172         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
173                                                     const qint16 op,
174                                                     const SourceLocationReflection *const reflection) const;
175         virtual QXmlName name(const NamePool::Ptr &np) const;
176         virtual QString displayName(const NamePool::Ptr &np) const;
177
178     protected:
179         friend class BuiltinTypes;
180         DateType();
181     };
182
183     /**
184      * @short Implements the type @c xs:time.
185      *
186      * @ingroup Patternist_types
187      * @author Frans Englich <frans.englich@nokia.com>
188      */
189     class SchemaTimeType : public BuiltinAtomicType
190     {
191     public:
192         typedef QExplicitlySharedDataPointer<SchemaTimeType> Ptr;
193
194         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
195                                                     const SourceLocationReflection *const reflection) const;
196         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
197                                                     const qint16 op,
198                                                     const SourceLocationReflection *const reflection) const;
199
200         virtual QXmlName name(const NamePool::Ptr &np) const;
201         virtual QString displayName(const NamePool::Ptr &np) const;
202
203     protected:
204         friend class BuiltinTypes;
205         SchemaTimeType();
206     };
207
208     /**
209      * @short Implements the type @c xs:duration.
210      *
211      * @ingroup Patternist_types
212      * @author Frans Englich <frans.englich@nokia.com>
213      */
214     class DurationType : public BuiltinAtomicType
215     {
216     public:
217         typedef QExplicitlySharedDataPointer<DurationType> Ptr;
218
219         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
220                                                     const SourceLocationReflection *const reflection) const;
221         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
222                                                     const qint16 op,
223                                                     const SourceLocationReflection *const reflection) const;
224         virtual QXmlName name(const NamePool::Ptr &np) const;
225         virtual QString displayName(const NamePool::Ptr &np) const;
226
227     protected:
228         friend class BuiltinTypes;
229         DurationType();
230     };
231
232     /**
233      * @short Implements the type @c xs:yearMonthDuration.
234      *
235      * @ingroup Patternist_types
236      * @author Frans Englich <frans.englich@nokia.com>
237      */
238     class YearMonthDurationType : public BuiltinAtomicType
239     {
240     public:
241         typedef QExplicitlySharedDataPointer<YearMonthDurationType> Ptr;
242
243         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
244                                                     const SourceLocationReflection *const reflection) const;
245         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
246                                                     const qint16 op,
247                                                     const SourceLocationReflection *const reflection) const;
248         virtual QXmlName name(const NamePool::Ptr &np) const;
249         virtual QString displayName(const NamePool::Ptr &np) const;
250
251     protected:
252         friend class BuiltinTypes;
253         YearMonthDurationType();
254     };
255
256     /**
257      * @short Implements the type @c xs:dayTimeDuration.
258      *
259      * @ingroup Patternist_types
260      * @author Frans Englich <frans.englich@nokia.com>
261      */
262     class DayTimeDurationType : public BuiltinAtomicType
263     {
264     public:
265         typedef QExplicitlySharedDataPointer<DayTimeDurationType> Ptr;
266
267         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
268                                                     const SourceLocationReflection *const reflection) const;
269         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
270                                                     const qint16 op,
271                                                     const SourceLocationReflection *const reflection) const;
272         virtual QXmlName name(const NamePool::Ptr &np) const;
273         virtual QString displayName(const NamePool::Ptr &np) const;
274
275     protected:
276         friend class BuiltinTypes;
277         DayTimeDurationType();
278     };
279
280     /**
281      * @short Implements the type @c xs:double.
282      *
283      * @ingroup Patternist_types
284      * @author Frans Englich <frans.englich@nokia.com>
285      */
286     class DoubleType : public BuiltinAtomicType
287     {
288     public:
289         typedef QExplicitlySharedDataPointer<DoubleType> Ptr;
290
291         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
292                                                     const SourceLocationReflection *const reflection) const;
293         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
294                                                     const qint16 op,
295                                                     const SourceLocationReflection *const reflection) const;
296         virtual QXmlName name(const NamePool::Ptr &np) const;
297         virtual QString displayName(const NamePool::Ptr &np) const;
298
299     protected:
300         friend class BuiltinTypes;
301         DoubleType();
302     };
303
304     /**
305      * @short Implements the type @c xs:float.
306      *
307      * @ingroup Patternist_types
308      * @author Frans Englich <frans.englich@nokia.com>
309      */
310     class FloatType : public BuiltinAtomicType
311     {
312     public:
313         typedef QExplicitlySharedDataPointer<FloatType> Ptr;
314
315         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
316                                                     const SourceLocationReflection *const reflection) const;
317         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
318                                                     const qint16 op,
319                                                     const SourceLocationReflection *const reflection) const;
320         virtual QXmlName name(const NamePool::Ptr &np) const;
321         virtual QString displayName(const NamePool::Ptr &np) const;
322
323     protected:
324         FloatType();
325         friend class BuiltinTypes;
326     };
327
328     /**
329      * @short Implements the type @c xs:decimal.
330      *
331      * @ingroup Patternist_types
332      * @author Frans Englich <frans.englich@nokia.com>
333      */
334     class DecimalType : public BuiltinAtomicType
335     {
336     public:
337         typedef QExplicitlySharedDataPointer<DecimalType> Ptr;
338
339         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
340                                                     const SourceLocationReflection *const reflection) const;
341         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
342                                                     const qint16 op,
343                                                     const SourceLocationReflection *const reflection) const;
344         virtual QXmlName name(const NamePool::Ptr &np) const;
345         virtual QString displayName(const NamePool::Ptr &np) const;
346
347     protected:
348         friend class BuiltinTypes;
349         DecimalType();
350     };
351
352     /**
353      * @short Implements the type @c xs:integer.
354      *
355      * IntegerType instances are used for representing all different xs:integer
356      * types. The purpose of this is that xs:integer sub-types must use the
357      * class, IntegerType, in order to use the correct behavior in call
358      * dispatch situations. That is, all xs:integer sub-types must use the
359      * same AtomicComparator as xs:integer itself uses, and that is achieved
360      * this way.
361      *
362      * @ingroup Patternist_types
363      * @author Frans Englich <frans.englich@nokia.com>
364      */
365     class IntegerType : public BuiltinAtomicType
366     {
367     public:
368         typedef QExplicitlySharedDataPointer<IntegerType> Ptr;
369
370         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
371                                                     const SourceLocationReflection *const reflection) const;
372         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
373                                                     const qint16 op,
374                                                     const SourceLocationReflection *const reflection) const;
375         virtual QXmlName name(const NamePool::Ptr &np) const;
376         virtual QString displayName(const NamePool::Ptr &np) const;
377
378     protected:
379         friend class BuiltinTypes;
380         IntegerType(const AtomicType::Ptr &parentType,
381                     const AtomicCasterLocator::Ptr &casterLocator);
382     };
383
384     template<TypeOfDerivedInteger derivedType>
385     class DerivedIntegerType : public IntegerType
386     {
387     public:
388         using IntegerType::accept;
389
390         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &v,
391                                                     const SourceLocationReflection *const r) const
392         {
393             return v->visit(this, r);
394         }
395
396         virtual QXmlName name(const NamePool::Ptr &np) const
397         {
398             switch(derivedType)
399             {
400                 case TypeByte:                  return np->allocateQName(StandardNamespaces::xs, QLatin1String("byte"));
401                 case TypeInt:                   return np->allocateQName(StandardNamespaces::xs, QLatin1String("int"));
402                 case TypeLong:                  return np->allocateQName(StandardNamespaces::xs, QLatin1String("long"));
403                 case TypeNegativeInteger:       return np->allocateQName(StandardNamespaces::xs, QLatin1String("negativeInteger"));
404                 case TypeNonNegativeInteger:    return np->allocateQName(StandardNamespaces::xs, QLatin1String("nonNegativeInteger"));
405                 case TypeNonPositiveInteger:    return np->allocateQName(StandardNamespaces::xs, QLatin1String("nonPositiveInteger"));
406                 case TypePositiveInteger:       return np->allocateQName(StandardNamespaces::xs, QLatin1String("positiveInteger"));
407                 case TypeShort:                 return np->allocateQName(StandardNamespaces::xs, QLatin1String("short"));
408                 case TypeUnsignedByte:          return np->allocateQName(StandardNamespaces::xs, QLatin1String("unsignedByte"));
409                 case TypeUnsignedInt:           return np->allocateQName(StandardNamespaces::xs, QLatin1String("unsignedInt"));
410                 case TypeUnsignedLong:          return np->allocateQName(StandardNamespaces::xs, QLatin1String("unsignedLong"));
411                 case TypeUnsignedShort:         return np->allocateQName(StandardNamespaces::xs, QLatin1String("unsignedShort"));
412             }
413
414             Q_ASSERT_X(false, "DerivedIntegerType::name()", "Invalid value in instantiation.");
415             return QXmlName();
416         }
417
418         virtual QString displayName(const NamePool::Ptr &np) const
419         {
420             return np->displayName(name(np));
421         }
422
423     protected:
424         friend class BuiltinTypes;
425
426         DerivedIntegerType(const AtomicType::Ptr &parentType,
427                            const AtomicCasterLocator::Ptr &casterLoc) : IntegerType(parentType, casterLoc)
428         {
429         }
430
431     };
432
433     /**
434      * @short Implements the type @c xs:gYearMonth.
435      *
436      * @ingroup Patternist_types
437      * @author Frans Englich <frans.englich@nokia.com>
438      */
439     class GYearMonthType : public BuiltinAtomicType
440     {
441     public:
442         typedef QExplicitlySharedDataPointer<GYearMonthType> Ptr;
443
444         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
445                                                     const SourceLocationReflection *const reflection) const;
446         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
447                                                     const qint16 op,
448                                                     const SourceLocationReflection *const reflection) const;
449         virtual QXmlName name(const NamePool::Ptr &np) const;
450         virtual QString displayName(const NamePool::Ptr &np) const;
451
452     protected:
453         friend class BuiltinTypes;
454         GYearMonthType();
455     };
456
457     /**
458      * @short Implements the type @c xs:gYear.
459      *
460      * @ingroup Patternist_types
461      * @author Frans Englich <frans.englich@nokia.com>
462      */
463     class GYearType : public BuiltinAtomicType
464     {
465     public:
466         typedef QExplicitlySharedDataPointer<GYearType> Ptr;
467
468         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
469                                                     const SourceLocationReflection *const reflection) const;
470         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
471                                                     const qint16 op,
472                                                     const SourceLocationReflection *const reflection) const;
473         virtual QXmlName name(const NamePool::Ptr &np) const;
474         virtual QString displayName(const NamePool::Ptr &np) const;
475
476     protected:
477         friend class BuiltinTypes;
478         GYearType();
479     };
480
481     /**
482      * @short Implements the type @c xs:gMonthDay.
483      *
484      * @ingroup Patternist_types
485      * @author Frans Englich <frans.englich@nokia.com>
486      */
487     class GMonthDayType : public BuiltinAtomicType
488     {
489     public:
490         typedef QExplicitlySharedDataPointer<GMonthDayType> Ptr;
491
492         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
493                                                     const SourceLocationReflection *const reflection) const;
494         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
495                                                     const qint16 op,
496                                                     const SourceLocationReflection *const reflection) const;
497         virtual QXmlName name(const NamePool::Ptr &np) const;
498         virtual QString displayName(const NamePool::Ptr &np) const;
499
500     protected:
501         friend class BuiltinTypes;
502         GMonthDayType();
503     };
504
505     /**
506      * @short Implements the type @c xs:gDay.
507      *
508      * @ingroup Patternist_types
509      * @author Frans Englich <frans.englich@nokia.com>
510      */
511     class GDayType : public BuiltinAtomicType
512     {
513     public:
514         typedef QExplicitlySharedDataPointer<GDayType> Ptr;
515
516         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
517                                                     const SourceLocationReflection *const reflection) const;
518         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
519                                                     const qint16 op,
520                                                     const SourceLocationReflection *const reflection) const;
521         virtual QXmlName name(const NamePool::Ptr &np) const;
522         virtual QString displayName(const NamePool::Ptr &np) const;
523
524     protected:
525         friend class BuiltinTypes;
526         GDayType();
527     };
528
529     /**
530      * @short Implements the type @c xs:gMonth.
531      *
532      * @ingroup Patternist_types
533      * @author Frans Englich <frans.englich@nokia.com>
534      */
535     class GMonthType : public BuiltinAtomicType
536     {
537     public:
538         typedef QExplicitlySharedDataPointer<GMonthType> Ptr;
539
540         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
541                                                     const SourceLocationReflection *const reflection) const;
542         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
543                                                     const qint16 op,
544                                                     const SourceLocationReflection *const reflection) const;
545         virtual QXmlName name(const NamePool::Ptr &np) const;
546         virtual QString displayName(const NamePool::Ptr &np) const;
547
548     protected:
549         friend class BuiltinTypes;
550         GMonthType();
551     };
552
553     /**
554      * @short Implements the type @c xs:boolean.
555      *
556      * @ingroup Patternist_types
557      * @author Frans Englich <frans.englich@nokia.com>
558      */
559     class BooleanType : public BuiltinAtomicType
560     {
561     public:
562         typedef QExplicitlySharedDataPointer<BooleanType> Ptr;
563
564         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
565                                                     const SourceLocationReflection *const reflection) const;
566         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
567                                                     const qint16 op,
568                                                     const SourceLocationReflection *const reflection) const;
569         virtual QXmlName name(const NamePool::Ptr &np) const;
570         virtual QString displayName(const NamePool::Ptr &np) const;
571
572     protected:
573         friend class BuiltinTypes;
574         BooleanType();
575     };
576
577     /**
578      * @short Implements the type @c xs:base64Binary.
579      *
580      * @ingroup Patternist_types
581      * @author Frans Englich <frans.englich@nokia.com>
582      */
583     class Base64BinaryType : public BuiltinAtomicType
584     {
585     public:
586         typedef QExplicitlySharedDataPointer<Base64BinaryType> Ptr;
587
588         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
589                                                     const SourceLocationReflection *const reflection) const;
590         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
591                                                     const qint16 op,
592                                                     const SourceLocationReflection *const reflection) const;
593         virtual QXmlName name(const NamePool::Ptr &np) const;
594         virtual QString displayName(const NamePool::Ptr &np) const;
595
596     protected:
597         friend class BuiltinTypes;
598         Base64BinaryType();
599     };
600
601     /**
602      * @short Implements the type @c xs:hexBinary.
603      *
604      * @ingroup Patternist_types
605      * @author Frans Englich <frans.englich@nokia.com>
606      */
607     class HexBinaryType : public BuiltinAtomicType
608     {
609     public:
610         typedef QExplicitlySharedDataPointer<HexBinaryType> Ptr;
611
612         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
613                                                     const SourceLocationReflection *const reflection) const;
614         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
615                                                     const qint16 op,
616                                                     const SourceLocationReflection *const reflection) const;
617         virtual QXmlName name(const NamePool::Ptr &np) const;
618         virtual QString displayName(const NamePool::Ptr &np) const;
619
620     protected:
621         friend class BuiltinTypes;
622         HexBinaryType();
623     };
624
625     /**
626      * @short Implements the type @c xs:anyURI.
627      *
628      * @ingroup Patternist_types
629      * @author Frans Englich <frans.englich@nokia.com>
630      */
631     class AnyURIType : public BuiltinAtomicType
632     {
633     public:
634         typedef QExplicitlySharedDataPointer<AnyURIType> Ptr;
635
636         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
637                                                     const SourceLocationReflection *const reflection) const;
638         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
639                                                     const qint16 op,
640                                                     const SourceLocationReflection *const reflection) const;
641         virtual QXmlName name(const NamePool::Ptr &np) const;
642         virtual QString displayName(const NamePool::Ptr &np) const;
643
644     protected:
645         friend class BuiltinTypes;
646         AnyURIType();
647     };
648
649     /**
650      * @short Implements the type @c xs:QName.
651      *
652      * @ingroup Patternist_types
653      * @author Frans Englich <frans.englich@nokia.com>
654      */
655     class QNameType : public BuiltinAtomicType
656     {
657     public:
658         typedef QExplicitlySharedDataPointer<QNameType> Ptr;
659
660         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
661                                                     const SourceLocationReflection *const reflection) const;
662         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
663                                                     const qint16 op,
664                                                     const SourceLocationReflection *const reflection) const;
665         virtual QXmlName name(const NamePool::Ptr &np) const;
666         virtual QString displayName(const NamePool::Ptr &np) const;
667
668     protected:
669         friend class BuiltinTypes;
670         QNameType();
671     };
672
673     /**
674      * Represents the xs:string type and all derived types of
675      * xs:string, such as xs:token.
676      *
677      * StringType instances are used for representing all different string
678      * types. The purpose of this is that xs:string sub-types must use the
679      * class, StringType, in order to use the correct behavior in call
680      * dispatch situations. That is, all xs:string sub-types must use the
681      * same AtomicComparator as xs:string itself uses, and that is achieved
682      * this way.
683      *
684      * @ingroup Patternist_types
685      * @author Frans Englich <frans.englich@nokia.com>
686      */
687     class StringType : public BuiltinAtomicType
688     {
689     public:
690         typedef QExplicitlySharedDataPointer<StringType> Ptr;
691
692         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
693                                                     const SourceLocationReflection *const reflection) const;
694         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
695                                                     const qint16 op,
696                                                     const SourceLocationReflection *const reflection) const;
697         virtual QXmlName name(const NamePool::Ptr &np) const;
698         virtual QString displayName(const NamePool::Ptr &np) const;
699
700     protected:
701         friend class BuiltinTypes;
702         StringType(const AtomicType::Ptr &parentType,
703                    const AtomicCasterLocator::Ptr &casterLoc);
704     };
705
706     template<TypeOfDerivedString derivedType>
707     class DerivedStringType : public StringType
708     {
709     public:
710         using StringType::accept;
711
712         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &v,
713                                                     const SourceLocationReflection *const r) const
714         {
715             return v->visit(this, r);
716         }
717
718         virtual QXmlName name(const NamePool::Ptr &np) const
719         {
720             switch(derivedType)
721             {
722                 case TypeString:            return np->allocateQName(StandardNamespaces::xs, QLatin1String("string"));
723                 case TypeNormalizedString:  return np->allocateQName(StandardNamespaces::xs, QLatin1String("normalizedString"));
724                 case TypeToken:             return np->allocateQName(StandardNamespaces::xs, QLatin1String("token"));
725                 case TypeLanguage:          return np->allocateQName(StandardNamespaces::xs, QLatin1String("language"));
726                 case TypeNMTOKEN:           return np->allocateQName(StandardNamespaces::xs, QLatin1String("NMTOKEN"));
727                 case TypeName:              return np->allocateQName(StandardNamespaces::xs, QLatin1String("Name"));
728                 case TypeNCName:            return np->allocateQName(StandardNamespaces::xs, QLatin1String("NCName"));
729                 case TypeID:                return np->allocateQName(StandardNamespaces::xs, QLatin1String("ID"));
730                 case TypeIDREF:             return np->allocateQName(StandardNamespaces::xs, QLatin1String("IDREF"));
731                 case TypeENTITY:            return np->allocateQName(StandardNamespaces::xs, QLatin1String("ENTITY"));
732             }
733
734             Q_ASSERT_X(false, "DerivedStringType::name()", "Invalid value in instantiation.");
735             return QXmlName();
736         }
737
738         virtual QString displayName(const NamePool::Ptr &np) const
739         {
740             return np->displayName(name(np));
741         }
742
743     protected:
744         friend class BuiltinTypes;
745
746         DerivedStringType(const AtomicType::Ptr &parentType,
747                           const AtomicCasterLocator::Ptr &casterLoc) : StringType(parentType, casterLoc)
748         {
749         }
750
751     };
752
753     /**
754      * @short Implements the type @c xs:NOTATION.
755      *
756      * @ingroup Patternist_types
757      * @author Frans Englich <frans.englich@nokia.com>
758      */
759     class NOTATIONType : public BuiltinAtomicType
760     {
761     public:
762         typedef QExplicitlySharedDataPointer<NOTATIONType> Ptr;
763
764         virtual AtomicTypeVisitorResult::Ptr accept(const AtomicTypeVisitor::Ptr &visitor,
765                                                     const SourceLocationReflection *const reflection) const;
766         virtual AtomicTypeVisitorResult::Ptr accept(const ParameterizedAtomicTypeVisitor::Ptr &visitor,
767                                                     const qint16 op,
768                                                     const SourceLocationReflection *const reflection) const;
769         virtual QXmlName name(const NamePool::Ptr &np) const;
770         virtual QString displayName(const NamePool::Ptr &np) const;
771
772         /**
773          * Overridden to return @c true, xs:NOTATION is abstract.
774          *
775          * @returns always @c true
776          */
777         virtual bool isAbstract() const;
778
779     protected:
780         friend class BuiltinTypes;
781         NOTATIONType();
782     };
783 }
784
785 QT_END_NAMESPACE
786
787 QT_END_HEADER
788
789 #endif