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