9#ifndef HEADER_SQLITEPP_ROW_ITERATOR_INCLUDED
10#define HEADER_SQLITEPP_ROW_ITERATOR_INCLUDED
12#include "statement_iface.hpp"
41 _owner(owner), _idx(idx)
45 cell(owner.get(), idx)
57 {
return _owner->column_type(_idx); }
70 const char *
name() const noexcept
71 {
return _owner->column_name(_idx); }
84 template<
class T> T
value() const noexcept
85 {
return _owner->column_value<T>(_idx); }
95 {
return _owner->column_database_name(_idx); }
104 {
return _owner->column_table_name(_idx); }
114 {
return _owner->column_origin_name(_idx); }
124 {
return _owner->column_declared_type(_idx); }
147 using value_type =
cell;
148 using size_type = int;
149 using difference_type = int;
150 using reference = value_type;
151 using pointer = void;
153 class const_iterator :
private cell
157 using value_type = row::value_type;
158 using size_type = row::size_type;
159 using difference_type = row::difference_type;
160 using reference = row::reference;
161 using pointer = row::pointer;
164 const_iterator()
noexcept:
168 cell operator*()
const noexcept
170 const cell * operator->()
const noexcept
172 cell operator[](size_type idx)
const noexcept
173 {
return *(*
this + idx); }
175 const_iterator & operator++()
noexcept
176 { ++_idx;
return *
this; }
177 const_iterator operator++(
int)
noexcept
178 {
return const_iterator(_owner, _idx++); }
179 const_iterator & operator+=(
int val)
noexcept
180 { _idx += val;
return *
this; }
181 const_iterator & operator--()
noexcept
182 { --_idx;
return *
this; }
183 const_iterator operator--(
int)
noexcept
184 {
return const_iterator(_owner, _idx--); }
185 const_iterator & operator-=(
int val)
noexcept
186 { _idx -= val;
return *
this; }
188 friend const_iterator operator+(
const const_iterator & lhs,
int rhs)
noexcept
189 {
return const_iterator(lhs._owner, lhs._idx + rhs); }
190 friend const_iterator operator+(
int lhs,
const const_iterator & rhs)
noexcept
191 {
return const_iterator(rhs._owner, rhs._idx + lhs); }
193 friend int operator-(
const const_iterator & lhs,
const const_iterator & rhs)
noexcept
194 {
return lhs._idx - rhs._idx; }
195 friend const_iterator operator-(
const const_iterator & lhs,
int rhs)
noexcept
196 {
return const_iterator(lhs._owner, lhs._idx - rhs); }
198 friend bool operator==(
const const_iterator & lhs,
const const_iterator & rhs)
noexcept
199 {
return lhs._idx == rhs._idx; }
200 friend bool operator!=(
const const_iterator & lhs,
const const_iterator & rhs)
noexcept
201 {
return lhs._idx != rhs._idx; }
202 friend bool operator<(
const const_iterator & lhs,
const const_iterator & rhs)
noexcept
203 {
return lhs._idx < rhs._idx; }
204 friend bool operator<=(
const const_iterator & lhs,
const const_iterator & rhs)
noexcept
205 {
return lhs._idx <= rhs._idx; }
206 friend bool operator>(
const const_iterator & lhs,
const const_iterator & rhs)
noexcept
207 {
return lhs._idx > rhs._idx; }
208 friend bool operator>=(
const const_iterator & lhs,
const const_iterator & rhs)
noexcept
209 {
return lhs._idx >= rhs._idx; }
211 const_iterator(
const statement * owner,
int idx)
noexcept:
215 using iterator = const_iterator;
233 int size() const noexcept
235 bool empty() const noexcept
236 {
return size() == 0; }
238 cell operator[](
int idx)
const noexcept
239 {
return cell(_owner, idx); }
241 const_iterator begin() const noexcept
242 {
return const_iterator(_owner, 0); }
243 const_iterator cbegin() const noexcept
244 {
return const_iterator(_owner, 0); }
245 const_iterator end() const noexcept
246 {
return const_iterator(_owner, size()); }
247 const_iterator cend() const noexcept
248 {
return const_iterator(_owner, size()); }
250 const_reverse_iterator rbegin() const noexcept
251 {
return const_reverse_iterator(end()); }
252 const_reverse_iterator crbegin() const noexcept
253 {
return const_reverse_iterator(end()); }
254 const_reverse_iterator rend() const noexcept
255 {
return const_reverse_iterator(begin()); }
256 const_reverse_iterator crend() const noexcept
257 {
return const_reverse_iterator(begin()); }
259 const statement * _owner;
275 using value_type =
row;
276 using size_type = int;
277 using difference_type = int;
278 using reference =
row;
279 using pointer = void;
309 row operator*() const noexcept
312 const row * operator->() const noexcept
316 { increment();
return *
this; }
321 {
return lhs._owner == rhs._owner; }
323 {
return lhs._owner != rhs._owner; }
327 if (!
const_cast<statement *
>(_owner)->step())
344 using value_type =
row;
345 using size_type = int;
346 using difference_type = int;
347 using reference = value_type;
348 using pointer = void;
351 using iterator = const_iterator;
368 const_iterator begin() const noexcept
370 const_iterator cbegin() const noexcept
372 const_iterator end() const noexcept
373 {
return const_iterator(); }
374 const_iterator cend() const noexcept
375 {
return const_iterator(); }
A cell in a row.
Definition row_iterator.hpp:35
const char * origin_name() const noexcept
Table column that is the origin of the cell.
Definition row_iterator.hpp:113
const char * name() const noexcept
Name of the cell's column.
Definition row_iterator.hpp:70
cell(const statement *owner, int idx) noexcept
Construct a cell for a given statement and column index.
Definition row_iterator.hpp:40
const char * database_name() const noexcept
Database that is the origin of the cell.
Definition row_iterator.hpp:94
const char * table_name() const noexcept
Table that is the origin of the cell.
Definition row_iterator.hpp:103
const char * declared_type() const noexcept
Declared datatype of the cell.
Definition row_iterator.hpp:123
T value() const noexcept
Cell's value.
Definition row_iterator.hpp:84
int type() const noexcept
Default datatype of the cell.
Definition row_iterator.hpp:56
cell(const std::unique_ptr< statement > &owner, int idx) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition row_iterator.hpp:44
An input iterator for statement results.
Definition row_iterator.hpp:273
row_iterator() noexcept
Create an empty iterator.
Definition row_iterator.hpp:288
row_iterator(std::unique_ptr< statement > &owner)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition row_iterator.hpp:305
row_iterator(statement *owner)
Create an instance referring to a given statement.
Definition row_iterator.hpp:297
row_range(std::unique_ptr< statement > &owner)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition row_iterator.hpp:364
row_range(statement *owner)
Create an instance referring to a given statement.
Definition row_iterator.hpp:359
Row result of a statement.
Definition row_iterator.hpp:145
row(const statement *owner) noexcept
Construct a row for a given statement.
Definition row_iterator.hpp:225
row(const std::unique_ptr< statement > &owner) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition row_iterator.hpp:229
Prepared Statement Object.
Definition statement_iface.hpp:87
int data_count() const noexcept
Number of columns in a result set.
Definition statement_iface.hpp:593
ThinSQLite++ namespace.
Definition backup_iface.hpp:17