Merge lp:~zorba-coders/zorba/bug-867059 into lp:zorba
- bug-867059
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~zorba-coders/zorba/bug-867059 |
Merge into: | lp:zorba |
Diff against target: |
3492 lines (+1442/-690) 39 files modified
NOTICE.txt (+1/-1) doc/zorba/build.dox (+2/-1) doc/zorba/build_options.dox (+35/-0) src/api/itemfactoryimpl.cpp (+6/-6) src/common/shared_types.h (+10/-4) src/compiler/rewriter/rules/flwor_rules.cpp (+1/-1) src/compiler/rewriter/rules/fold_rules.cpp (+1/-1) src/compiler/translator/translator.cpp (+3/-3) src/runtime/booleans/BooleanImpl.cpp (+2/-2) src/runtime/core/flwor_iterator.cpp (+1/-1) src/runtime/core/gflwor/count_iterator.cpp (+1/-1) src/runtime/core/gflwor/for_iterator.cpp (+1/-1) src/runtime/numerics/NumericsImpl.cpp (+2/-1) src/store/api/item.h (+1/-1) src/store/api/item_factory.h (+2/-2) src/store/naive/atomic_items.cpp (+192/-27) src/store/naive/atomic_items.h (+103/-47) src/store/naive/item.cpp (+1/-1) src/store/naive/simple_item_factory.cpp (+6/-6) src/store/naive/simple_item_factory.h (+2/-2) src/types/casting.cpp (+252/-46) src/types/casting.h (+2/-2) src/types/schema/XercesParseUtils.cpp (+2/-2) src/util/stl_util.h (+31/-0) src/util/string_util.cpp (+13/-5) src/zorbaserialization/zorba_class_serializer.cpp (+12/-3) src/zorbaserialization/zorba_class_serializer.h (+11/-2) src/zorbatypes/decimal.cpp (+80/-47) src/zorbatypes/decimal.h (+68/-48) src/zorbatypes/floatimpl.cpp (+20/-1) src/zorbatypes/floatimpl.h (+19/-4) src/zorbatypes/integer.cpp (+144/-96) src/zorbatypes/integer.h (+369/-308) src/zorbatypes/numconversions.cpp (+8/-1) src/zorbatypes/numconversions.h (+4/-0) src/zorbatypes/schema_types.h (+5/-1) src/zorbatypes/zorbatypes_decl.h (+13/-1) test/rbkt/Queries/CMakeLists.txt (+13/-12) test/rbkt/Queries/w3c_known_failures.txt (+3/-2) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug-867059 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Pending | ||
Matthias Brantner | Pending | ||
Review via email: mp+80848@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-11-29.
Commit message
Better implementation of ZORBA_WITH_
Description of the change
Better implementation of ZORBA_WITH_
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-867059 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-867059-2011-10-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Attempt to merge into lp:zorba failed due to conflicts:
text conflict in test/rbkt/
- 10514. By Paul J. Lucas
-
Merge from trunk.
- 10515. By Paul J. Lucas
-
Merge from trunk.
- 10516. By Paul J. Lucas
-
Merge from trunk.
Unmerged revisions
Preview Diff
1 | === modified file 'NOTICE.txt' | |||
2 | --- NOTICE.txt 2011-10-21 08:09:17 +0000 | |||
3 | +++ NOTICE.txt 2011-11-29 00:43:26 +0000 | |||
4 | @@ -1,5 +1,5 @@ | |||
5 | 1 | ----------- | 1 | ----------- |
7 | 2 | Zorba 2.1.0 | 2 | Zorba 2.0.1 |
8 | 3 | ----------- | 3 | ----------- |
9 | 4 | 4 | ||
10 | 5 | (Note: This file is generated automatically from NOTICE.xml. | 5 | (Note: This file is generated automatically from NOTICE.xml. |
11 | 6 | 6 | ||
12 | === modified file 'doc/zorba/build.dox' | |||
13 | --- doc/zorba/build.dox 2011-09-23 10:54:01 +0000 | |||
14 | +++ doc/zorba/build.dox 2011-11-29 00:43:26 +0000 | |||
15 | @@ -116,7 +116,8 @@ | |||
16 | 116 | To change the build mode (to Debug, Release, RelWithDebInfo or MinSizeRel), | 116 | To change the build mode (to Debug, Release, RelWithDebInfo or MinSizeRel), |
17 | 117 | you can pass an additional parameter to CMake, e.g., | 117 | you can pass an additional parameter to CMake, e.g., |
18 | 118 | <tt>cmake -D CMAKE_BUILD_TYPE=Debug [ZORBA]</tt>. | 118 | <tt>cmake -D CMAKE_BUILD_TYPE=Debug [ZORBA]</tt>. |
20 | 119 | - Zorba has other options as well. | 119 | - Zorba has other build options as well |
21 | 120 | (see \ref build_options). | ||
22 | 120 | You can tweak the performance and library footprint | 121 | You can tweak the performance and library footprint |
23 | 121 | by enabling or disabling various features from Zorba. | 122 | by enabling or disabling various features from Zorba. |
24 | 122 | 123 | ||
25 | 123 | 124 | ||
26 | === added file 'doc/zorba/build_options.dox' | |||
27 | --- doc/zorba/build_options.dox 1970-01-01 00:00:00 +0000 | |||
28 | +++ doc/zorba/build_options.dox 2011-11-29 00:43:26 +0000 | |||
29 | @@ -0,0 +1,35 @@ | |||
30 | 1 | /** \page build_options Zorba Build Options | ||
31 | 2 | |||
32 | 3 | \section ZORBA_WITH_BIG_INTEGER Big Integer Support (ZORBA_WITH_BIG_INTEGER) | ||
33 | 4 | |||
34 | 5 | The Zorba XQuery processor | ||
35 | 6 | by default | ||
36 | 7 | has arbitrary precision | ||
37 | 8 | for the \c xs:integer type. | ||
38 | 9 | Compared to a C++ \c int, | ||
39 | 10 | however, | ||
40 | 11 | arbitrary precision integers | ||
41 | 12 | are orders of magnitude slower. | ||
42 | 13 | If arbitrary precision integers are not needed, | ||
43 | 14 | they can be disabled | ||
44 | 15 | by configuring Zorba | ||
45 | 16 | with the | ||
46 | 17 | \c ZORBA_WITH_BIG_INTEGER | ||
47 | 18 | option set to \c OFF. | ||
48 | 19 | |||
49 | 20 | When arbitrary precision integers are disabled, | ||
50 | 21 | Zorba uses a C++ <code>long long</code> | ||
51 | 22 | for \c xs:integer, | ||
52 | 23 | the precision for which | ||
53 | 24 | is dependent on your C++ implementation. | ||
54 | 25 | Typically, however, | ||
55 | 26 | the precision is at least 64 bits. | ||
56 | 27 | However, | ||
57 | 28 | in order to maintain the condition | ||
58 | 29 | that the value space for \c xs:nonNegativeInteger | ||
59 | 30 | is a subset of that of \c xs:integer, | ||
60 | 31 | one less bit is allowed | ||
61 | 32 | for \c xs:nonNegativeInteger. | ||
62 | 33 | |||
63 | 34 | */ | ||
64 | 35 | /* vim:set et sw=2 ts=2: */ | ||
65 | 0 | 36 | ||
66 | === modified file 'src/api/itemfactoryimpl.cpp' | |||
67 | --- src/api/itemfactoryimpl.cpp 2011-07-22 07:23:17 +0000 | |||
68 | +++ src/api/itemfactoryimpl.cpp 2011-11-29 00:43:26 +0000 | |||
69 | @@ -269,7 +269,7 @@ | |||
70 | 269 | ItemFactoryImpl::createInteger(long long aInteger) | 269 | ItemFactoryImpl::createInteger(long long aInteger) |
71 | 270 | { | 270 | { |
72 | 271 | store::Item_t lItem; | 271 | store::Item_t lItem; |
74 | 272 | Integer const lInteger(aInteger); | 272 | xs_integer const lInteger(aInteger); |
75 | 273 | theItemFactory->createInteger(lItem, lInteger); | 273 | theItemFactory->createInteger(lItem, lInteger); |
76 | 274 | return &*lItem; | 274 | return &*lItem; |
77 | 275 | } | 275 | } |
78 | @@ -281,7 +281,7 @@ | |||
79 | 281 | zstring const &lString = Unmarshaller::getInternalString( aInteger ); | 281 | zstring const &lString = Unmarshaller::getInternalString( aInteger ); |
80 | 282 | store::Item_t lItem; | 282 | store::Item_t lItem; |
81 | 283 | try { | 283 | try { |
83 | 284 | Integer const lInteger( lString.c_str() ); | 284 | xs_integer const lInteger( lString.c_str() ); |
84 | 285 | theItemFactory->createInteger(lItem, lInteger); | 285 | theItemFactory->createInteger(lItem, lInteger); |
85 | 286 | } | 286 | } |
86 | 287 | catch ( std::exception const& ) { | 287 | catch ( std::exception const& ) { |
87 | @@ -447,7 +447,7 @@ | |||
88 | 447 | { | 447 | { |
89 | 448 | store::Item_t lItem; | 448 | store::Item_t lItem; |
90 | 449 | if (aValue < 0) { | 449 | if (aValue < 0) { |
92 | 450 | Integer const lInteger(aValue); | 450 | xs_integer const lInteger(aValue); |
93 | 451 | theItemFactory->createNegativeInteger(lItem, lInteger); | 451 | theItemFactory->createNegativeInteger(lItem, lInteger); |
94 | 452 | } | 452 | } |
95 | 453 | return &*lItem; | 453 | return &*lItem; |
96 | @@ -457,7 +457,7 @@ | |||
97 | 457 | Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue ) | 457 | Item ItemFactoryImpl::createNonNegativeInteger ( unsigned long long aValue ) |
98 | 458 | { | 458 | { |
99 | 459 | store::Item_t lItem; | 459 | store::Item_t lItem; |
101 | 460 | Integer lInteger(aValue); | 460 | xs_nonNegativeInteger lInteger(aValue); |
102 | 461 | theItemFactory->createNonNegativeInteger(lItem, lInteger); | 461 | theItemFactory->createNonNegativeInteger(lItem, lInteger); |
103 | 462 | return &*lItem; | 462 | return &*lItem; |
104 | 463 | } | 463 | } |
105 | @@ -467,7 +467,7 @@ | |||
106 | 467 | { | 467 | { |
107 | 468 | store::Item_t lItem; | 468 | store::Item_t lItem; |
108 | 469 | if (aValue < 0) { | 469 | if (aValue < 0) { |
110 | 470 | Integer const lInteger(aValue); | 470 | xs_integer const lInteger(aValue); |
111 | 471 | theItemFactory->createNonPositiveInteger(lItem, lInteger); | 471 | theItemFactory->createNonPositiveInteger(lItem, lInteger); |
112 | 472 | } | 472 | } |
113 | 473 | return &*lItem; | 473 | return &*lItem; |
114 | @@ -477,7 +477,7 @@ | |||
115 | 477 | Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue ) | 477 | Item ItemFactoryImpl::createPositiveInteger ( unsigned long long aValue ) |
116 | 478 | { | 478 | { |
117 | 479 | store::Item_t lItem; | 479 | store::Item_t lItem; |
119 | 480 | Integer lInteger(aValue); | 480 | xs_nonNegativeInteger lInteger(aValue); |
120 | 481 | theItemFactory->createPositiveInteger(lItem, lInteger); | 481 | theItemFactory->createPositiveInteger(lItem, lInteger); |
121 | 482 | return &*lItem; | 482 | return &*lItem; |
122 | 483 | } | 483 | } |
123 | 484 | 484 | ||
124 | === modified file 'src/common/shared_types.h' | |||
125 | --- src/common/shared_types.h 2011-09-12 22:42:28 +0000 | |||
126 | +++ src/common/shared_types.h 2011-11-29 00:43:26 +0000 | |||
127 | @@ -140,12 +140,18 @@ | |||
128 | 140 | typedef rchandle<GMonth> GMonth_t; | 140 | typedef rchandle<GMonth> GMonth_t; |
129 | 141 | 141 | ||
130 | 142 | /* numerics */ | 142 | /* numerics */ |
135 | 143 | template <class Object> class FloatImpl; | 143 | template<typename FloatType> class FloatImpl; |
132 | 144 | class Integer; | ||
133 | 145 | |||
134 | 146 | /* numerics */ | ||
136 | 147 | typedef FloatImpl<double> Double; | 144 | typedef FloatImpl<double> Double; |
137 | 148 | typedef FloatImpl<float> Float; | 145 | typedef FloatImpl<float> Float; |
138 | 146 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
139 | 147 | class IntegerImpl; | ||
140 | 148 | typedef IntegerImpl Integer; | ||
141 | 149 | typedef IntegerImpl UInteger; | ||
142 | 150 | #else | ||
143 | 151 | template<typename IntType> class IntegerImpl; | ||
144 | 152 | typedef IntegerImpl<long long> Integer; | ||
145 | 153 | typedef IntegerImpl<unsigned long long> UInteger; | ||
146 | 154 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
147 | 149 | 155 | ||
148 | 150 | /* api */ | 156 | /* api */ |
149 | 151 | class serializer; | 157 | class serializer; |
150 | 152 | 158 | ||
151 | === modified file 'src/compiler/rewriter/rules/flwor_rules.cpp' | |||
152 | --- src/compiler/rewriter/rules/flwor_rules.cpp 2011-09-02 20:43:46 +0000 | |||
153 | +++ src/compiler/rewriter/rules/flwor_rules.cpp 2011-11-29 00:43:26 +0000 | |||
154 | @@ -950,7 +950,7 @@ | |||
155 | 950 | (a) op is eq or =, and | 950 | (a) op is eq or =, and |
156 | 951 | (b1) posExpr is an integer literal with value >= 1, or | 951 | (b1) posExpr is an integer literal with value >= 1, or |
157 | 952 | (b2) the flwor expr has no sequential clauses and posExpr is an expression | 952 | (b2) the flwor expr has no sequential clauses and posExpr is an expression |
159 | 953 | whose type is xs:Integer? and which does not reference the for var | 953 | whose type is xs:integer? and which does not reference the for var |
160 | 954 | associated with posVar nor any other vars that are defined after that | 954 | associated with posVar nor any other vars that are defined after that |
161 | 955 | for var. | 955 | for var. |
162 | 956 | 956 | ||
163 | 957 | 957 | ||
164 | === modified file 'src/compiler/rewriter/rules/fold_rules.cpp' | |||
165 | --- src/compiler/rewriter/rules/fold_rules.cpp 2011-11-22 13:28:23 +0000 | |||
166 | +++ src/compiler/rewriter/rules/fold_rules.cpp 2011-11-29 00:43:26 +0000 | |||
167 | @@ -754,7 +754,7 @@ | |||
168 | 754 | { | 754 | { |
169 | 755 | return new const_expr(fo->get_sctx(), | 755 | return new const_expr(fo->get_sctx(), |
170 | 756 | fo->get_loc(), | 756 | fo->get_loc(), |
172 | 757 | Integer(type_cnt)); | 757 | xs_integer(type_cnt)); |
173 | 758 | } | 758 | } |
174 | 759 | else if (fkind == FunctionConsts::FN_EMPTY_1) | 759 | else if (fkind == FunctionConsts::FN_EMPTY_1) |
175 | 760 | { | 760 | { |
176 | 761 | 761 | ||
177 | === modified file 'src/compiler/translator/translator.cpp' | |||
178 | --- src/compiler/translator/translator.cpp 2011-11-29 00:16:24 +0000 | |||
179 | +++ src/compiler/translator/translator.cpp 2011-11-29 00:43:26 +0000 | |||
180 | @@ -9666,8 +9666,8 @@ | |||
181 | 9666 | { | 9666 | { |
182 | 9667 | case FunctionConsts::FN_HEAD_1: | 9667 | case FunctionConsts::FN_HEAD_1: |
183 | 9668 | { | 9668 | { |
186 | 9669 | arguments.push_back(new const_expr(theRootSctx, loc, Integer(1))); | 9669 | arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1))); |
187 | 9670 | arguments.push_back(new const_expr(theRootSctx, loc, Integer(1))); | 9670 | arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(1))); |
188 | 9671 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3); | 9671 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_3); |
189 | 9672 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); | 9672 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); |
190 | 9673 | normalize_fo(foExpr); | 9673 | normalize_fo(foExpr); |
191 | @@ -9676,7 +9676,7 @@ | |||
192 | 9676 | } | 9676 | } |
193 | 9677 | case FunctionConsts::FN_TAIL_1: | 9677 | case FunctionConsts::FN_TAIL_1: |
194 | 9678 | { | 9678 | { |
196 | 9679 | arguments.push_back(new const_expr(theRootSctx, loc, Integer(2))); | 9679 | arguments.push_back(new const_expr(theRootSctx, loc, xs_integer(2))); |
197 | 9680 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2); | 9680 | function* f = GET_BUILTIN_FUNCTION(OP_ZORBA_SUBSEQUENCE_INT_2); |
198 | 9681 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); | 9681 | fo_expr_t foExpr = new fo_expr(theRootSctx, loc, f, arguments); |
199 | 9682 | normalize_fo(foExpr); | 9682 | normalize_fo(foExpr); |
200 | 9683 | 9683 | ||
201 | === modified file 'src/runtime/booleans/BooleanImpl.cpp' | |||
202 | --- src/runtime/booleans/BooleanImpl.cpp 2011-08-08 17:46:14 +0000 | |||
203 | +++ src/runtime/booleans/BooleanImpl.cpp 2011-11-29 00:43:26 +0000 | |||
204 | @@ -852,7 +852,7 @@ | |||
205 | 852 | { | 852 | { |
206 | 853 | // There are 2 cases when two types are comparable without one being a | 853 | // There are 2 cases when two types are comparable without one being a |
207 | 854 | // subtype of the other: (a) they belong to different branches under of | 854 | // subtype of the other: (a) they belong to different branches under of |
209 | 855 | // the type-inheritance subtree rooted at xs:Integer, (b) they belong to | 855 | // the type-inheritance subtree rooted at xs:integer, (b) they belong to |
210 | 856 | // different branches under of the type-inheritance subtree rooted at | 856 | // different branches under of the type-inheritance subtree rooted at |
211 | 857 | // xs::duration (i.e. one is xs:yearMonthDuration and the other is | 857 | // xs::duration (i.e. one is xs:yearMonthDuration and the other is |
212 | 858 | // xs:dayTimeDuration). | 858 | // xs:dayTimeDuration). |
213 | @@ -949,7 +949,7 @@ | |||
214 | 949 | { | 949 | { |
215 | 950 | // There is 1 case when two types are order-comparable without one being a | 950 | // There is 1 case when two types are order-comparable without one being a |
216 | 951 | // subtype of the other: they belong to different branches under of the | 951 | // subtype of the other: they belong to different branches under of the |
218 | 952 | // type-inheritance subtree rooted at xs:Integer. | 952 | // type-inheritance subtree rooted at xs:integer. |
219 | 953 | if (TypeOps::is_subtype(tm, *type0, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE) && | 953 | if (TypeOps::is_subtype(tm, *type0, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE) && |
220 | 954 | TypeOps::is_subtype(tm, *type1, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE)) | 954 | TypeOps::is_subtype(tm, *type1, *GENV_TYPESYSTEM.INTEGER_TYPE_ONE)) |
221 | 955 | { | 955 | { |
222 | 956 | 956 | ||
223 | === modified file 'src/runtime/core/flwor_iterator.cpp' | |||
224 | --- src/runtime/core/flwor_iterator.cpp 2011-11-22 13:42:18 +0000 | |||
225 | +++ src/runtime/core/flwor_iterator.cpp 2011-11-29 00:43:26 +0000 | |||
226 | @@ -1215,7 +1215,7 @@ | |||
227 | 1215 | if (!flc.thePosVarRefs.empty()) | 1215 | if (!flc.thePosVarRefs.empty()) |
228 | 1216 | { | 1216 | { |
229 | 1217 | store::Item_t posItem; | 1217 | store::Item_t posItem; |
231 | 1218 | GENV_ITEMFACTORY->createInteger(posItem, Integer(bindingState)); | 1218 | GENV_ITEMFACTORY->createInteger(posItem, xs_integer(bindingState)); |
232 | 1219 | 1219 | ||
233 | 1220 | std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin(); | 1220 | std::vector<PlanIter_t>::const_iterator viter = flc.thePosVarRefs.begin(); |
234 | 1221 | std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end(); | 1221 | std::vector<PlanIter_t>::const_iterator end = flc.thePosVarRefs.end(); |
235 | 1222 | 1222 | ||
236 | === modified file 'src/runtime/core/gflwor/count_iterator.cpp' | |||
237 | --- src/runtime/core/gflwor/count_iterator.cpp 2011-06-14 17:26:33 +0000 | |||
238 | +++ src/runtime/core/gflwor/count_iterator.cpp 2011-11-29 00:43:26 +0000 | |||
239 | @@ -91,7 +91,7 @@ | |||
240 | 91 | { | 91 | { |
241 | 92 | { | 92 | { |
242 | 93 | store::Item_t lCountItem; | 93 | store::Item_t lCountItem; |
244 | 94 | GENV_ITEMFACTORY->createInteger(lCountItem, Integer(lState->incCount())); | 94 | GENV_ITEMFACTORY->createInteger(lCountItem, xs_integer(lState->incCount())); |
245 | 95 | bindVariables(lCountItem, theCountVars, aPlanState); | 95 | bindVariables(lCountItem, theCountVars, aPlanState); |
246 | 96 | } | 96 | } |
247 | 97 | STACK_PUSH(true, lState); | 97 | STACK_PUSH(true, lState); |
248 | 98 | 98 | ||
249 | === modified file 'src/runtime/core/gflwor/for_iterator.cpp' | |||
250 | --- src/runtime/core/gflwor/for_iterator.cpp 2011-06-22 14:42:38 +0000 | |||
251 | +++ src/runtime/core/gflwor/for_iterator.cpp 2011-11-29 00:43:26 +0000 | |||
252 | @@ -126,7 +126,7 @@ | |||
253 | 126 | { | 126 | { |
254 | 127 | store::Item_t lPosItem; | 127 | store::Item_t lPosItem; |
255 | 128 | GENV_ITEMFACTORY->createInteger(lPosItem, | 128 | GENV_ITEMFACTORY->createInteger(lPosItem, |
257 | 129 | Integer(lState->incReturnPosition())); | 129 | xs_integer(lState->incReturnPosition())); |
258 | 130 | bindVariables(lPosItem, thePosVarRefs, aPlanState); | 130 | bindVariables(lPosItem, thePosVarRefs, aPlanState); |
259 | 131 | } | 131 | } |
260 | 132 | STACK_PUSH(true, lState); | 132 | STACK_PUSH(true, lState); |
261 | 133 | 133 | ||
262 | === modified file 'src/runtime/numerics/NumericsImpl.cpp' | |||
263 | --- src/runtime/numerics/NumericsImpl.cpp 2011-07-10 14:04:53 +0000 | |||
264 | +++ src/runtime/numerics/NumericsImpl.cpp 2011-11-29 00:43:26 +0000 | |||
265 | @@ -441,10 +441,11 @@ | |||
266 | 441 | xs_integer ll0 = i0->getIntegerValue(); | 441 | xs_integer ll0 = i0->getIntegerValue(); |
267 | 442 | xs_integer ll1 = i1->getIntegerValue(); | 442 | xs_integer ll1 = i1->getIntegerValue(); |
268 | 443 | 443 | ||
270 | 444 | if ( ll1 == Integer::zero() ) | 444 | if ( ll1.sign() == 0 ) |
271 | 445 | { | 445 | { |
272 | 446 | throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) ); | 446 | throw XQUERY_EXCEPTION( err::FOAR0001, ERROR_LOC( loc ) ); |
273 | 447 | } | 447 | } |
274 | 448 | |||
275 | 448 | return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1); | 449 | return GENV_ITEMFACTORY->createInteger (result, ll0 / ll1); |
276 | 449 | } | 450 | } |
277 | 450 | 451 | ||
278 | 451 | 452 | ||
279 | === modified file 'src/store/api/item.h' | |||
280 | --- src/store/api/item.h 2011-10-15 10:41:19 +0000 | |||
281 | +++ src/store/api/item.h 2011-11-29 00:43:26 +0000 | |||
282 | @@ -292,7 +292,7 @@ | |||
283 | 292 | 292 | ||
284 | 293 | /** Accessor for xs:nonNegativeInteager, xs:positiveInteger | 293 | /** Accessor for xs:nonNegativeInteager, xs:positiveInteger |
285 | 294 | */ | 294 | */ |
287 | 295 | virtual xs_uinteger | 295 | virtual xs_nonNegativeInteger |
288 | 296 | getUnsignedIntegerValue() const; | 296 | getUnsignedIntegerValue() const; |
289 | 297 | 297 | ||
290 | 298 | /** Accessor for xs:long | 298 | /** Accessor for xs:long |
291 | 299 | 299 | ||
292 | === modified file 'src/store/api/item_factory.h' | |||
293 | --- src/store/api/item_factory.h 2011-07-22 07:23:17 +0000 | |||
294 | +++ src/store/api/item_factory.h 2011-11-29 00:43:26 +0000 | |||
295 | @@ -236,13 +236,13 @@ | |||
296 | 236 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger] | 236 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger] |
297 | 237 | * @param value | 237 | * @param value |
298 | 238 | */ | 238 | */ |
300 | 239 | virtual bool createNonNegativeInteger(Item_t& result, const xs_uinteger& value) = 0; | 239 | virtual bool createNonNegativeInteger(Item_t& result, const xs_nonNegativeInteger& value) = 0; |
301 | 240 | 240 | ||
302 | 241 | /** | 241 | /** |
303 | 242 | * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger] | 242 | * Specification: [http://www.w3.org/TR/xmlschema-2/#positiveInteger] |
304 | 243 | * @param value | 243 | * @param value |
305 | 244 | */ | 244 | */ |
307 | 245 | virtual bool createPositiveInteger(Item_t& result, const xs_uinteger& value) = 0; | 245 | virtual bool createPositiveInteger(Item_t& result, const xs_positiveInteger& value) = 0; |
308 | 246 | 246 | ||
309 | 247 | /** | 247 | /** |
310 | 248 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger] | 248 | * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger] |
311 | 249 | 249 | ||
312 | === modified file 'src/store/naive/atomic_items.cpp' | |||
313 | --- src/store/naive/atomic_items.cpp 2011-10-27 20:55:51 +0000 | |||
314 | +++ src/store/naive/atomic_items.cpp 2011-11-29 00:43:26 +0000 | |||
315 | @@ -147,7 +147,7 @@ | |||
316 | 147 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); | 147 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); |
317 | 148 | try | 148 | try |
318 | 149 | { | 149 | { |
320 | 150 | longValue = to_xs_long(item->theValue); | 150 | longValue = item->getLongValue(); |
321 | 151 | GET_FACTORY().createLong(result, longValue); | 151 | GET_FACTORY().createLong(result, longValue); |
322 | 152 | } | 152 | } |
323 | 153 | catch (std::range_error const&) | 153 | catch (std::range_error const&) |
324 | @@ -217,11 +217,11 @@ | |||
325 | 217 | { | 217 | { |
326 | 218 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); | 218 | const IntegerItem* item = static_cast<const IntegerItem*>(item1); |
327 | 219 | 219 | ||
329 | 220 | doubleValue = item->theValue; | 220 | doubleValue = item->getIntegerValue(); |
330 | 221 | 221 | ||
331 | 222 | const xs_integer intValue(doubleValue); | 222 | const xs_integer intValue(doubleValue); |
332 | 223 | 223 | ||
334 | 224 | lossy = (intValue != item->theValue); | 224 | lossy = (intValue != item->getIntegerValue()); |
335 | 225 | break; | 225 | break; |
336 | 226 | } | 226 | } |
337 | 227 | 227 | ||
338 | @@ -2400,10 +2400,11 @@ | |||
339 | 2400 | 2400 | ||
340 | 2401 | 2401 | ||
341 | 2402 | /******************************************************************************* | 2402 | /******************************************************************************* |
343 | 2403 | class IntegerItem | 2403 | class IntegerItemImpl |
344 | 2404 | ********************************************************************************/ | 2404 | ********************************************************************************/ |
345 | 2405 | 2405 | ||
347 | 2406 | long IntegerItem::compare( Item const *other, long, const XQPCollator* ) const { | 2406 | long IntegerItemImpl::compare( Item const *other, long, |
348 | 2407 | const XQPCollator* ) const { | ||
349 | 2407 | try | 2408 | try |
350 | 2408 | { | 2409 | { |
351 | 2409 | return theValue.compare( other->getIntegerValue() ); | 2410 | return theValue.compare( other->getIntegerValue() ); |
352 | @@ -2414,8 +2415,8 @@ | |||
353 | 2414 | } | 2415 | } |
354 | 2415 | } | 2416 | } |
355 | 2416 | 2417 | ||
358 | 2417 | bool IntegerItem::equals( const store::Item* other, long, | 2418 | bool IntegerItemImpl::equals( const store::Item* other, long, |
359 | 2418 | const XQPCollator*) const | 2419 | const XQPCollator*) const |
360 | 2419 | { | 2420 | { |
361 | 2420 | try | 2421 | try |
362 | 2421 | { | 2422 | { |
363 | @@ -2427,13 +2428,13 @@ | |||
364 | 2427 | } | 2428 | } |
365 | 2428 | } | 2429 | } |
366 | 2429 | 2430 | ||
368 | 2430 | xs_decimal IntegerItem::getDecimalValue() const | 2431 | xs_decimal IntegerItemImpl::getDecimalValue() const |
369 | 2431 | { | 2432 | { |
370 | 2432 | return xs_decimal(theValue); | 2433 | return xs_decimal(theValue); |
371 | 2433 | } | 2434 | } |
372 | 2434 | 2435 | ||
373 | 2435 | 2436 | ||
375 | 2436 | xs_long IntegerItem::getLongValue() const | 2437 | xs_long IntegerItemImpl::getLongValue() const |
376 | 2437 | { | 2438 | { |
377 | 2438 | try | 2439 | try |
378 | 2439 | { | 2440 | { |
379 | @@ -2449,44 +2450,45 @@ | |||
380 | 2449 | } | 2450 | } |
381 | 2450 | 2451 | ||
382 | 2451 | 2452 | ||
384 | 2452 | store::Item* IntegerItem::getType() const | 2453 | store::Item* IntegerItemImpl::getType() const |
385 | 2453 | { | 2454 | { |
386 | 2454 | return GET_STORE().theSchemaTypeNames[XS_INTEGER]; | 2455 | return GET_STORE().theSchemaTypeNames[XS_INTEGER]; |
387 | 2455 | } | 2456 | } |
388 | 2456 | 2457 | ||
389 | 2457 | 2458 | ||
391 | 2458 | store::Item_t IntegerItem::getEBV() const | 2459 | store::Item_t IntegerItemImpl::getEBV() const |
392 | 2459 | { | 2460 | { |
394 | 2460 | bool b = ( theValue != xs_integer::zero() ); | 2461 | bool b = !!theValue.sign(); |
395 | 2461 | store::Item_t bVal; | 2462 | store::Item_t bVal; |
396 | 2462 | CREATE_BOOLITEM(bVal, b); | 2463 | CREATE_BOOLITEM(bVal, b); |
397 | 2463 | return bVal; | 2464 | return bVal; |
398 | 2464 | } | 2465 | } |
399 | 2465 | 2466 | ||
400 | 2466 | 2467 | ||
402 | 2467 | zstring IntegerItem::getStringValue() const | 2468 | zstring IntegerItemImpl::getStringValue() const |
403 | 2468 | { | 2469 | { |
404 | 2469 | return theValue.toString(); | 2470 | return theValue.toString(); |
405 | 2470 | } | 2471 | } |
406 | 2471 | 2472 | ||
407 | 2472 | 2473 | ||
409 | 2473 | void IntegerItem::getStringValue2(zstring& val) const | 2474 | void IntegerItemImpl::getStringValue2(zstring& val) const |
410 | 2474 | { | 2475 | { |
411 | 2475 | val = theValue.toString(); | 2476 | val = theValue.toString(); |
412 | 2476 | } | 2477 | } |
413 | 2477 | 2478 | ||
415 | 2478 | uint32_t IntegerItem::hash(long, const XQPCollator*) const | 2479 | uint32_t IntegerItemImpl::hash(long, const XQPCollator*) const |
416 | 2479 | { | 2480 | { |
417 | 2480 | return theValue.hash(); | 2481 | return theValue.hash(); |
418 | 2481 | } | 2482 | } |
419 | 2482 | 2483 | ||
421 | 2483 | void IntegerItem::appendStringValue(zstring& buf) const | 2484 | |
422 | 2485 | void IntegerItemImpl::appendStringValue(zstring& buf) const | ||
423 | 2484 | { | 2486 | { |
424 | 2485 | buf += theValue.toString(); | 2487 | buf += theValue.toString(); |
425 | 2486 | } | 2488 | } |
426 | 2487 | 2489 | ||
427 | 2488 | 2490 | ||
429 | 2489 | zstring IntegerItem::show() const | 2491 | zstring IntegerItemImpl::show() const |
430 | 2490 | { | 2492 | { |
431 | 2491 | zstring res("xs:integer("); | 2493 | zstring res("xs:integer("); |
432 | 2492 | appendStringValue(res); | 2494 | appendStringValue(res); |
433 | @@ -2498,11 +2500,91 @@ | |||
434 | 2498 | /******************************************************************************* | 2500 | /******************************************************************************* |
435 | 2499 | class NonPositiveIntegerItem | 2501 | class NonPositiveIntegerItem |
436 | 2500 | ********************************************************************************/ | 2502 | ********************************************************************************/ |
437 | 2503 | long NonPositiveIntegerItem::compare( Item const *other, long, | ||
438 | 2504 | const XQPCollator* ) const { | ||
439 | 2505 | try | ||
440 | 2506 | { | ||
441 | 2507 | return theValue.compare( other->getIntegerValue() ); | ||
442 | 2508 | } | ||
443 | 2509 | catch ( ZorbaException const& ) | ||
444 | 2510 | { | ||
445 | 2511 | return getDecimalValue().compare( other->getDecimalValue() ); | ||
446 | 2512 | } | ||
447 | 2513 | } | ||
448 | 2514 | |||
449 | 2515 | bool NonPositiveIntegerItem::equals( const store::Item* other, long, | ||
450 | 2516 | const XQPCollator* ) const | ||
451 | 2517 | { | ||
452 | 2518 | try | ||
453 | 2519 | { | ||
454 | 2520 | return theValue == other->getIntegerValue(); | ||
455 | 2521 | } | ||
456 | 2522 | catch (ZorbaException const&) | ||
457 | 2523 | { | ||
458 | 2524 | return getDecimalValue() == other->getDecimalValue(); | ||
459 | 2525 | } | ||
460 | 2526 | } | ||
461 | 2527 | |||
462 | 2501 | store::Item* NonPositiveIntegerItem::getType() const | 2528 | store::Item* NonPositiveIntegerItem::getType() const |
463 | 2502 | { | 2529 | { |
464 | 2503 | return GET_STORE().theSchemaTypeNames[XS_NON_POSITIVE_INTEGER]; | 2530 | return GET_STORE().theSchemaTypeNames[XS_NON_POSITIVE_INTEGER]; |
465 | 2504 | } | 2531 | } |
466 | 2505 | 2532 | ||
467 | 2533 | xs_decimal NonPositiveIntegerItem::getDecimalValue() const | ||
468 | 2534 | { | ||
469 | 2535 | return xs_decimal(theValue); | ||
470 | 2536 | } | ||
471 | 2537 | |||
472 | 2538 | xs_integer NonPositiveIntegerItem::getIntegerValue() const | ||
473 | 2539 | { | ||
474 | 2540 | return xs_integer(theValue); | ||
475 | 2541 | } | ||
476 | 2542 | |||
477 | 2543 | xs_long NonPositiveIntegerItem::getLongValue() const | ||
478 | 2544 | { | ||
479 | 2545 | try | ||
480 | 2546 | { | ||
481 | 2547 | return to_xs_long(theValue); | ||
482 | 2548 | } | ||
483 | 2549 | catch ( std::range_error const& ) | ||
484 | 2550 | { | ||
485 | 2551 | throw XQUERY_EXCEPTION( | ||
486 | 2552 | err::FORG0001, | ||
487 | 2553 | ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" ) | ||
488 | 2554 | ); | ||
489 | 2555 | } | ||
490 | 2556 | } | ||
491 | 2557 | |||
492 | 2558 | zstring NonPositiveIntegerItem::getStringValue() const | ||
493 | 2559 | { | ||
494 | 2560 | return theValue.toString(); | ||
495 | 2561 | } | ||
496 | 2562 | |||
497 | 2563 | |||
498 | 2564 | void NonPositiveIntegerItem::getStringValue2(zstring& val) const | ||
499 | 2565 | { | ||
500 | 2566 | val = theValue.toString(); | ||
501 | 2567 | } | ||
502 | 2568 | |||
503 | 2569 | uint32_t NonPositiveIntegerItem::hash(long, const XQPCollator*) const | ||
504 | 2570 | { | ||
505 | 2571 | return theValue.hash(); | ||
506 | 2572 | } | ||
507 | 2573 | |||
508 | 2574 | |||
509 | 2575 | void NonPositiveIntegerItem::appendStringValue(zstring& buf) const | ||
510 | 2576 | { | ||
511 | 2577 | buf += theValue.toString(); | ||
512 | 2578 | } | ||
513 | 2579 | |||
514 | 2580 | store::Item_t NonPositiveIntegerItem::getEBV() const | ||
515 | 2581 | { | ||
516 | 2582 | bool b = !!theValue.sign(); | ||
517 | 2583 | store::Item_t bVal; | ||
518 | 2584 | CREATE_BOOLITEM(bVal, b); | ||
519 | 2585 | return bVal; | ||
520 | 2586 | } | ||
521 | 2587 | |||
522 | 2506 | zstring NonPositiveIntegerItem::show() const | 2588 | zstring NonPositiveIntegerItem::show() const |
523 | 2507 | { | 2589 | { |
524 | 2508 | zstring res("xs:nonPositiveInteger("); | 2590 | zstring res("xs:nonPositiveInteger("); |
525 | @@ -2531,14 +2613,94 @@ | |||
526 | 2531 | 2613 | ||
527 | 2532 | 2614 | ||
528 | 2533 | /******************************************************************************* | 2615 | /******************************************************************************* |
530 | 2534 | class NonNegativeINtegerItem | 2616 | class NonNegativeIntegerItem |
531 | 2535 | ********************************************************************************/ | 2617 | ********************************************************************************/ |
532 | 2618 | long NonNegativeIntegerItem::compare( Item const *other, long, | ||
533 | 2619 | const XQPCollator* ) const { | ||
534 | 2620 | try | ||
535 | 2621 | { | ||
536 | 2622 | return theValue.compare( other->getUnsignedIntegerValue() ); | ||
537 | 2623 | } | ||
538 | 2624 | catch ( ZorbaException const& ) | ||
539 | 2625 | { | ||
540 | 2626 | return getDecimalValue().compare( other->getDecimalValue() ); | ||
541 | 2627 | } | ||
542 | 2628 | } | ||
543 | 2629 | |||
544 | 2630 | bool NonNegativeIntegerItem::equals( const store::Item* other, long, | ||
545 | 2631 | const XQPCollator* ) const | ||
546 | 2632 | { | ||
547 | 2633 | try | ||
548 | 2634 | { | ||
549 | 2635 | return theValue == other->getUnsignedIntegerValue(); | ||
550 | 2636 | } | ||
551 | 2637 | catch (ZorbaException const&) | ||
552 | 2638 | { | ||
553 | 2639 | return getDecimalValue() == other->getDecimalValue(); | ||
554 | 2640 | } | ||
555 | 2641 | } | ||
556 | 2642 | |||
557 | 2536 | store::Item* NonNegativeIntegerItem::getType() const | 2643 | store::Item* NonNegativeIntegerItem::getType() const |
558 | 2537 | { | 2644 | { |
559 | 2538 | return GET_STORE().theSchemaTypeNames[XS_NON_NEGATIVE_INTEGER]; | 2645 | return GET_STORE().theSchemaTypeNames[XS_NON_NEGATIVE_INTEGER]; |
560 | 2539 | } | 2646 | } |
561 | 2540 | 2647 | ||
562 | 2541 | 2648 | ||
563 | 2649 | xs_decimal NonNegativeIntegerItem::getDecimalValue() const | ||
564 | 2650 | { | ||
565 | 2651 | return xs_decimal(theValue); | ||
566 | 2652 | } | ||
567 | 2653 | |||
568 | 2654 | xs_integer NonNegativeIntegerItem::getIntegerValue() const | ||
569 | 2655 | { | ||
570 | 2656 | return xs_integer(theValue); | ||
571 | 2657 | } | ||
572 | 2658 | |||
573 | 2659 | xs_long NonNegativeIntegerItem::getLongValue() const | ||
574 | 2660 | { | ||
575 | 2661 | try | ||
576 | 2662 | { | ||
577 | 2663 | return to_xs_long(theValue); | ||
578 | 2664 | } | ||
579 | 2665 | catch ( std::range_error const& ) | ||
580 | 2666 | { | ||
581 | 2667 | throw XQUERY_EXCEPTION( | ||
582 | 2668 | err::FORG0001, | ||
583 | 2669 | ERROR_PARAMS( theValue, ZED( CastFromToFailed_34 ), "integer", "long" ) | ||
584 | 2670 | ); | ||
585 | 2671 | } | ||
586 | 2672 | } | ||
587 | 2673 | |||
588 | 2674 | zstring NonNegativeIntegerItem::getStringValue() const | ||
589 | 2675 | { | ||
590 | 2676 | return theValue.toString(); | ||
591 | 2677 | } | ||
592 | 2678 | |||
593 | 2679 | |||
594 | 2680 | void NonNegativeIntegerItem::getStringValue2(zstring& val) const | ||
595 | 2681 | { | ||
596 | 2682 | val = theValue.toString(); | ||
597 | 2683 | } | ||
598 | 2684 | |||
599 | 2685 | uint32_t NonNegativeIntegerItem::hash(long, const XQPCollator*) const | ||
600 | 2686 | { | ||
601 | 2687 | return theValue.hash(); | ||
602 | 2688 | } | ||
603 | 2689 | |||
604 | 2690 | |||
605 | 2691 | void NonNegativeIntegerItem::appendStringValue(zstring& buf) const | ||
606 | 2692 | { | ||
607 | 2693 | buf += theValue.toString(); | ||
608 | 2694 | } | ||
609 | 2695 | |||
610 | 2696 | store::Item_t NonNegativeIntegerItem::getEBV() const | ||
611 | 2697 | { | ||
612 | 2698 | bool b = !!theValue.sign(); | ||
613 | 2699 | store::Item_t bVal; | ||
614 | 2700 | CREATE_BOOLITEM(bVal, b); | ||
615 | 2701 | return bVal; | ||
616 | 2702 | } | ||
617 | 2703 | |||
618 | 2542 | zstring NonNegativeIntegerItem::show() const | 2704 | zstring NonNegativeIntegerItem::show() const |
619 | 2543 | { | 2705 | { |
620 | 2544 | zstring res("xs:nonNegativeInteger("); | 2706 | zstring res("xs:nonNegativeInteger("); |
621 | @@ -2580,6 +2742,9 @@ | |||
622 | 2580 | return xs_integer(theValue); | 2742 | return xs_integer(theValue); |
623 | 2581 | } | 2743 | } |
624 | 2582 | 2744 | ||
625 | 2745 | xs_nonNegativeInteger LongItem::getUnsignedIntegerValue() const { | ||
626 | 2746 | return theValue >= 0 ? theValue : -theValue; | ||
627 | 2747 | } | ||
628 | 2583 | 2748 | ||
629 | 2584 | store::Item* LongItem::getType() const | 2749 | store::Item* LongItem::getType() const |
630 | 2585 | { | 2750 | { |
631 | @@ -2824,9 +2989,9 @@ | |||
632 | 2824 | } | 2989 | } |
633 | 2825 | 2990 | ||
634 | 2826 | 2991 | ||
636 | 2827 | xs_uinteger UnsignedLongItem::getUnsignedIntegerValue() const | 2992 | xs_nonNegativeInteger UnsignedLongItem::getUnsignedIntegerValue() const |
637 | 2828 | { | 2993 | { |
639 | 2829 | return xs_uinteger(theValue); | 2994 | return xs_nonNegativeInteger(theValue); |
640 | 2830 | } | 2995 | } |
641 | 2831 | 2996 | ||
642 | 2832 | 2997 | ||
643 | @@ -2891,9 +3056,9 @@ | |||
644 | 2891 | } | 3056 | } |
645 | 2892 | 3057 | ||
646 | 2893 | 3058 | ||
648 | 2894 | xs_uinteger UnsignedIntItem::getUnsignedIntegerValue() const | 3059 | xs_nonNegativeInteger UnsignedIntItem::getUnsignedIntegerValue() const |
649 | 2895 | { | 3060 | { |
651 | 2896 | return Integer(theValue); | 3061 | return xs_nonNegativeInteger(theValue); |
652 | 2897 | } | 3062 | } |
653 | 2898 | 3063 | ||
654 | 2899 | 3064 | ||
655 | @@ -2958,9 +3123,9 @@ | |||
656 | 2958 | } | 3123 | } |
657 | 2959 | 3124 | ||
658 | 2960 | 3125 | ||
660 | 2961 | xs_uinteger UnsignedShortItem::getUnsignedIntegerValue() const | 3126 | xs_nonNegativeInteger UnsignedShortItem::getUnsignedIntegerValue() const |
661 | 2962 | { | 3127 | { |
663 | 2963 | return Integer(theValue); | 3128 | return xs_nonNegativeInteger(theValue); |
664 | 2964 | } | 3129 | } |
665 | 2965 | 3130 | ||
666 | 2966 | 3131 | ||
667 | @@ -3021,13 +3186,13 @@ | |||
668 | 3021 | 3186 | ||
669 | 3022 | xs_integer UnsignedByteItem::getIntegerValue() const | 3187 | xs_integer UnsignedByteItem::getIntegerValue() const |
670 | 3023 | { | 3188 | { |
672 | 3024 | return Integer((uint32_t)theValue); | 3189 | return xs_integer((uint32_t)theValue); |
673 | 3025 | } | 3190 | } |
674 | 3026 | 3191 | ||
675 | 3027 | 3192 | ||
677 | 3028 | xs_uinteger UnsignedByteItem::getUnsignedIntegerValue() const | 3193 | xs_nonNegativeInteger UnsignedByteItem::getUnsignedIntegerValue() const |
678 | 3029 | { | 3194 | { |
680 | 3030 | return Integer(theValue); | 3195 | return xs_nonNegativeInteger(theValue); |
681 | 3031 | } | 3196 | } |
682 | 3032 | 3197 | ||
683 | 3033 | 3198 | ||
684 | 3034 | 3199 | ||
685 | === modified file 'src/store/naive/atomic_items.h' | |||
686 | --- src/store/naive/atomic_items.h 2011-11-02 17:19:09 +0000 | |||
687 | +++ src/store/naive/atomic_items.h 2011-11-29 00:43:26 +0000 | |||
688 | @@ -173,7 +173,7 @@ | |||
689 | 173 | 173 | ||
690 | 174 | xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); } | 174 | xs_integer getIntegerValue() const { return theBaseItem->getIntegerValue(); } |
691 | 175 | 175 | ||
693 | 176 | xs_uinteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); } | 176 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theBaseItem->getUnsignedIntegerValue(); } |
694 | 177 | 177 | ||
695 | 178 | xs_long getLongValue() const { return theBaseItem->getLongValue(); } | 178 | xs_long getLongValue() const { return theBaseItem->getLongValue(); } |
696 | 179 | 179 | ||
697 | @@ -1333,6 +1333,31 @@ | |||
698 | 1333 | ********************************************************************************/ | 1333 | ********************************************************************************/ |
699 | 1334 | class IntegerItem : public AtomicItem | 1334 | class IntegerItem : public AtomicItem |
700 | 1335 | { | 1335 | { |
701 | 1336 | protected: | ||
702 | 1337 | IntegerItem() {} | ||
703 | 1338 | |||
704 | 1339 | public: | ||
705 | 1340 | virtual xs_decimal getDecimalValue() const = 0; | ||
706 | 1341 | virtual xs_integer getIntegerValue() const = 0; | ||
707 | 1342 | virtual xs_long getLongValue() const = 0; | ||
708 | 1343 | |||
709 | 1344 | virtual store::Item_t getEBV() const = 0; | ||
710 | 1345 | virtual store::Item* getType() const = 0; | ||
711 | 1346 | |||
712 | 1347 | virtual zstring getStringValue() const = 0; | ||
713 | 1348 | virtual void getStringValue2(zstring&) const = 0; | ||
714 | 1349 | virtual void appendStringValue(zstring& buf) const = 0; | ||
715 | 1350 | |||
716 | 1351 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const = 0; | ||
717 | 1352 | bool isNaN() const { return false; } | ||
718 | 1353 | }; | ||
719 | 1354 | |||
720 | 1355 | |||
721 | 1356 | /******************************************************************************* | ||
722 | 1357 | class IntegerItemImpl | ||
723 | 1358 | ********************************************************************************/ | ||
724 | 1359 | class IntegerItemImpl : public IntegerItem | ||
725 | 1360 | { | ||
726 | 1336 | friend class BasicItemFactory; | 1361 | friend class BasicItemFactory; |
727 | 1337 | friend class AtomicItem; | 1362 | friend class AtomicItem; |
728 | 1338 | 1363 | ||
729 | @@ -1340,44 +1365,35 @@ | |||
730 | 1340 | xs_integer theValue; | 1365 | xs_integer theValue; |
731 | 1341 | 1366 | ||
732 | 1342 | protected: | 1367 | protected: |
734 | 1343 | IntegerItem(const xs_integer& aValue) : theValue ( aValue ) {} | 1368 | IntegerItemImpl(const xs_integer& aValue) : theValue ( aValue ) {} |
735 | 1344 | 1369 | ||
737 | 1345 | IntegerItem() {} | 1370 | IntegerItemImpl() {} |
738 | 1346 | 1371 | ||
739 | 1347 | public: | 1372 | public: |
740 | 1348 | xs_decimal getDecimalValue() const; | 1373 | xs_decimal getDecimalValue() const; |
741 | 1349 | |||
742 | 1350 | xs_integer getIntegerValue() const { return theValue; } | 1374 | xs_integer getIntegerValue() const { return theValue; } |
746 | 1351 | 1375 | xs_long getLongValue() const; | |
747 | 1352 | xs_long getLongValue() const; | 1376 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; } |
748 | 1353 | 1377 | ||
749 | 1378 | zstring getStringValue() const; | ||
750 | 1379 | void getStringValue2(zstring&) const; | ||
751 | 1380 | void appendStringValue(zstring&) const; | ||
752 | 1381 | |||
753 | 1382 | store::Item_t getEBV() const; | ||
754 | 1354 | virtual SchemaTypeCode getTypeCode() const { return XS_INTEGER; } | 1383 | virtual SchemaTypeCode getTypeCode() const { return XS_INTEGER; } |
755 | 1355 | |||
756 | 1356 | virtual store::Item* getType() const; | 1384 | virtual store::Item* getType() const; |
757 | 1357 | |||
758 | 1358 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; | 1385 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; |
759 | 1386 | virtual zstring show() const; | ||
760 | 1387 | |||
761 | 1388 | long compare( | ||
762 | 1389 | const Item* other, | ||
763 | 1390 | long timezone = 0, | ||
764 | 1391 | const XQPCollator* aCollation = 0) const; | ||
765 | 1359 | 1392 | ||
766 | 1360 | bool equals( | 1393 | bool equals( |
767 | 1361 | const store::Item* other, | 1394 | const store::Item* other, |
768 | 1362 | long timezone = 0, | 1395 | long timezone = 0, |
769 | 1363 | const XQPCollator* aCollation = 0) const; | 1396 | const XQPCollator* aCollation = 0) const; |
770 | 1364 | |||
771 | 1365 | long compare( | ||
772 | 1366 | const Item* other, | ||
773 | 1367 | long timezone = 0, | ||
774 | 1368 | const XQPCollator* aCollation = 0) const; | ||
775 | 1369 | |||
776 | 1370 | store::Item_t getEBV( ) const; | ||
777 | 1371 | |||
778 | 1372 | zstring getStringValue() const; | ||
779 | 1373 | |||
780 | 1374 | void getStringValue2(zstring& val) const; | ||
781 | 1375 | |||
782 | 1376 | void appendStringValue(zstring& buf) const; | ||
783 | 1377 | |||
784 | 1378 | bool isNaN() const { return false; } | ||
785 | 1379 | |||
786 | 1380 | virtual zstring show() const; | ||
787 | 1381 | }; | 1397 | }; |
788 | 1382 | 1398 | ||
789 | 1383 | 1399 | ||
790 | @@ -1389,28 +1405,50 @@ | |||
791 | 1389 | friend class BasicItemFactory; | 1405 | friend class BasicItemFactory; |
792 | 1390 | 1406 | ||
793 | 1391 | protected: | 1407 | protected: |
795 | 1392 | NonPositiveIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {} | 1408 | xs_nonPositiveInteger theValue; |
796 | 1409 | |||
797 | 1410 | NonPositiveIntegerItem(const xs_integer& aValue) : theValue(aValue) {} | ||
798 | 1393 | 1411 | ||
799 | 1394 | NonPositiveIntegerItem() {} | 1412 | NonPositiveIntegerItem() {} |
800 | 1395 | 1413 | ||
801 | 1396 | public: | 1414 | public: |
802 | 1415 | // inherited | ||
803 | 1416 | xs_decimal getDecimalValue() const; | ||
804 | 1417 | xs_integer getIntegerValue() const; | ||
805 | 1418 | xs_long getLongValue() const; | ||
806 | 1419 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; } | ||
807 | 1420 | |||
808 | 1421 | zstring getStringValue() const; | ||
809 | 1422 | void getStringValue2(zstring& val) const; | ||
810 | 1423 | void appendStringValue(zstring&) const; | ||
811 | 1424 | |||
812 | 1425 | store::Item_t getEBV() const; | ||
813 | 1426 | store::Item* getType() const; | ||
814 | 1397 | SchemaTypeCode getTypeCode() const { return XS_NON_POSITIVE_INTEGER; } | 1427 | SchemaTypeCode getTypeCode() const { return XS_NON_POSITIVE_INTEGER; } |
818 | 1398 | 1428 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; | |
816 | 1399 | store::Item* getType() const; | ||
817 | 1400 | |||
819 | 1401 | zstring show() const; | 1429 | zstring show() const; |
820 | 1430 | |||
821 | 1431 | long compare( | ||
822 | 1432 | const Item* other, | ||
823 | 1433 | long timezone = 0, | ||
824 | 1434 | const XQPCollator* aCollation = 0) const; | ||
825 | 1435 | |||
826 | 1436 | bool equals( | ||
827 | 1437 | const store::Item* other, | ||
828 | 1438 | long timezone = 0, | ||
829 | 1439 | const XQPCollator* aCollation = 0) const; | ||
830 | 1402 | }; | 1440 | }; |
831 | 1403 | 1441 | ||
832 | 1404 | 1442 | ||
833 | 1405 | /******************************************************************************* | 1443 | /******************************************************************************* |
834 | 1406 | class NegativeIntegerItem | 1444 | class NegativeIntegerItem |
835 | 1407 | ********************************************************************************/ | 1445 | ********************************************************************************/ |
837 | 1408 | class NegativeIntegerItem : public IntegerItem | 1446 | class NegativeIntegerItem : public NonPositiveIntegerItem |
838 | 1409 | { | 1447 | { |
839 | 1410 | friend class BasicItemFactory; | 1448 | friend class BasicItemFactory; |
840 | 1411 | 1449 | ||
841 | 1412 | protected: | 1450 | protected: |
843 | 1413 | NegativeIntegerItem(const xs_integer& aValue) : IntegerItem(aValue) {} | 1451 | NegativeIntegerItem(const xs_integer& aValue) : NonPositiveIntegerItem(aValue) {} |
844 | 1414 | 1452 | ||
845 | 1415 | NegativeIntegerItem() {} | 1453 | NegativeIntegerItem() {} |
846 | 1416 | 1454 | ||
847 | @@ -1425,44 +1463,60 @@ | |||
848 | 1425 | 1463 | ||
849 | 1426 | /******************************************************************************* | 1464 | /******************************************************************************* |
850 | 1427 | class NonNegativeIntegerItem | 1465 | class NonNegativeIntegerItem |
851 | 1428 | |||
852 | 1429 | Note: xs_uinteger is typedef of Integer | ||
853 | 1430 | ********************************************************************************/ | 1466 | ********************************************************************************/ |
854 | 1431 | class NonNegativeIntegerItem : public IntegerItem | 1467 | class NonNegativeIntegerItem : public IntegerItem |
855 | 1432 | { | 1468 | { |
856 | 1433 | friend class BasicItemFactory; | 1469 | friend class BasicItemFactory; |
857 | 1434 | 1470 | ||
858 | 1435 | protected: | 1471 | protected: |
860 | 1436 | NonNegativeIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) {} | 1472 | xs_nonNegativeInteger theValue; |
861 | 1473 | |||
862 | 1474 | NonNegativeIntegerItem(const xs_nonNegativeInteger& aValue) : theValue(aValue) {} | ||
863 | 1437 | 1475 | ||
864 | 1438 | NonNegativeIntegerItem() {} | 1476 | NonNegativeIntegerItem() {} |
865 | 1439 | 1477 | ||
866 | 1440 | public: | 1478 | public: |
868 | 1441 | xs_uinteger getUnsignedIntegerValue() const { return theValue; } | 1479 | // inherited |
869 | 1480 | xs_decimal getDecimalValue() const; | ||
870 | 1481 | xs_integer getIntegerValue() const; | ||
871 | 1482 | xs_long getLongValue() const; | ||
872 | 1483 | xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; } | ||
873 | 1442 | 1484 | ||
874 | 1485 | store::Item_t getEBV() const; | ||
875 | 1486 | store::Item* getType() const; | ||
876 | 1443 | SchemaTypeCode getTypeCode() const { return XS_NON_NEGATIVE_INTEGER; } | 1487 | SchemaTypeCode getTypeCode() const { return XS_NON_NEGATIVE_INTEGER; } |
880 | 1444 | 1488 | uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const; | |
878 | 1445 | store::Item* getType() const; | ||
879 | 1446 | |||
881 | 1447 | zstring show() const; | 1489 | zstring show() const; |
882 | 1490 | |||
883 | 1491 | zstring getStringValue() const; | ||
884 | 1492 | void getStringValue2(zstring& val) const; | ||
885 | 1493 | void appendStringValue(zstring&) const; | ||
886 | 1494 | |||
887 | 1495 | long compare( | ||
888 | 1496 | const Item* other, | ||
889 | 1497 | long timezone = 0, | ||
890 | 1498 | const XQPCollator* aCollation = 0) const; | ||
891 | 1499 | |||
892 | 1500 | bool equals( | ||
893 | 1501 | const store::Item* other, | ||
894 | 1502 | long timezone = 0, | ||
895 | 1503 | const XQPCollator* aCollation = 0) const; | ||
896 | 1448 | }; | 1504 | }; |
897 | 1449 | 1505 | ||
898 | 1450 | 1506 | ||
899 | 1451 | /******************************************************************************* | 1507 | /******************************************************************************* |
900 | 1452 | class PositiveIntegerItem | 1508 | class PositiveIntegerItem |
901 | 1453 | ********************************************************************************/ | 1509 | ********************************************************************************/ |
903 | 1454 | class PositiveIntegerItem : public IntegerItem | 1510 | class PositiveIntegerItem : public NonNegativeIntegerItem |
904 | 1455 | { | 1511 | { |
905 | 1456 | friend class BasicItemFactory; | 1512 | friend class BasicItemFactory; |
906 | 1457 | 1513 | ||
907 | 1458 | protected: | 1514 | protected: |
909 | 1459 | PositiveIntegerItem(const xs_uinteger& aValue) : IntegerItem(aValue) { } | 1515 | PositiveIntegerItem(const xs_positiveInteger& aValue) : NonNegativeIntegerItem(aValue) { } |
910 | 1460 | 1516 | ||
911 | 1461 | PositiveIntegerItem() {} | 1517 | PositiveIntegerItem() {} |
912 | 1462 | 1518 | ||
913 | 1463 | public: | 1519 | public: |
914 | 1464 | xs_uinteger getUnsignedIntegerValue() const { return theValue; } | ||
915 | 1465 | |||
916 | 1466 | SchemaTypeCode getTypeCode() const { return XS_POSITIVE_INTEGER; } | 1520 | SchemaTypeCode getTypeCode() const { return XS_POSITIVE_INTEGER; } |
917 | 1467 | 1521 | ||
918 | 1468 | store::Item* getType() const; | 1522 | store::Item* getType() const; |
919 | @@ -1494,6 +1548,8 @@ | |||
920 | 1494 | 1548 | ||
921 | 1495 | xs_long getLongValue() const { return theValue; } | 1549 | xs_long getLongValue() const { return theValue; } |
922 | 1496 | 1550 | ||
923 | 1551 | xs_nonNegativeInteger getUnsignedIntegerValue() const; | ||
924 | 1552 | |||
925 | 1497 | SchemaTypeCode getTypeCode() const { return XS_LONG; } | 1553 | SchemaTypeCode getTypeCode() const { return XS_LONG; } |
926 | 1498 | 1554 | ||
927 | 1499 | store::Item* getType() const; | 1555 | store::Item* getType() const; |
928 | @@ -1818,7 +1874,7 @@ | |||
929 | 1818 | 1874 | ||
930 | 1819 | xs_integer getIntegerValue() const; | 1875 | xs_integer getIntegerValue() const; |
931 | 1820 | 1876 | ||
933 | 1821 | xs_uinteger getUnsignedIntegerValue() const; | 1877 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
934 | 1822 | 1878 | ||
935 | 1823 | xs_unsignedLong getUnsignedLongValue() const { return theValue; } | 1879 | xs_unsignedLong getUnsignedLongValue() const { return theValue; } |
936 | 1824 | 1880 | ||
937 | @@ -1898,7 +1954,7 @@ | |||
938 | 1898 | 1954 | ||
939 | 1899 | xs_integer getIntegerValue() const; | 1955 | xs_integer getIntegerValue() const; |
940 | 1900 | 1956 | ||
942 | 1901 | xs_uinteger getUnsignedIntegerValue() const; | 1957 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
943 | 1902 | 1958 | ||
944 | 1903 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } | 1959 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } |
945 | 1904 | 1960 | ||
946 | @@ -1987,7 +2043,7 @@ | |||
947 | 1987 | 2043 | ||
948 | 1988 | xs_integer getIntegerValue() const; | 2044 | xs_integer getIntegerValue() const; |
949 | 1989 | 2045 | ||
951 | 1990 | xs_uinteger getUnsignedIntegerValue() const; | 2046 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
952 | 1991 | 2047 | ||
953 | 1992 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } | 2048 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } |
954 | 1993 | 2049 | ||
955 | @@ -2080,7 +2136,7 @@ | |||
956 | 2080 | 2136 | ||
957 | 2081 | xs_integer getIntegerValue() const; | 2137 | xs_integer getIntegerValue() const; |
958 | 2082 | 2138 | ||
960 | 2083 | xs_uinteger getUnsignedIntegerValue() const; | 2139 | xs_nonNegativeInteger getUnsignedIntegerValue() const; |
961 | 2084 | 2140 | ||
962 | 2085 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } | 2141 | xs_long getLongValue() const { return static_cast<xs_long>(theValue); } |
963 | 2086 | 2142 | ||
964 | 2087 | 2143 | ||
965 | === modified file 'src/store/naive/item.cpp' | |||
966 | --- src/store/naive/item.cpp 2011-10-15 10:41:19 +0000 | |||
967 | +++ src/store/naive/item.cpp 2011-11-29 00:43:26 +0000 | |||
968 | @@ -508,7 +508,7 @@ | |||
969 | 508 | * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort, | 508 | * Accessor for xs:unsignedLong, xs:unsignedInt, xs:unsignedShort, |
970 | 509 | * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger | 509 | * xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger |
971 | 510 | */ | 510 | */ |
973 | 511 | xs_uinteger Item::getUnsignedIntegerValue() const | 511 | xs_nonNegativeInteger Item::getUnsignedIntegerValue() const |
974 | 512 | { | 512 | { |
975 | 513 | throw ZORBA_EXCEPTION( | 513 | throw ZORBA_EXCEPTION( |
976 | 514 | zerr::ZSTR0040_TYPE_ERROR, | 514 | zerr::ZSTR0040_TYPE_ERROR, |
977 | 515 | 515 | ||
978 | === modified file 'src/store/naive/simple_item_factory.cpp' | |||
979 | --- src/store/naive/simple_item_factory.cpp 2011-10-15 10:41:19 +0000 | |||
980 | +++ src/store/naive/simple_item_factory.cpp 2011-11-29 00:43:26 +0000 | |||
981 | @@ -314,7 +314,7 @@ | |||
982 | 314 | 314 | ||
983 | 315 | bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value) | 315 | bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value) |
984 | 316 | { | 316 | { |
986 | 317 | result = new IntegerItem( value ); | 317 | result = new IntegerItemImpl( value ); |
987 | 318 | return true; | 318 | return true; |
988 | 319 | } | 319 | } |
989 | 320 | 320 | ||
990 | @@ -323,7 +323,7 @@ | |||
991 | 323 | store::Item_t& result, | 323 | store::Item_t& result, |
992 | 324 | const xs_integer& value) | 324 | const xs_integer& value) |
993 | 325 | { | 325 | { |
995 | 326 | ZORBA_ASSERT(value <= Integer::zero()); | 326 | ZORBA_ASSERT(value.sign() <= 0); |
996 | 327 | result = new NonPositiveIntegerItem( value ); | 327 | result = new NonPositiveIntegerItem( value ); |
997 | 328 | return true; | 328 | return true; |
998 | 329 | } | 329 | } |
999 | @@ -333,7 +333,7 @@ | |||
1000 | 333 | store::Item_t& result, | 333 | store::Item_t& result, |
1001 | 334 | const xs_integer& value) | 334 | const xs_integer& value) |
1002 | 335 | { | 335 | { |
1004 | 336 | ZORBA_ASSERT(value < xs_integer::zero()); | 336 | ZORBA_ASSERT(value.sign() < 0); |
1005 | 337 | result = new NegativeIntegerItem(value); | 337 | result = new NegativeIntegerItem(value); |
1006 | 338 | return true; | 338 | return true; |
1007 | 339 | } | 339 | } |
1008 | @@ -341,7 +341,7 @@ | |||
1009 | 341 | 341 | ||
1010 | 342 | bool BasicItemFactory::createNonNegativeInteger( | 342 | bool BasicItemFactory::createNonNegativeInteger( |
1011 | 343 | store::Item_t& result, | 343 | store::Item_t& result, |
1013 | 344 | const xs_uinteger& value ) | 344 | const xs_nonNegativeInteger& value ) |
1014 | 345 | { | 345 | { |
1015 | 346 | result = new NonNegativeIntegerItem( value ); | 346 | result = new NonNegativeIntegerItem( value ); |
1016 | 347 | return true; | 347 | return true; |
1017 | @@ -351,9 +351,9 @@ | |||
1018 | 351 | 351 | ||
1019 | 352 | bool BasicItemFactory::createPositiveInteger( | 352 | bool BasicItemFactory::createPositiveInteger( |
1020 | 353 | store::Item_t& result, | 353 | store::Item_t& result, |
1022 | 354 | const xs_uinteger& value) | 354 | const xs_positiveInteger& value) |
1023 | 355 | { | 355 | { |
1025 | 356 | ZORBA_ASSERT(value > Integer::zero()); | 356 | ZORBA_ASSERT(value.sign() > 0); |
1026 | 357 | result = new PositiveIntegerItem( value ); | 357 | result = new PositiveIntegerItem( value ); |
1027 | 358 | return true; | 358 | return true; |
1028 | 359 | } | 359 | } |
1029 | 360 | 360 | ||
1030 | === modified file 'src/store/naive/simple_item_factory.h' | |||
1031 | --- src/store/naive/simple_item_factory.h 2011-10-15 10:41:19 +0000 | |||
1032 | +++ src/store/naive/simple_item_factory.h 2011-11-29 00:43:26 +0000 | |||
1033 | @@ -111,9 +111,9 @@ | |||
1034 | 111 | 111 | ||
1035 | 112 | bool createInteger(store::Item_t& result, const xs_integer& value); | 112 | bool createInteger(store::Item_t& result, const xs_integer& value); |
1036 | 113 | 113 | ||
1038 | 114 | bool createNonNegativeInteger(store::Item_t& result, const xs_uinteger& value); | 114 | bool createNonNegativeInteger(store::Item_t& result, const xs_nonNegativeInteger& value); |
1039 | 115 | 115 | ||
1041 | 116 | bool createPositiveInteger(store::Item_t& result, const xs_uinteger& value ); | 116 | bool createPositiveInteger(store::Item_t& result, const xs_positiveInteger& value ); |
1042 | 117 | 117 | ||
1043 | 118 | bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value); | 118 | bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value); |
1044 | 119 | 119 | ||
1045 | 120 | 120 | ||
1046 | === modified file 'src/types/casting.cpp' | |||
1047 | --- src/types/casting.cpp 2011-10-22 15:44:45 +0000 | |||
1048 | +++ src/types/casting.cpp 2011-11-29 00:43:26 +0000 | |||
1049 | @@ -119,6 +119,7 @@ | |||
1050 | 119 | SAME_S_AND_T(aURI) | 119 | SAME_S_AND_T(aURI) |
1051 | 120 | SAME_S_AND_T(QN) | 120 | SAME_S_AND_T(QN) |
1052 | 121 | SAME_S_AND_T(NOT) | 121 | SAME_S_AND_T(NOT) |
1053 | 122 | SAME_S_AND_T(uint) | ||
1054 | 122 | 123 | ||
1055 | 123 | #undef SAME_S_AND_T | 124 | #undef SAME_S_AND_T |
1056 | 124 | 125 | ||
1057 | @@ -1263,6 +1264,148 @@ | |||
1058 | 1263 | return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo); | 1264 | return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo); |
1059 | 1264 | } | 1265 | } |
1060 | 1265 | 1266 | ||
1061 | 1267 | T1_TO_T2(uint, uA) | ||
1062 | 1268 | { | ||
1063 | 1269 | zstring strval2; | ||
1064 | 1270 | aItem->getStringValue2(strval2); | ||
1065 | 1271 | return str_uA(result, aItem, strval2, aFactory, nsCtx, aErrorInfo); | ||
1066 | 1272 | } | ||
1067 | 1273 | |||
1068 | 1274 | |||
1069 | 1275 | T1_TO_T2(uint, str) | ||
1070 | 1276 | { | ||
1071 | 1277 | return uA_str(result, aItem, strval, aFactory, nsCtx, aErrorInfo); | ||
1072 | 1278 | } | ||
1073 | 1279 | |||
1074 | 1280 | |||
1075 | 1281 | T1_TO_T2(uint, flt) | ||
1076 | 1282 | { | ||
1077 | 1283 | return aFactory->createFloat( | ||
1078 | 1284 | result, xs_float(aItem->getUnsignedIntegerValue()) | ||
1079 | 1285 | ); | ||
1080 | 1286 | } | ||
1081 | 1287 | |||
1082 | 1288 | |||
1083 | 1289 | T1_TO_T2(uint, dbl) | ||
1084 | 1290 | { | ||
1085 | 1291 | return aFactory->createDouble( | ||
1086 | 1292 | result, xs_double(aItem->getUnsignedIntegerValue()) | ||
1087 | 1293 | ); | ||
1088 | 1294 | } | ||
1089 | 1295 | |||
1090 | 1296 | |||
1091 | 1297 | T1_TO_T2(uint, dec) | ||
1092 | 1298 | { | ||
1093 | 1299 | return aFactory->createDecimal( | ||
1094 | 1300 | result, xs_decimal(aItem->getUnsignedIntegerValue()) | ||
1095 | 1301 | ); | ||
1096 | 1302 | } | ||
1097 | 1303 | |||
1098 | 1304 | |||
1099 | 1305 | T1_TO_T2(uint, bool) | ||
1100 | 1306 | { | ||
1101 | 1307 | result = aItem->getEBV(); | ||
1102 | 1308 | return true; | ||
1103 | 1309 | } | ||
1104 | 1310 | |||
1105 | 1311 | |||
1106 | 1312 | T1_TO_T2(uA, uint) | ||
1107 | 1313 | { | ||
1108 | 1314 | zstring strval2; | ||
1109 | 1315 | aItem->getStringValue2(strval2); | ||
1110 | 1316 | return str_int(result, aItem, strval2, aFactory, nsCtx, aErrorInfo); | ||
1111 | 1317 | } | ||
1112 | 1318 | |||
1113 | 1319 | |||
1114 | 1320 | T1_TO_T2(flt, uint) | ||
1115 | 1321 | { | ||
1116 | 1322 | try | ||
1117 | 1323 | { | ||
1118 | 1324 | xs_nonNegativeInteger const n(aItem->getFloatValue()); | ||
1119 | 1325 | return aFactory->createNonNegativeInteger(result, n); | ||
1120 | 1326 | } | ||
1121 | 1327 | catch ( std::exception const& ) | ||
1122 | 1328 | { | ||
1123 | 1329 | throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo ); | ||
1124 | 1330 | } | ||
1125 | 1331 | } | ||
1126 | 1332 | |||
1127 | 1333 | |||
1128 | 1334 | T1_TO_T2(int, uint) | ||
1129 | 1335 | { | ||
1130 | 1336 | try | ||
1131 | 1337 | { | ||
1132 | 1338 | xs_nonNegativeInteger const n(aItem->getIntegerValue()); | ||
1133 | 1339 | return aFactory->createNonNegativeInteger(result, n); | ||
1134 | 1340 | } | ||
1135 | 1341 | catch ( std::exception const& ) | ||
1136 | 1342 | { | ||
1137 | 1343 | throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo ); | ||
1138 | 1344 | } | ||
1139 | 1345 | } | ||
1140 | 1346 | |||
1141 | 1347 | |||
1142 | 1348 | T1_TO_T2(uint, int) | ||
1143 | 1349 | { | ||
1144 | 1350 | try | ||
1145 | 1351 | { | ||
1146 | 1352 | xs_integer const n(aItem->getIntegerValue()); | ||
1147 | 1353 | return aFactory->createInteger(result, n); | ||
1148 | 1354 | } | ||
1149 | 1355 | catch ( std::exception const& ) | ||
1150 | 1356 | { | ||
1151 | 1357 | throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo ); | ||
1152 | 1358 | } | ||
1153 | 1359 | } | ||
1154 | 1360 | |||
1155 | 1361 | |||
1156 | 1362 | T1_TO_T2(dbl, uint) | ||
1157 | 1363 | { | ||
1158 | 1364 | try | ||
1159 | 1365 | { | ||
1160 | 1366 | xs_nonNegativeInteger const n(aItem->getDoubleValue()); | ||
1161 | 1367 | return aFactory->createInteger(result, n); | ||
1162 | 1368 | } | ||
1163 | 1369 | catch ( std::exception const& ) | ||
1164 | 1370 | { | ||
1165 | 1371 | throw TYPE_EXCEPTION( err::FOCA0002, aErrorInfo ); | ||
1166 | 1372 | } | ||
1167 | 1373 | } | ||
1168 | 1374 | |||
1169 | 1375 | |||
1170 | 1376 | T1_TO_T2(dec, uint) | ||
1171 | 1377 | { | ||
1172 | 1378 | xs_nonNegativeInteger const n(aItem->getDecimalValue()); | ||
1173 | 1379 | return aFactory->createNonNegativeInteger(result, n); | ||
1174 | 1380 | } | ||
1175 | 1381 | |||
1176 | 1382 | |||
1177 | 1383 | T1_TO_T2(bool, uint) | ||
1178 | 1384 | { | ||
1179 | 1385 | if (aItem->getBooleanValue()) | ||
1180 | 1386 | return aFactory->createNonNegativeInteger( | ||
1181 | 1387 | result, xs_nonNegativeInteger::one() | ||
1182 | 1388 | ); | ||
1183 | 1389 | else | ||
1184 | 1390 | return aFactory->createNonNegativeInteger( | ||
1185 | 1391 | result, xs_nonNegativeInteger::zero() | ||
1186 | 1392 | ); | ||
1187 | 1393 | } | ||
1188 | 1394 | |||
1189 | 1395 | |||
1190 | 1396 | T1_TO_T2(str, uint) | ||
1191 | 1397 | { | ||
1192 | 1398 | try { | ||
1193 | 1399 | xs_nonNegativeInteger const n(strval.c_str()); | ||
1194 | 1400 | return aFactory->createNonNegativeInteger(result, n); | ||
1195 | 1401 | } | ||
1196 | 1402 | catch ( std::invalid_argument const& ) { | ||
1197 | 1403 | throw TYPE_EXCEPTION( err::FORG0001, aErrorInfo ); | ||
1198 | 1404 | } | ||
1199 | 1405 | catch ( std::range_error const& ) { | ||
1200 | 1406 | throw TYPE_EXCEPTION( err::FOAR0002, aErrorInfo ); | ||
1201 | 1407 | } | ||
1202 | 1408 | } | ||
1203 | 1266 | 1409 | ||
1204 | 1267 | /******************************************************************************* | 1410 | /******************************************************************************* |
1205 | 1268 | 1411 | ||
1206 | @@ -1371,14 +1514,14 @@ | |||
1207 | 1371 | case TypeConstants::XS_NON_POSITIVE_INTEGER: | 1514 | case TypeConstants::XS_NON_POSITIVE_INTEGER: |
1208 | 1372 | { | 1515 | { |
1209 | 1373 | xs_integer const lInteger = aItem->getIntegerValue(); | 1516 | xs_integer const lInteger = aItem->getIntegerValue(); |
1211 | 1374 | if (lInteger <= xs_integer::zero()) | 1517 | if (lInteger.sign() <= 0) |
1212 | 1375 | return aFactory->createNonPositiveInteger(result, lInteger); | 1518 | return aFactory->createNonPositiveInteger(result, lInteger); |
1213 | 1376 | break; | 1519 | break; |
1214 | 1377 | } | 1520 | } |
1215 | 1378 | case TypeConstants::XS_NEGATIVE_INTEGER: | 1521 | case TypeConstants::XS_NEGATIVE_INTEGER: |
1216 | 1379 | { | 1522 | { |
1217 | 1380 | xs_integer const lInteger = aItem->getIntegerValue(); | 1523 | xs_integer const lInteger = aItem->getIntegerValue(); |
1219 | 1381 | if (lInteger < xs_integer::zero()) | 1524 | if (lInteger.sign() < 0) |
1220 | 1382 | return aFactory->createNegativeInteger(result, lInteger); | 1525 | return aFactory->createNegativeInteger(result, lInteger); |
1221 | 1383 | break; | 1526 | break; |
1222 | 1384 | } | 1527 | } |
1223 | @@ -1436,9 +1579,15 @@ | |||
1224 | 1436 | } | 1579 | } |
1225 | 1437 | case TypeConstants::XS_NON_NEGATIVE_INTEGER: | 1580 | case TypeConstants::XS_NON_NEGATIVE_INTEGER: |
1226 | 1438 | { | 1581 | { |
1230 | 1439 | xs_integer const lInteger = aItem->getIntegerValue(); | 1582 | xs_decimal const d = aItem->getDecimalValue(); |
1231 | 1440 | if (lInteger >= xs_integer::zero()) | 1583 | if (d.sign() >= 0) |
1232 | 1441 | return aFactory->createNonNegativeInteger(result, lInteger); | 1584 | try { |
1233 | 1585 | xs_nonNegativeInteger const i(d); | ||
1234 | 1586 | return aFactory->createNonNegativeInteger(result, i); | ||
1235 | 1587 | } | ||
1236 | 1588 | catch ( std::exception const& ) { | ||
1237 | 1589 | // ignore | ||
1238 | 1590 | } | ||
1239 | 1442 | break; | 1591 | break; |
1240 | 1443 | } | 1592 | } |
1241 | 1444 | case TypeConstants::XS_UNSIGNED_LONG: | 1593 | case TypeConstants::XS_UNSIGNED_LONG: |
1242 | @@ -1495,9 +1644,9 @@ | |||
1243 | 1495 | } | 1644 | } |
1244 | 1496 | case TypeConstants::XS_POSITIVE_INTEGER: | 1645 | case TypeConstants::XS_POSITIVE_INTEGER: |
1245 | 1497 | { | 1646 | { |
1249 | 1498 | xs_integer lInteger = aItem->getIntegerValue(); | 1647 | xs_positiveInteger const i = aItem->getUnsignedIntegerValue(); |
1250 | 1499 | if (lInteger > xs_integer::zero()) | 1648 | if (i.sign() > 0) |
1251 | 1500 | return aFactory->createPositiveInteger(result, lInteger); | 1649 | return aFactory->createPositiveInteger(result, i); |
1252 | 1501 | break; | 1650 | break; |
1253 | 1502 | } | 1651 | } |
1254 | 1503 | default: | 1652 | default: |
1255 | @@ -1541,12 +1690,12 @@ | |||
1256 | 1541 | 5, // 25 XS_INT | 1690 | 5, // 25 XS_INT |
1257 | 1542 | 5, // 26 XS_SHORT | 1691 | 5, // 26 XS_SHORT |
1258 | 1543 | 5, // 27 XS_BYTE | 1692 | 5, // 27 XS_BYTE |
1265 | 1544 | 5, // 28 XS_NON_NEGATIVE_INTEGER | 1693 | 23, // 28 XS_NON_NEGATIVE_INTEGER |
1266 | 1545 | 5, // 29 XS_UNSIGNED_LONG | 1694 | 23, // 29 XS_UNSIGNED_LONG |
1267 | 1546 | 5, // 30 XS_UNSIGNED_INT | 1695 | 23, // 30 XS_UNSIGNED_INT |
1268 | 1547 | 5, // 31 XS_UNSIGNED_SHORT | 1696 | 23, // 31 XS_UNSIGNED_SHORT |
1269 | 1548 | 5, // 32 XS_UNSIGNED_BYTE | 1697 | 23, // 32 XS_UNSIGNED_BYTE |
1270 | 1549 | 5, // 33 XS_POSITIVE_INTEGER | 1698 | 23, // 33 XS_POSITIVE_INTEGER |
1271 | 1550 | 12, // 34 XS_GYEAR_MONTH | 1699 | 12, // 34 XS_GYEAR_MONTH |
1272 | 1551 | 13, // 35 XS_GYEAR | 1700 | 13, // 35 XS_GYEAR |
1273 | 1552 | 14, // 36 XS_GMONTH_DAY | 1701 | 14, // 36 XS_GMONTH_DAY |
1274 | @@ -1564,98 +1713,155 @@ | |||
1275 | 1564 | /******************************************************************************* | 1713 | /******************************************************************************* |
1276 | 1565 | 1714 | ||
1277 | 1566 | ********************************************************************************/ | 1715 | ********************************************************************************/ |
1279 | 1567 | const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[23] = | 1716 | const GenericCast::DownCastFunc GenericCast::theDownCastMatrix[24] = |
1280 | 1568 | { | 1717 | { |
1284 | 1569 | /*uA*/ 0, /*str*/ str_down, /*flt*/ 0, /*dbl*/ 0, /*dec*/ 0, /*int*/ int_down, /*dur*/ 0, | 1718 | /*uA*/ 0, |
1285 | 1570 | /*yMD*/ 0, /*dTD*/ 0, /*dT*/ 0, /*tim*/ 0, /*dat*/ 0, /*gYM*/ 0, /*gYr*/ 0, /*gMD*/ 0, | 1719 | /*str*/ str_down, |
1286 | 1571 | /*gDay*/0, /*gMon*/0, /*bool*/0, /*b64*/ 0, /*hxB*/ 0, /*aURI*/0, /*QN*/ 0, /*NOT*/ 0 | 1720 | /*flt*/ 0, |
1287 | 1721 | /*dbl*/ 0, | ||
1288 | 1722 | /*dec*/ 0, | ||
1289 | 1723 | /*int*/ int_down, | ||
1290 | 1724 | /*dur*/ 0, | ||
1291 | 1725 | /*yMD*/ 0, | ||
1292 | 1726 | /*dTD*/ 0, | ||
1293 | 1727 | /*dT*/ 0, | ||
1294 | 1728 | /*tim*/ 0, | ||
1295 | 1729 | /*dat*/ 0, | ||
1296 | 1730 | /*gYM*/ 0, | ||
1297 | 1731 | /*gYr*/ 0, | ||
1298 | 1732 | /*gMD*/ 0, | ||
1299 | 1733 | /*gDay*/ 0, | ||
1300 | 1734 | /*gMon*/ 0, | ||
1301 | 1735 | /*bool*/ 0, | ||
1302 | 1736 | /*b64*/ 0, | ||
1303 | 1737 | /*hxB*/ 0, | ||
1304 | 1738 | /*aURI*/ 0, | ||
1305 | 1739 | /*QN*/ 0, | ||
1306 | 1740 | /*NOT*/ 0, | ||
1307 | 1741 | /*uint*/ int_down, | ||
1308 | 1572 | }; | 1742 | }; |
1309 | 1573 | 1743 | ||
1310 | 1574 | 1744 | ||
1311 | 1575 | /******************************************************************************* | 1745 | /******************************************************************************* |
1312 | 1576 | 1746 | ||
1313 | 1577 | ********************************************************************************/ | 1747 | ********************************************************************************/ |
1315 | 1578 | const GenericCast::CastFunc GenericCast::theCastMatrix[23][23] = | 1748 | const GenericCast::CastFunc GenericCast::theCastMatrix[24][24] = |
1316 | 1579 | { | 1749 | { |
1317 | 1580 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | 1750 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ |
1318 | 1581 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | 1751 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ |
1320 | 1582 | /*aURI*/ /*QN*/ /*NOT*/ | 1752 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ |
1321 | 1753 | |||
1322 | 1583 | /*uA*/ {&uA_uA, &uA_str, &uA_flt, &uA_dbl, &uA_dec, &uA_int, &uA_dur, &uA_yMD, &uA_dTD, &uA_dT, | 1754 | /*uA*/ {&uA_uA, &uA_str, &uA_flt, &uA_dbl, &uA_dec, &uA_int, &uA_dur, &uA_yMD, &uA_dTD, &uA_dT, |
1323 | 1584 | &uA_tim, &uA_dat, &uA_gYM, &uA_gYr, &uA_gMD, &uA_gDay, &uA_gMon, &uA_bool, &uA_b64, &uA_hxB, | 1755 | &uA_tim, &uA_dat, &uA_gYM, &uA_gYr, &uA_gMD, &uA_gDay, &uA_gMon, &uA_bool, &uA_b64, &uA_hxB, |
1325 | 1585 | &uA_aURI, 0, 0}, | 1756 | &uA_aURI, 0, 0, &uA_uint}, |
1326 | 1586 | 1757 | ||
1327 | 1587 | /*str*/ {&str_uA, &str_str, &str_flt, &str_dbl, &str_dec, &str_int, &str_dur, &str_yMD, &str_dTD, &str_dT, | 1758 | /*str*/ {&str_uA, &str_str, &str_flt, &str_dbl, &str_dec, &str_int, &str_dur, &str_yMD, &str_dTD, &str_dT, |
1328 | 1588 | &str_tim, &str_dat, &str_gYM, &str_gYr, &str_gMD, &str_gDay, &str_gMon, &str_bool, &str_b64, &str_hxB, | 1759 | &str_tim, &str_dat, &str_gYM, &str_gYr, &str_gMD, &str_gDay, &str_gMon, &str_bool, &str_b64, &str_hxB, |
1330 | 1589 | &str_aURI, &str_QN, &str_NOT}, | 1760 | &str_aURI, &str_QN, &str_NOT, &str_uint}, |
1331 | 1590 | 1761 | ||
1332 | 1591 | /*flt*/ {&flt_uA, &flt_str, &flt_flt, &flt_dbl, &flt_dec, &flt_int, 0, 0, 0, 0, | 1762 | /*flt*/ {&flt_uA, &flt_str, &flt_flt, &flt_dbl, &flt_dec, &flt_int, 0, 0, 0, 0, |
1333 | 1592 | 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0, | 1763 | 0, 0, 0, 0, 0, 0, 0, &flt_bool, 0, 0, |
1335 | 1593 | 0, 0, 0}, | 1764 | 0, 0, 0, &flt_uint}, |
1336 | 1594 | 1765 | ||
1337 | 1595 | /*dbl*/ {&dbl_uA, &dbl_str, &dbl_flt, &dbl_dbl, &dbl_dec, &dbl_int, 0, 0, 0, 0, | 1766 | /*dbl*/ {&dbl_uA, &dbl_str, &dbl_flt, &dbl_dbl, &dbl_dec, &dbl_int, 0, 0, 0, 0, |
1338 | 1596 | 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0, | 1767 | 0, 0, 0, 0, 0, 0, 0, &dbl_bool, 0, 0, |
1340 | 1597 | 0, 0, 0}, | 1768 | 0, 0, 0, &dbl_uint}, |
1341 | 1598 | 1769 | ||
1342 | 1599 | /*dec*/ {&dec_uA, &dec_str, &dec_flt, &dec_dbl, &dec_dec, &dec_int, 0, 0, 0, 0, | 1770 | /*dec*/ {&dec_uA, &dec_str, &dec_flt, &dec_dbl, &dec_dec, &dec_int, 0, 0, 0, 0, |
1343 | 1600 | 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0, | 1771 | 0, 0, 0, 0, 0, 0, 0, &dec_bool, 0, 0, |
1345 | 1601 | 0, 0, 0}, | 1772 | 0, 0, 0, &dec_uint}, |
1346 | 1773 | |||
1347 | 1774 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1348 | 1775 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1349 | 1776 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1350 | 1777 | |||
1351 | 1602 | /*int*/ {&int_uA, &int_str, &int_flt, &int_dbl, &int_dec, &int_int, 0, 0, 0, 0, | 1778 | /*int*/ {&int_uA, &int_str, &int_flt, &int_dbl, &int_dec, &int_int, 0, 0, 0, 0, |
1352 | 1603 | 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0, | 1779 | 0, 0, 0, 0, 0, 0, 0, &int_bool, 0, 0, |
1354 | 1604 | 0, 0, 0}, | 1780 | 0, 0, 0, &int_uint}, |
1355 | 1781 | |||
1356 | 1605 | /*dur*/ {&dur_uA, &dur_str, 0, 0, 0, 0, &dur_dur, &dur_yMD, &dur_dTD, 0, | 1782 | /*dur*/ {&dur_uA, &dur_str, 0, 0, 0, 0, &dur_dur, &dur_yMD, &dur_dTD, 0, |
1357 | 1606 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1783 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1359 | 1607 | 0, 0, 0}, | 1784 | 0, 0, 0, 0}, |
1360 | 1785 | |||
1361 | 1608 | /*yMD*/ {&yMD_uA, &yMD_str, 0, 0, 0, 0, &yMD_dur, &yMD_yMD, &yMD_dTD, 0, | 1786 | /*yMD*/ {&yMD_uA, &yMD_str, 0, 0, 0, 0, &yMD_dur, &yMD_yMD, &yMD_dTD, 0, |
1362 | 1609 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1787 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1364 | 1610 | 0, 0, 0}, | 1788 | 0, 0, 0, 0}, |
1365 | 1789 | |||
1366 | 1611 | /*dTD*/ {&dTD_uA, &dTD_str, 0, 0, 0, 0, &dTD_dur, &dTD_yMD, &dTD_dTD, 0, | 1790 | /*dTD*/ {&dTD_uA, &dTD_str, 0, 0, 0, 0, &dTD_dur, &dTD_yMD, &dTD_dTD, 0, |
1367 | 1612 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1791 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1372 | 1613 | 0, 0, 0}, | 1792 | 0, 0, 0, 0}, |
1373 | 1614 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | 1793 | |
1370 | 1615 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1371 | 1616 | /*aURI*/ /*QN*/ /*NOT*/ | ||
1374 | 1617 | /*dT*/ {&dT_uA, &dT_str, 0, 0, 0, 0, 0, 0, 0, &dT_dT, | 1794 | /*dT*/ {&dT_uA, &dT_str, 0, 0, 0, 0, 0, 0, 0, &dT_dT, |
1375 | 1618 | &dT_tim, &dT_dat, &dT_gYM, &dT_gYr, &dT_gMD, &dT_gDay, &dT_gMon, 0, 0, 0, | 1795 | &dT_tim, &dT_dat, &dT_gYM, &dT_gYr, &dT_gMD, &dT_gDay, &dT_gMon, 0, 0, 0, |
1377 | 1619 | 0, 0, 0}, | 1796 | 0, 0, 0, 0}, |
1378 | 1797 | |||
1379 | 1798 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1380 | 1799 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1381 | 1800 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1382 | 1801 | |||
1383 | 1620 | /*tim*/ {&tim_uA, &tim_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1802 | /*tim*/ {&tim_uA, &tim_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1384 | 1621 | &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1803 | &tim_tim, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1386 | 1622 | 0, 0, 0}, | 1804 | 0, 0, 0, 0}, |
1387 | 1805 | |||
1388 | 1623 | /*dat*/ {&dat_uA, &dat_str, 0, 0, 0, 0, 0, 0, 0, &dat_dT, | 1806 | /*dat*/ {&dat_uA, &dat_str, 0, 0, 0, 0, 0, 0, 0, &dat_dT, |
1389 | 1624 | 0, &dat_dat, &dat_gYM, &dat_gYr, &dat_gMD, &dat_gDay, &dat_gMon, 0, 0, 0, | 1807 | 0, &dat_dat, &dat_gYM, &dat_gYr, &dat_gMD, &dat_gDay, &dat_gMon, 0, 0, 0, |
1391 | 1625 | 0, 0, 0}, | 1808 | 0, 0, 0, 0}, |
1392 | 1809 | |||
1393 | 1626 | /*gYM*/ {&gYM_uA, &gYM_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1810 | /*gYM*/ {&gYM_uA, &gYM_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1394 | 1627 | 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0, | 1811 | 0, 0, &gYM_gYM, 0, 0, 0, 0, 0, 0, 0, |
1396 | 1628 | 0, 0, 0}, | 1812 | 0, 0, 0, 0}, |
1397 | 1813 | |||
1398 | 1629 | /*gYr*/ {&gYr_uA, &gYr_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1814 | /*gYr*/ {&gYr_uA, &gYr_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1399 | 1630 | 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0, | 1815 | 0, 0, 0, &gYr_gYr, 0, 0, 0, 0, 0, 0, |
1401 | 1631 | 0, 0, 0}, | 1816 | 0, 0, 0, 0}, |
1402 | 1817 | |||
1403 | 1632 | /*gMD*/ {&gMD_uA, &gMD_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1818 | /*gMD*/ {&gMD_uA, &gMD_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1404 | 1633 | 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0, | 1819 | 0, 0, 0, 0, &gMD_gMD, 0, 0, 0, 0, 0, |
1406 | 1634 | 0, 0, 0}, | 1820 | 0, 0, 0, 0}, |
1407 | 1821 | |||
1408 | 1822 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1409 | 1823 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1410 | 1824 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1411 | 1825 | |||
1412 | 1635 | /*gDay*/ {&gDay_uA, &gDay_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1826 | /*gDay*/ {&gDay_uA, &gDay_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1413 | 1636 | 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0, | 1827 | 0, 0, 0, 0, 0, &gDay_gDay,0, 0, 0, 0, |
1415 | 1637 | 0, 0, 0}, | 1828 | 0, 0, 0, 0}, |
1416 | 1829 | |||
1417 | 1638 | /*gMon*/ {&gMon_uA, &gMon_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1830 | /*gMon*/ {&gMon_uA, &gMon_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1418 | 1639 | 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0, | 1831 | 0, 0, 0, 0, 0, 0, &gMon_gMon,0, 0, 0, |
1420 | 1640 | 0, 0, 0}, | 1832 | 0, 0, 0, 0}, |
1421 | 1833 | |||
1422 | 1641 | /*bool*/ {&bool_uA, &bool_str, &bool_flt, &bool_dbl, &bool_dec, &bool_int, 0, 0, 0, 0, | 1834 | /*bool*/ {&bool_uA, &bool_str, &bool_flt, &bool_dbl, &bool_dec, &bool_int, 0, 0, 0, 0, |
1423 | 1642 | 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0, | 1835 | 0, 0, 0, 0, 0, 0, 0, &bool_bool,0, 0, |
1425 | 1643 | 0, 0, 0}, | 1836 | 0, 0, 0, &bool_uint}, |
1426 | 1837 | |||
1427 | 1644 | /*b64*/ {&b64_uA, &b64_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1838 | /*b64*/ {&b64_uA, &b64_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1428 | 1645 | 0, 0, 0, 0, 0, 0, 0, 0, &b64_b64, &b64_hxB, | 1839 | 0, 0, 0, 0, 0, 0, 0, 0, &b64_b64, &b64_hxB, |
1430 | 1646 | 0, 0, 0}, | 1840 | 0, 0, 0, 0}, |
1431 | 1841 | |||
1432 | 1647 | /*hxB*/ {&hxB_uA, &hxB_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1842 | /*hxB*/ {&hxB_uA, &hxB_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1433 | 1648 | 0, 0, 0, 0, 0, 0, 0, 0, &hxB_b64, &hxB_hxB, | 1843 | 0, 0, 0, 0, 0, 0, 0, 0, &hxB_b64, &hxB_hxB, |
1435 | 1649 | 0, 0, 0}, | 1844 | 0, 0, 0, 0}, |
1436 | 1845 | |||
1437 | 1846 | /*uA*/ /*str*/ /*flt*/ /*dbl*/ /*dec*/ /*int*/ /*dur*/ /*yMD*/ /*dTD*/ /*dT*/ | ||
1438 | 1847 | /*tim*/ /*dat*/ /*gYM*/ /*gYr*/ /*gMD*/ /*gDay*/ /*gMon*/ /*bool*/ /*b64*/ /*hxB*/ | ||
1439 | 1848 | /*aURI*/ /*QN*/ /*NOT*/ /*uint*/ | ||
1440 | 1849 | |||
1441 | 1650 | /*aURI*/ {&aURI_uA, &aURI_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1850 | /*aURI*/ {&aURI_uA, &aURI_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1442 | 1651 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1851 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1444 | 1652 | &aURI_aURI,0, 0}, | 1852 | &aURI_aURI,0, 0, 0}, |
1445 | 1853 | |||
1446 | 1653 | /*QN*/ {&QN_uA, &QN_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1854 | /*QN*/ {&QN_uA, &QN_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1447 | 1654 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1855 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1449 | 1655 | 0, &QN_QN, 0}, | 1856 | 0, &QN_QN, 0, 0}, |
1450 | 1857 | |||
1451 | 1656 | /*NOT*/ {&NOT_uA, &NOT_str, 0, 0, 0, 0, 0, 0, 0, 0, | 1858 | /*NOT*/ {&NOT_uA, &NOT_str, 0, 0, 0, 0, 0, 0, 0, 0, |
1452 | 1657 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 1859 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
1454 | 1658 | 0, 0, &NOT_NOT} | 1860 | 0, 0, &NOT_NOT, 0}, |
1455 | 1861 | |||
1456 | 1862 | /*uint*/ {&uint_uA, &uint_str, &uint_flt, &uint_dbl, &uint_dec, &uint_int, 0, 0, 0, 0, | ||
1457 | 1863 | 0, 0, 0, 0, 0, 0, 0, &uint_bool,0, 0, | ||
1458 | 1864 | 0, 0, 0, &uint_uint}, | ||
1459 | 1659 | }; | 1865 | }; |
1460 | 1660 | 1866 | ||
1461 | 1661 | 1867 | ||
1462 | 1662 | 1868 | ||
1463 | === modified file 'src/types/casting.h' | |||
1464 | --- src/types/casting.h 2011-06-14 17:26:33 +0000 | |||
1465 | +++ src/types/casting.h 2011-11-29 00:43:26 +0000 | |||
1466 | @@ -49,8 +49,8 @@ | |||
1467 | 49 | ); | 49 | ); |
1468 | 50 | private: | 50 | private: |
1469 | 51 | static const int theMapping[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE]; | 51 | static const int theMapping[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE]; |
1472 | 52 | static const CastFunc theCastMatrix[23][23]; | 52 | static const CastFunc theCastMatrix[24][24]; |
1473 | 53 | static const DownCastFunc theDownCastMatrix[23]; | 53 | static const DownCastFunc theDownCastMatrix[24]; |
1474 | 54 | 54 | ||
1475 | 55 | GenericCast() {} | 55 | GenericCast() {} |
1476 | 56 | 56 | ||
1477 | 57 | 57 | ||
1478 | === modified file 'src/types/schema/XercesParseUtils.cpp' | |||
1479 | --- src/types/schema/XercesParseUtils.cpp 2011-06-30 05:16:55 +0000 | |||
1480 | +++ src/types/schema/XercesParseUtils.cpp 2011-11-29 00:43:26 +0000 | |||
1481 | @@ -118,7 +118,7 @@ | |||
1482 | 118 | { | 118 | { |
1483 | 119 | long value = xsval->fData.fValue.f_long; | 119 | long value = xsval->fData.fValue.f_long; |
1484 | 120 | 120 | ||
1486 | 121 | xs_integer tvalue(value); | 121 | xs_positiveInteger tvalue(value); |
1487 | 122 | 122 | ||
1488 | 123 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 123 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
1489 | 124 | return factory->createPositiveInteger(result, tvalue); | 124 | return factory->createPositiveInteger(result, tvalue); |
1490 | @@ -207,7 +207,7 @@ | |||
1491 | 207 | { | 207 | { |
1492 | 208 | long value = xsval->fData.fValue.f_long; | 208 | long value = xsval->fData.fValue.f_long; |
1493 | 209 | 209 | ||
1495 | 210 | xs_integer tvalue(value); | 210 | xs_nonNegativeInteger tvalue(value); |
1496 | 211 | 211 | ||
1497 | 212 | store::ItemFactory* factory = GENV_ITEMFACTORY; | 212 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
1498 | 213 | return factory->createNonNegativeInteger(result, tvalue); | 213 | return factory->createNonNegativeInteger(result, tvalue); |
1499 | 214 | 214 | ||
1500 | === modified file 'src/util/stl_util.h' | |||
1501 | --- src/util/stl_util.h 2011-10-11 17:59:20 +0000 | |||
1502 | +++ src/util/stl_util.h 2011-11-29 00:43:26 +0000 | |||
1503 | @@ -199,6 +199,13 @@ | |||
1504 | 199 | /////////////////////////////////////////////////////////////////////////////// | 199 | /////////////////////////////////////////////////////////////////////////////// |
1505 | 200 | 200 | ||
1506 | 201 | template<typename NumericType> inline | 201 | template<typename NumericType> inline |
1507 | 202 | typename std::enable_if<ZORBA_TR1_NS::is_arithmetic<NumericType>::value, | ||
1508 | 203 | bool>::type | ||
1509 | 204 | gt0( NumericType n ) { // for completeness | ||
1510 | 205 | return n > 0; | ||
1511 | 206 | } | ||
1512 | 207 | |||
1513 | 208 | template<typename NumericType> inline | ||
1514 | 202 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type | 209 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type |
1515 | 203 | ge0( NumericType n ) { | 210 | ge0( NumericType n ) { |
1516 | 204 | return n >= 0; | 211 | return n >= 0; |
1517 | @@ -210,6 +217,30 @@ | |||
1518 | 210 | return true; | 217 | return true; |
1519 | 211 | } | 218 | } |
1520 | 212 | 219 | ||
1521 | 220 | template<typename NumericType> inline | ||
1522 | 221 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type | ||
1523 | 222 | lt0( NumericType n ) { | ||
1524 | 223 | return n < 0; | ||
1525 | 224 | } | ||
1526 | 225 | |||
1527 | 226 | template<typename IntType> inline | ||
1528 | 227 | typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type | ||
1529 | 228 | lt0( IntType ) { | ||
1530 | 229 | return false; | ||
1531 | 230 | } | ||
1532 | 231 | |||
1533 | 232 | template<typename NumericType> inline | ||
1534 | 233 | typename std::enable_if<ZORBA_TR1_NS::is_signed<NumericType>::value,bool>::type | ||
1535 | 234 | le0( NumericType n ) { | ||
1536 | 235 | return n <= 0; | ||
1537 | 236 | } | ||
1538 | 237 | |||
1539 | 238 | template<typename IntType> inline | ||
1540 | 239 | typename std::enable_if<ZORBA_TR1_NS::is_unsigned<IntType>::value,bool>::type | ||
1541 | 240 | le0( IntType n ) { | ||
1542 | 241 | return n == 0; | ||
1543 | 242 | } | ||
1544 | 243 | |||
1545 | 213 | /////////////////////////////////////////////////////////////////////////////// | 244 | /////////////////////////////////////////////////////////////////////////////// |
1546 | 214 | 245 | ||
1547 | 215 | template<typename T> class stack_generator { | 246 | template<typename T> class stack_generator { |
1548 | 216 | 247 | ||
1549 | === modified file 'src/util/string_util.cpp' | |||
1550 | --- src/util/string_util.cpp 2011-07-07 18:48:27 +0000 | |||
1551 | +++ src/util/string_util.cpp 2011-11-29 00:43:26 +0000 | |||
1552 | @@ -110,14 +110,22 @@ | |||
1553 | 110 | // We have to check for '-' ourselves since strtoull(3) allows it (oddly). | 110 | // We have to check for '-' ourselves since strtoull(3) allows it (oddly). |
1554 | 111 | // | 111 | // |
1555 | 112 | s = ascii::trim_start_whitespace( s ); | 112 | s = ascii::trim_start_whitespace( s ); |
1557 | 113 | if ( *s == '-' ) | 113 | bool const minus = *s == '-'; |
1558 | 114 | |||
1559 | 115 | char *end; | ||
1560 | 116 | errno = 0; | ||
1561 | 117 | unsigned long long const result = std::strtoull( s, &end, 10 ); | ||
1562 | 118 | check_parse_number( s, end, static_cast<unsigned long long*>( nullptr ) ); | ||
1563 | 119 | |||
1564 | 120 | if ( minus && result ) { | ||
1565 | 121 | // | ||
1566 | 122 | // Throw an exception only if there was a '-' and the result is non-zero. | ||
1567 | 123 | // Hence, this allows "-0" and treats it as "0". | ||
1568 | 124 | // | ||
1569 | 114 | throw std::invalid_argument( | 125 | throw std::invalid_argument( |
1570 | 115 | "\"-\": invalid character for unsigned integer" | 126 | "\"-\": invalid character for unsigned integer" |
1571 | 116 | ); | 127 | ); |
1576 | 117 | char *end; | 128 | } |
1573 | 118 | errno = 0; | ||
1574 | 119 | unsigned long long const result = std::strtoull( s, &end, 10 ); | ||
1575 | 120 | check_parse_number( s, end, static_cast<unsigned long long*>( nullptr ) ); | ||
1577 | 121 | return result; | 129 | return result; |
1578 | 122 | } | 130 | } |
1579 | 123 | 131 | ||
1580 | 124 | 132 | ||
1581 | === modified file 'src/zorbaserialization/zorba_class_serializer.cpp' | |||
1582 | --- src/zorbaserialization/zorba_class_serializer.cpp 2011-09-30 14:06:33 +0000 | |||
1583 | +++ src/zorbaserialization/zorba_class_serializer.cpp 2011-11-29 00:43:26 +0000 | |||
1584 | @@ -205,10 +205,19 @@ | |||
1585 | 205 | } | 205 | } |
1586 | 206 | } | 206 | } |
1587 | 207 | 207 | ||
1589 | 208 | void operator&(serialization::Archiver &ar, Integer &obj) | 208 | #ifdef ZORBA_WITH_BIG_INTEGER |
1590 | 209 | void operator&(serialization::Archiver &ar, IntegerImpl &obj) | ||
1591 | 210 | #else | ||
1592 | 211 | template<typename IntType> | ||
1593 | 212 | void operator&(serialization::Archiver &ar, IntegerImpl<IntType> &obj) | ||
1594 | 213 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1595 | 209 | { | 214 | { |
1596 | 210 | ar & obj.value_; | 215 | ar & obj.value_; |
1597 | 211 | } | 216 | } |
1598 | 217 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1599 | 218 | template void operator&(serialization::Archiver&, IntegerImpl<long long>&); | ||
1600 | 219 | template void operator&(serialization::Archiver&, IntegerImpl<unsigned long long>&); | ||
1601 | 220 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1602 | 212 | 221 | ||
1603 | 213 | void iterator_to_vector(store::Iterator_t iter, std::vector<store::Item_t> &items) | 222 | void iterator_to_vector(store::Iterator_t iter, std::vector<store::Item_t> &items) |
1604 | 214 | { | 223 | { |
1605 | @@ -590,7 +599,7 @@ | |||
1606 | 590 | } | 599 | } |
1607 | 591 | else if(name_of_type == "nonNegativeInteger") | 600 | else if(name_of_type == "nonNegativeInteger") |
1608 | 592 | { | 601 | { |
1610 | 593 | SERIALIZE_FIELD(xs_uinteger, value, getUnsignedIntegerValue()); | 602 | SERIALIZE_FIELD(xs_nonNegativeInteger, value, getUnsignedIntegerValue()); |
1611 | 594 | FINALIZE_SERIALIZE(createNonNegativeInteger, (result, value)); | 603 | FINALIZE_SERIALIZE(createNonNegativeInteger, (result, value)); |
1612 | 595 | } | 604 | } |
1613 | 596 | else if(name_of_type == "negativeInteger") | 605 | else if(name_of_type == "negativeInteger") |
1614 | @@ -600,7 +609,7 @@ | |||
1615 | 600 | } | 609 | } |
1616 | 601 | else if(name_of_type == "positiveInteger") | 610 | else if(name_of_type == "positiveInteger") |
1617 | 602 | { | 611 | { |
1619 | 603 | SERIALIZE_FIELD(xs_uinteger, value, getUnsignedIntegerValue()); | 612 | SERIALIZE_FIELD(xs_positiveInteger, value, getUnsignedIntegerValue()); |
1620 | 604 | FINALIZE_SERIALIZE(createPositiveInteger, (result, value)); | 613 | FINALIZE_SERIALIZE(createPositiveInteger, (result, value)); |
1621 | 605 | } | 614 | } |
1622 | 606 | 615 | ||
1623 | 607 | 616 | ||
1624 | === modified file 'src/zorbaserialization/zorba_class_serializer.h' | |||
1625 | --- src/zorbaserialization/zorba_class_serializer.h 2011-07-07 12:05:43 +0000 | |||
1626 | +++ src/zorbaserialization/zorba_class_serializer.h 2011-11-29 00:43:26 +0000 | |||
1627 | @@ -37,13 +37,22 @@ | |||
1628 | 37 | class function; | 37 | class function; |
1629 | 38 | class Diagnostic; | 38 | class Diagnostic; |
1630 | 39 | class ZorbaException; | 39 | class ZorbaException; |
1632 | 40 | class Integer; | 40 | #ifdef ZORBA_WITH_BIG_INTEGER |
1633 | 41 | class IntegerImpl; | ||
1634 | 42 | #else | ||
1635 | 43 | template<typename IntType> class IntegerImpl; | ||
1636 | 44 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1637 | 41 | 45 | ||
1638 | 42 | namespace serialization{ | 46 | namespace serialization{ |
1639 | 43 | //void operator&(Archiver &ar, XQType *&obj); | 47 | //void operator&(Archiver &ar, XQType *&obj); |
1640 | 44 | void operator&(Archiver &ar, const XQType *&obj); | 48 | void operator&(Archiver &ar, const XQType *&obj); |
1641 | 45 | void operator&(Archiver &ar, MAPM &obj); | 49 | void operator&(Archiver &ar, MAPM &obj); |
1643 | 46 | void operator&(Archiver &ar, Integer &obj); | 50 | #ifdef ZORBA_WITH_BIG_INTEGER |
1644 | 51 | void operator&(Archiver &ar, IntegerImpl &obj); | ||
1645 | 52 | #else | ||
1646 | 53 | template<typename IntType> | ||
1647 | 54 | void operator&(Archiver &ar, IntegerImpl<IntType> &obj); | ||
1648 | 55 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1649 | 47 | 56 | ||
1650 | 48 | void operator&(Archiver &ar, XQPCollator *&obj); | 57 | void operator&(Archiver &ar, XQPCollator *&obj); |
1651 | 49 | void operator&(Archiver &ar, store::Item* &obj); | 58 | void operator&(Archiver &ar, store::Item* &obj); |
1652 | 50 | 59 | ||
1653 | === modified file 'src/zorbatypes/decimal.cpp' | |||
1654 | --- src/zorbatypes/decimal.cpp 2011-07-06 19:59:26 +0000 | |||
1655 | +++ src/zorbatypes/decimal.cpp 2011-11-29 00:43:26 +0000 | |||
1656 | @@ -28,6 +28,16 @@ | |||
1657 | 28 | #include "integer.h" | 28 | #include "integer.h" |
1658 | 29 | #include "numconversions.h" | 29 | #include "numconversions.h" |
1659 | 30 | 30 | ||
1660 | 31 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
1661 | 32 | # define TEMPLATE_DECL(T) /* nothing */ | ||
1662 | 33 | # define INTEGER_IMPL(T) IntegerImpl | ||
1663 | 34 | #else | ||
1664 | 35 | # define TEMPLATE_DECL(T) template<typename T> | ||
1665 | 36 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
1666 | 37 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1667 | 38 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
1668 | 39 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
1669 | 40 | |||
1670 | 31 | namespace zorba { | 41 | namespace zorba { |
1671 | 32 | 42 | ||
1672 | 33 | SERIALIZABLE_CLASS_VERSIONS(Decimal) | 43 | SERIALIZABLE_CLASS_VERSIONS(Decimal) |
1673 | @@ -218,8 +228,13 @@ | |||
1674 | 218 | value_ = f.getNumber(); | 228 | value_ = f.getNumber(); |
1675 | 219 | } | 229 | } |
1676 | 220 | 230 | ||
1678 | 221 | Decimal::Decimal( Integer const &i ) : value_( i.itod() ) { | 231 | TEMPLATE_DECL(T) |
1679 | 232 | Decimal::Decimal( INTEGER_IMPL(T) const &i ) : value_( i.itod() ) { | ||
1680 | 222 | } | 233 | } |
1681 | 234 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1682 | 235 | template Decimal::Decimal( INTEGER_IMPL_LL const& ); | ||
1683 | 236 | template Decimal::Decimal( INTEGER_IMPL_ULL const& ); | ||
1684 | 237 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1685 | 223 | 238 | ||
1686 | 224 | ////////// assignment operators /////////////////////////////////////////////// | 239 | ////////// assignment operators /////////////////////////////////////////////// |
1687 | 225 | 240 | ||
1688 | @@ -235,10 +250,15 @@ | |||
1689 | 235 | return *this; | 250 | return *this; |
1690 | 236 | } | 251 | } |
1691 | 237 | 252 | ||
1693 | 238 | Decimal& Decimal::operator=( Integer const &i ) { | 253 | TEMPLATE_DECL(T) |
1694 | 254 | Decimal& Decimal::operator=( INTEGER_IMPL(T) const &i ) { | ||
1695 | 239 | value_ = i.itod(); | 255 | value_ = i.itod(); |
1696 | 240 | return *this; | 256 | return *this; |
1697 | 241 | } | 257 | } |
1698 | 258 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1699 | 259 | template Decimal& Decimal::operator=( INTEGER_IMPL_LL const& ); | ||
1700 | 260 | template Decimal& Decimal::operator=( INTEGER_IMPL_ULL const& ); | ||
1701 | 261 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1702 | 242 | 262 | ||
1703 | 243 | Decimal& Decimal::operator=( Double const &d ) { | 263 | Decimal& Decimal::operator=( Double const &d ) { |
1704 | 244 | if ( !d.isFinite() ) | 264 | if ( !d.isFinite() ) |
1705 | @@ -256,61 +276,69 @@ | |||
1706 | 256 | 276 | ||
1707 | 257 | ////////// arithmetic operators /////////////////////////////////////////////// | 277 | ////////// arithmetic operators /////////////////////////////////////////////// |
1708 | 258 | 278 | ||
1728 | 259 | Decimal operator+( Decimal const &d, Integer const &i ) { | 279 | #ifdef ZORBA_WITH_BIG_INTEGER |
1729 | 260 | return d.value_ + i.itod(); | 280 | # define ZORBA_INSTANTIATE(OP) /* nothing */ |
1730 | 261 | } | 281 | #else |
1731 | 262 | 282 | # define ZORBA_INSTANTIATE(OP) \ | |
1732 | 263 | Decimal operator-( Decimal const &d, Integer const &i ) { | 283 | template Decimal operator OP( Decimal const&, INTEGER_IMPL_LL const& ); \ |
1733 | 264 | return d.value_ - i.itod(); | 284 | template Decimal operator OP( Decimal const&, INTEGER_IMPL_ULL const& ) |
1734 | 265 | } | 285 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
1735 | 266 | 286 | ||
1736 | 267 | Decimal operator*( Decimal const &d, Integer const &i ) { | 287 | #define ZORBA_DECIMAL_OP(OP) \ |
1737 | 268 | return d.value_ * i.itod(); | 288 | TEMPLATE_DECL(T) \ |
1738 | 269 | } | 289 | Decimal operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \ |
1739 | 270 | 290 | return d.value_ OP i.itod(); \ | |
1740 | 271 | Decimal operator/( Decimal const &d, Integer const &i ) { | 291 | } \ |
1741 | 272 | return d.value_ / i.itod(); | 292 | ZORBA_INSTANTIATE(OP) |
1742 | 273 | } | 293 | |
1743 | 274 | 294 | ZORBA_DECIMAL_OP(+); | |
1744 | 275 | Decimal operator%( Decimal const &d, Integer const &i ) { | 295 | ZORBA_DECIMAL_OP(-); |
1745 | 276 | return d.value_ % i.itod(); | 296 | ZORBA_DECIMAL_OP(*); |
1746 | 277 | } | 297 | ZORBA_DECIMAL_OP(/); |
1747 | 298 | ZORBA_DECIMAL_OP(%); | ||
1748 | 299 | #undef ZORBA_DECIMAL_OP | ||
1749 | 300 | #undef ZORBA_INSTANTIATE | ||
1750 | 278 | 301 | ||
1751 | 279 | ////////// relational operators /////////////////////////////////////////////// | 302 | ////////// relational operators /////////////////////////////////////////////// |
1752 | 280 | 303 | ||
1776 | 281 | bool operator==( Decimal const &d, Integer const &i ) { | 304 | #ifdef ZORBA_WITH_BIG_INTEGER |
1777 | 282 | return d.value_ == i.itod(); | 305 | # define ZORBA_INSTANTIATE(OP) /* nothing */ |
1778 | 283 | } | 306 | #else |
1779 | 284 | 307 | # define ZORBA_INSTANTIATE(OP) \ | |
1780 | 285 | bool operator!=( Decimal const &d, Integer const &i ) { | 308 | template bool operator OP( Decimal const&, INTEGER_IMPL_LL const& ); \ |
1781 | 286 | return d.value_ != i.itod(); | 309 | template bool operator OP( Decimal const&, INTEGER_IMPL_ULL const& ) |
1782 | 287 | } | 310 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
1783 | 288 | 311 | ||
1784 | 289 | bool operator<( Decimal const &d, Integer const &i ) { | 312 | #define ZORBA_DECIMAL_OP(OP) \ |
1785 | 290 | return d.value_ < i.itod(); | 313 | TEMPLATE_DECL(T) \ |
1786 | 291 | } | 314 | bool operator OP( Decimal const &d, INTEGER_IMPL(T) const &i ) { \ |
1787 | 292 | 315 | return d.value_ OP i.itod(); \ | |
1788 | 293 | bool operator<=( Decimal const &d, Integer const &i ) { | 316 | } \ |
1789 | 294 | return d.value_ <= i.itod(); | 317 | ZORBA_INSTANTIATE(OP) |
1790 | 295 | } | 318 | |
1791 | 296 | 319 | ZORBA_DECIMAL_OP(==); | |
1792 | 297 | bool operator>( Decimal const &d, Integer const &i ) { | 320 | ZORBA_DECIMAL_OP(!=); |
1793 | 298 | return d.value_ > i.itod(); | 321 | ZORBA_DECIMAL_OP(< ); |
1794 | 299 | } | 322 | ZORBA_DECIMAL_OP(<=); |
1795 | 300 | 323 | ZORBA_DECIMAL_OP(> ); | |
1796 | 301 | bool operator>=( Decimal const &d, Integer const &i ) { | 324 | ZORBA_DECIMAL_OP(>=); |
1797 | 302 | return d.value_ >= i.itod(); | 325 | #undef ZORBA_DECIMAL_OP |
1798 | 303 | } | 326 | #undef ZORBA_INSTANTIATE |
1799 | 304 | 327 | ||
1800 | 305 | ////////// math functions ///////////////////////////////////////////////////// | 328 | ////////// math functions ///////////////////////////////////////////////////// |
1801 | 306 | 329 | ||
1802 | 307 | Decimal Decimal::round() const { | 330 | Decimal Decimal::round() const { |
1804 | 308 | return round( Integer::zero() ); | 331 | return round( INTEGER_IMPL_LL::zero() ); |
1805 | 309 | } | 332 | } |
1806 | 310 | 333 | ||
1808 | 311 | Decimal Decimal::round( Integer const &precision ) const { | 334 | TEMPLATE_DECL(T) |
1809 | 335 | Decimal Decimal::round( INTEGER_IMPL(T) const &precision ) const { | ||
1810 | 312 | return round( value_, precision.itod() ); | 336 | return round( value_, precision.itod() ); |
1811 | 313 | } | 337 | } |
1812 | 338 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1813 | 339 | template Decimal Decimal::round( INTEGER_IMPL_LL const& ) const; | ||
1814 | 340 | template Decimal Decimal::round( INTEGER_IMPL_ULL const& ) const; | ||
1815 | 341 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1816 | 314 | 342 | ||
1817 | 315 | Decimal::value_type Decimal::round( value_type const &v, | 343 | Decimal::value_type Decimal::round( value_type const &v, |
1818 | 316 | value_type const &precision ) { | 344 | value_type const &precision ) { |
1819 | @@ -322,9 +350,14 @@ | |||
1820 | 322 | return result; | 350 | return result; |
1821 | 323 | } | 351 | } |
1822 | 324 | 352 | ||
1824 | 325 | Decimal Decimal::roundHalfToEven( Integer const &precision ) const { | 353 | TEMPLATE_DECL(T) |
1825 | 354 | Decimal Decimal::roundHalfToEven( INTEGER_IMPL(T) const &precision ) const { | ||
1826 | 326 | return roundHalfToEven( value_, precision.itod() ); | 355 | return roundHalfToEven( value_, precision.itod() ); |
1827 | 327 | } | 356 | } |
1828 | 357 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
1829 | 358 | template Decimal Decimal::roundHalfToEven( INTEGER_IMPL_LL const& ) const; | ||
1830 | 359 | template Decimal Decimal::roundHalfToEven( INTEGER_IMPL_ULL const& ) const; | ||
1831 | 360 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1832 | 328 | 361 | ||
1833 | 329 | Decimal::value_type Decimal::roundHalfToEven( value_type const &v, | 362 | Decimal::value_type Decimal::roundHalfToEven( value_type const &v, |
1834 | 330 | value_type const &precision ) { | 363 | value_type const &precision ) { |
1835 | 331 | 364 | ||
1836 | === modified file 'src/zorbatypes/decimal.h' | |||
1837 | --- src/zorbatypes/decimal.h 2011-06-24 18:27:08 +0000 | |||
1838 | +++ src/zorbatypes/decimal.h 2011-11-29 00:43:26 +0000 | |||
1839 | @@ -29,6 +29,14 @@ | |||
1840 | 29 | #include "zorbatypes_decl.h" | 29 | #include "zorbatypes_decl.h" |
1841 | 30 | #include "zstring.h" | 30 | #include "zstring.h" |
1842 | 31 | 31 | ||
1843 | 32 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
1844 | 33 | # define TEMPLATE_DECL(T) /* nothing */ | ||
1845 | 34 | # define INTEGER_IMPL(T) IntegerImpl | ||
1846 | 35 | #else | ||
1847 | 36 | # define TEMPLATE_DECL(T) template<typename T> | ||
1848 | 37 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
1849 | 38 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
1850 | 39 | |||
1851 | 32 | namespace zorba { | 40 | namespace zorba { |
1852 | 33 | 41 | ||
1853 | 34 | /////////////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////////////// |
1854 | @@ -52,7 +60,9 @@ | |||
1855 | 52 | Decimal( float n ); | 60 | Decimal( float n ); |
1856 | 53 | Decimal( double n ); | 61 | Decimal( double n ); |
1857 | 54 | Decimal( Decimal const &d ); | 62 | Decimal( Decimal const &d ); |
1859 | 55 | Decimal( Integer const &i ); | 63 | |
1860 | 64 | TEMPLATE_DECL(T) | ||
1861 | 65 | Decimal( INTEGER_IMPL(T) const &i ); | ||
1862 | 56 | 66 | ||
1863 | 57 | /** | 67 | /** |
1864 | 58 | * Constructs a %Decimal from a C string. | 68 | * Constructs a %Decimal from a C string. |
1865 | @@ -98,27 +108,30 @@ | |||
1866 | 98 | Decimal& operator=( Decimal const &d ); | 108 | Decimal& operator=( Decimal const &d ); |
1867 | 99 | Decimal& operator=( Double const &d ); | 109 | Decimal& operator=( Double const &d ); |
1868 | 100 | Decimal& operator=( Float const &f ); | 110 | Decimal& operator=( Float const &f ); |
1870 | 101 | Decimal& operator=( Integer const &i ); | 111 | |
1871 | 112 | TEMPLATE_DECL(T) | ||
1872 | 113 | Decimal& operator=( INTEGER_IMPL(T) const &i ); | ||
1873 | 102 | 114 | ||
1874 | 103 | ////////// arithmetic operators ///////////////////////////////////////////// | 115 | ////////// arithmetic operators ///////////////////////////////////////////// |
1875 | 104 | 116 | ||
1893 | 105 | friend Decimal operator+( Decimal const &d1, Decimal const &d2 ); | 117 | friend Decimal operator+( Decimal const&, Decimal const& ); |
1894 | 106 | friend Decimal operator-( Decimal const &d1, Decimal const &d2 ); | 118 | friend Decimal operator-( Decimal const&, Decimal const& ); |
1895 | 107 | friend Decimal operator*( Decimal const &d1, Decimal const &d2 ); | 119 | friend Decimal operator*( Decimal const&, Decimal const& ); |
1896 | 108 | friend Decimal operator/( Decimal const &d1, Decimal const &d2 ); | 120 | friend Decimal operator/( Decimal const&, Decimal const& ); |
1897 | 109 | friend Decimal operator%( Decimal const &d1, Decimal const &d2 ); | 121 | friend Decimal operator%( Decimal const&, Decimal const& ); |
1898 | 110 | 122 | ||
1899 | 111 | friend Decimal operator+( Decimal const &d, Integer const &i ); | 123 | #define ZORBA_DECIMAL_OP(OP) \ |
1900 | 112 | friend Decimal operator-( Decimal const &d, Integer const &i ); | 124 | TEMPLATE_DECL(T) \ |
1901 | 113 | friend Decimal operator*( Decimal const &d, Integer const &i ); | 125 | friend Decimal operator OP( Decimal const&, INTEGER_IMPL(T) const& ); \ |
1902 | 114 | friend Decimal operator/( Decimal const &d, Integer const &i ); | 126 | TEMPLATE_DECL(T) \ |
1903 | 115 | friend Decimal operator%( Decimal const &d, Integer const &i ); | 127 | friend Decimal operator OP( INTEGER_IMPL(T) const&, Decimal const& ) |
1904 | 116 | 128 | ||
1905 | 117 | friend Decimal operator+( Integer const &i, Decimal const &d ); | 129 | ZORBA_DECIMAL_OP(+); |
1906 | 118 | friend Decimal operator-( Integer const &i, Decimal const &d ); | 130 | ZORBA_DECIMAL_OP(-); |
1907 | 119 | friend Decimal operator*( Integer const &i, Decimal const &d ); | 131 | ZORBA_DECIMAL_OP(*); |
1908 | 120 | friend Decimal operator/( Integer const &i, Decimal const &d ); | 132 | ZORBA_DECIMAL_OP(/); |
1909 | 121 | friend Decimal operator%( Integer const &i, Decimal const &d ); | 133 | ZORBA_DECIMAL_OP(%); |
1910 | 134 | #undef ZORBA_DECIMAL_OP | ||
1911 | 122 | 135 | ||
1912 | 123 | Decimal& operator+=( Decimal const& ); | 136 | Decimal& operator+=( Decimal const& ); |
1913 | 124 | Decimal& operator-=( Decimal const& ); | 137 | Decimal& operator-=( Decimal const& ); |
1914 | @@ -126,46 +139,49 @@ | |||
1915 | 126 | Decimal& operator/=( Decimal const& ); | 139 | Decimal& operator/=( Decimal const& ); |
1916 | 127 | Decimal& operator%=( Decimal const& ); | 140 | Decimal& operator%=( Decimal const& ); |
1917 | 128 | 141 | ||
1923 | 129 | Decimal& operator+=( Integer const& ); | 142 | #define ZORBA_DECIMAL_OP(OP) \ |
1924 | 130 | Decimal& operator-=( Integer const& ); | 143 | TEMPLATE_DECL(T) Decimal& operator OP( INTEGER_IMPL(T) const& ) |
1925 | 131 | Decimal& operator*=( Integer const& ); | 144 | |
1926 | 132 | Decimal& operator/=( Integer const& ); | 145 | ZORBA_DECIMAL_OP(+=); |
1927 | 133 | Decimal& operator%=( Integer const& ); | 146 | ZORBA_DECIMAL_OP(-=); |
1928 | 147 | ZORBA_DECIMAL_OP(*=); | ||
1929 | 148 | ZORBA_DECIMAL_OP(/=); | ||
1930 | 149 | ZORBA_DECIMAL_OP(%=); | ||
1931 | 150 | #undef ZORBA_DECIMAL_OP | ||
1932 | 134 | 151 | ||
1933 | 135 | Decimal operator-() const; | 152 | Decimal operator-() const; |
1934 | 136 | 153 | ||
1935 | 137 | ////////// relational operators ///////////////////////////////////////////// | 154 | ////////// relational operators ///////////////////////////////////////////// |
1936 | 138 | 155 | ||
1957 | 139 | friend bool operator==( Decimal const &d1, Decimal const &d2 ); | 156 | #define ZORBA_DECIMAL_OP(OP) \ |
1958 | 140 | friend bool operator!=( Decimal const &d1, Decimal const &d2 ); | 157 | friend bool operator OP( Decimal const&, Decimal const& ); \ |
1959 | 141 | friend bool operator< ( Decimal const &d1, Decimal const &d2 ); | 158 | TEMPLATE_DECL(T) \ |
1960 | 142 | friend bool operator<=( Decimal const &d1, Decimal const &d2 ); | 159 | friend bool operator OP( Decimal const&, INTEGER_IMPL(T) const& ); \ |
1961 | 143 | friend bool operator> ( Decimal const &d1, Decimal const &d2 ); | 160 | TEMPLATE_DECL(T) \ |
1962 | 144 | friend bool operator>=( Decimal const &d1, Decimal const &d2 ); | 161 | friend bool operator OP( INTEGER_IMPL(T) const&, Decimal const& ) |
1963 | 145 | 162 | ||
1964 | 146 | friend bool operator==( Decimal const &d, Integer const &i ); | 163 | ZORBA_DECIMAL_OP(==); |
1965 | 147 | friend bool operator!=( Decimal const &d, Integer const &i ); | 164 | ZORBA_DECIMAL_OP(!=); |
1966 | 148 | friend bool operator< ( Decimal const &d, Integer const &i ); | 165 | ZORBA_DECIMAL_OP(< ); |
1967 | 149 | friend bool operator<=( Decimal const &d, Integer const &i ); | 166 | ZORBA_DECIMAL_OP(<=); |
1968 | 150 | friend bool operator> ( Decimal const &d, Integer const &i ); | 167 | ZORBA_DECIMAL_OP(> ); |
1969 | 151 | friend bool operator>=( Decimal const &d, Integer const &i ); | 168 | ZORBA_DECIMAL_OP(>=); |
1970 | 152 | 169 | #undef ZORBA_DECIMAL_OP | |
1951 | 153 | friend bool operator==( Integer const &i, Decimal const &d ); | ||
1952 | 154 | friend bool operator!=( Integer const &i, Decimal const &d ); | ||
1953 | 155 | friend bool operator< ( Integer const &i, Decimal const &d ); | ||
1954 | 156 | friend bool operator<=( Integer const &i, Decimal const &d ); | ||
1955 | 157 | friend bool operator> ( Integer const &i, Decimal const &d ); | ||
1956 | 158 | friend bool operator>=( Integer const &i, Decimal const &d ); | ||
1971 | 159 | 170 | ||
1972 | 160 | ////////// math functions /////////////////////////////////////////////////// | 171 | ////////// math functions /////////////////////////////////////////////////// |
1973 | 161 | 172 | ||
1975 | 162 | int compare( Decimal const &d ) const; | 173 | int compare( Decimal const& ) const; |
1976 | 163 | 174 | ||
1977 | 164 | Decimal ceil() const; | 175 | Decimal ceil() const; |
1978 | 165 | Decimal floor() const; | 176 | Decimal floor() const; |
1979 | 166 | Decimal round() const; | 177 | Decimal round() const; |
1982 | 167 | Decimal round( Integer const &precision ) const; | 178 | |
1983 | 168 | Decimal roundHalfToEven( Integer const &precision ) const; | 179 | TEMPLATE_DECL(T) |
1984 | 180 | Decimal round( INTEGER_IMPL(T) const &precision ) const; | ||
1985 | 181 | |||
1986 | 182 | TEMPLATE_DECL(T) | ||
1987 | 183 | Decimal roundHalfToEven( INTEGER_IMPL(T) const &precision ) const; | ||
1988 | 184 | |||
1989 | 169 | Decimal sqrt() const; | 185 | Decimal sqrt() const; |
1990 | 170 | 186 | ||
1991 | 171 | ////////// miscellaneous //////////////////////////////////////////////////// | 187 | ////////// miscellaneous //////////////////////////////////////////////////// |
1992 | @@ -215,7 +231,7 @@ | |||
1993 | 215 | static zstring toString( value_type const&, | 231 | static zstring toString( value_type const&, |
1994 | 216 | int precision = ZORBA_FLOAT_POINT_PRECISION ); | 232 | int precision = ZORBA_FLOAT_POINT_PRECISION ); |
1995 | 217 | 233 | ||
1997 | 218 | friend class Integer; | 234 | TEMPLATE_DECL(T) friend class IntegerImpl; |
1998 | 219 | template<typename T> friend class FloatImpl; | 235 | template<typename T> friend class FloatImpl; |
1999 | 220 | 236 | ||
2000 | 221 | friend xs_long to_xs_long( Decimal const& ); | 237 | friend xs_long to_xs_long( Decimal const& ); |
2001 | @@ -443,6 +459,10 @@ | |||
2002 | 443 | /////////////////////////////////////////////////////////////////////////////// | 459 | /////////////////////////////////////////////////////////////////////////////// |
2003 | 444 | 460 | ||
2004 | 445 | } // namespace zorba | 461 | } // namespace zorba |
2005 | 462 | |||
2006 | 463 | #undef TEMPLATE_DECL | ||
2007 | 464 | #undef INTEGER_IMPL | ||
2008 | 465 | |||
2009 | 446 | #endif /* ZORBA_DECIMAL_H */ | 466 | #endif /* ZORBA_DECIMAL_H */ |
2010 | 447 | /* | 467 | /* |
2011 | 448 | * Local variables: | 468 | * Local variables: |
2012 | 449 | 469 | ||
2013 | === modified file 'src/zorbatypes/floatimpl.cpp' | |||
2014 | --- src/zorbatypes/floatimpl.cpp 2011-07-07 12:05:43 +0000 | |||
2015 | +++ src/zorbatypes/floatimpl.cpp 2011-11-29 00:43:26 +0000 | |||
2016 | @@ -29,6 +29,16 @@ | |||
2017 | 29 | 29 | ||
2018 | 30 | #include "zorbaserialization/serialization_engine.h" | 30 | #include "zorbaserialization/serialization_engine.h" |
2019 | 31 | 31 | ||
2020 | 32 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2021 | 33 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2022 | 34 | # define INTEGER_IMPL(T) IntegerImpl | ||
2023 | 35 | #else | ||
2024 | 36 | # define TEMPLATE_DECL(T) template<typename T> | ||
2025 | 37 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2026 | 38 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2027 | 39 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
2028 | 40 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
2029 | 41 | |||
2030 | 32 | /////////////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////////////// |
2031 | 33 | 43 | ||
2032 | 34 | namespace zorba { | 44 | namespace zorba { |
2033 | @@ -144,11 +154,20 @@ | |||
2034 | 144 | } | 154 | } |
2035 | 145 | 155 | ||
2036 | 146 | template<typename FloatType> | 156 | template<typename FloatType> |
2038 | 147 | FloatImpl<FloatType>::FloatImpl( Integer const &i ) { | 157 | TEMPLATE_DECL(IntType) |
2039 | 158 | FloatImpl<FloatType>::FloatImpl( INTEGER_IMPL(IntType) const &i ) { | ||
2040 | 148 | zstring const temp( i.toString() ); | 159 | zstring const temp( i.toString() ); |
2041 | 149 | parse( temp.c_str() ); | 160 | parse( temp.c_str() ); |
2042 | 150 | } | 161 | } |
2043 | 151 | 162 | ||
2044 | 163 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
2045 | 164 | template FloatImpl<float>::FloatImpl( INTEGER_IMPL_LL const& ); | ||
2046 | 165 | template FloatImpl<float>::FloatImpl( INTEGER_IMPL_ULL const& ); | ||
2047 | 166 | |||
2048 | 167 | template FloatImpl<double>::FloatImpl( INTEGER_IMPL_LL const& ); | ||
2049 | 168 | template FloatImpl<double>::FloatImpl( INTEGER_IMPL_ULL const& ); | ||
2050 | 169 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2051 | 170 | |||
2052 | 152 | ////////// math functions ///////////////////////////////////////////////////// | 171 | ////////// math functions ///////////////////////////////////////////////////// |
2053 | 153 | 172 | ||
2054 | 154 | template<typename FloatType> | 173 | template<typename FloatType> |
2055 | 155 | 174 | ||
2056 | === modified file 'src/zorbatypes/floatimpl.h' | |||
2057 | --- src/zorbatypes/floatimpl.h 2011-10-03 09:18:49 +0000 | |||
2058 | +++ src/zorbatypes/floatimpl.h 2011-11-29 00:43:26 +0000 | |||
2059 | @@ -29,13 +29,22 @@ | |||
2060 | 29 | #include "schema_types.h" | 29 | #include "schema_types.h" |
2061 | 30 | #include "zorbatypes_decl.h" | 30 | #include "zorbatypes_decl.h" |
2062 | 31 | 31 | ||
2063 | 32 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2064 | 33 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2065 | 34 | # define INTEGER_IMPL(T) IntegerImpl | ||
2066 | 35 | #else | ||
2067 | 36 | # define TEMPLATE_DECL(T) template<typename T> | ||
2068 | 37 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2069 | 38 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2070 | 39 | |||
2071 | 32 | namespace zorba { | 40 | namespace zorba { |
2072 | 33 | 41 | ||
2073 | 34 | template<typename FloatType> | 42 | template<typename FloatType> |
2074 | 35 | class FloatImpl; | 43 | class FloatImpl; |
2076 | 36 | namespace serialization{ | 44 | |
2077 | 45 | namespace serialization { | ||
2078 | 37 | template<typename FloatType> | 46 | template<typename FloatType> |
2080 | 38 | void operator&(Archiver &ar, FloatImpl<FloatType> &obj); | 47 | void operator&( Archiver&, FloatImpl<FloatType>& ); |
2081 | 39 | } | 48 | } |
2082 | 40 | 49 | ||
2083 | 41 | /////////////////////////////////////////////////////////////////////////////// | 50 | /////////////////////////////////////////////////////////////////////////////// |
2084 | @@ -61,7 +70,9 @@ | |||
2085 | 61 | FloatImpl( float n ); | 70 | FloatImpl( float n ); |
2086 | 62 | FloatImpl( double n ); | 71 | FloatImpl( double n ); |
2087 | 63 | FloatImpl( Decimal const &d ); | 72 | FloatImpl( Decimal const &d ); |
2089 | 64 | FloatImpl( Integer const &i ); | 73 | |
2090 | 74 | TEMPLATE_DECL(T) | ||
2091 | 75 | FloatImpl( INTEGER_IMPL(T) const &i ); | ||
2092 | 65 | 76 | ||
2093 | 66 | /** | 77 | /** |
2094 | 67 | * Constructs a %FloatImpl from a C string. | 78 | * Constructs a %FloatImpl from a C string. |
2095 | @@ -220,7 +231,7 @@ | |||
2096 | 220 | void parse( char const* ); | 231 | void parse( char const* ); |
2097 | 221 | bool parse_etc( char const* ); | 232 | bool parse_etc( char const* ); |
2098 | 222 | 233 | ||
2100 | 223 | friend class Integer; | 234 | TEMPLATE_DECL(T) friend class IntegerImpl; |
2101 | 224 | friend class Decimal; | 235 | friend class Decimal; |
2102 | 225 | 236 | ||
2103 | 226 | friend class FloatImpl<float>; | 237 | friend class FloatImpl<float>; |
2104 | @@ -772,6 +783,10 @@ | |||
2105 | 772 | /////////////////////////////////////////////////////////////////////////////// | 783 | /////////////////////////////////////////////////////////////////////////////// |
2106 | 773 | 784 | ||
2107 | 774 | } // namespace zorba | 785 | } // namespace zorba |
2108 | 786 | |||
2109 | 787 | #undef TEMPLATE_DECL | ||
2110 | 788 | #undef INTEGER_IMPL | ||
2111 | 789 | |||
2112 | 775 | #endif // ZORBA_FLOATIMPL_H | 790 | #endif // ZORBA_FLOATIMPL_H |
2113 | 776 | /* | 791 | /* |
2114 | 777 | * Local variables: | 792 | * Local variables: |
2115 | 778 | 793 | ||
2116 | === modified file 'src/zorbatypes/integer.cpp' | |||
2117 | --- src/zorbatypes/integer.cpp 2011-07-06 20:13:28 +0000 | |||
2118 | +++ src/zorbatypes/integer.cpp 2011-11-29 00:43:26 +0000 | |||
2119 | @@ -27,62 +27,82 @@ | |||
2120 | 27 | #include "floatimpl.h" | 27 | #include "floatimpl.h" |
2121 | 28 | #include "numconversions.h" | 28 | #include "numconversions.h" |
2122 | 29 | 29 | ||
2123 | 30 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2124 | 31 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2125 | 32 | # define INTEGER_IMPL(T) IntegerImpl | ||
2126 | 33 | #else | ||
2127 | 34 | # define TEMPLATE_DECL(T) template<typename T> | ||
2128 | 35 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2129 | 36 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2130 | 37 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
2131 | 38 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
2132 | 39 | |||
2133 | 30 | using namespace std; | 40 | using namespace std; |
2134 | 31 | 41 | ||
2146 | 32 | #ifdef WIN32 | 42 | #ifndef ZORBA_WITH_BIG_INTEGER |
2147 | 33 | namespace std { | 43 | unsigned long long MaxUIntegerValue = ~0ull >> 1; |
2148 | 34 | inline long long strtoll( char const *s, char **end, int base ) { | 44 | |
2149 | 35 | return ::_strtoi64( s, end, base ); | 45 | inline bool is_too_big( long long ) { |
2150 | 36 | } | 46 | return false; |
2151 | 37 | 47 | } | |
2152 | 38 | inline long long strtoull( char const *s, char **end, int base ) { | 48 | |
2153 | 39 | return ::_strtoui64( s, end, base ); | 49 | inline bool is_too_big( unsigned long long n ) { |
2154 | 40 | } | 50 | return n > MaxUIntegerValue; |
2155 | 41 | } | 51 | } |
2156 | 42 | #endif /* WIN32 */ | 52 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2157 | 43 | 53 | ||
2158 | 44 | namespace zorba { | 54 | namespace zorba { |
2159 | 45 | 55 | ||
2160 | 46 | /////////////////////////////////////////////////////////////////////////////// | 56 | /////////////////////////////////////////////////////////////////////////////// |
2161 | 47 | 57 | ||
2162 | 48 | void Integer::parse( char const *s ) { | ||
2163 | 49 | #ifdef ZORBA_WITH_BIG_INTEGER | 58 | #ifdef ZORBA_WITH_BIG_INTEGER |
2164 | 59 | void IntegerImpl::parse( char const *s ) { | ||
2165 | 50 | Decimal::parse( s, &value_, Decimal::parse_integer ); | 60 | Decimal::parse( s, &value_, Decimal::parse_integer ); |
2166 | 51 | #else | 61 | #else |
2168 | 52 | value_ = ztd::aton<value_type>( s ); | 62 | template<typename IntType> |
2169 | 63 | void IntegerImpl<IntType>::parse( char const *s ) { | ||
2170 | 64 | value_type const temp = ztd::aton<value_type>( s ); | ||
2171 | 65 | if ( is_too_big( temp ) ) | ||
2172 | 66 | throw std::invalid_argument( | ||
2173 | 67 | BUILD_STRING( '"', temp, "\": unsigned integer too big" ) | ||
2174 | 68 | ); | ||
2175 | 69 | value_ = temp; | ||
2176 | 53 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 70 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2177 | 54 | } | 71 | } |
2178 | 55 | 72 | ||
2179 | 56 | ////////// constructors /////////////////////////////////////////////////////// | 73 | ////////// constructors /////////////////////////////////////////////////////// |
2180 | 57 | 74 | ||
2181 | 58 | #ifdef ZORBA_WITH_BIG_INTEGER | 75 | #ifdef ZORBA_WITH_BIG_INTEGER |
2193 | 59 | Integer::Integer( long long n ) { | 76 | IntegerImpl::IntegerImpl( long long n ) { |
2194 | 60 | ztd::itoa_buf_type buf; | 77 | ztd::itoa_buf_type buf; |
2195 | 61 | value_ = ztd::itoa( n, buf ); | 78 | value_ = ztd::itoa( n, buf ); |
2196 | 62 | } | 79 | } |
2197 | 63 | 80 | ||
2198 | 64 | Integer::Integer( unsigned long n ) { | 81 | IntegerImpl::IntegerImpl( unsigned long n ) { |
2199 | 65 | ztd::itoa_buf_type buf; | 82 | ztd::itoa_buf_type buf; |
2200 | 66 | value_ = ztd::itoa( n, buf ); | 83 | value_ = ztd::itoa( n, buf ); |
2201 | 67 | } | 84 | } |
2202 | 68 | 85 | ||
2203 | 69 | Integer::Integer( unsigned long long n ) { | 86 | IntegerImpl::IntegerImpl( unsigned long long n ) { |
2204 | 70 | ztd::itoa_buf_type buf; | 87 | ztd::itoa_buf_type buf; |
2205 | 71 | value_ = ztd::itoa( n, buf ); | 88 | value_ = ztd::itoa( n, buf ); |
2206 | 72 | } | 89 | } |
2207 | 73 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 90 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2208 | 74 | 91 | ||
2210 | 75 | Integer::Integer( Decimal const &d ) { | 92 | TEMPLATE_DECL(T) |
2211 | 93 | INTEGER_IMPL(T)::IntegerImpl( Decimal const &d ) { | ||
2212 | 76 | value_ = ftoi( d.value_ ); | 94 | value_ = ftoi( d.value_ ); |
2213 | 77 | } | 95 | } |
2214 | 78 | 96 | ||
2216 | 79 | Integer::Integer( Double const &d ) { | 97 | TEMPLATE_DECL(T) |
2217 | 98 | INTEGER_IMPL(T)::IntegerImpl( Double const &d ) { | ||
2218 | 80 | if ( !d.isFinite() ) | 99 | if ( !d.isFinite() ) |
2219 | 81 | throw std::invalid_argument( "not finite" ); | 100 | throw std::invalid_argument( "not finite" ); |
2220 | 82 | value_ = ftoi( d.getNumber() ); | 101 | value_ = ftoi( d.getNumber() ); |
2221 | 83 | } | 102 | } |
2222 | 84 | 103 | ||
2224 | 85 | Integer::Integer( Float const &f ) { | 104 | TEMPLATE_DECL(T) |
2225 | 105 | INTEGER_IMPL(T)::IntegerImpl( Float const &f ) { | ||
2226 | 86 | if ( !f.isFinite() ) | 106 | if ( !f.isFinite() ) |
2227 | 87 | throw std::invalid_argument( "not finite" ); | 107 | throw std::invalid_argument( "not finite" ); |
2228 | 88 | value_ = ftoi( f.getNumber() ); | 108 | value_ = ftoi( f.getNumber() ); |
2229 | @@ -91,38 +111,41 @@ | |||
2230 | 91 | ////////// assignment operators /////////////////////////////////////////////// | 111 | ////////// assignment operators /////////////////////////////////////////////// |
2231 | 92 | 112 | ||
2232 | 93 | #ifdef ZORBA_WITH_BIG_INTEGER | 113 | #ifdef ZORBA_WITH_BIG_INTEGER |
2246 | 94 | Integer& Integer::operator=( long long n ) { | 114 | IntegerImpl& IntegerImpl::operator=( long long n ) { |
2247 | 95 | ztd::itoa_buf_type buf; | 115 | ztd::itoa_buf_type buf; |
2248 | 96 | value_ = ztd::itoa( n, buf ); | 116 | value_ = ztd::itoa( n, buf ); |
2249 | 97 | return *this; | 117 | return *this; |
2250 | 98 | } | 118 | } |
2251 | 99 | 119 | ||
2252 | 100 | Integer& Integer::operator=( unsigned long n ) { | 120 | IntegerImpl& IntegerImpl::operator=( unsigned long n ) { |
2253 | 101 | ztd::itoa_buf_type buf; | 121 | ztd::itoa_buf_type buf; |
2254 | 102 | value_ = ztd::itoa( n, buf ); | 122 | value_ = ztd::itoa( n, buf ); |
2255 | 103 | return *this; | 123 | return *this; |
2256 | 104 | } | 124 | } |
2257 | 105 | 125 | ||
2258 | 106 | Integer& Integer::operator=( unsigned long long n ) { | 126 | IntegerImpl& IntegerImpl::operator=( unsigned long long n ) { |
2259 | 107 | ztd::itoa_buf_type buf; | 127 | ztd::itoa_buf_type buf; |
2260 | 108 | value_ = ztd::itoa( n, buf ); | 128 | value_ = ztd::itoa( n, buf ); |
2261 | 109 | return *this; | 129 | return *this; |
2262 | 110 | } | 130 | } |
2263 | 111 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 131 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2264 | 112 | 132 | ||
2266 | 113 | Integer& Integer::operator=( Decimal const &d ) { | 133 | TEMPLATE_DECL(T) |
2267 | 134 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Decimal const &d ) { | ||
2268 | 114 | value_ = ftoi( d.value_ ); | 135 | value_ = ftoi( d.value_ ); |
2269 | 115 | return *this; | 136 | return *this; |
2270 | 116 | } | 137 | } |
2271 | 117 | 138 | ||
2273 | 118 | Integer& Integer::operator=( Double const &d ) { | 139 | TEMPLATE_DECL(T) |
2274 | 140 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Double const &d ) { | ||
2275 | 119 | if ( !d.isFinite() ) | 141 | if ( !d.isFinite() ) |
2276 | 120 | throw std::invalid_argument( "not finite" ); | 142 | throw std::invalid_argument( "not finite" ); |
2277 | 121 | value_ = ftoi( d.getNumber() ); | 143 | value_ = ftoi( d.getNumber() ); |
2278 | 122 | return *this; | 144 | return *this; |
2279 | 123 | } | 145 | } |
2280 | 124 | 146 | ||
2282 | 125 | Integer& Integer::operator=( Float const &f ) { | 147 | TEMPLATE_DECL(T) |
2283 | 148 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( Float const &f ) { | ||
2284 | 126 | if ( !f.isFinite() ) | 149 | if ( !f.isFinite() ) |
2285 | 127 | throw std::invalid_argument( "not finite" ); | 150 | throw std::invalid_argument( "not finite" ); |
2286 | 128 | value_ = ftoi( f.getNumber() ); | 151 | value_ = ftoi( f.getNumber() ); |
2287 | @@ -131,55 +154,67 @@ | |||
2288 | 131 | 154 | ||
2289 | 132 | ////////// arithmetic operators /////////////////////////////////////////////// | 155 | ////////// arithmetic operators /////////////////////////////////////////////// |
2290 | 133 | 156 | ||
2310 | 134 | Decimal operator+( Integer const &i, Decimal const &d ) { | 157 | #ifdef ZORBA_WITH_BIG_INTEGER |
2311 | 135 | return i.itod() + d.value_; | 158 | # define ZORBA_INSTANTIATE(OP) /* nothing */ |
2312 | 136 | } | 159 | #else |
2313 | 137 | 160 | # define ZORBA_INSTANTIATE(OP) \ | |
2314 | 138 | Decimal operator-( Integer const &i, Decimal const &d ) { | 161 | template Decimal operator OP( INTEGER_IMPL_LL const&, Decimal const& ); \ |
2315 | 139 | return i.itod() - d.value_; | 162 | template Decimal operator OP( INTEGER_IMPL_ULL const&, Decimal const& ); |
2316 | 140 | } | 163 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2317 | 141 | 164 | ||
2318 | 142 | Decimal operator*( Integer const &i, Decimal const &d ) { | 165 | #define ZORBA_INTEGER_OP(OP) \ |
2319 | 143 | return i.itod() * d.value_; | 166 | TEMPLATE_DECL(T) \ |
2320 | 144 | } | 167 | Decimal operator OP( INTEGER_IMPL(T) const &i, Decimal const &d ) { \ |
2321 | 145 | 168 | return i.itod() OP d.value_; \ | |
2322 | 146 | Decimal operator/( Integer const &i, Decimal const &d ) { | 169 | } \ |
2323 | 147 | return i.itod() / d.value_; | 170 | ZORBA_INSTANTIATE(OP) |
2324 | 148 | } | 171 | |
2325 | 149 | 172 | ZORBA_INTEGER_OP(+) | |
2326 | 150 | Decimal operator%( Integer const &i, Decimal const &d ) { | 173 | ZORBA_INTEGER_OP(-) |
2327 | 151 | return i.itod() % d.value_; | 174 | ZORBA_INTEGER_OP(*) |
2328 | 152 | } | 175 | ZORBA_INTEGER_OP(/) |
2329 | 176 | ZORBA_INTEGER_OP(%) | ||
2330 | 177 | #undef ZORBA_INTEGER_OP | ||
2331 | 178 | #undef ZORBA_INSTANTIATE | ||
2332 | 153 | 179 | ||
2333 | 154 | ////////// relational operators /////////////////////////////////////////////// | 180 | ////////// relational operators /////////////////////////////////////////////// |
2334 | 155 | 181 | ||
2336 | 156 | bool operator==( Integer const &i, Decimal const &d ) { | 182 | TEMPLATE_DECL(T) |
2337 | 183 | bool operator==( INTEGER_IMPL(T) const &i, Decimal const &d ) { | ||
2338 | 157 | return d.is_integer() && i.itod() == d.value_; | 184 | return d.is_integer() && i.itod() == d.value_; |
2339 | 158 | } | 185 | } |
2340 | 159 | 186 | ||
2360 | 160 | bool operator!=( Integer const &i, Decimal const &d ) { | 187 | #define ZORBA_INTEGER_OP(OP) \ |
2361 | 161 | return i.itod() != d.value_; | 188 | TEMPLATE_DECL(T) \ |
2362 | 162 | } | 189 | bool operator OP( INTEGER_IMPL(T) const &i, Decimal const &d ) { \ |
2363 | 163 | 190 | return i.itod() OP d.value_; \ | |
2364 | 164 | bool operator<( Integer const &i, Decimal const &d ) { | 191 | } |
2365 | 165 | return i.itod() < d.value_; | 192 | |
2366 | 166 | } | 193 | ZORBA_INTEGER_OP(!=) |
2367 | 167 | 194 | ZORBA_INTEGER_OP(< ) | |
2368 | 168 | bool operator<=( Integer const &i, Decimal const &d ) { | 195 | ZORBA_INTEGER_OP(<=) |
2369 | 169 | return i.itod() <= d.value_; | 196 | ZORBA_INTEGER_OP(> ) |
2370 | 170 | } | 197 | ZORBA_INTEGER_OP(>=) |
2371 | 171 | 198 | #undef ZORBA_INTEGER_OP | |
2372 | 172 | bool operator>( Integer const &i, Decimal const &d ) { | 199 | |
2373 | 173 | return i.itod() > d.value_; | 200 | #ifndef ZORBA_WITH_BIG_INTEGER |
2374 | 174 | } | 201 | #define ZORBA_INSTANTIATE(OP) \ |
2375 | 175 | 202 | template bool operator OP( INTEGER_IMPL_LL const&, Decimal const& ); \ | |
2376 | 176 | bool operator>=( Integer const &i, Decimal const &d ) { | 203 | template bool operator OP( INTEGER_IMPL_ULL const&, Decimal const& ) |
2377 | 177 | return i.itod() >= d.value_; | 204 | |
2378 | 178 | } | 205 | ZORBA_INSTANTIATE(==); |
2379 | 206 | ZORBA_INSTANTIATE(!=); | ||
2380 | 207 | ZORBA_INSTANTIATE(< ); | ||
2381 | 208 | ZORBA_INSTANTIATE(<=); | ||
2382 | 209 | ZORBA_INSTANTIATE(> ); | ||
2383 | 210 | ZORBA_INSTANTIATE(>=); | ||
2384 | 211 | #undef ZORBA_INSTANTIATE | ||
2385 | 212 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2386 | 179 | 213 | ||
2387 | 180 | ////////// math functions ///////////////////////////////////////////////////// | 214 | ////////// math functions ///////////////////////////////////////////////////// |
2388 | 181 | 215 | ||
2390 | 182 | Double Integer::pow( Integer const &power ) const { | 216 | TEMPLATE_DECL(T) |
2391 | 217 | Double INTEGER_IMPL(T)::pow( INTEGER_IMPL(T) const &power ) const { | ||
2392 | 183 | #ifdef ZORBA_WITH_BIG_INTEGER | 218 | #ifdef ZORBA_WITH_BIG_INTEGER |
2393 | 184 | value_type const result( value_.pow( power.value_, 15 ) ); | 219 | value_type const result( value_.pow( power.value_, 15 ) ); |
2394 | 185 | char buf[300]; | 220 | char buf[300]; |
2395 | @@ -193,27 +228,32 @@ | |||
2396 | 193 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 228 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2397 | 194 | } | 229 | } |
2398 | 195 | 230 | ||
2401 | 196 | Integer Integer::round( Integer const &precision ) const { | 231 | TEMPLATE_DECL(T) |
2402 | 197 | return Integer( Decimal::round( itod(), precision.itod() ) ); | 232 | INTEGER_IMPL(T) INTEGER_IMPL(T)::round( IntegerImpl const &precision ) const { |
2403 | 233 | return IntegerImpl( Decimal::round( itod(), precision.itod() ) ); | ||
2404 | 198 | } | 234 | } |
2405 | 199 | 235 | ||
2408 | 200 | Integer Integer::roundHalfToEven( Integer const &precision ) const { | 236 | TEMPLATE_DECL(T) |
2409 | 201 | return Integer( Decimal::roundHalfToEven( itod(), precision.itod() ) ); | 237 | INTEGER_IMPL(T) |
2410 | 238 | INTEGER_IMPL(T)::roundHalfToEven( IntegerImpl const &precision ) const { | ||
2411 | 239 | return IntegerImpl( Decimal::roundHalfToEven( itod(), precision.itod() ) ); | ||
2412 | 202 | } | 240 | } |
2413 | 203 | 241 | ||
2414 | 204 | ////////// miscellaneous ////////////////////////////////////////////////////// | 242 | ////////// miscellaneous ////////////////////////////////////////////////////// |
2415 | 205 | 243 | ||
2416 | 206 | #ifndef ZORBA_WITH_BIG_INTEGER | 244 | #ifndef ZORBA_WITH_BIG_INTEGER |
2418 | 207 | Integer::value_type Integer::ftoi( MAPM const &d ) { | 245 | TEMPLATE_DECL(T) |
2419 | 246 | typename INTEGER_IMPL(T)::value_type INTEGER_IMPL(T)::ftoi( MAPM const &d ) { | ||
2420 | 208 | MAPM const temp( d.sign() >= 0 ? d.floor() : d.ceil() ); | 247 | MAPM const temp( d.sign() >= 0 ? d.floor() : d.ceil() ); |
2421 | 209 | char *const buf = new char[ temp.exponent() + 3 ]; | 248 | char *const buf = new char[ temp.exponent() + 3 ]; |
2422 | 210 | temp.toIntegerString( buf ); | 249 | temp.toIntegerString( buf ); |
2424 | 211 | value_type const result( std::strtoll( buf, nullptr, 10 ) ); | 250 | value_type const result( ztd::aton<value_type>( buf ) ); |
2425 | 212 | delete[] buf; | 251 | delete[] buf; |
2426 | 213 | return result; | 252 | return result; |
2427 | 214 | } | 253 | } |
2428 | 215 | 254 | ||
2430 | 216 | MAPM Integer::itod() const { | 255 | TEMPLATE_DECL(T) |
2431 | 256 | MAPM INTEGER_IMPL(T)::itod() const { | ||
2432 | 217 | if ( is_long() ) | 257 | if ( is_long() ) |
2433 | 218 | return static_cast<long>( value_ ); | 258 | return static_cast<long>( value_ ); |
2434 | 219 | ztd::itoa_buf_type buf; | 259 | ztd::itoa_buf_type buf; |
2435 | @@ -222,17 +262,19 @@ | |||
2436 | 222 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 262 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2437 | 223 | 263 | ||
2438 | 224 | #ifdef ZORBA_WITH_BIG_INTEGER | 264 | #ifdef ZORBA_WITH_BIG_INTEGER |
2440 | 225 | uint32_t Integer::hash() const { | 265 | uint32_t IntegerImpl::hash() const { |
2441 | 226 | return Decimal::hash( value_ ); | 266 | return Decimal::hash( value_ ); |
2442 | 227 | } | 267 | } |
2443 | 228 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 268 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2444 | 229 | 269 | ||
2447 | 230 | Integer const& Integer::one() { | 270 | TEMPLATE_DECL(T) |
2448 | 231 | static Integer const i(1); | 271 | INTEGER_IMPL(T) const& INTEGER_IMPL(T)::one() { |
2449 | 272 | static INTEGER_IMPL(T) const i(1); | ||
2450 | 232 | return i; | 273 | return i; |
2451 | 233 | } | 274 | } |
2452 | 234 | 275 | ||
2454 | 235 | zstring Integer::toString() const { | 276 | TEMPLATE_DECL(T) |
2455 | 277 | zstring INTEGER_IMPL(T)::toString() const { | ||
2456 | 236 | #ifdef ZORBA_WITH_BIG_INTEGER | 278 | #ifdef ZORBA_WITH_BIG_INTEGER |
2457 | 237 | char *const buf = new char[ value_.exponent() + 3 ]; | 279 | char *const buf = new char[ value_.exponent() + 3 ]; |
2458 | 238 | value_.toIntegerString( buf ); | 280 | value_.toIntegerString( buf ); |
2459 | @@ -245,12 +287,18 @@ | |||
2460 | 245 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 287 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2461 | 246 | } | 288 | } |
2462 | 247 | 289 | ||
2465 | 248 | Integer const& Integer::zero() { | 290 | TEMPLATE_DECL(T) |
2466 | 249 | static Integer const i(0); | 291 | INTEGER_IMPL(T) const& INTEGER_IMPL(T)::zero() { |
2467 | 292 | static INTEGER_IMPL(T) const i(0); | ||
2468 | 250 | return i; | 293 | return i; |
2469 | 251 | } | 294 | } |
2470 | 252 | 295 | ||
2471 | 253 | /////////////////////////////////////////////////////////////////////////////// | 296 | /////////////////////////////////////////////////////////////////////////////// |
2472 | 254 | 297 | ||
2473 | 298 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
2474 | 299 | template class IntegerImpl<long long>; | ||
2475 | 300 | template class IntegerImpl<unsigned long long>; | ||
2476 | 301 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2477 | 302 | |||
2478 | 255 | } // namespace zorba | 303 | } // namespace zorba |
2479 | 256 | /* vim:set et sw=2 ts=2: */ | 304 | /* vim:set et sw=2 ts=2: */ |
2480 | 257 | 305 | ||
2481 | === modified file 'src/zorbatypes/integer.h' | |||
2482 | --- src/zorbatypes/integer.h 2011-06-29 20:31:44 +0000 | |||
2483 | +++ src/zorbatypes/integer.h 2011-11-29 00:43:26 +0000 | |||
2484 | @@ -24,6 +24,7 @@ | |||
2485 | 24 | #include <zorba/config.h> | 24 | #include <zorba/config.h> |
2486 | 25 | #include "common/common.h" | 25 | #include "common/common.h" |
2487 | 26 | 26 | ||
2488 | 27 | #include "util/stl_util.h" | ||
2489 | 27 | #include "zorbaserialization/archiver.h" | 28 | #include "zorbaserialization/archiver.h" |
2490 | 28 | #include "zorbaserialization/zorba_class_serializer.h" | 29 | #include "zorbaserialization/zorba_class_serializer.h" |
2491 | 29 | 30 | ||
2492 | @@ -32,39 +33,53 @@ | |||
2493 | 32 | #include "zorbatypes_decl.h" | 33 | #include "zorbatypes_decl.h" |
2494 | 33 | #include "zstring.h" | 34 | #include "zstring.h" |
2495 | 34 | 35 | ||
2496 | 36 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
2497 | 37 | # define TEMPLATE_DECL(T) /* nothing */ | ||
2498 | 38 | # define INTEGER_IMPL(T) IntegerImpl | ||
2499 | 39 | #else | ||
2500 | 40 | # define TEMPLATE_DECL(T) template<typename T> | ||
2501 | 41 | # define INTEGER_IMPL(T) IntegerImpl<T> | ||
2502 | 42 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2503 | 43 | #define INTEGER_IMPL_LL INTEGER_IMPL(long long) | ||
2504 | 44 | #define INTEGER_IMPL_ULL INTEGER_IMPL(unsigned long long) | ||
2505 | 45 | |||
2506 | 35 | namespace zorba { | 46 | namespace zorba { |
2507 | 36 | 47 | ||
2509 | 37 | class Integer; | 48 | TEMPLATE_DECL(T) |
2510 | 49 | class IntegerImpl; | ||
2511 | 50 | |||
2512 | 38 | namespace serialization { | 51 | namespace serialization { |
2514 | 39 | void operator&(serialization::Archiver&, zorba::Integer&); | 52 | TEMPLATE_DECL(T) void operator&( Archiver&, INTEGER_IMPL(T)& ); |
2515 | 40 | } | 53 | } |
2516 | 41 | 54 | ||
2517 | 42 | /////////////////////////////////////////////////////////////////////////////// | 55 | /////////////////////////////////////////////////////////////////////////////// |
2518 | 43 | 56 | ||
2521 | 44 | // exported for testing only | 57 | TEMPLATE_DECL(IntType) |
2522 | 45 | class ZORBA_DLL_PUBLIC Integer { | 58 | class IntegerImpl { |
2523 | 46 | public: | 59 | public: |
2524 | 47 | 60 | ||
2525 | 48 | ////////// constructors ///////////////////////////////////////////////////// | 61 | ////////// constructors ///////////////////////////////////////////////////// |
2526 | 49 | 62 | ||
2542 | 50 | Integer( char c ); | 63 | IntegerImpl( char c ); |
2543 | 51 | Integer( signed char c ); | 64 | IntegerImpl( signed char c ); |
2544 | 52 | Integer( short n ); | 65 | IntegerImpl( short n ); |
2545 | 53 | Integer( int n = 0 ); | 66 | IntegerImpl( int n = 0 ); |
2546 | 54 | Integer( long n ); | 67 | IntegerImpl( long n ); |
2547 | 55 | Integer( long long n ); | 68 | IntegerImpl( long long n ); |
2548 | 56 | Integer( unsigned char c ); | 69 | IntegerImpl( unsigned char c ); |
2549 | 57 | Integer( unsigned short n ); | 70 | IntegerImpl( unsigned short n ); |
2550 | 58 | Integer( unsigned int n ); | 71 | IntegerImpl( unsigned int n ); |
2551 | 59 | Integer( unsigned long n ); | 72 | IntegerImpl( unsigned long n ); |
2552 | 60 | Integer( unsigned long long n ); | 73 | IntegerImpl( unsigned long long n ); |
2553 | 61 | Integer( float n ); | 74 | IntegerImpl( float n ); |
2554 | 62 | Integer( double n ); | 75 | IntegerImpl( double n ); |
2555 | 63 | Integer( Decimal const &d ); | 76 | IntegerImpl( Decimal const &d ); |
2556 | 64 | Integer( Integer const &i ); | 77 | |
2557 | 78 | TEMPLATE_DECL(U) | ||
2558 | 79 | IntegerImpl( INTEGER_IMPL(U) const &i ); | ||
2559 | 65 | 80 | ||
2560 | 66 | /** | 81 | /** |
2562 | 67 | * Constructs an %Integer from a C string. | 82 | * Constructs an %IntegerImpl from a C string. |
2563 | 68 | * | 83 | * |
2564 | 69 | * @param s The null-terminated C string to parse. Leading and trailing | 84 | * @param s The null-terminated C string to parse. Leading and trailing |
2565 | 70 | * whitespace is ignored. | 85 | * whitespace is ignored. |
2566 | @@ -73,115 +88,110 @@ | |||
2567 | 73 | * or overflows the smallest or largest representable integer (only when not | 88 | * or overflows the smallest or largest representable integer (only when not |
2568 | 74 | * compiled with ZORBA_WITH_BIG_INTEGER). | 89 | * compiled with ZORBA_WITH_BIG_INTEGER). |
2569 | 75 | */ | 90 | */ |
2571 | 76 | Integer( char const *s ); | 91 | IntegerImpl( char const *s ); |
2572 | 77 | 92 | ||
2573 | 78 | /** | 93 | /** |
2575 | 79 | * Constructs an %Integer from a Double. | 94 | * Constructs an %IntegerImpl from a Double. |
2576 | 80 | * | 95 | * |
2577 | 81 | * @param d The Double. | 96 | * @param d The Double. |
2578 | 82 | * @throw std::invalid_argument if \a d is not finite. | 97 | * @throw std::invalid_argument if \a d is not finite. |
2579 | 83 | */ | 98 | */ |
2581 | 84 | Integer( Double const &d ); | 99 | IntegerImpl( Double const &d ); |
2582 | 85 | 100 | ||
2583 | 86 | /** | 101 | /** |
2585 | 87 | * Constructs an %Integer from a Float. | 102 | * Constructs an %IntegerImpl from a Float. |
2586 | 88 | * | 103 | * |
2587 | 89 | * @param f The Float. | 104 | * @param f The Float. |
2588 | 90 | * @throw std::invalid_argument if \a f is not finite. | 105 | * @throw std::invalid_argument if \a f is not finite. |
2589 | 91 | */ | 106 | */ |
2591 | 92 | Integer( Float const &f ); | 107 | IntegerImpl( Float const &f ); |
2592 | 93 | 108 | ||
2593 | 94 | ////////// assignment operators ///////////////////////////////////////////// | 109 | ////////// assignment operators ///////////////////////////////////////////// |
2594 | 95 | 110 | ||
2613 | 96 | Integer& operator=( char c ); | 111 | IntegerImpl& operator=( char c ); |
2614 | 97 | Integer& operator=( signed char c ); | 112 | IntegerImpl& operator=( signed char c ); |
2615 | 98 | Integer& operator=( short n ); | 113 | IntegerImpl& operator=( short n ); |
2616 | 99 | Integer& operator=( int n ); | 114 | IntegerImpl& operator=( int n ); |
2617 | 100 | Integer& operator=( long n ); | 115 | IntegerImpl& operator=( long n ); |
2618 | 101 | Integer& operator=( long long n ); | 116 | IntegerImpl& operator=( long long n ); |
2619 | 102 | Integer& operator=( unsigned char c ); | 117 | IntegerImpl& operator=( unsigned char c ); |
2620 | 103 | Integer& operator=( unsigned short n ); | 118 | IntegerImpl& operator=( unsigned short n ); |
2621 | 104 | Integer& operator=( unsigned int n ); | 119 | IntegerImpl& operator=( unsigned int n ); |
2622 | 105 | Integer& operator=( unsigned long n ); | 120 | IntegerImpl& operator=( unsigned long n ); |
2623 | 106 | Integer& operator=( unsigned long long n ); | 121 | IntegerImpl& operator=( unsigned long long n ); |
2624 | 107 | Integer& operator=( float n ); | 122 | IntegerImpl& operator=( float n ); |
2625 | 108 | Integer& operator=( double n ); | 123 | IntegerImpl& operator=( double n ); |
2626 | 109 | Integer& operator=( char const *s ); | 124 | IntegerImpl& operator=( char const *s ); |
2627 | 110 | Integer& operator=( Decimal const &d ); | 125 | IntegerImpl& operator=( Decimal const &d ); |
2628 | 111 | Integer& operator=( Double const &d ); | 126 | IntegerImpl& operator=( Double const &d ); |
2629 | 112 | Integer& operator=( Float const &f ); | 127 | IntegerImpl& operator=( Float const &f ); |
2630 | 113 | Integer& operator=( Integer const &i ); | 128 | |
2631 | 129 | TEMPLATE_DECL(U) | ||
2632 | 130 | IntegerImpl& operator=( INTEGER_IMPL(U) const &i ); | ||
2633 | 114 | 131 | ||
2634 | 115 | ////////// arithmetic operators ///////////////////////////////////////////// | 132 | ////////// arithmetic operators ///////////////////////////////////////////// |
2635 | 116 | 133 | ||
2666 | 117 | friend Integer operator+( Integer const &i, Integer const &j ); | 134 | #define ZORBA_INTEGER_OP(OP) \ |
2667 | 118 | friend Integer operator-( Integer const &i, Integer const &j ); | 135 | TEMPLATE_DECL(T) friend \ |
2668 | 119 | friend Integer operator*( Integer const &i, Integer const &j ); | 136 | INTEGER_IMPL(T) operator OP( INTEGER_IMPL(T) const&, \ |
2669 | 120 | friend Integer operator/( Integer const &i, Integer const &j ); | 137 | INTEGER_IMPL(T) const& ); \ |
2670 | 121 | friend Integer operator%( Integer const &i, Integer const &j ); | 138 | TEMPLATE_DECL(T) friend \ |
2671 | 122 | 139 | Decimal operator OP( INTEGER_IMPL(T) const&, Decimal const& ); \ | |
2672 | 123 | friend Decimal operator+( Integer const &i, Decimal const &d ); | 140 | TEMPLATE_DECL(T) friend \ |
2673 | 124 | friend Decimal operator-( Integer const &i, Decimal const &d ); | 141 | Decimal operator OP( Decimal const&, INTEGER_IMPL(T) const& ) |
2674 | 125 | friend Decimal operator*( Integer const &i, Decimal const &d ); | 142 | |
2675 | 126 | friend Decimal operator/( Integer const &i, Decimal const &d ); | 143 | ZORBA_INTEGER_OP(+); |
2676 | 127 | friend Decimal operator%( Integer const &i, Decimal const &d ); | 144 | ZORBA_INTEGER_OP(-); |
2677 | 128 | 145 | ZORBA_INTEGER_OP(*); | |
2678 | 129 | friend Decimal operator+( Decimal const &d, Integer const &i ); | 146 | ZORBA_INTEGER_OP(/); |
2679 | 130 | friend Decimal operator-( Decimal const &d, Integer const &i ); | 147 | ZORBA_INTEGER_OP(%); |
2680 | 131 | friend Decimal operator*( Decimal const &d, Integer const &i ); | 148 | #undef ZORBA_INTEGER_OP |
2681 | 132 | friend Decimal operator/( Decimal const &d, Integer const &i ); | 149 | |
2682 | 133 | friend Decimal operator%( Decimal const &d, Integer const &i ); | 150 | IntegerImpl& operator+=( IntegerImpl const& ); |
2683 | 134 | 151 | IntegerImpl& operator-=( IntegerImpl const& ); | |
2684 | 135 | Integer& operator+=( Integer const &i ); | 152 | IntegerImpl& operator*=( IntegerImpl const& ); |
2685 | 136 | Integer& operator-=( Integer const &i ); | 153 | IntegerImpl& operator/=( IntegerImpl const& ); |
2686 | 137 | Integer& operator*=( Integer const &i ); | 154 | IntegerImpl& operator%=( IntegerImpl const& ); |
2687 | 138 | Integer& operator/=( Integer const &i ); | 155 | |
2688 | 139 | Integer& operator%=( Integer const &i ); | 156 | IntegerImpl operator-() const; |
2689 | 140 | 157 | ||
2690 | 141 | Integer operator-() const; | 158 | IntegerImpl& operator++(); |
2691 | 142 | 159 | IntegerImpl operator++(int); | |
2692 | 143 | Integer& operator++(); | 160 | IntegerImpl& operator--(); |
2693 | 144 | Integer operator++(int); | 161 | IntegerImpl operator--(int); |
2664 | 145 | Integer& operator--(); | ||
2665 | 146 | Integer operator--(int); | ||
2694 | 147 | 162 | ||
2695 | 148 | ////////// relational operators ///////////////////////////////////////////// | 163 | ////////// relational operators ///////////////////////////////////////////// |
2696 | 149 | 164 | ||
2717 | 150 | friend bool operator==( Integer const &i, Integer const &j ); | 165 | #define ZORBA_INTEGER_OP(OP) \ |
2718 | 151 | friend bool operator!=( Integer const &i, Integer const &j ); | 166 | TEMPLATE_DECL(T) friend \ |
2719 | 152 | friend bool operator< ( Integer const &i, Integer const &j ); | 167 | bool operator OP( INTEGER_IMPL(T) const&, INTEGER_IMPL(T) const& ); \ |
2720 | 153 | friend bool operator<=( Integer const &i, Integer const &j ); | 168 | TEMPLATE_DECL(T) friend \ |
2721 | 154 | friend bool operator> ( Integer const &i, Integer const &j ); | 169 | bool operator OP( INTEGER_IMPL(T) const&, Decimal const& ); \ |
2722 | 155 | friend bool operator>=( Integer const &i, Integer const &j ); | 170 | TEMPLATE_DECL(T) friend \ |
2723 | 156 | 171 | bool operator OP( Decimal const&, INTEGER_IMPL(T) const& ) | |
2724 | 157 | friend bool operator==( Integer const &i, Decimal const &d ); | 172 | |
2725 | 158 | friend bool operator!=( Integer const &i, Decimal const &d ); | 173 | ZORBA_INTEGER_OP(==); |
2726 | 159 | friend bool operator< ( Integer const &i, Decimal const &d ); | 174 | ZORBA_INTEGER_OP(!=); |
2727 | 160 | friend bool operator<=( Integer const &i, Decimal const &d ); | 175 | ZORBA_INTEGER_OP(< ); |
2728 | 161 | friend bool operator> ( Integer const &i, Decimal const &d ); | 176 | ZORBA_INTEGER_OP(<=); |
2729 | 162 | friend bool operator>=( Integer const &i, Decimal const &d ); | 177 | ZORBA_INTEGER_OP(> ); |
2730 | 163 | 178 | ZORBA_INTEGER_OP(>=); | |
2731 | 164 | friend bool operator==( Decimal const &d, Integer const &i ); | 179 | #undef ZORBA_INTEGER_OP |
2712 | 165 | friend bool operator!=( Decimal const &d, Integer const &i ); | ||
2713 | 166 | friend bool operator< ( Decimal const &d, Integer const &i ); | ||
2714 | 167 | friend bool operator<=( Decimal const &d, Integer const &i ); | ||
2715 | 168 | friend bool operator> ( Decimal const &d, Integer const &i ); | ||
2716 | 169 | friend bool operator>=( Decimal const &d, Integer const &i ); | ||
2732 | 170 | 180 | ||
2733 | 171 | ////////// math functions /////////////////////////////////////////////////// | 181 | ////////// math functions /////////////////////////////////////////////////// |
2734 | 172 | 182 | ||
2738 | 173 | Double pow( Integer const &power ) const; | 183 | Double pow( IntegerImpl const &power ) const; |
2739 | 174 | Integer round( Integer const &precision ) const; | 184 | IntegerImpl round( IntegerImpl const &precision ) const; |
2740 | 175 | Integer roundHalfToEven( Integer const &precision ) const; | 185 | IntegerImpl roundHalfToEven( IntegerImpl const &precision ) const; |
2741 | 176 | 186 | ||
2742 | 177 | ////////// miscellaneous //////////////////////////////////////////////////// | 187 | ////////// miscellaneous //////////////////////////////////////////////////// |
2743 | 178 | 188 | ||
2745 | 179 | int compare( Integer const &i ) const; | 189 | int compare( IntegerImpl const& ) const; |
2746 | 180 | uint32_t hash() const; | 190 | uint32_t hash() const; |
2747 | 181 | int sign() const; | 191 | int sign() const; |
2748 | 182 | zstring toString() const; | 192 | zstring toString() const; |
2751 | 183 | static Integer const& one(); | 193 | static IntegerImpl const& one(); |
2752 | 184 | static Integer const& zero(); | 194 | static IntegerImpl const& zero(); |
2753 | 185 | 195 | ||
2754 | 186 | ///////////////////////////////////////////////////////////////////////////// | 196 | ///////////////////////////////////////////////////////////////////////////// |
2755 | 187 | 197 | ||
2756 | @@ -189,13 +199,13 @@ | |||
2757 | 189 | #ifdef ZORBA_WITH_BIG_INTEGER | 199 | #ifdef ZORBA_WITH_BIG_INTEGER |
2758 | 190 | typedef MAPM value_type; | 200 | typedef MAPM value_type; |
2759 | 191 | #else | 201 | #else |
2761 | 192 | typedef long long value_type; | 202 | typedef IntType value_type; |
2762 | 193 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 203 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2763 | 194 | 204 | ||
2764 | 195 | value_type value_; | 205 | value_type value_; |
2765 | 196 | 206 | ||
2766 | 197 | #ifdef ZORBA_WITH_BIG_INTEGER | 207 | #ifdef ZORBA_WITH_BIG_INTEGER |
2768 | 198 | Integer( value_type const &v ) : value_( v ) { } | 208 | IntegerImpl( value_type const &v ) : value_( v ) { } |
2769 | 199 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 209 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2770 | 200 | 210 | ||
2771 | 201 | static value_type ftoi( double d ) { | 211 | static value_type ftoi( double d ) { |
2772 | @@ -227,58 +237,96 @@ | |||
2773 | 227 | friend class Decimal; | 237 | friend class Decimal; |
2774 | 228 | template<typename T> friend class FloatImpl; | 238 | template<typename T> friend class FloatImpl; |
2775 | 229 | 239 | ||
2782 | 230 | friend xs_int to_xs_int( Integer const& ); | 240 | #ifndef ZORBA_WITH_BIG_INTEGER |
2783 | 231 | friend xs_long to_xs_long( Integer const& ); | 241 | template<typename U> friend class IntegerImpl; |
2784 | 232 | friend xs_unsignedInt to_xs_unsignedInt( Integer const& ); | 242 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2785 | 233 | friend xs_unsignedLong to_xs_unsignedLong( Integer const& ); | 243 | |
2786 | 234 | 244 | friend xs_int to_xs_int( INTEGER_IMPL_LL const& ); | |
2787 | 235 | friend void serialization::operator&(serialization::Archiver&, Integer&); | 245 | friend xs_long to_xs_long( INTEGER_IMPL_LL const& ); |
2788 | 246 | friend xs_unsignedInt to_xs_unsignedInt( INTEGER_IMPL_LL const& ); | ||
2789 | 247 | friend xs_unsignedLong to_xs_unsignedLong( INTEGER_IMPL_LL const& ); | ||
2790 | 248 | |||
2791 | 249 | TEMPLATE_DECL(T) friend | ||
2792 | 250 | void serialization::operator&( serialization::Archiver&, INTEGER_IMPL(T)& ); | ||
2793 | 236 | }; | 251 | }; |
2794 | 237 | 252 | ||
2795 | 253 | typedef INTEGER_IMPL_LL Integer; | ||
2796 | 254 | typedef INTEGER_IMPL_ULL UInteger; | ||
2797 | 255 | |||
2798 | 238 | ////////// constructors /////////////////////////////////////////////////////// | 256 | ////////// constructors /////////////////////////////////////////////////////// |
2799 | 239 | 257 | ||
2842 | 240 | inline Integer::Integer( char c ) : value_( static_cast<long>( c ) ) { | 258 | TEMPLATE_DECL(T) |
2843 | 241 | } | 259 | inline INTEGER_IMPL(T)::IntegerImpl( char c ) : |
2844 | 242 | 260 | value_( static_cast<long>( c ) ) | |
2845 | 243 | inline Integer::Integer( signed char c ) : value_( static_cast<long>( c ) ) { | 261 | { |
2846 | 244 | } | 262 | } |
2847 | 245 | 263 | ||
2848 | 246 | inline Integer::Integer( short n ) : value_( static_cast<long>( n ) ) { | 264 | TEMPLATE_DECL(T) |
2849 | 247 | } | 265 | inline INTEGER_IMPL(T)::IntegerImpl( signed char c ) : |
2850 | 248 | 266 | value_( static_cast<long>( c ) ) | |
2851 | 249 | inline Integer::Integer( int n ) : value_( static_cast<long>( n ) ) { | 267 | { |
2852 | 250 | } | 268 | } |
2853 | 251 | 269 | ||
2854 | 252 | inline Integer::Integer( long n ) : value_( n ) { | 270 | TEMPLATE_DECL(T) |
2855 | 253 | } | 271 | inline INTEGER_IMPL(T)::IntegerImpl( short n ) : |
2856 | 254 | 272 | value_( static_cast<long>( n ) ) | |
2857 | 255 | #ifndef ZORBA_WITH_BIG_INTEGER | 273 | { |
2858 | 256 | inline Integer::Integer( long long n ) : value_( n ) { | 274 | } |
2859 | 257 | } | 275 | |
2860 | 258 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 276 | TEMPLATE_DECL(T) |
2861 | 259 | 277 | inline INTEGER_IMPL(T)::IntegerImpl( int n ) : | |
2862 | 260 | inline Integer::Integer( unsigned char c ) : value_( static_cast<long>( c ) ) { | 278 | value_( static_cast<long>( n ) ) |
2863 | 261 | } | 279 | { |
2864 | 262 | 280 | } | |
2865 | 263 | inline Integer::Integer( unsigned short n ) : value_( static_cast<long>( n ) ) { | 281 | |
2866 | 264 | } | 282 | TEMPLATE_DECL(T) |
2867 | 265 | 283 | inline INTEGER_IMPL(T)::IntegerImpl( long n ) : | |
2868 | 266 | inline Integer::Integer( unsigned int n ) : value_( static_cast<long>( n ) ) { | 284 | value_( n ) |
2869 | 267 | } | 285 | { |
2870 | 268 | 286 | } | |
2871 | 269 | #ifndef ZORBA_WITH_BIG_INTEGER | 287 | |
2872 | 270 | inline Integer::Integer( unsigned long n ) : | 288 | #ifndef ZORBA_WITH_BIG_INTEGER |
2873 | 271 | value_( static_cast<value_type>( n ) ) | 289 | TEMPLATE_DECL(T) |
2874 | 272 | { | 290 | inline INTEGER_IMPL(T)::IntegerImpl( long long n ) : |
2875 | 273 | } | 291 | value_( n ) |
2876 | 274 | 292 | { | |
2877 | 275 | inline Integer::Integer( unsigned long long n ) : | 293 | } |
2878 | 276 | value_( static_cast<value_type>( n ) ) | 294 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
2879 | 277 | { | 295 | |
2880 | 278 | } | 296 | TEMPLATE_DECL(T) |
2881 | 279 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 297 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned char c ) : |
2882 | 280 | 298 | value_( static_cast<long>( c ) ) | |
2883 | 281 | inline Integer::Integer( float n ) : | 299 | { |
2884 | 300 | } | ||
2885 | 301 | |||
2886 | 302 | TEMPLATE_DECL(T) | ||
2887 | 303 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned short n ) : | ||
2888 | 304 | value_( static_cast<long>( n ) ) | ||
2889 | 305 | { | ||
2890 | 306 | } | ||
2891 | 307 | |||
2892 | 308 | TEMPLATE_DECL(T) | ||
2893 | 309 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned int n ) : | ||
2894 | 310 | value_( static_cast<long>( n ) ) | ||
2895 | 311 | { | ||
2896 | 312 | } | ||
2897 | 313 | |||
2898 | 314 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
2899 | 315 | TEMPLATE_DECL(T) | ||
2900 | 316 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned long n ) : | ||
2901 | 317 | value_( static_cast<value_type>( n ) ) | ||
2902 | 318 | { | ||
2903 | 319 | } | ||
2904 | 320 | |||
2905 | 321 | TEMPLATE_DECL(T) | ||
2906 | 322 | inline INTEGER_IMPL(T)::IntegerImpl( unsigned long long n ) : | ||
2907 | 323 | value_( static_cast<value_type>( n ) ) | ||
2908 | 324 | { | ||
2909 | 325 | } | ||
2910 | 326 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
2911 | 327 | |||
2912 | 328 | TEMPLATE_DECL(T) | ||
2913 | 329 | inline INTEGER_IMPL(T)::IntegerImpl( float n ) : | ||
2914 | 282 | #ifdef ZORBA_WITH_BIG_INTEGER | 330 | #ifdef ZORBA_WITH_BIG_INTEGER |
2915 | 283 | value_( static_cast<double>( n ) ) | 331 | value_( static_cast<double>( n ) ) |
2916 | 284 | #else | 332 | #else |
2917 | @@ -287,7 +335,8 @@ | |||
2918 | 287 | { | 335 | { |
2919 | 288 | } | 336 | } |
2920 | 289 | 337 | ||
2922 | 290 | inline Integer::Integer( double n ) : | 338 | TEMPLATE_DECL(T) |
2923 | 339 | inline INTEGER_IMPL(T)::IntegerImpl( double n ) : | ||
2924 | 291 | #ifdef ZORBA_WITH_BIG_INTEGER | 340 | #ifdef ZORBA_WITH_BIG_INTEGER |
2925 | 292 | value_( n ) | 341 | value_( n ) |
2926 | 293 | #else | 342 | #else |
2927 | @@ -296,240 +345,252 @@ | |||
2928 | 296 | { | 345 | { |
2929 | 297 | } | 346 | } |
2930 | 298 | 347 | ||
2932 | 299 | inline Integer::Integer( char const *s ) { | 348 | TEMPLATE_DECL(T) |
2933 | 349 | inline INTEGER_IMPL(T)::IntegerImpl( char const *s ) { | ||
2934 | 300 | parse( s ); | 350 | parse( s ); |
2935 | 301 | } | 351 | } |
2936 | 302 | 352 | ||
2938 | 303 | inline Integer::Integer( Integer const &i ) : | 353 | TEMPLATE_DECL(T) |
2939 | 354 | TEMPLATE_DECL(U) | ||
2940 | 355 | inline INTEGER_IMPL(T)::IntegerImpl( INTEGER_IMPL(U) const &i ) : | ||
2941 | 304 | value_( i.value_ ) | 356 | value_( i.value_ ) |
2942 | 305 | { | 357 | { |
2943 | 306 | } | 358 | } |
2944 | 307 | 359 | ||
2945 | 308 | ////////// assignment operators /////////////////////////////////////////////// | 360 | ////////// assignment operators /////////////////////////////////////////////// |
2946 | 309 | 361 | ||
3017 | 310 | inline Integer& Integer::operator=( char c ) { | 362 | TEMPLATE_DECL(T) |
3018 | 311 | value_ = static_cast<long>( c ); | 363 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( char c ) { |
3019 | 312 | return *this; | 364 | value_ = static_cast<long>( c ); |
3020 | 313 | } | 365 | return *this; |
3021 | 314 | 366 | } | |
3022 | 315 | inline Integer& Integer::operator=( signed char c ) { | 367 | |
3023 | 316 | value_ = static_cast<long>( c ); | 368 | TEMPLATE_DECL(T) |
3024 | 317 | return *this; | 369 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( signed char c ) { |
3025 | 318 | } | 370 | value_ = static_cast<long>( c ); |
3026 | 319 | 371 | return *this; | |
3027 | 320 | inline Integer& Integer::operator=( short n ) { | 372 | } |
3028 | 321 | value_ = static_cast<long>( n ); | 373 | |
3029 | 322 | return *this; | 374 | TEMPLATE_DECL(T) |
3030 | 323 | } | 375 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( short n ) { |
3031 | 324 | 376 | value_ = static_cast<long>( n ); | |
3032 | 325 | inline Integer& Integer::operator=( int n ) { | 377 | return *this; |
3033 | 326 | value_ = static_cast<long>( n ); | 378 | } |
3034 | 327 | return *this; | 379 | |
3035 | 328 | } | 380 | TEMPLATE_DECL(T) |
3036 | 329 | 381 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( int n ) { | |
3037 | 330 | inline Integer& Integer::operator=( long n ) { | 382 | value_ = static_cast<long>( n ); |
3038 | 331 | value_ = n; | 383 | return *this; |
3039 | 332 | return *this; | 384 | } |
3040 | 333 | } | 385 | |
3041 | 334 | 386 | TEMPLATE_DECL(T) | |
3042 | 335 | #ifndef ZORBA_WITH_BIG_INTEGER | 387 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( long n ) { |
3043 | 336 | inline Integer& Integer::operator=( long long n ) { | 388 | value_ = n; |
3044 | 337 | value_ = n; | 389 | return *this; |
3045 | 338 | return *this; | 390 | } |
3046 | 339 | } | 391 | |
3047 | 340 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 392 | #ifndef ZORBA_WITH_BIG_INTEGER |
3048 | 341 | 393 | TEMPLATE_DECL(T) | |
3049 | 342 | inline Integer& Integer::operator=( unsigned char c ) { | 394 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( long long n ) { |
3050 | 343 | value_ = static_cast<long>( c ); | 395 | value_ = n; |
3051 | 344 | return *this; | 396 | return *this; |
3052 | 345 | } | 397 | } |
3053 | 346 | 398 | #endif /* ZORBA_WITH_BIG_INTEGER */ | |
3054 | 347 | inline Integer& Integer::operator=( unsigned short n ) { | 399 | |
3055 | 348 | value_ = static_cast<long>( n ); | 400 | TEMPLATE_DECL(T) |
3056 | 349 | return *this; | 401 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned char c ) { |
3057 | 350 | } | 402 | value_ = static_cast<long>( c ); |
3058 | 351 | 403 | return *this; | |
3059 | 352 | inline Integer& Integer::operator=( unsigned int n ) { | 404 | } |
3060 | 353 | value_ = static_cast<long>( n ); | 405 | |
3061 | 354 | return *this; | 406 | TEMPLATE_DECL(T) |
3062 | 355 | } | 407 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned short n ) { |
3063 | 356 | 408 | value_ = static_cast<long>( n ); | |
3064 | 357 | #ifndef ZORBA_WITH_BIG_INTEGER | 409 | return *this; |
3065 | 358 | inline Integer& Integer::operator=( unsigned long n ) { | 410 | } |
3066 | 359 | value_ = static_cast<long>( n ); | 411 | |
3067 | 360 | return *this; | 412 | TEMPLATE_DECL(T) |
3068 | 361 | } | 413 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned int n ) { |
3069 | 362 | 414 | value_ = static_cast<long>( n ); | |
3070 | 363 | inline Integer& Integer::operator=( unsigned long long n ) { | 415 | return *this; |
3071 | 364 | value_ = n; | 416 | } |
3072 | 365 | return *this; | 417 | |
3073 | 366 | } | 418 | #ifndef ZORBA_WITH_BIG_INTEGER |
3074 | 367 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 419 | TEMPLATE_DECL(T) |
3075 | 368 | 420 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned long n ) { | |
3076 | 369 | inline Integer& Integer::operator=( float n ) { | 421 | value_ = static_cast<long>( n ); |
3077 | 370 | value_ = static_cast<long>( n ); | 422 | return *this; |
3078 | 371 | return *this; | 423 | } |
3079 | 372 | } | 424 | |
3080 | 373 | 425 | TEMPLATE_DECL(T) | |
3081 | 374 | inline Integer& Integer::operator=( double n ) { | 426 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( unsigned long long n ) { |
3082 | 375 | value_ = static_cast<long>( n ); | 427 | value_ = n; |
3083 | 376 | return *this; | 428 | return *this; |
3084 | 377 | } | 429 | } |
3085 | 378 | 430 | #endif /* ZORBA_WITH_BIG_INTEGER */ | |
3086 | 379 | inline Integer& Integer::operator=( char const *s ) { | 431 | |
3087 | 432 | TEMPLATE_DECL(T) | ||
3088 | 433 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( float n ) { | ||
3089 | 434 | value_ = static_cast<long>( n ); | ||
3090 | 435 | return *this; | ||
3091 | 436 | } | ||
3092 | 437 | |||
3093 | 438 | TEMPLATE_DECL(T) | ||
3094 | 439 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( double n ) { | ||
3095 | 440 | value_ = static_cast<long>( n ); | ||
3096 | 441 | return *this; | ||
3097 | 442 | } | ||
3098 | 443 | |||
3099 | 444 | TEMPLATE_DECL(T) | ||
3100 | 445 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( char const *s ) { | ||
3101 | 380 | parse( s ); | 446 | parse( s ); |
3102 | 381 | return *this; | 447 | return *this; |
3103 | 382 | } | 448 | } |
3104 | 383 | 449 | ||
3106 | 384 | inline Integer& Integer::operator=( Integer const &i ) { | 450 | TEMPLATE_DECL(T) |
3107 | 451 | TEMPLATE_DECL(U) | ||
3108 | 452 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator=( INTEGER_IMPL(U) const &i ) { | ||
3109 | 385 | value_ = i.value_; | 453 | value_ = i.value_; |
3110 | 386 | return *this; | 454 | return *this; |
3111 | 387 | } | 455 | } |
3112 | 388 | 456 | ||
3113 | 389 | ////////// arithmetic operators /////////////////////////////////////////////// | 457 | ////////// arithmetic operators /////////////////////////////////////////////// |
3114 | 390 | 458 | ||
3151 | 391 | inline Integer operator+( Integer const &i, Integer const &j ) { | 459 | #define ZORBA_INTEGER_OP(OP) \ |
3152 | 392 | return i.value_ + j.value_; | 460 | TEMPLATE_DECL(T) inline \ |
3153 | 393 | } | 461 | INTEGER_IMPL(T) operator OP( INTEGER_IMPL(T) const &i, \ |
3154 | 394 | 462 | INTEGER_IMPL(T) const &j ) { \ | |
3155 | 395 | inline Integer operator-( Integer const &i, Integer const &j ) { | 463 | return i.value_ OP j.value_; \ |
3156 | 396 | return i.value_ - j.value_; | 464 | } |
3157 | 397 | } | 465 | |
3158 | 398 | 466 | ZORBA_INTEGER_OP(+) | |
3159 | 399 | inline Integer operator*( Integer const &i, Integer const &j ) { | 467 | ZORBA_INTEGER_OP(-) |
3160 | 400 | return i.value_ * j.value_; | 468 | ZORBA_INTEGER_OP(*) |
3161 | 401 | } | 469 | ZORBA_INTEGER_OP(%) |
3162 | 402 | 470 | #undef ZORBA_INTEGER_OP | |
3163 | 403 | inline Integer operator/( Integer const &i, Integer const &j ) { | 471 | |
3164 | 404 | return Integer::ftoi( i.value_ / j.value_ ); | 472 | TEMPLATE_DECL(T) inline |
3165 | 405 | } | 473 | INTEGER_IMPL(T) operator/( INTEGER_IMPL(T) const &i, INTEGER_IMPL(T) const &j ) { |
3166 | 406 | 474 | return INTEGER_IMPL(T)::ftoi( i.value_ / j.value_ ); | |
3167 | 407 | inline Integer operator%( Integer const &i, Integer const &j ) { | 475 | } |
3168 | 408 | return i.value_ % j.value_; | 476 | |
3169 | 409 | } | 477 | #define ZORBA_INTEGER_OP(OP) \ |
3170 | 410 | 478 | TEMPLATE_DECL(T) inline \ | |
3171 | 411 | inline Integer& Integer::operator+=( Integer const &i ) { | 479 | INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator OP( IntegerImpl const &i ) { \ |
3172 | 412 | value_ += i.value_; | 480 | value_ OP i.value_; \ |
3173 | 413 | return *this; | 481 | return *this; \ |
3174 | 414 | } | 482 | } |
3175 | 415 | 483 | ||
3176 | 416 | inline Integer& Integer::operator-=( Integer const &i ) { | 484 | ZORBA_INTEGER_OP(+=) |
3177 | 417 | value_ -= i.value_; | 485 | ZORBA_INTEGER_OP(-=) |
3178 | 418 | return *this; | 486 | ZORBA_INTEGER_OP(*=) |
3179 | 419 | } | 487 | ZORBA_INTEGER_OP(%=) |
3180 | 420 | 488 | #undef ZORBA_INTEGER_OP | |
3181 | 421 | inline Integer& Integer::operator*=( Integer const &i ) { | 489 | |
3182 | 422 | value_ *= i.value_; | 490 | TEMPLATE_DECL(T) |
3183 | 423 | return *this; | 491 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator/=( IntegerImpl const &i ) { |
3148 | 424 | } | ||
3149 | 425 | |||
3150 | 426 | inline Integer& Integer::operator/=( Integer const &i ) { | ||
3184 | 427 | value_ = ftoi( value_ / i.value_ ); | 492 | value_ = ftoi( value_ / i.value_ ); |
3185 | 428 | return *this; | 493 | return *this; |
3186 | 429 | } | 494 | } |
3187 | 430 | 495 | ||
3194 | 431 | inline Integer& Integer::operator%=( Integer const &i ) { | 496 | TEMPLATE_DECL(T) |
3195 | 432 | value_ %= i.value_; | 497 | inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator-() const { |
3190 | 433 | return *this; | ||
3191 | 434 | } | ||
3192 | 435 | |||
3193 | 436 | inline Integer Integer::operator-() const { | ||
3196 | 437 | return -value_; | 498 | return -value_; |
3197 | 438 | } | 499 | } |
3198 | 439 | 500 | ||
3200 | 440 | inline Integer& Integer::operator++() { | 501 | TEMPLATE_DECL(T) |
3201 | 502 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator++() { | ||
3202 | 441 | ++value_; | 503 | ++value_; |
3203 | 442 | return *this; | 504 | return *this; |
3204 | 443 | } | 505 | } |
3205 | 444 | 506 | ||
3208 | 445 | inline Integer Integer::operator++(int) { | 507 | TEMPLATE_DECL(T) |
3209 | 446 | Integer const result( *this ); | 508 | inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator++(int) { |
3210 | 509 | INTEGER_IMPL(T) const result( *this ); | ||
3211 | 447 | ++value_; | 510 | ++value_; |
3212 | 448 | return result; | 511 | return result; |
3213 | 449 | } | 512 | } |
3214 | 450 | 513 | ||
3216 | 451 | inline Integer& Integer::operator--() { | 514 | TEMPLATE_DECL(T) |
3217 | 515 | inline INTEGER_IMPL(T)& INTEGER_IMPL(T)::operator--() { | ||
3218 | 452 | --value_; | 516 | --value_; |
3219 | 453 | return *this; | 517 | return *this; |
3220 | 454 | } | 518 | } |
3221 | 455 | 519 | ||
3224 | 456 | inline Integer Integer::operator--(int) { | 520 | TEMPLATE_DECL(T) |
3225 | 457 | Integer const result( *this ); | 521 | inline INTEGER_IMPL(T) INTEGER_IMPL(T)::operator--(int) { |
3226 | 522 | INTEGER_IMPL(T) const result( *this ); | ||
3227 | 458 | --value_; | 523 | --value_; |
3228 | 459 | return result; | 524 | return result; |
3229 | 460 | } | 525 | } |
3230 | 461 | 526 | ||
3231 | 462 | ////////// relational operators /////////////////////////////////////////////// | 527 | ////////// relational operators /////////////////////////////////////////////// |
3232 | 463 | 528 | ||
3256 | 464 | inline bool operator==( Integer const &i, Integer const &j ) { | 529 | #define ZORBA_INTEGER_OP(OP) \ |
3257 | 465 | return i.value_ == j.value_; | 530 | TEMPLATE_DECL(T) inline \ |
3258 | 466 | } | 531 | bool operator OP( INTEGER_IMPL(T) const &i, INTEGER_IMPL(T) const &j ) { \ |
3259 | 467 | 532 | return i.value_ OP j.value_; \ | |
3260 | 468 | inline bool operator!=( Integer const &i, Integer const &j ) { | 533 | } |
3261 | 469 | return i.value_ != j.value_; | 534 | |
3262 | 470 | } | 535 | ZORBA_INTEGER_OP(==) |
3263 | 471 | 536 | ZORBA_INTEGER_OP(!=) | |
3264 | 472 | inline bool operator<( Integer const &i, Integer const &j ) { | 537 | ZORBA_INTEGER_OP(< ) |
3265 | 473 | return i.value_ < j.value_; | 538 | ZORBA_INTEGER_OP(<=) |
3266 | 474 | } | 539 | ZORBA_INTEGER_OP(> ) |
3267 | 475 | 540 | ZORBA_INTEGER_OP(>=) | |
3268 | 476 | inline bool operator<=( Integer const &i, Integer const &j ) { | 541 | #undef ZORBA_INTEGER_OP |
3246 | 477 | return i.value_ <= j.value_; | ||
3247 | 478 | } | ||
3248 | 479 | |||
3249 | 480 | inline bool operator>( Integer const &i, Integer const &j ) { | ||
3250 | 481 | return i.value_ > j.value_; | ||
3251 | 482 | } | ||
3252 | 483 | |||
3253 | 484 | inline bool operator>=( Integer const &i, Integer const &j ) { | ||
3254 | 485 | return i.value_ >= j.value_; | ||
3255 | 486 | } | ||
3269 | 487 | 542 | ||
3270 | 488 | ////////// miscellaneous ////////////////////////////////////////////////////// | 543 | ////////// miscellaneous ////////////////////////////////////////////////////// |
3271 | 489 | 544 | ||
3272 | 490 | #ifdef ZORBA_WITH_BIG_INTEGER | 545 | #ifdef ZORBA_WITH_BIG_INTEGER |
3273 | 491 | 546 | ||
3275 | 492 | inline int Integer::compare( Integer const &i ) const { | 547 | inline int IntegerImpl::compare( IntegerImpl const &i ) const { |
3276 | 493 | return value_.compare( i.value_ ); | 548 | return value_.compare( i.value_ ); |
3277 | 494 | } | 549 | } |
3278 | 495 | 550 | ||
3280 | 496 | inline int Integer::sign() const { | 551 | inline int IntegerImpl::sign() const { |
3281 | 497 | return value_.sign(); | 552 | return value_.sign(); |
3282 | 498 | } | 553 | } |
3283 | 499 | 554 | ||
3284 | 500 | #else | 555 | #else |
3285 | 501 | 556 | ||
3293 | 502 | inline int Integer::compare( Integer const &i ) const { | 557 | template<typename IntType> |
3294 | 503 | // | 558 | inline int IntegerImpl<IntType>::compare( IntegerImpl const &i ) const { |
3295 | 504 | // Note that we can't return the difference directly since it will be | 559 | return value_ < i.value_ ? -1 : value_ > i.value_ ? 1 : 0; |
3289 | 505 | // truncated if it's ether > max(int) or < min(int) yielding a wrong result. | ||
3290 | 506 | // | ||
3291 | 507 | value_type const temp = value_ - i.value_; | ||
3292 | 508 | return temp < 0 ? -1 : temp > 0 ? 1 : 0; | ||
3296 | 509 | } | 560 | } |
3297 | 510 | 561 | ||
3299 | 511 | inline uint32_t Integer::hash() const { | 562 | template<typename IntType> |
3300 | 563 | inline uint32_t IntegerImpl<IntType>::hash() const { | ||
3301 | 512 | return static_cast<uint32_t>( value_ ); | 564 | return static_cast<uint32_t>( value_ ); |
3302 | 513 | } | 565 | } |
3303 | 514 | 566 | ||
3305 | 515 | inline bool Integer::is_long() const { | 567 | template<typename IntType> |
3306 | 568 | inline bool IntegerImpl<IntType>::is_long() const { | ||
3307 | 516 | return value_ >= std::numeric_limits<long>::min() && | 569 | return value_ >= std::numeric_limits<long>::min() && |
3308 | 517 | value_ <= std::numeric_limits<long>::max(); | 570 | value_ <= std::numeric_limits<long>::max(); |
3309 | 518 | } | 571 | } |
3310 | 519 | 572 | ||
3313 | 520 | inline int Integer::sign() const { | 573 | template<typename IntType> |
3314 | 521 | return value_ < 0 ? -1 : value_ > 0 ? 1 : 0; | 574 | inline int IntegerImpl<IntType>::sign() const { |
3315 | 575 | return ztd::lt0( value_ ) ? -1 : value_ > 0 ? 1 : 0; | ||
3316 | 522 | } | 576 | } |
3317 | 523 | 577 | ||
3318 | 524 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 578 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
3319 | 525 | 579 | ||
3321 | 526 | inline std::ostream& operator<<( std::ostream &os, Integer const &i ) { | 580 | TEMPLATE_DECL(T) |
3322 | 581 | inline std::ostream& operator<<( std::ostream &os, INTEGER_IMPL(T) const &i ) { | ||
3323 | 527 | return os << i.toString(); | 582 | return os << i.toString(); |
3324 | 528 | } | 583 | } |
3325 | 529 | 584 | ||
3326 | 530 | /////////////////////////////////////////////////////////////////////////////// | 585 | /////////////////////////////////////////////////////////////////////////////// |
3327 | 531 | 586 | ||
3328 | 532 | } // namespace zorba | 587 | } // namespace zorba |
3329 | 588 | |||
3330 | 589 | #undef TEMPLATE_DECL | ||
3331 | 590 | #undef INTEGER_IMPL | ||
3332 | 591 | #undef INTEGER_IMPL_LL | ||
3333 | 592 | #undef INTEGER_IMPL_ULL | ||
3334 | 593 | |||
3335 | 533 | #endif // ZORBA_INTEGER_H | 594 | #endif // ZORBA_INTEGER_H |
3336 | 534 | /* | 595 | /* |
3337 | 535 | * Local variables: | 596 | * Local variables: |
3338 | 536 | 597 | ||
3339 | === modified file 'src/zorbatypes/numconversions.cpp' | |||
3340 | --- src/zorbatypes/numconversions.cpp 2011-06-29 20:31:44 +0000 | |||
3341 | +++ src/zorbatypes/numconversions.cpp 2011-11-29 00:43:26 +0000 | |||
3342 | @@ -33,7 +33,7 @@ | |||
3343 | 33 | zstring const temp( i.toString() ); | 33 | zstring const temp( i.toString() ); |
3344 | 34 | return ztd::aton<xs_int>( temp.c_str() ); | 34 | return ztd::aton<xs_int>( temp.c_str() ); |
3345 | 35 | #else | 35 | #else |
3347 | 36 | return static_cast<xs_int>(i.value_); | 36 | return static_cast<xs_int>( i.value_ ); |
3348 | 37 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 37 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
3349 | 38 | } | 38 | } |
3350 | 39 | 39 | ||
3351 | @@ -56,6 +56,13 @@ | |||
3352 | 56 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 56 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
3353 | 57 | } | 57 | } |
3354 | 58 | 58 | ||
3355 | 59 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
3356 | 60 | xs_long to_xs_long( xs_nonNegativeInteger const &i ) { | ||
3357 | 61 | zstring const temp( i.toString() ); | ||
3358 | 62 | return ztd::aton<xs_long>( temp.c_str() ); | ||
3359 | 63 | } | ||
3360 | 64 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
3361 | 65 | |||
3362 | 59 | xs_unsignedInt to_xs_unsignedInt( xs_integer const &i ) { | 66 | xs_unsignedInt to_xs_unsignedInt( xs_integer const &i ) { |
3363 | 60 | #ifdef ZORBA_WITH_BIG_INTEGER | 67 | #ifdef ZORBA_WITH_BIG_INTEGER |
3364 | 61 | zstring const temp( i.toString() ); | 68 | zstring const temp( i.toString() ); |
3365 | 62 | 69 | ||
3366 | === modified file 'src/zorbatypes/numconversions.h' | |||
3367 | --- src/zorbatypes/numconversions.h 2011-06-29 20:31:44 +0000 | |||
3368 | +++ src/zorbatypes/numconversions.h 2011-11-29 00:43:26 +0000 | |||
3369 | @@ -64,6 +64,10 @@ | |||
3370 | 64 | */ | 64 | */ |
3371 | 65 | xs_long to_xs_long( xs_integer const &i ); | 65 | xs_long to_xs_long( xs_integer const &i ); |
3372 | 66 | 66 | ||
3373 | 67 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
3374 | 68 | xs_long to_xs_long( xs_nonNegativeInteger const &i ); | ||
3375 | 69 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
3376 | 70 | |||
3377 | 67 | /** | 71 | /** |
3378 | 68 | * Converts an \c xs:integer value to an \c xs:unsignedInt. | 72 | * Converts an \c xs:integer value to an \c xs:unsignedInt. |
3379 | 69 | * | 73 | * |
3380 | 70 | 74 | ||
3381 | === modified file 'src/zorbatypes/schema_types.h' | |||
3382 | --- src/zorbatypes/schema_types.h 2011-06-24 13:38:42 +0000 | |||
3383 | +++ src/zorbatypes/schema_types.h 2011-11-29 00:43:26 +0000 | |||
3384 | @@ -46,8 +46,12 @@ | |||
3385 | 46 | typedef DateTime xs_gYearMonth; | 46 | typedef DateTime xs_gYearMonth; |
3386 | 47 | typedef Base16 xs_hexBinary; | 47 | typedef Base16 xs_hexBinary; |
3387 | 48 | typedef Integer xs_integer; | 48 | typedef Integer xs_integer; |
3388 | 49 | typedef Integer xs_negativeInteger; // this isn't quite right | ||
3389 | 50 | typedef UInteger xs_nonNegativeInteger; // i.e., "unsigned" | ||
3390 | 51 | typedef Integer xs_nonPositiveInteger; // this isn't quite right either | ||
3391 | 52 | typedef UInteger xs_positiveInteger; | ||
3392 | 49 | typedef DateTime xs_time; | 53 | typedef DateTime xs_time; |
3394 | 50 | typedef Integer xs_uinteger; | 54 | typedef UInteger xs_uinteger; // old, deprecated name |
3395 | 51 | typedef Duration xs_yearMonthDuration; | 55 | typedef Duration xs_yearMonthDuration; |
3396 | 52 | 56 | ||
3397 | 53 | /////////////////////////////////////////////////////////////////////////////// | 57 | /////////////////////////////////////////////////////////////////////////////// |
3398 | 54 | 58 | ||
3399 | === modified file 'src/zorbatypes/zorbatypes_decl.h' | |||
3400 | --- src/zorbatypes/zorbatypes_decl.h 2011-06-14 17:26:33 +0000 | |||
3401 | +++ src/zorbatypes/zorbatypes_decl.h 2011-11-29 00:43:26 +0000 | |||
3402 | @@ -18,11 +18,23 @@ | |||
3403 | 18 | #ifndef ZORBA_ZORBATYPES_DECL_H | 18 | #ifndef ZORBA_ZORBATYPES_DECL_H |
3404 | 19 | #define ZORBA_ZORBATYPES_DECL_H | 19 | #define ZORBA_ZORBATYPES_DECL_H |
3405 | 20 | 20 | ||
3406 | 21 | #include <zorba/config.h> | ||
3407 | 22 | |||
3408 | 21 | namespace zorba | 23 | namespace zorba |
3409 | 22 | { | 24 | { |
3410 | 23 | /* numerics */ | 25 | /* numerics */ |
3411 | 24 | class Decimal; | 26 | class Decimal; |
3413 | 25 | class Integer; | 27 | |
3414 | 28 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
3415 | 29 | class IntegerImpl; | ||
3416 | 30 | typedef IntegerImpl Integer; | ||
3417 | 31 | typedef IntegerImpl UInteger; | ||
3418 | 32 | #else | ||
3419 | 33 | template<typename T> class IntegerImpl; | ||
3420 | 34 | typedef IntegerImpl<long long> Integer; | ||
3421 | 35 | typedef IntegerImpl<unsigned long long> UInteger; | ||
3422 | 36 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
3423 | 37 | |||
3424 | 26 | template<typename T> class FloatImpl; | 38 | template<typename T> class FloatImpl; |
3425 | 27 | typedef FloatImpl<double> Double; | 39 | typedef FloatImpl<double> Double; |
3426 | 28 | typedef FloatImpl<float> Float; | 40 | typedef FloatImpl<float> Float; |
3427 | 29 | 41 | ||
3428 | === modified file 'test/rbkt/Queries/CMakeLists.txt' | |||
3429 | --- test/rbkt/Queries/CMakeLists.txt 2011-10-26 13:43:15 +0000 | |||
3430 | +++ test/rbkt/Queries/CMakeLists.txt 2011-11-29 00:43:26 +0000 | |||
3431 | @@ -213,15 +213,7 @@ | |||
3432 | 213 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285) | 213 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/PathExpr/Steps/Steps-leading-lone-slash-8a 3408285) |
3433 | 214 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 872732) | 214 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Functions/QNameFunc/NamespaceURIForPrefixFunc/K2-NamespaceURIForPrefixFunc-2 872732) |
3434 | 215 | 215 | ||
3444 | 216 | IF(NOT ZORBA_WITH_BIG_INTEGER) | 216 | IF (ZORBA_TEST_XQUERYX) |
3436 | 217 | # These tests fail due to integer overflow. | ||
3437 | 218 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 3323548) | ||
3438 | 219 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 3323548) | ||
3439 | 220 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 3323548) | ||
3440 | 221 | EXPECTED_FAILURE(test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 3323548) | ||
3441 | 222 | ENDIF(NOT ZORBA_WITH_BIG_INTEGER) | ||
3442 | 223 | |||
3443 | 224 | IF(ZORBA_TEST_XQUERYX) | ||
3445 | 225 | 217 | ||
3446 | 226 | #w3c bug | 218 | #w3c bug |
3447 | 227 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes011 3355019) | 219 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes011 3355019) |
3448 | @@ -229,12 +221,22 @@ | |||
3449 | 229 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes013 3355019) | 221 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes013 3355019) |
3450 | 230 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes014 3355019) | 222 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes014 3355019) |
3451 | 231 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes015 3355019) | 223 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQueryX/StaticTyping/STPathExpr/STSteps/STAxes/ST-Axes015 3355019) |
3454 | 232 | ENDIF(ZORBA_TEST_XQUERYX) | 224 | ENDIF (ZORBA_TEST_XQUERYX) |
3455 | 233 | 225 | ||
3456 | 234 | #this is marked as expected failure because the RQ uses XQTS_1_0_3. In that version the expected result is err:FODC0004 instead of err:FODC0002. | 226 | #this is marked as expected failure because the RQ uses XQTS_1_0_3. In that version the expected result is err:FODC0004 instead of err:FODC0002. |
3457 | 235 | #W3C has changed the expected result for this test in the meantime: please see http://www.w3.org/Bugs/Public/show_bug.cgi?id=12542 | 227 | #W3C has changed the expected result for this test in the meantime: please see http://www.w3.org/Bugs/Public/show_bug.cgi?id=12542 |
3458 | 236 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Functions/NodeSeqFunc/SeqCollectionFunc/fn-collection-2 882002) | 228 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Functions/NodeSeqFunc/SeqCollectionFunc/fn-collection-2 882002) |
3459 | 237 | 229 | ||
3460 | 230 | IF (NOT ZORBA_WITH_BIG_INTEGER) | ||
3461 | 231 | # These test will never pass without big integers beause the integers used | ||
3462 | 232 | # in the queries exceed a 63-bit signed integer. | ||
3463 | 233 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22 867059) | ||
3464 | 234 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 867059) | ||
3465 | 235 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 867059) | ||
3466 | 236 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 867059) | ||
3467 | 237 | EXPECTED_FAILURE (test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 867059) | ||
3468 | 238 | ENDIF (NOT ZORBA_WITH_BIG_INTEGER) | ||
3469 | 239 | |||
3470 | 238 | ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS) | 240 | ENDIF (FOUND_XQTS AND NOT ZORBA_TEST_W3C_TO_SUBMIT_RESULTS) |
3471 | 239 | 241 | ||
3472 | 240 | # The dirname_basename test depends on the system module | 242 | # The dirname_basename test depends on the system module |
3473 | @@ -293,4 +295,3 @@ | |||
3474 | 293 | EXPECTED_FAILURE(test/rbkt/zorba/http-client/post/post3_binary_element 3391756) | 295 | EXPECTED_FAILURE(test/rbkt/zorba/http-client/post/post3_binary_element 3391756) |
3475 | 294 | 296 | ||
3476 | 295 | EXPECTED_FAILURE(test/rbkt/zorba/reference/reference_5 868640) | 297 | EXPECTED_FAILURE(test/rbkt/zorba/reference/reference_5 868640) |
3477 | 296 | |||
3478 | 297 | 298 | ||
3479 | === modified file 'test/rbkt/Queries/w3c_known_failures.txt' | |||
3480 | --- test/rbkt/Queries/w3c_known_failures.txt 2011-10-26 13:43:15 +0000 | |||
3481 | +++ test/rbkt/Queries/w3c_known_failures.txt 2011-11-29 00:43:26 +0000 | |||
3482 | @@ -117,7 +117,8 @@ | |||
3483 | 117 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-01 | 117 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFLWORExpr/ST-PITest-01 |
3484 | 118 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFunctions/ST-Data001 | 118 | test/rbkt/w3c_testsuite/XQuery/StaticTyping/STFunctions/ST-Data001 |
3485 | 119 | test/rbkt/w3c_testsuite/XQuery/SchemaImport/SchemaImportProlog/modules-schema-context | 119 | test/rbkt/w3c_testsuite/XQuery/SchemaImport/SchemaImportProlog/modules-schema-context |
3486 | 120 | test/rbkt/w3c_testsuite/XQuery/exprSeqTypes/SeqExprCast/K2-SeqExprCast-22 | ||
3487 | 121 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 | ||
3488 | 120 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 | 122 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-2 |
3490 | 121 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericLT/K2-NumericLT-1 | 123 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 |
3491 | 122 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 | 124 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-2 |
3492 | 123 | test/rbkt/w3c_testsuite/XQuery/Operators/CompExpr/ValComp/NumericComp/NumericGT/K2-NumericGT-1 |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug-867059- 2011-10- 31T23-16- 07.098Z/ log.html
Log at: http://