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 "qatomicmathematicianlocators_p.h" |
41 | #include "qbuiltintypes_p.h" |
42 | |
43 | #include "qbuiltinatomictypes_p.h" |
44 | |
45 | QT_BEGIN_NAMESPACE |
46 | |
47 | using namespace QPatternist; |
48 | |
49 | /* -------------------------------------------------------------- */ |
50 | #define implAccept(className) \ |
51 | AtomicTypeVisitorResult::Ptr className##Type::accept(const AtomicTypeVisitor::Ptr &v, \ |
52 | const SourceLocationReflection *const r) const \ |
53 | { \ |
54 | return v->visit(this, r); \ |
55 | } \ |
56 | \ |
57 | AtomicTypeVisitorResult::Ptr \ |
58 | className##Type::accept(const ParameterizedAtomicTypeVisitor::Ptr &v, \ |
59 | const qint16 op, \ |
60 | const SourceLocationReflection *const r) const \ |
61 | { \ |
62 | return v->visit(this, op, r); \ |
63 | } |
64 | |
65 | #define deployComp(className, qname, parent, comp, mather, caster) \ |
66 | className##Type::className##Type() : BuiltinAtomicType(BuiltinTypes::parent, \ |
67 | comp, \ |
68 | mather, \ |
69 | caster) \ |
70 | { \ |
71 | } \ |
72 | implAccept(className) |
73 | |
74 | #define deployBase(className, qname, parent) deployComp(className, qname, parent, \ |
75 | AtomicComparatorLocator::Ptr(), \ |
76 | AtomicMathematicianLocator::Ptr(), \ |
77 | AtomicCasterLocator::Ptr()) |
78 | |
79 | #define deployFull(className, qname, parent) \ |
80 | deployComp(className, qname, parent, \ |
81 | AtomicComparatorLocator::Ptr(new className##ComparatorLocator()), \ |
82 | AtomicMathematicianLocator::Ptr(), \ |
83 | AtomicCasterLocator::Ptr(new To##className##CasterLocator())) |
84 | |
85 | #define deployMathComp(className, qname, parent) \ |
86 | deployComp(className, qname, parent, \ |
87 | AtomicComparatorLocator::Ptr(new className##ComparatorLocator()), \ |
88 | AtomicMathematicianLocator::Ptr(new className##MathematicianLocator()), \ |
89 | AtomicCasterLocator::Ptr(new To##className##CasterLocator())) |
90 | /* -------------------------------------------------------------- */ |
91 | |
92 | /* -------------------------------------------------------------- */ |
93 | /* xs:anyURI & xs:untypedAtomic are much treated like strings. This ensures |
94 | * they get the correct operators and automatically takes care of type promotion. */ |
95 | deployComp(UntypedAtomic, xsUntypedAtomic, xsAnyAtomicType, |
96 | AtomicComparatorLocator::Ptr(new StringComparatorLocator()), |
97 | AtomicMathematicianLocator::Ptr(), |
98 | AtomicCasterLocator::Ptr(new ToUntypedAtomicCasterLocator())) |
99 | deployComp(AnyURI, xsAnyURI, xsAnyAtomicType, |
100 | AtomicComparatorLocator::Ptr(new StringComparatorLocator()), |
101 | AtomicMathematicianLocator::Ptr(), |
102 | AtomicCasterLocator::Ptr(new ToAnyURICasterLocator())) |
103 | |
104 | deployBase(NOTATION, xsNOTATION, xsAnyAtomicType) |
105 | |
106 | deployMathComp(Float, xsFloat, numeric) |
107 | deployMathComp(Double, xsDouble, numeric) |
108 | deployMathComp(Decimal, xsDecimal, numeric) |
109 | deployMathComp(DayTimeDuration, xsDayTimeDuration, xsDuration) |
110 | deployMathComp(YearMonthDuration, xsYearMonthDuration, xsDuration) |
111 | deployMathComp(Date, xsDate, xsAnyAtomicType) |
112 | deployMathComp(DateTime, xsDateTime, xsAnyAtomicType) |
113 | deployMathComp(SchemaTime, xsTime, xsAnyAtomicType) |
114 | |
115 | deployFull(Base64Binary, xsBase64Binary, xsAnyAtomicType) |
116 | deployFull(Boolean, xsBoolean, xsAnyAtomicType) |
117 | deployFull(Duration, xsDuration, xsAnyAtomicType) |
118 | deployFull(GDay, xsGDay, xsAnyAtomicType) |
119 | deployFull(GMonth, xsGMonth, xsAnyAtomicType) |
120 | deployFull(GMonthDay, xsGMonthDay, xsAnyAtomicType) |
121 | deployFull(GYear, xsGYear, xsAnyAtomicType) |
122 | deployFull(GYearMonth, xsGYearMonth, xsAnyAtomicType) |
123 | deployFull(HexBinary, xsHexBinary, xsAnyAtomicType) |
124 | deployFull(QName, xsQName, xsAnyAtomicType) |
125 | /* --------------------------------------------------------------- */ |
126 | |
127 | /* --------------------------------------------------------------- */ |
128 | StringType::StringType(const AtomicType::Ptr &pType, |
129 | const AtomicCasterLocator::Ptr &casterLoc) |
130 | : BuiltinAtomicType(pType, |
131 | AtomicComparatorLocator::Ptr(new StringComparatorLocator()), |
132 | AtomicMathematicianLocator::Ptr(), |
133 | casterLoc) |
134 | { |
135 | } |
136 | implAccept(String) |
137 | /* --------------------------------------------------------------- */ |
138 | |
139 | /* --------------------------------------------------------------- */ |
140 | IntegerType::IntegerType(const AtomicType::Ptr &pType, |
141 | const AtomicCasterLocator::Ptr &casterLoc) |
142 | : BuiltinAtomicType(pType, |
143 | AtomicComparatorLocator::Ptr(new IntegerComparatorLocator()), |
144 | AtomicMathematicianLocator::Ptr(new IntegerMathematicianLocator()), |
145 | casterLoc) |
146 | { |
147 | } |
148 | implAccept(Integer) |
149 | /* --------------------------------------------------------------- */ |
150 | |
151 | /* ---------------------- Special Overrides ---------------------- */ |
152 | AnyAtomicType::AnyAtomicType() : BuiltinAtomicType(AtomicType::Ptr(), |
153 | AtomicComparatorLocator::Ptr(), |
154 | AtomicMathematicianLocator::Ptr(), |
155 | AtomicCasterLocator::Ptr()) |
156 | { |
157 | } |
158 | implAccept(AnyAtomic) |
159 | |
160 | ItemType::Ptr AnyAtomicType::xdtSuperType() const |
161 | { |
162 | return BuiltinTypes::item; |
163 | } |
164 | |
165 | SchemaType::Ptr AnyAtomicType::wxsSuperType() const |
166 | { |
167 | return BuiltinTypes::xsAnySimpleType; |
168 | } |
169 | |
170 | bool AnyAtomicType::isAbstract() const |
171 | { |
172 | return true; |
173 | } |
174 | |
175 | bool NOTATIONType::isAbstract() const |
176 | { |
177 | return true; |
178 | } |
179 | |
180 | #define implementName(className, typeName) \ |
181 | QXmlName className##Type::name(const NamePool::Ptr &np) const \ |
182 | { \ |
183 | return np->allocateQName(StandardNamespaces::xs, typeName); \ |
184 | } \ |
185 | \ |
186 | QString className##Type::displayName(const NamePool::Ptr &np) const \ |
187 | { \ |
188 | return np->displayName(name(np)); \ |
189 | } |
190 | |
191 | implementName(AnyAtomic, QLatin1String("anyAtomicType" )) |
192 | implementName(AnyURI, QLatin1String("anyURI" )) |
193 | implementName(Base64Binary, QLatin1String("base64Binary" )) |
194 | implementName(Boolean, QLatin1String("boolean" )) |
195 | implementName(Date, QLatin1String("date" )) |
196 | implementName(DateTime, QLatin1String("dateTime" )) |
197 | implementName(DayTimeDuration, QLatin1String("dayTimeDuration" )) |
198 | implementName(Decimal, QLatin1String("decimal" )) |
199 | implementName(Double, QLatin1String("double" )) |
200 | implementName(Duration, QLatin1String("duration" )) |
201 | implementName(Float, QLatin1String("float" )) |
202 | implementName(GDay, QLatin1String("gDay" )) |
203 | implementName(GMonthDay, QLatin1String("gMonthDay" )) |
204 | implementName(GMonth, QLatin1String("gMonth" )) |
205 | implementName(GYearMonth, QLatin1String("gYearMonth" )) |
206 | implementName(GYear, QLatin1String("gYear" )) |
207 | implementName(HexBinary, QLatin1String("hexBinary" )) |
208 | implementName(Integer, QLatin1String("integer" )) |
209 | implementName(NOTATION, QLatin1String("NOTATION" )) |
210 | implementName(QName, QLatin1String("QName" )) |
211 | implementName(String, QLatin1String("string" )) |
212 | implementName(SchemaTime, QLatin1String("time" )) |
213 | implementName(UntypedAtomic, QLatin1String("untypedAtomic" )) |
214 | implementName(YearMonthDuration, QLatin1String("yearMonthDuration" )) |
215 | /* --------------------------------------------------------------- */ |
216 | |
217 | #undef implAccept |
218 | #undef implementName |
219 | #undef deployComp |
220 | #undef deployBase |
221 | #undef deployFull |
222 | #undef deployMathComp |
223 | |
224 | QT_END_NAMESPACE |
225 | |