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#include "qanyitemtype_p.h"
41#include "qderivedinteger_p.h"
42
43#include "qbuiltinatomictypes_p.h"
44#include "qbuiltinnodetype_p.h"
45#include "qbuiltintypes_p.h"
46#include "qxsltnodetest_p.h"
47
48/* Included here to avoid the static initialization failure. */
49#include "qatomiccasterlocators.cpp"
50#include "qatomiccomparatorlocators.cpp"
51#include "qatomicmathematicianlocators.cpp"
52
53QT_BEGIN_NAMESPACE
54
55using namespace QPatternist;
56
57// STATIC DATA
58/* Special cases. */
59#define initType(var, cls) const cls::Ptr BuiltinTypes::var(new cls())
60initType(item, AnyItemType);
61initType(node, AnyNodeType);
62#undef initType
63
64#define initSType(var, cls) const SchemaType::Ptr BuiltinTypes::var(new cls())
65initSType(xsAnyType, AnyType);
66initSType(xsAnySimpleType, AnySimpleType);
67initSType(xsUntyped, Untyped);
68#undef initSType
69
70/* The primitive atomic types. */
71#define at(className, varName) const AtomicType::Ptr BuiltinTypes::varName(new className());
72at(AnyAtomicType, xsAnyAtomicType)
73at(UntypedAtomicType, xsUntypedAtomic)
74at(DateTimeType, xsDateTime)
75at(DateType, xsDate)
76at(SchemaTimeType, xsTime)
77at(DurationType, xsDuration)
78at(YearMonthDurationType, xsYearMonthDuration)
79at(DayTimeDurationType, xsDayTimeDuration)
80
81at(NumericType, numeric)
82at(DecimalType, xsDecimal)
83at(GYearMonthType, xsGYearMonth)
84at(GYearType, xsGYear)
85at(GMonthDayType, xsGMonthDay)
86at(GDayType, xsGDay)
87at(GMonthType, xsGMonth)
88
89at(BooleanType, xsBoolean)
90at(Base64BinaryType, xsBase64Binary)
91at(AnyURIType, xsAnyURI)
92
93#define it(className, varName) const ItemType::Ptr BuiltinTypes::varName(new className());
94at(QNameType, xsQName)
95at(HexBinaryType, xsHexBinary)
96at(FloatType, xsFloat)
97at(DoubleType, xsDouble)
98#undef it
99
100const AtomicType::Ptr BuiltinTypes::xsString(new StringType(BuiltinTypes::xsAnyAtomicType,
101 AtomicCasterLocator::Ptr(new ToStringCasterLocator())));
102
103#define dsType(varName, parent) \
104 const AtomicType::Ptr BuiltinTypes::xs ## varName \
105 (new DerivedStringType<Type ## varName>(BuiltinTypes::parent, \
106 AtomicCasterLocator::Ptr(new ToDerivedStringCasterLocator<Type ## varName>())))
107
108dsType(NormalizedString, xsString);
109dsType(Token, xsNormalizedString);
110dsType(Language, xsToken);
111dsType(NMTOKEN, xsToken);
112dsType(Name, xsToken);
113dsType(NCName, xsName);
114dsType(ID, xsNCName);
115dsType(IDREF, xsNCName);
116dsType(ENTITY, xsNCName);
117#undef sType
118
119const AtomicType::Ptr BuiltinTypes::xsInteger(new IntegerType(BuiltinTypes::xsDecimal,
120 AtomicCasterLocator::Ptr(new ToIntegerCasterLocator())));
121
122#define iType(varName, parent) \
123 const AtomicType::Ptr BuiltinTypes::xs ## varName \
124 (new DerivedIntegerType<Type ## varName>(parent, \
125 AtomicCasterLocator::Ptr(new ToDerivedIntegerCasterLocator<Type ## varName>())))
126
127/* Initialize derived integers. The order of initialization is significant. */
128iType(NonPositiveInteger, xsInteger);
129iType(NegativeInteger, xsNonPositiveInteger);
130iType(Long, xsInteger);
131iType(Int, xsLong);
132iType(Short, xsInt);
133iType(Byte, xsShort);
134iType(NonNegativeInteger, xsInteger);
135iType(UnsignedLong, xsNonNegativeInteger);
136iType(UnsignedInt, xsUnsignedLong);
137iType(UnsignedShort, xsUnsignedInt);
138iType(UnsignedByte, xsUnsignedShort);
139iType(PositiveInteger, xsNonNegativeInteger);
140#undef iType
141
142at(NOTATIONType, xsNOTATION)
143#undef at
144
145/* QXmlNodeModelIndex types */
146#define nt(var, enu) const ItemType::Ptr BuiltinTypes::var = \
147 ItemType::Ptr(new BuiltinNodeType<QXmlNodeModelIndex::enu>())
148
149nt(comment, Comment);
150nt(attribute, Attribute);
151nt(document, Document);
152nt(element, Element);
153nt(text, Text);
154nt(pi, ProcessingInstruction);
155#undef nt
156
157const ItemType::Ptr BuiltinTypes::xsltNodeTest(new XSLTNodeTest());
158
159QT_END_NAMESPACE
160

source code of qtxmlpatterns/src/xmlpatterns/type/qbuiltintypes.cpp