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
45QT_BEGIN_NAMESPACE
46
47using namespace QPatternist;
48
49/* -------------------------------------------------------------- */
50#define implAccept(className) \
51AtomicTypeVisitorResult::Ptr className##Type::accept(const AtomicTypeVisitor::Ptr &v, \
52 const SourceLocationReflection *const r) const \
53{ \
54 return v->visit(this, r); \
55} \
56 \
57AtomicTypeVisitorResult::Ptr \
58className##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) \
66className##Type::className##Type() : BuiltinAtomicType(BuiltinTypes::parent, \
67 comp, \
68 mather, \
69 caster) \
70{ \
71} \
72implAccept(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) \
80deployComp(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) \
86deployComp(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. */
95deployComp(UntypedAtomic, xsUntypedAtomic, xsAnyAtomicType,
96 AtomicComparatorLocator::Ptr(new StringComparatorLocator()),
97 AtomicMathematicianLocator::Ptr(),
98 AtomicCasterLocator::Ptr(new ToUntypedAtomicCasterLocator()))
99deployComp(AnyURI, xsAnyURI, xsAnyAtomicType,
100 AtomicComparatorLocator::Ptr(new StringComparatorLocator()),
101 AtomicMathematicianLocator::Ptr(),
102 AtomicCasterLocator::Ptr(new ToAnyURICasterLocator()))
103
104deployBase(NOTATION, xsNOTATION, xsAnyAtomicType)
105
106deployMathComp(Float, xsFloat, numeric)
107deployMathComp(Double, xsDouble, numeric)
108deployMathComp(Decimal, xsDecimal, numeric)
109deployMathComp(DayTimeDuration, xsDayTimeDuration, xsDuration)
110deployMathComp(YearMonthDuration, xsYearMonthDuration, xsDuration)
111deployMathComp(Date, xsDate, xsAnyAtomicType)
112deployMathComp(DateTime, xsDateTime, xsAnyAtomicType)
113deployMathComp(SchemaTime, xsTime, xsAnyAtomicType)
114
115deployFull(Base64Binary, xsBase64Binary, xsAnyAtomicType)
116deployFull(Boolean, xsBoolean, xsAnyAtomicType)
117deployFull(Duration, xsDuration, xsAnyAtomicType)
118deployFull(GDay, xsGDay, xsAnyAtomicType)
119deployFull(GMonth, xsGMonth, xsAnyAtomicType)
120deployFull(GMonthDay, xsGMonthDay, xsAnyAtomicType)
121deployFull(GYear, xsGYear, xsAnyAtomicType)
122deployFull(GYearMonth, xsGYearMonth, xsAnyAtomicType)
123deployFull(HexBinary, xsHexBinary, xsAnyAtomicType)
124deployFull(QName, xsQName, xsAnyAtomicType)
125/* --------------------------------------------------------------- */
126
127/* --------------------------------------------------------------- */
128StringType::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}
136implAccept(String)
137/* --------------------------------------------------------------- */
138
139/* --------------------------------------------------------------- */
140IntegerType::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}
148implAccept(Integer)
149/* --------------------------------------------------------------- */
150
151/* ---------------------- Special Overrides ---------------------- */
152AnyAtomicType::AnyAtomicType() : BuiltinAtomicType(AtomicType::Ptr(),
153 AtomicComparatorLocator::Ptr(),
154 AtomicMathematicianLocator::Ptr(),
155 AtomicCasterLocator::Ptr())
156{
157}
158implAccept(AnyAtomic)
159
160ItemType::Ptr AnyAtomicType::xdtSuperType() const
161{
162 return BuiltinTypes::item;
163}
164
165SchemaType::Ptr AnyAtomicType::wxsSuperType() const
166{
167 return BuiltinTypes::xsAnySimpleType;
168}
169
170bool AnyAtomicType::isAbstract() const
171{
172 return true;
173}
174
175bool NOTATIONType::isAbstract() const
176{
177 return true;
178}
179
180#define implementName(className, typeName) \
181QXmlName className##Type::name(const NamePool::Ptr &np) const \
182{ \
183 return np->allocateQName(StandardNamespaces::xs, typeName); \
184} \
185 \
186QString className##Type::displayName(const NamePool::Ptr &np) const \
187{ \
188 return np->displayName(name(np)); \
189}
190
191implementName(AnyAtomic, QLatin1String("anyAtomicType"))
192implementName(AnyURI, QLatin1String("anyURI"))
193implementName(Base64Binary, QLatin1String("base64Binary"))
194implementName(Boolean, QLatin1String("boolean"))
195implementName(Date, QLatin1String("date"))
196implementName(DateTime, QLatin1String("dateTime"))
197implementName(DayTimeDuration, QLatin1String("dayTimeDuration"))
198implementName(Decimal, QLatin1String("decimal"))
199implementName(Double, QLatin1String("double"))
200implementName(Duration, QLatin1String("duration"))
201implementName(Float, QLatin1String("float"))
202implementName(GDay, QLatin1String("gDay"))
203implementName(GMonthDay, QLatin1String("gMonthDay"))
204implementName(GMonth, QLatin1String("gMonth"))
205implementName(GYearMonth, QLatin1String("gYearMonth"))
206implementName(GYear, QLatin1String("gYear"))
207implementName(HexBinary, QLatin1String("hexBinary"))
208implementName(Integer, QLatin1String("integer"))
209implementName(NOTATION, QLatin1String("NOTATION"))
210implementName(QName, QLatin1String("QName"))
211implementName(String, QLatin1String("string"))
212implementName(SchemaTime, QLatin1String("time"))
213implementName(UntypedAtomic, QLatin1String("untypedAtomic"))
214implementName(YearMonthDuration, QLatin1String("yearMonthDuration"))
215/* --------------------------------------------------------------- */
216
217#undef implAccept
218#undef implementName
219#undef deployComp
220#undef deployBase
221#undef deployFull
222#undef deployMathComp
223
224QT_END_NAMESPACE
225

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