TreeFrogFramework  1.18
tsqlormapperiterator.h
Go to the documentation of this file.
1 #ifndef TSQLORMAPPERITERATOR_H
2 #define TSQLORMAPPERITERATOR_H
3 
4 #include <TSqlORMapper>
5 
6 
7 template <class T>
9 {
10 public:
11  TSqlORMapperIterator(const TSqlORMapper<T> &mapper) : m(&mapper), i(0), n(m->rowCount()) { }
12 
13  bool hasNext() const { return i >= 0 && i < m->rowCount(); }
14  bool hasPrevious() const { return i > 0 && i <= m->rowCount(); }
15  T next() { n = i++; return m->value(n); }
16  T previous() { n = --i; return m->value(n); }
17  void toBack() { i = n = m->rowCount(); }
18  void toFront() { i = 0; n = m->rowCount(); }
19  T value() const { return m->value(n); }
20 
21 private:
24 
25  const TSqlORMapper<T> *m;
26  int i, n;
27 };
28 
29 #endif // TSQLORMAPPERITERATOR_H
void toFront()
Moves the iterator to the front of the results (before the first object).
Definition: tsqlormapperiterator.h:18
T value() const
Returns the current object and does not move the iterator.
Definition: tsqlormapperiterator.h:19
bool hasPrevious() const
Returns true if there is at least one object behind the iterator; otherwise returns false...
Definition: tsqlormapperiterator.h:14
The TSqlORMapper class is a template class that provides concise functionality to object-relational m...
Definition: tsqlormapper.h:26
T next()
Returns the next object and advances the iterator by one position.
Definition: tsqlormapperiterator.h:15
bool hasNext() const
Returns true if there is at least one object ahead of the iterator; otherwise returns false...
Definition: tsqlormapperiterator.h:13
TSqlORMapperIterator(const TSqlORMapper< T > &mapper)
Constructor.
Definition: tsqlormapperiterator.h:11
void toBack()
Moves the iterator to the back of the results (after the last object).
Definition: tsqlormapperiterator.h:17
T previous()
Returns the previous object and moves the iterator back by one position.
Definition: tsqlormapperiterator.h:16
The TSqlORMapperIterator class provides a Java-style iterator for TSqlORMapper.
Definition: tsqlormapperiterator.h:8