TreeFrogFramework  1.18
tsqlqueryormapperiterator.h
Go to the documentation of this file.
1 #ifndef TSQLQUERYORMAPPERITERATOR_H
2 #define TSQLQUERYORMAPPERITERATOR_H
3 
4 #include <TSqlQueryORMapper>
5 
6 
7 template <class T>
9 {
10 public:
11  TSqlQueryORMapperIterator(TSqlQueryORMapper<T> &mapper) : m(&mapper), it(0) { }
12 
13  bool hasNext() const { return (it >= 0 && it < m->size()); }
14  bool hasPrevious() const { return (it > 0 && it <= m->size()); }
15  T next();
16  T previous();
17  void toBack() { m->last(); it = m->size(); }
18  void toFront() { m->first(); it = 0; }
19  T value() const { return m->value(); }
20 
21 private:
24 
26  int it;
27 };
28 
29 
33 template <class T>
35 {
36  if (it++ != m->at()) {
37  m->next();
38  }
39  return m->value();
40 }
41 
46 template <class T>
48 {
49  if (--it != m->at()) {
50  m->previous();
51  }
52  return m->value();
53 }
54 
55 #endif // TSQLQUERYORMAPPERITERATOR_H
The TSqlQueryORMapperIterator class provides a Java-style iterator for TSqlQueryORMapper.
Definition: tsqlqueryormapperiterator.h:8
T previous()
Returns the previous object and moves the iterator back by one position.
Definition: tsqlqueryormapperiterator.h:47
bool hasNext() const
Returns true if there is at least one object ahead of the iterator; otherwise returns false...
Definition: tsqlqueryormapperiterator.h:13
T next()
Returns the next object and advances the iterator by one position.
Definition: tsqlqueryormapperiterator.h:34
T value() const
Returns the current object and does not move the iterator.
Definition: tsqlqueryormapperiterator.h:19
TSqlQueryORMapperIterator(TSqlQueryORMapper< T > &mapper)
Constructs a TSqlQueryORMapperIterator object using the mapper mapper.
Definition: tsqlqueryormapperiterator.h:11
void toFront()
Moves the iterator to the front of the results (before the first object).
Definition: tsqlqueryormapperiterator.h:18
The TSqlQueryORMapper class is a template class that creates ORM objects by executing and manipulatin...
Definition: tsqlqueryormapper.h:20
bool hasPrevious() const
Returns true if there is at least one object behind the iterator; otherwise returns false...
Definition: tsqlqueryormapperiterator.h:14
void toBack()
Moves the iterator to the back of the results (after the last object).
Definition: tsqlqueryormapperiterator.h:17