4
* ========================================================================
5
* Copyright 2007 FLWOR Foundation
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
18
* ========================================================================
20
* @author Markos Zaharioudakis
21
* @file runtime/path_iterators.h
25
#ifndef XQP_PATH_ITERATORS_H
26
#define XQP_PATH_ITERATORS_H
29
#include "util/rchandle.h"
30
#include "exprtree/expr_consts.h"
38
/*******************************************************************************
40
********************************************************************************/
41
class KindTestIterator : public Batcher<KindTestIterator>
47
match_test_t theTestKind;
48
bool theNilledAllowed;
59
Batcher<KindTestIterator>(loc),
64
theNilledAllowed(nilled)
68
~KindTestIterator() {}
71
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
72
void resetImpl(IteratorTreeStateBlock& stateBlock);
73
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
75
std::ostream& _show(std::ostream& os) const;
79
/*******************************************************************************
81
********************************************************************************/
82
class NameTestIterator : public Batcher<NameTestIterator>
87
match_wild_t theWildKind;
96
Batcher<NameTestIterator>(loc),
103
~NameTestIterator() {}
106
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
107
void resetImpl(IteratorTreeStateBlock& stateBlock);
108
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
110
std::ostream& _show(std::ostream& os) const;
114
/*******************************************************************************
116
********************************************************************************/
121
Item_t theContextNode;
122
TypeCode theNodeKind;
125
AxisIterator(Iterator_t input)
132
virtual ~AxisIterator() {}
134
void setNodeKind(TypeCode k) { theNodeKind = k; }
138
/*******************************************************************************
140
********************************************************************************/
141
class SelfAxisIterator : public Batcher<SelfAxisIterator>,
145
SelfAxisIterator(yy::location loc, Iterator_t input)
147
Batcher<SelfAxisIterator>(loc),
152
~SelfAxisIterator() {}
155
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
156
void resetImpl(IteratorTreeStateBlock& stateBlock);
157
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
159
std::ostream& _show(std::ostream& os) const;
163
/*******************************************************************************
165
********************************************************************************/
166
class AttributeAxisIterator : public Batcher<AttributeAxisIterator>,
170
Iterator_t theAttributes;
172
Item_t theCurrentAttr;
176
AttributeAxisIterator(yy::location loc, Iterator_t input)
178
Batcher<AttributeAxisIterator>(loc),
183
~AttributeAxisIterator() {}
186
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
187
void resetImpl(IteratorTreeStateBlock& stateBlock);
188
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
190
std::ostream& _show(std::ostream& os) const;
194
/*******************************************************************************
196
********************************************************************************/
197
class ParentAxisIterator : public Batcher<ParentAxisIterator>,
206
ParentAxisIterator(yy::location loc, Iterator_t input)
208
Batcher<ParentAxisIterator>(loc),
213
~ParentAxisIterator() {}
216
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
217
void resetImpl(IteratorTreeStateBlock& stateBlock);
218
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
220
std::ostream& _show(std::ostream& os) const;
224
/*******************************************************************************
226
********************************************************************************/
227
class AncestorAxisIterator : public Batcher<AncestorAxisIterator>,
231
Item_t theCurrentAnc;
234
AncestorAxisIterator(yy::location loc, Iterator_t input)
236
Batcher<AncestorAxisIterator>(loc),
241
~AncestorAxisIterator() {}
244
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
245
void resetImpl(IteratorTreeStateBlock& stateBlock);
246
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
248
std::ostream& _show(std::ostream& os) const;
252
/*******************************************************************************
254
********************************************************************************/
255
class AncestorSelfAxisIterator : public Batcher<AncestorSelfAxisIterator>,
259
Item_t theCurrentAnc;
262
AncestorSelfAxisIterator(yy::location loc, Iterator_t input)
264
Batcher<AncestorSelfAxisIterator>(loc),
269
~AncestorSelfAxisIterator() {}
272
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
273
void resetImpl(IteratorTreeStateBlock& stateBlock);
274
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
276
std::ostream& _show(std::ostream& os) const;
280
/*******************************************************************************
282
********************************************************************************/
283
class RSiblingAxisIterator : public Batcher<RSiblingAxisIterator>,
287
Iterator_t theChildren;
293
RSiblingAxisIterator(yy::location loc, Iterator_t input)
295
Batcher<RSiblingAxisIterator>(loc),
300
~RSiblingAxisIterator() {}
303
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
304
void resetImpl(IteratorTreeStateBlock& stateBlock);
305
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
307
std::ostream& _show(std::ostream& os) const;
311
/*******************************************************************************
313
********************************************************************************/
314
class LSiblingAxisIterator : public Batcher<LSiblingAxisIterator>,
318
Iterator_t theChildren;
324
LSiblingAxisIterator(yy::location loc, Iterator_t input)
326
Batcher<LSiblingAxisIterator>(loc),
331
~LSiblingAxisIterator() {}
334
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
335
void resetImpl(IteratorTreeStateBlock& stateBlock);
336
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
338
std::ostream& _show(std::ostream& os) const;
342
/*******************************************************************************
344
********************************************************************************/
345
class ChildAxisIterator : public Batcher<ChildAxisIterator>,
349
Iterator_t theChildren;
351
Item_t theCurrentChild;
355
ChildAxisIterator(yy::location loc, Iterator_t input)
357
Batcher<ChildAxisIterator>(loc),
362
~ChildAxisIterator() {}
365
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
366
void resetImpl(IteratorTreeStateBlock& stateBlock);
367
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
369
std::ostream& _show(std::ostream& os) const;
373
/*******************************************************************************
375
********************************************************************************/
376
class DescendantAxisIterator : public Batcher<DescendantAxisIterator>,
380
std::stack<std::pair<Item_t, Iterator_t> > theCurrentPath;
382
Item_t theCurrentDesc;
385
DescendantAxisIterator(yy::location loc, Iterator_t input)
387
Batcher<DescendantAxisIterator>(loc),
392
~DescendantAxisIterator() {}
395
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
396
void resetImpl(IteratorTreeStateBlock& stateBlock);
397
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
399
std::ostream& _show(std::ostream& os) const;
403
/*******************************************************************************
405
********************************************************************************/
406
class DescendantSelfAxisIterator : public Batcher<DescendantSelfAxisIterator>,
410
std::stack<std::pair<Item_t, Iterator_t> > theCurrentPath;
412
Item_t theCurrentDesc;
415
DescendantSelfAxisIterator(yy::location loc, Iterator_t input)
417
Batcher<DescendantSelfAxisIterator>(loc),
422
~DescendantSelfAxisIterator() {}
425
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
426
void resetImpl(IteratorTreeStateBlock& stateBlock);
427
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
429
std::ostream& _show(std::ostream& os) const;
433
/*******************************************************************************
435
********************************************************************************/
436
class PrecedingAxisIterator : public Batcher<PrecedingAxisIterator>,
440
std::stack<Item_t> theAncestorPath;
441
std::stack<std::pair<Item_t, Iterator_t> > theCurrentPath;
443
Item_t theCurrentPrec;
446
PrecedingAxisIterator(yy::location loc, Iterator_t input)
448
Batcher<PrecedingAxisIterator>(loc),
453
~PrecedingAxisIterator() {}
456
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
457
void resetImpl(IteratorTreeStateBlock& stateBlock);
458
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
460
std::ostream& _show(std::ostream& os) const;
464
/*******************************************************************************
466
********************************************************************************/
467
class FollowingAxisIterator : public Batcher<FollowingAxisIterator>,
471
std::stack<Item_t> theAncestorPath;
472
std::stack<std::pair<Item_t, Iterator_t> > theCurrentPath;
474
Item_t theCurrentFollowing;
477
FollowingAxisIterator(yy::location loc, Iterator_t input)
479
Batcher<FollowingAxisIterator>(loc),
484
~FollowingAxisIterator() {}
487
Item_t nextImpl(IteratorTreeStateBlock& stateBlock);
488
void resetImpl(IteratorTreeStateBlock& stateBlock);
489
void releaseResourcesImpl(IteratorTreeStateBlock& stateBlock);
491
std::ostream& _show(std::ostream& os) const;
495
} /* namespace xqp */
497
#endif /* XQP_PATH_ITERATORS_H */