1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #include "qanyitemtype_p.h"
43 #include "qderivedinteger_p.h"
45 #include "qbuiltinatomictypes_p.h"
46 #include "qbuiltinnodetype_p.h"
47 #include "qbuiltintypes_p.h"
48 #include "qxsltnodetest_p.h"
50 /* Included here to avoid the static initialization failure. */
51 #include "qatomiccasterlocators.cpp"
52 #include "qatomiccomparatorlocators.cpp"
53 #include "qatomicmathematicianlocators.cpp"
57 using namespace QPatternist;
61 #define initType(var, cls) const cls::Ptr BuiltinTypes::var(new cls())
62 initType(item, AnyItemType);
63 initType(node, AnyNodeType);
66 #define initSType(var, cls) const SchemaType::Ptr BuiltinTypes::var(new cls())
67 initSType(xsAnyType, AnyType);
68 initSType(xsAnySimpleType, AnySimpleType);
69 initSType(xsUntyped, Untyped);
72 /* The primitive atomic types. */
73 #define at(className, varName) const AtomicType::Ptr BuiltinTypes::varName(new className());
74 at(AnyAtomicType, xsAnyAtomicType)
75 at(UntypedAtomicType, xsUntypedAtomic)
76 at(DateTimeType, xsDateTime)
78 at(SchemaTimeType, xsTime)
79 at(DurationType, xsDuration)
80 at(YearMonthDurationType, xsYearMonthDuration)
81 at(DayTimeDurationType, xsDayTimeDuration)
83 at(NumericType, numeric)
84 at(DecimalType, xsDecimal)
85 at(GYearMonthType, xsGYearMonth)
86 at(GYearType, xsGYear)
87 at(GMonthDayType, xsGMonthDay)
89 at(GMonthType, xsGMonth)
91 at(BooleanType, xsBoolean)
92 at(Base64BinaryType, xsBase64Binary)
93 at(AnyURIType, xsAnyURI)
95 #define it(className, varName) const ItemType::Ptr BuiltinTypes::varName(new className());
96 at(QNameType, xsQName)
97 at(HexBinaryType, xsHexBinary)
98 at(FloatType, xsFloat)
99 at(DoubleType, xsDouble)
102 const AtomicType::Ptr BuiltinTypes::xsString(new StringType(BuiltinTypes::xsAnyAtomicType,
103 AtomicCasterLocator::Ptr(new ToStringCasterLocator())));
105 #define dsType(varName, parent) \
106 const AtomicType::Ptr BuiltinTypes::xs ## varName \
107 (new DerivedStringType<Type ## varName>(BuiltinTypes::parent, \
108 AtomicCasterLocator::Ptr(new ToDerivedStringCasterLocator<Type ## varName>())))
110 dsType(NormalizedString, xsString);
111 dsType(Token, xsNormalizedString);
112 dsType(Language, xsToken);
113 dsType(NMTOKEN, xsToken);
114 dsType(Name, xsToken);
115 dsType(NCName, xsName);
116 dsType(ID, xsNCName);
117 dsType(IDREF, xsNCName);
118 dsType(ENTITY, xsNCName);
121 const AtomicType::Ptr BuiltinTypes::xsInteger(new IntegerType(BuiltinTypes::xsDecimal,
122 AtomicCasterLocator::Ptr(new ToIntegerCasterLocator())));
124 #define iType(varName, parent) \
125 const AtomicType::Ptr BuiltinTypes::xs ## varName \
126 (new DerivedIntegerType<Type ## varName>(parent, \
127 AtomicCasterLocator::Ptr(new ToDerivedIntegerCasterLocator<Type ## varName>())))
129 /* Initialize derived integers. The order of initialization is significant. */
130 iType(NonPositiveInteger, xsInteger);
131 iType(NegativeInteger, xsNonPositiveInteger);
132 iType(Long, xsInteger);
135 iType(Byte, xsShort);
136 iType(NonNegativeInteger, xsInteger);
137 iType(UnsignedLong, xsNonNegativeInteger);
138 iType(UnsignedInt, xsUnsignedLong);
139 iType(UnsignedShort, xsUnsignedInt);
140 iType(UnsignedByte, xsUnsignedShort);
141 iType(PositiveInteger, xsNonNegativeInteger);
144 at(NOTATIONType, xsNOTATION)
147 /* QXmlNodeModelIndex types */
148 #define nt(var, enu) const ItemType::Ptr BuiltinTypes::var = \
149 ItemType::Ptr(new BuiltinNodeType<QXmlNodeModelIndex::enu>())
151 nt(comment, Comment);
152 nt(attribute, Attribute);
153 nt(document, Document);
154 nt(element, Element);
156 nt(pi, ProcessingInstruction);
159 const ItemType::Ptr BuiltinTypes::xsltNodeTest(new XSLTNodeTest());