10461.2.4
by danielturcanu
Merged with latest trunk |
1 |
/*
|
2 |
* Copyright 2006-2008 The FLWOR Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
#pragma once
|
|
17 |
#ifndef ZORBA_RUNTIME_BOOLEAN
|
|
18 |
#define ZORBA_RUNTIME_BOOLEAN
|
|
19 |
||
20 |
#include "common/shared_types.h" |
|
21 |
||
22 |
#include "types/typeconstants.h" |
|
23 |
#include "types/typemanager.h" |
|
24 |
||
25 |
#include "compiler/expression/expr_consts.h" |
|
26 |
||
27 |
#include "runtime/base/unarybase.h" |
|
28 |
#include "runtime/base/binarybase.h" |
|
29 |
#include "runtime/base/narybase.h" |
|
30 |
||
31 |
#include "system/globalenv.h" |
|
32 |
||
33 |
||
34 |
namespace zorba |
|
35 |
{
|
|
36 |
||
37 |
class RuntimeCB; // TODO we should have a shared_runtime_types.h |
|
38 |
class GenericCast; |
|
39 |
||
40 |
||
41 |
/*******************************************************************************
|
|
42 |
15.1.1 fn:boolean
|
|
43 |
fn:boolean($arg as item()*) as xs:boolean
|
|
44 |
||
45 |
Computes the effective boolean value of the sequence $arg.
|
|
46 |
********************************************************************************/
|
|
47 |
class FnBooleanIterator : public UnaryBaseIterator<FnBooleanIterator, PlanIteratorState> |
|
48 |
{
|
|
49 |
private: |
|
50 |
bool theNegate; |
|
51 |
||
52 |
public: |
|
53 |
SERIALIZABLE_CLASS(FnBooleanIterator); |
|
54 |
SERIALIZABLE_CLASS_CONSTRUCTOR2T( |
|
55 |
FnBooleanIterator, |
|
56 |
UnaryBaseIterator<FnBooleanIterator, PlanIteratorState>); |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
57 |
void serialize(::zorba::serialization::Archiver& ar); |
10461.2.4
by danielturcanu
Merged with latest trunk |
58 |
|
59 |
public: |
|
60 |
FnBooleanIterator( |
|
10783.1.21
by Markos Zaharioudakis
trying to fix compilation problems |
61 |
static_context* sctx, |
62 |
const QueryLoc& loc, |
|
63 |
PlanIter_t& aIter, |
|
64 |
bool aNegate = false ); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
65 |
|
66 |
void accept(PlanIterVisitor& v) const; |
|
67 |
||
11690.1.25
by Paul J. Lucas
Intermediate check-in. |
68 |
zstring getNameAsString() const; |
69 |
||
10461.2.4
by danielturcanu
Merged with latest trunk |
70 |
bool nextImpl(store::Item_t& result, PlanState& planState) const; |
71 |
||
72 |
public: |
|
73 |
/**
|
|
74 |
* Static function which computes the effective boolean value of a passed iterator.
|
|
75 |
*
|
|
76 |
* @param loc location of the iterator which invokes this function
|
|
77 |
* @param planState
|
|
78 |
* @param iterator
|
|
79 |
* @param negate optinal parameter which negates the effective boolean value (default == false)
|
|
80 |
* @return effective boolean value
|
|
81 |
*/
|
|
82 |
static bool effectiveBooleanValue( |
|
10783.1.21
by Markos Zaharioudakis
trying to fix compilation problems |
83 |
const QueryLoc& loc, |
84 |
PlanState& planState, |
|
85 |
const PlanIterator* , |
|
86 |
bool negate = false); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
87 |
};
|
88 |
||
89 |
||
90 |
/*******************************************************************************
|
|
91 |
||
92 |
********************************************************************************/
|
|
93 |
class OrIterator : public NaryBaseIterator<OrIterator, PlanIteratorState> |
|
94 |
{
|
|
95 |
public: |
|
96 |
SERIALIZABLE_CLASS(OrIterator); |
|
97 |
SERIALIZABLE_CLASS_CONSTRUCTOR2T( |
|
98 |
OrIterator, |
|
99 |
NaryBaseIterator<OrIterator, PlanIteratorState>); |
|
100 |
void serialize(::zorba::serialization::Archiver& ar); |
|
101 |
||
102 |
public: |
|
103 |
OrIterator( |
|
104 |
static_context* sctx, |
|
105 |
const QueryLoc& loc, |
|
106 |
std::vector<PlanIter_t>& inChildren); |
|
107 |
||
108 |
void accept(PlanIterVisitor& v) const; |
|
109 |
||
11690.1.25
by Paul J. Lucas
Intermediate check-in. |
110 |
zstring getNameAsString() const; |
111 |
||
10461.2.4
by danielturcanu
Merged with latest trunk |
112 |
bool nextImpl(store::Item_t& result, PlanState& planState) const; |
113 |
};
|
|
114 |
||
115 |
||
116 |
/*******************************************************************************
|
|
117 |
||
118 |
********************************************************************************/
|
|
119 |
class AndIterator : public NaryBaseIterator<AndIterator, PlanIteratorState> |
|
120 |
{
|
|
121 |
public: |
|
122 |
SERIALIZABLE_CLASS(AndIterator); |
|
123 |
SERIALIZABLE_CLASS_CONSTRUCTOR2T( |
|
124 |
AndIterator, |
|
125 |
NaryBaseIterator<AndIterator, PlanIteratorState>); |
|
126 |
void serialize(::zorba::serialization::Archiver& ar); |
|
127 |
||
128 |
public: |
|
129 |
AndIterator( |
|
130 |
static_context* sctx, |
|
131 |
const QueryLoc& loc, |
|
132 |
std::vector<PlanIter_t>& inChildren); |
|
133 |
||
134 |
void accept(PlanIterVisitor& v) const; |
|
135 |
||
11690.1.25
by Paul J. Lucas
Intermediate check-in. |
136 |
zstring getNameAsString() const; |
137 |
||
10461.2.4
by danielturcanu
Merged with latest trunk |
138 |
bool nextImpl(store::Item_t& result, PlanState& planState) const; |
139 |
};
|
|
140 |
||
141 |
||
142 |
/*******************************************************************************
|
|
143 |
Iterator for general and value comparisons
|
|
144 |
********************************************************************************/
|
|
145 |
class CompareIterator : public BinaryBaseIterator<CompareIterator, PlanIteratorState> |
|
146 |
{
|
|
147 |
private: |
|
148 |
CompareConsts::CompareType theCompType; |
|
149 |
bool theIsGeneralComparison; |
|
150 |
TypeManager * theTypeManager; |
|
10783.1.22
by Markos Zaharioudakis
added serialize_enu and serialize_long |
151 |
long theTimezone; |
10461.2.4
by danielturcanu
Merged with latest trunk |
152 |
XQPCollator * theCollation; |
153 |
||
154 |
public: |
|
155 |
SERIALIZABLE_CLASS(CompareIterator); |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
156 |
CompareIterator(::zorba::serialization::Archiver& ar); |
157 |
void serialize(::zorba::serialization::Archiver& ar); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
158 |
|
159 |
public: |
|
160 |
CompareIterator ( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
161 |
static_context* sctx, |
162 |
const QueryLoc& loc, |
|
163 |
PlanIter_t theChild0, |
|
164 |
PlanIter_t theChild1, |
|
165 |
CompareConsts::CompareType aCompType); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
166 |
|
167 |
void accept(PlanIterVisitor& v) const; |
|
168 |
||
169 |
void openImpl(PlanState& planState, uint32_t& offset); |
|
170 |
||
11690.1.25
by Paul J. Lucas
Intermediate check-in. |
171 |
zstring getNameAsString() const; |
172 |
||
10461.2.4
by danielturcanu
Merged with latest trunk |
173 |
bool nextImpl(store::Item_t& result, PlanState& planState) const; |
174 |
||
175 |
public: |
|
176 |
static bool valueComparison( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
177 |
const QueryLoc& loc, |
178 |
store::Item_t& aItem0, |
|
179 |
store::Item_t& aItem1, |
|
180 |
CompareConsts::CompareType aCompType, |
|
181 |
const TypeManager* typemgr, |
|
182 |
long timezone, |
|
183 |
XQPCollator* aCollation); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
184 |
|
185 |
static bool valueEqual( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
186 |
const QueryLoc& loc, |
187 |
store::Item_t& aItem0, |
|
188 |
store::Item_t& aItem1, |
|
189 |
const TypeManager* typemgr, |
|
190 |
long timezone, |
|
11714.2.1
by Federico Cavalieri
Function caching/function caching annotations/dynamic context module |
191 |
XQPCollator* aCollation, |
192 |
bool raiseError); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
193 |
|
194 |
static long valueCompare( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
195 |
const QueryLoc& loc, |
196 |
store::Item_t& aItem0, |
|
197 |
store::Item_t& aItem1, |
|
198 |
const TypeManager* typemgr, |
|
199 |
long timezone, |
|
200 |
XQPCollator* aCollation); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
201 |
|
202 |
static bool generalComparison( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
203 |
const QueryLoc& loc, |
204 |
store::Item_t& aItem0, |
|
205 |
store::Item_t& aItem_1, |
|
206 |
CompareConsts::CompareType aCompType, |
|
207 |
const TypeManager* typemgr, |
|
208 |
long timezone, |
|
209 |
XQPCollator* aCollation); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
210 |
|
211 |
static bool generalEqual( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
212 |
const QueryLoc& loc, |
213 |
store::Item_t& aItem0, |
|
214 |
store::Item_t& aItem1, |
|
215 |
const TypeManager* typemgr, |
|
216 |
long timezone, |
|
217 |
XQPCollator* aCollation); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
218 |
|
219 |
static long generalCompare( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
220 |
const QueryLoc& loc, |
221 |
store::Item_t& aItem0, |
|
222 |
store::Item_t& aItem1, |
|
223 |
const TypeManager* typemgr, |
|
224 |
long timezone, |
|
225 |
XQPCollator* aCollation); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
226 |
|
227 |
static bool equal( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
228 |
const QueryLoc& loc, |
229 |
const store::Item_t& aItem0, |
|
230 |
const store::Item_t& aItem1, |
|
231 |
const TypeManager* typemgr, |
|
232 |
long timezone, |
|
11714.2.1
by Federico Cavalieri
Function caching/function caching annotations/dynamic context module |
233 |
XQPCollator* aCollation, |
234 |
bool raiseError); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
235 |
|
236 |
static long compare( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
237 |
const QueryLoc& loc, |
238 |
const store::Item_t& aItem0, |
|
239 |
const store::Item_t& aItem1, |
|
240 |
const TypeManager* typemgr, |
|
241 |
long timezone, |
|
242 |
XQPCollator* aCollation); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
243 |
|
244 |
private: |
|
11714.2.1
by Federico Cavalieri
Function caching/function caching annotations/dynamic context module |
245 |
static bool valueCasting( |
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
246 |
const QueryLoc& loc, |
247 |
const TypeManager* typemgr, |
|
248 |
store::Item_t& aItem0, |
|
249 |
store::Item_t& aItem1, |
|
250 |
store::Item_t& castItem0, |
|
11714.2.1
by Federico Cavalieri
Function caching/function caching annotations/dynamic context module |
251 |
store::Item_t& castItem1, |
252 |
bool raiseError); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
253 |
|
254 |
static void generalCasting( |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
255 |
const QueryLoc& loc, |
256 |
const TypeManager* typemgr, |
|
257 |
store::Item_t& aItem0, |
|
258 |
store::Item_t& aItem1, |
|
259 |
store::Item_t& castItem0, |
|
260 |
store::Item_t& castItem1); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
261 |
};
|
262 |
||
263 |
||
264 |
/*******************************************************************************
|
|
265 |
||
266 |
********************************************************************************/
|
|
10584.1.13
by Markos Zaharioudakis
moved atomic type codes enum to the store api |
267 |
template <store::SchemaTypeCode ATC> |
10461.2.4
by danielturcanu
Merged with latest trunk |
268 |
class TypedValueCompareIterator : public NaryBaseIterator<TypedValueCompareIterator<ATC>, |
269 |
PlanIteratorState> |
|
270 |
{
|
|
271 |
CompareConsts::CompareType theCompType; |
|
10783.1.22
by Markos Zaharioudakis
added serialize_enu and serialize_long |
272 |
long theTimezone; |
10461.2.4
by danielturcanu
Merged with latest trunk |
273 |
XQPCollator * theCollation; |
274 |
||
275 |
public: |
|
276 |
SERIALIZABLE_TEMPLATE_CLASS(TypedValueCompareIterator); |
|
277 |
SERIALIZABLE_CLASS_CONSTRUCTOR2T( |
|
278 |
TypedValueCompareIterator, |
|
279 |
NaryBaseIterator<TypedValueCompareIterator<ATC>, PlanIteratorState>); |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
280 |
void serialize(::zorba::serialization::Archiver& ar); |
10461.2.4
by danielturcanu
Merged with latest trunk |
281 |
|
282 |
public: |
|
283 |
TypedValueCompareIterator( |
|
284 |
static_context* sctx, |
|
285 |
const QueryLoc& loc, |
|
286 |
std::vector<PlanIter_t>& children, |
|
287 |
CompareConsts::CompareType aCompType) |
|
288 |
:
|
|
289 |
NaryBaseIterator<TypedValueCompareIterator<ATC>, PlanIteratorState>(sctx, loc, children), |
|
290 |
theCompType(aCompType), |
|
10783.1.21
by Markos Zaharioudakis
trying to fix compilation problems |
291 |
theTimezone(0), |
10461.2.4
by danielturcanu
Merged with latest trunk |
292 |
theCollation(NULL) |
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
293 |
{
|
294 |
}
|
|
10461.2.4
by danielturcanu
Merged with latest trunk |
295 |
|
296 |
~TypedValueCompareIterator () {} |
|
297 |
||
298 |
void accept(PlanIterVisitor& v) const; |
|
299 |
||
300 |
void openImpl(PlanState& planState, uint32_t& offset); |
|
301 |
||
11690.1.25
by Paul J. Lucas
Intermediate check-in. |
302 |
zstring getNameAsString() const; |
303 |
||
10461.2.4
by danielturcanu
Merged with latest trunk |
304 |
bool nextImpl(store::Item_t& result, PlanState& planState) const; |
305 |
};
|
|
306 |
||
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
307 |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
308 |
/*******************************************************************************
|
309 |
Atomic Values Equivalence Iterator
|
|
310 |
||
311 |
http://www.w3.org/TR/xquery-11/#dt-equivalence-two-atomic-values
|
|
312 |
********************************************************************************/
|
|
10783.1.21
by Markos Zaharioudakis
trying to fix compilation problems |
313 |
class AtomicValuesEquivalenceIterator : |
314 |
public BinaryBaseIterator<AtomicValuesEquivalenceIterator, PlanIteratorState> |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
315 |
{
|
316 |
private: |
|
317 |
TypeManager * theTypeManager; |
|
10783.1.22
by Markos Zaharioudakis
added serialize_enu and serialize_long |
318 |
long theTimezone; |
10461.2.4
by danielturcanu
Merged with latest trunk |
319 |
XQPCollator * theCollation; |
320 |
||
321 |
public: |
|
322 |
SERIALIZABLE_CLASS(AtomicValuesEquivalenceIterator); |
|
10783.1.28
by Markos Zaharioudakis
no distinction for normal and non-normal strings |
323 |
AtomicValuesEquivalenceIterator(::zorba::serialization::Archiver& ar); |
324 |
void serialize(::zorba::serialization::Archiver& ar); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
325 |
|
326 |
public: |
|
10783.1.21
by Markos Zaharioudakis
trying to fix compilation problems |
327 |
AtomicValuesEquivalenceIterator( |
328 |
static_context* sctx, |
|
329 |
const QueryLoc& loc, |
|
330 |
PlanIter_t theChild0, |
|
331 |
PlanIter_t theChild1); |
|
10461.2.4
by danielturcanu
Merged with latest trunk |
332 |
|
333 |
void accept(PlanIterVisitor& v) const; |
|
334 |
||
335 |
void openImpl(PlanState& planState, uint32_t& offset); |
|
336 |
||
11690.1.25
by Paul J. Lucas
Intermediate check-in. |
337 |
zstring getNameAsString() const; |
338 |
||
10461.2.4
by danielturcanu
Merged with latest trunk |
339 |
bool nextImpl(store::Item_t& result, PlanState& planState) const; |
340 |
||
341 |
};
|
|
342 |
||
343 |
}
|
|
344 |
||
345 |
#endif
|
|
346 |
||
347 |
/*
|
|
348 |
* Local variables:
|
|
349 |
* mode: c++
|
|
350 |
* End:
|
|
351 |
*/
|
|
352 |
/* vim:set et sw=2 ts=2: */
|