10#include <Pt/Db/IRow.h>
11#include <Pt/Db/Value.h>
12#include <Pt/SmartPtr.h>
38 typedef std::size_t size_type;
40 typedef Value value_type;
61 size_type
size()
const {
return row->size(); }
70 {
return row->getValue(field_num); }
74 Value operator[] (size_type field_num)
const
75 {
return row->getValue(field_num); }
79 bool isNull(size_type field_num)
const
80 {
return getValue(field_num).isNull(); }
87 {
return getValue(field_num).getBool(); }
93 int getInt(size_type field_num)
const
94 {
return getValue(field_num).getInt(); }
101 {
return getValue(field_num).getUnsigned(); }
108 {
return getValue(field_num).getFloat(); }
115 {
return getValue(field_num).getDouble(); }
124 {
return getValue(field_num).getChar(); }
131 {
return getValue(field_num).getString(); }
156 typedef std::random_access_iterator_tag iterator_category;
157 typedef Value value_type;
158 typedef std::ptrdiff_t difference_type;
159 typedef const Value* pointer;
160 typedef const Value& reference;
162 typedef const value_type& const_reference;
164 typedef const value_type* const_pointer;
171 void setOffset(size_type off)
177 if (_offset < _row.size())
178 _current = _row.getValue(_offset);
184 ConstIterator(
const Row& row, size_type offset)
189 if (_offset < row.size())
190 _current = row.getValue(_offset);
193 bool operator== (
const ConstIterator& it)
const
194 {
return _offset == it._offset; }
196 bool operator!= (
const ConstIterator& it)
const
197 {
return !operator== (it); }
199 ConstIterator& operator++()
200 { this->setOffset(_offset + 1);
return *
this; }
202 ConstIterator operator++(
int)
204 ConstIterator ret = *
this;
205 this->setOffset(_offset + 1);
209 ConstIterator operator--()
210 { setOffset(_offset - 1);
return *
this; }
212 ConstIterator operator--(
int)
214 ConstIterator ret = *
this;
215 this->setOffset(_offset - 1);
219 const_reference operator*()
const
222 const_pointer operator->()
const
223 {
return &_current; }
225 ConstIterator& operator+= (difference_type n)
227 this->setOffset(_offset + n);
231 ConstIterator operator+ (difference_type n)
const
233 ConstIterator it(*
this);
238 ConstIterator& operator-= (difference_type n)
240 this->setOffset(_offset - n);
244 ConstIterator operator- (difference_type n)
const
246 ConstIterator it(*
this);
251 difference_type operator- (
const ConstIterator& it)
const
252 {
return _offset - it._offset; }
Database-row backend.
Definition IRow.h:22
Random-access iterator over the values of a Row.
Definition Row.h:154
bool isNull(size_type field_num) const
Returns true if the value at field_num is SQL NULL.
Definition Row.h:79
float getFloat(size_type field_num) const
Returns the value at field_num as float.
Definition Row.h:107
std::string getString(size_type field_num) const
Returns the value at field_num as string.
Definition Row.h:130
double getDouble(size_type field_num) const
Returns the value at field_num as double.
Definition Row.h:114
size_type size() const
Returns the number of columns.
Definition Row.h:61
bool operator!() const
Returns true if this object is not bound to a row.
Definition Row.h:143
bool empty() const
Returns true if this row has no columns.
Definition Row.h:65
Row(IRow *row_)
Takes ownership of the backend row_.
Definition Row.h:54
ConstIterator end() const
Returns a random-access iterator past the last column.
const IRow * getImpl() const
Returns the backend implementation.
Definition Row.h:147
int getInt(size_type field_num) const
Returns the value at field_num as int.
Definition Row.h:93
bool getBool(size_type field_num) const
Returns the value at field_num as bool.
Definition Row.h:86
char getChar(size_type field_num) const
Returns the value at field_num as char.
Definition Row.h:123
Row()
Creates an unbound row.
Definition Row.h:50
ConstIterator begin() const
Returns a random-access iterator to the first column.
unsigned getUnsigned(size_type field_num) const
Returns the value at field_num as unsigned.
Definition Row.h:100
Value getValue(size_type field_num) const
Returns the value at field_num without range checking.
Definition Row.h:69
One column value of a query result.
Definition Value.h:35
Policy based smart pointer.
Definition SmartPtr.h:462
Portable SQL database access.
Core module.
Definition Allocator.h:33