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