source: trunk/src/xmlpatterns/data/qderivedinteger_p.h@ 617

Last change on this file since 617 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 21.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtXmlPatterns module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists purely as an
47// implementation detail. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51
52#ifndef Patternist_DerivedInteger_H
53#define Patternist_DerivedInteger_H
54
55#include "qbuiltintypes_p.h"
56#include "qinteger_p.h"
57#include "qpatternistlocale_p.h"
58#include "qvalidationerror_p.h"
59
60QT_BEGIN_HEADER
61
62QT_BEGIN_NAMESPACE
63
64namespace QPatternist
65{
66 /**
67 * @relates DerivedInteger
68 */
69 enum DerivedIntegerLimitsUsage
70 {
71 None = 1,
72 LimitUpwards = 2,
73 LimitDownwards = 4,
74 LimitBoth = LimitUpwards | LimitDownwards
75 };
76
77 enum
78 {
79 IgnorableSignedValue = 0,
80 IgnorableUnsignedValue = 0
81 };
82
83 template<TypeOfDerivedInteger DerivedType> class DerivedInteger;
84
85 template<TypeOfDerivedInteger DerivedType> class DerivedIntegerDetails;
86
87 template<>
88 class DerivedIntegerDetails<TypeByte>
89 {
90 private:
91 friend class DerivedInteger<TypeByte>;
92 typedef qint8 StorageType;
93 typedef xsInteger TemporaryStorageType;
94 static const StorageType maxInclusive = 127;
95 static const StorageType minInclusive = -128;
96 static const DerivedIntegerLimitsUsage limitsUsage = LimitBoth;
97
98 /**
99 * Disable the default constructor.
100 */
101 DerivedIntegerDetails() {}
102
103 Q_DISABLE_COPY(DerivedIntegerDetails)
104 };
105
106 template<>
107 class DerivedIntegerDetails<TypeInt>
108 {
109 private:
110 friend class DerivedInteger<TypeInt>;
111 typedef qint32 StorageType;
112 typedef xsInteger TemporaryStorageType;
113 static const StorageType maxInclusive = Q_INT64_C(2147483647);
114 static const StorageType minInclusive = Q_INT64_C(-2147483648);
115 static const DerivedIntegerLimitsUsage limitsUsage = LimitBoth;
116
117 /**
118 * Disable the default constructor.
119 */
120 DerivedIntegerDetails() {}
121
122 Q_DISABLE_COPY(DerivedIntegerDetails)
123 };
124
125 template<>
126 class DerivedIntegerDetails<TypeLong>
127 {
128 private:
129 friend class DerivedInteger<TypeLong>;
130 typedef qint64 StorageType;
131 typedef StorageType TemporaryStorageType;
132 static const StorageType maxInclusive = Q_INT64_C(9223372036854775807);
133
134 /**
135 * This messy arithmetic expression ensures that we don't get a warning
136 * on neither GCC nor MSVC.
137 */
138 static const StorageType minInclusive = -(Q_INT64_C(9223372036854775807)) - 1;
139
140 static const DerivedIntegerLimitsUsage limitsUsage = LimitBoth;
141
142 /**
143 * Disable the default constructor.
144 */
145 DerivedIntegerDetails() {}
146
147 Q_DISABLE_COPY(DerivedIntegerDetails)
148 };
149
150 template<>
151 class DerivedIntegerDetails<TypeNegativeInteger>
152 {
153 private:
154 friend class DerivedInteger<TypeNegativeInteger>;
155 typedef xsInteger StorageType;
156 typedef StorageType TemporaryStorageType;
157 static const StorageType maxInclusive = -1;
158 static const StorageType minInclusive = IgnorableSignedValue;
159 static const DerivedIntegerLimitsUsage limitsUsage = LimitUpwards;
160
161 /**
162 * Disable the default constructor.
163 */
164 DerivedIntegerDetails() {}
165
166 Q_DISABLE_COPY(DerivedIntegerDetails)
167 };
168
169 template<>
170 class DerivedIntegerDetails<TypeNonNegativeInteger>
171 {
172 private:
173 friend class DerivedInteger<TypeNonNegativeInteger>;
174 typedef xsInteger StorageType;
175 typedef StorageType TemporaryStorageType;
176 static const StorageType maxInclusive = IgnorableSignedValue;
177 static const StorageType minInclusive = 0;
178 static const DerivedIntegerLimitsUsage limitsUsage = LimitDownwards;
179
180 /**
181 * Disable the default constructor.
182 */
183 DerivedIntegerDetails() {}
184
185 Q_DISABLE_COPY(DerivedIntegerDetails)
186 };
187
188 template<>
189 class DerivedIntegerDetails<TypeNonPositiveInteger>
190 {
191 private:
192 friend class DerivedInteger<TypeNonPositiveInteger>;
193 typedef xsInteger StorageType;
194 typedef StorageType TemporaryStorageType;
195 static const StorageType maxInclusive = 0;
196 static const StorageType minInclusive = IgnorableSignedValue;
197 static const DerivedIntegerLimitsUsage limitsUsage = LimitUpwards;
198
199 /**
200 * Disable the default constructor.
201 */
202 DerivedIntegerDetails() {}
203
204 Q_DISABLE_COPY(DerivedIntegerDetails)
205 };
206
207 template<>
208 class DerivedIntegerDetails<TypePositiveInteger>
209 {
210 private:
211 friend class DerivedInteger<TypePositiveInteger>;
212 typedef xsInteger StorageType;
213 typedef StorageType TemporaryStorageType;
214 static const StorageType maxInclusive = IgnorableSignedValue;
215 static const StorageType minInclusive = 1;
216 static const DerivedIntegerLimitsUsage limitsUsage = LimitDownwards;
217
218 /**
219 * Disable the default constructor.
220 */
221 DerivedIntegerDetails() {}
222
223 Q_DISABLE_COPY(DerivedIntegerDetails)
224 };
225
226 template<>