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