OZO 「お象」
Boost.Asio and libpq based asynchronous PostgreSQL unofficial header-only C++17 client library.
ozo::row Class Reference

#include <ozo/result.h>

Description

Database request result row proxy.

Types

using const_iterator = < implementation defined >
 
using iterator = const_iterator
 

Public Member Functions

const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
const_iterator find (const char *name) const noexcept
 
value operator[] (int index) const noexcept
 
std::size_t size () const noexcept
 
bool empty () const noexcept
 
value at (int index) const
 
value at (const char *name) const
 

Types

◆ const_iterator

using ozo::row::const_iterator = <implementation defined>

Constant iterator on value in the row.

Random access iterator. Provides access to a ozo::value object. Since ozo::basic_result provides read-only access to a database request result, all the iterators provide a read-only access to a ozo::value object.

◆ iterator

Iterator on value in the row, alias on iterator class.

Member Function Documentation

◆ at() [1/2]

value ozo::row::at ( const char *  name) const

Get value by field name with range check

If value with field name not found throws std::out_of_range.

Parameters
name— index of value in the row.
Returns
value — proxy object to a value.

References end(), and find().

◆ at() [2/2]

value ozo::row::at ( int  index) const

Get value by field index with range check

If index in not range [0, size()) throws std::out_of_range.

Parameters
index— index of value in the row.
Returns
ozo::value — proxy object to a value.

References size().

◆ begin()

const_iterator ozo::row::begin ( ) const
noexcept

Iterator on the first of row values sequence.

Returns
const_iterator — iterator on the first of row values sequence

Referenced by end(), find(), and operator[]().

◆ empty()

bool ozo::row::empty ( ) const
noexcept

Indicates if there are no values in row.

Returns
true — no values in the row, size() == 0, begin() == end().
false — row is not empty, size() > 0, begin() != end().

References size().

◆ end()

const_iterator ozo::row::end ( ) const
noexcept

Iterator on end of row values sequence.

Returns
const_iterator — iterator on the end of row values sequence

References begin(), and size().

Referenced by at(), and find().

◆ find()

const_iterator ozo::row::find ( const char *  name) const
noexcept

Find value by field name.

Parameters
name— value field name to find.
Returns
const_iterator — iterator on found value.
end() — in no field with given name found.

References begin(), and end().

Referenced by at().

◆ operator[]()

value ozo::row::operator[] ( int  index) const
noexcept

Get value by field index.

Valid index is in range [0, size()). No index-in-range check is performing.

Note
If given index is out of range the result is UB.
Parameters
index— index of the value field.
Returns
ozo::value — proxy object on the value.

References begin().

◆ size()

std::size_t ozo::row::size ( ) const
noexcept

Get count of values in row.

Returns
std::size_t — count of values in row.

Referenced by at(), empty(), and end().