result_iterator.hxx
#ifndef PQXX_H_RESULT_ITERATOR
#define PQXX_H_RESULT_ITERATOR
#include "pqxx/compiler-public.hxx"
#include "pqxx/compiler-internal-pre.hxx"
#include "pqxx/row.hxx"
/* Result iterator.
*
* Don't include this header from your own application; it is included for you
* by other libpqxx headers.
*/
namespace pqxx
{
class PQXX_LIBEXPORT const_result_iterator : public row
{
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = const row;
using pointer = const row *;
using reference = row;
using size_type = result_size_type;
using difference_type = result_difference_type;
const_result_iterator() noexcept : row{result(), 0} {}
const_result_iterator(const row &t) noexcept : row{t} {}
pointer operator->() const { return this; } //[t12]
reference operator*() const { return row{*this}; } //[t12]
const_result_iterator operator++(int); //[t12]
const_result_iterator &operator++() { ++m_index; return *this; } //[t01]
const_result_iterator operator--(int); //[t12]
const_result_iterator &operator--() { --m_index; return *this; } //[t12]
const_result_iterator &operator+=(difference_type i) //[t12]
{ m_index += i; return *this; }
const_result_iterator &operator-=(difference_type i) //[t12]
{ m_index -= i; return *this; }
bool operator==(const const_result_iterator &i) const //[t12]
{return m_index==i.m_index;}
bool operator!=(const const_result_iterator &i) const //[t12]
{return m_index!=i.m_index;}
bool operator<(const const_result_iterator &i) const //[t12]
{return m_index<i.m_index;}
bool operator<=(const const_result_iterator &i) const //[t12]
{return m_index<=i.m_index;}
bool operator>(const const_result_iterator &i) const //[t12]
{return m_index>i.m_index;}
bool operator>=(const const_result_iterator &i) const //[t12]
{return m_index>=i.m_index;}
inline const_result_iterator operator+(difference_type) const; //[t12]
friend const_result_iterator operator+( //[t12]
difference_type,
const_result_iterator);
inline const_result_iterator operator-(difference_type) const; //[t12]
inline difference_type operator-(const_result_iterator) const; //[t12]
private:
friend class pqxx::result;
const_result_iterator(const pqxx::result *r, result_size_type i) noexcept :
row{*r, i} {}
};
class PQXX_LIBEXPORT const_reverse_result_iterator :
private const_result_iterator
{
public:
using super = const_result_iterator;
using iterator_type = const_result_iterator;
using iterator_type::iterator_category;
using iterator_type::difference_type;
using iterator_type::pointer;
using value_type = iterator_type::value_type;
using reference = iterator_type::reference;
const_reverse_result_iterator( //[t75]
const const_reverse_result_iterator &rhs) :
const_result_iterator{rhs} {}
explicit const_reverse_result_iterator( //[t75]
const const_result_iterator &rhs) :
const_result_iterator{rhs} { super::operator--(); }
PQXX_PURE const_result_iterator base() const noexcept; //[t75]
using const_result_iterator::operator->; //[t75]
using const_result_iterator::operator*; //[t75]
const_reverse_result_iterator &operator=( //[t75]
const const_reverse_result_iterator &r)
{ iterator_type::operator=(r); return *this; }
const_reverse_result_iterator &operator++() //[t75]
{ iterator_type::operator--(); return *this; }
const_reverse_result_iterator operator++(int); //[t75]
const_reverse_result_iterator &operator--() //[t75]
{ iterator_type::operator++(); return *this; }
const_reverse_result_iterator operator--(int); //[t75]
const_reverse_result_iterator &operator+=(difference_type i) //[t75]
{ iterator_type::operator-=(i); return *this; }
const_reverse_result_iterator &operator-=(difference_type i) //[t75]
{ iterator_type::operator+=(i); return *this; }
const_reverse_result_iterator operator+(difference_type i) const //[t75]
{ return const_reverse_result_iterator(base() - i); }
const_reverse_result_iterator operator-(difference_type i) //[t75]
{ return const_reverse_result_iterator(base() + i); }
difference_type operator-( //[t75]
const const_reverse_result_iterator &rhs) const
{ return rhs.const_result_iterator::operator-(*this); }
bool operator==( //[t75]
const const_reverse_result_iterator &rhs) const noexcept
{ return iterator_type::operator==(rhs); }
bool operator!=( //[t75]
const const_reverse_result_iterator &rhs) const noexcept
{ return not operator==(rhs); }
bool operator<(const const_reverse_result_iterator &rhs) const //[t75]
{ return iterator_type::operator>(rhs); }
bool operator<=(const const_reverse_result_iterator &rhs) const //[t75]
{ return iterator_type::operator>=(rhs); }
bool operator>(const const_reverse_result_iterator &rhs) const //[t75]
{ return iterator_type::operator<(rhs); }
bool operator>=(const const_reverse_result_iterator &rhs) const //[t75]
{ return iterator_type::operator<=(rhs); }
};
inline const_result_iterator
const_result_iterator::operator+(result::difference_type o) const
{
return const_result_iterator{
&m_result, size_type(result::difference_type(m_index) + o)};
}
inline const_result_iterator
operator+(result::difference_type o, const_result_iterator i)
{ return i + o; }
inline const_result_iterator
const_result_iterator::operator-(result::difference_type o) const
{
return const_result_iterator{
&m_result,
result_size_type(result::difference_type(m_index) - o)};
}
inline result::difference_type
const_result_iterator::operator-(const_result_iterator i) const
{ return result::difference_type(num() - i.num()); }
inline const_result_iterator result::end() const noexcept
{ return const_result_iterator{this, size()}; }
inline const_result_iterator result::cend() const noexcept
{ return end(); }
inline const_reverse_result_iterator
operator+(
result::difference_type n,
const const_reverse_result_iterator &i)
{ return const_reverse_result_iterator{i.base() - n}; }
} // namespace pqxx
#include "pqxx/compiler-internal-post.hxx"
#endif
pqxx::result::size
PQXX_PURE size_type size() const noexcept
Definition: result.cxx:94
pqxx::result::end
const_iterator end() const noexcept
Definition: result_iterator.hxx:227
pqxx::const_result_iterator::operator+
const_result_iterator operator+(difference_type) const
Definition: result_iterator.hxx:205
pqxx::const_result_iterator::const_result_iterator
const_result_iterator() noexcept
Definition: result_iterator.hxx:45
pqxx::const_reverse_result_iterator::operator-
difference_type operator-(const const_reverse_result_iterator &rhs) const
Definition: result_iterator.hxx:176
pqxx::const_reverse_result_iterator::operator-=
const_reverse_result_iterator & operator-=(difference_type i)
Definition: result_iterator.hxx:164
pqxx::const_reverse_result_iterator
Reverse iterator for result. Use as result::const_reverse_iterator.
Definition: result_iterator.hxx:120
pqxx::const_reverse_result_iterator::base
PQXX_PURE const_result_iterator base() const noexcept
Definition: result.cxx:425
pqxx::const_result_iterator
Iterator for rows in a result. Use as result::const_iterator.
Definition: result_iterator.hxx:35
pqxx::const_reverse_result_iterator::operator--
const_reverse_result_iterator & operator--()
Definition: result_iterator.hxx:159
pqxx::const_result_iterator::operator==
bool operator==(const const_result_iterator &i) const
Definition: result_iterator.hxx:86
pqxx::result::difference_type
result_difference_type difference_type
Definition: result.hxx:73
pqxx::const_result_iterator::operator>
bool operator>(const const_result_iterator &i) const
Definition: result_iterator.hxx:94
pqxx::const_result_iterator::operator+=
const_result_iterator & operator+=(difference_type i)
Definition: result_iterator.hxx:76
pqxx::const_result_iterator::operator--
const_result_iterator & operator--()
Definition: result_iterator.hxx:74
pqxx::result::cend
const_iterator cend() const noexcept
Definition: result_iterator.hxx:231
pqxx::const_reverse_result_iterator::operator<
bool operator<(const const_reverse_result_iterator &rhs) const
Definition: result_iterator.hxx:192
pqxx::result
Result set containing data returned by a query or command.
Definition: result.hxx:69
pqxx::result_difference_type
signed long result_difference_type
Difference between result sizes.
Definition: types.hxx:21
pqxx::row::num
size_t num() const
Definition: row.hxx:170
pqxx::const_reverse_result_iterator::operator++
const_reverse_result_iterator & operator++()
Definition: result_iterator.hxx:156
pqxx::const_reverse_result_iterator::operator!=
bool operator!=(const const_reverse_result_iterator &rhs) const noexcept
Definition: result_iterator.hxx:188
pqxx::const_result_iterator::operator->
pointer operator->() const
Definition: result_iterator.hxx:63
pqxx::const_reverse_result_iterator::operator<=
bool operator<=(const const_reverse_result_iterator &rhs) const
Definition: result_iterator.hxx:194
pqxx::const_result_iterator::operator>=
bool operator>=(const const_result_iterator &i) const
Definition: result_iterator.hxx:96
pqxx::const_reverse_result_iterator::operator>=
bool operator>=(const const_reverse_result_iterator &rhs) const
Definition: result_iterator.hxx:198
pqxx::const_reverse_result_iterator::operator-
const_reverse_result_iterator operator-(difference_type i)
Definition: result_iterator.hxx:174
pqxx::const_reverse_result_iterator::operator+=
const_reverse_result_iterator & operator+=(difference_type i)
Definition: result_iterator.hxx:162
pqxx::const_result_iterator::size_type
result_size_type size_type
Definition: result_iterator.hxx:42
pqxx::const_result_iterator::difference_type
result_difference_type difference_type
Definition: result_iterator.hxx:43
pqxx::operator+
const_result_iterator operator+(result::difference_type o, const_result_iterator i)
Definition: result_iterator.hxx:212
pqxx::const_result_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: result_iterator.hxx:38
pqxx::result_size_type
unsigned long result_size_type
Number of rows in a result set.
Definition: types.hxx:18
pqxx::const_result_iterator::operator-
const_result_iterator operator-(difference_type) const
Definition: result_iterator.hxx:216
pqxx::row::m_index
long m_index
Row number.
Definition: row.hxx:198
pqxx::row::m_result
result m_result
Result set of which this is one row.
Definition: row.hxx:192
pqxx::const_reverse_result_iterator::const_reverse_result_iterator
const_reverse_result_iterator(const const_result_iterator &rhs)
Definition: result_iterator.hxx:135
pqxx::const_result_iterator::operator-=
const_result_iterator & operator-=(difference_type i)
Definition: result_iterator.hxx:78
pqxx::const_reverse_result_iterator::operator==
bool operator==(const const_reverse_result_iterator &rhs) const noexcept
Definition: result_iterator.hxx:185
pqxx::const_reverse_result_iterator::operator+
const_reverse_result_iterator operator+(difference_type i) const
Definition: result_iterator.hxx:172
pqxx::const_result_iterator::const_result_iterator
const_result_iterator(const row &t) noexcept
Definition: result_iterator.hxx:46
pqxx::const_result_iterator::operator*
reference operator*() const
Definition: result_iterator.hxx:64
pqxx::const_reverse_result_iterator::const_reverse_result_iterator
const_reverse_result_iterator(const const_reverse_result_iterator &rhs)
Definition: result_iterator.hxx:132
pqxx::const_result_iterator::operator<=
bool operator<=(const const_result_iterator &i) const
Definition: result_iterator.hxx:92
pqxx::const_reverse_result_iterator::operator>
bool operator>(const const_reverse_result_iterator &rhs) const
Definition: result_iterator.hxx:196
pqxx::const_result_iterator::operator!=
bool operator!=(const const_result_iterator &i) const
Definition: result_iterator.hxx:88
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
pqxx::row
Reference to one row in a result.
Definition: row.hxx:40
pqxx::const_result_iterator::operator++
const_result_iterator & operator++()
Definition: result_iterator.hxx:72
pqxx::const_result_iterator::operator<
bool operator<(const const_result_iterator &i) const
Definition: result_iterator.hxx:90