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

#include <ozo/result.h>

Description

template<typename T>
class ozo::basic_result< T >

Database raw result representation.

This class provides access to the raw representation of a database request result. It models range of rows. Each row can be accessed via index or iterator.

Template Parameters
T— underlying native result handler type, in common case ozo::pg::result.

Types

using const_iterator = < implementation defined >
 
using iterator = const_iterator
 

Public Member Functions

const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
std::size_t size () const noexcept
 
bool empty () const noexcept
 
row operator[] (int i) const noexcept
 
row at (int i) const
 
native_handle_type native_handle () const noexcept
 
bool valid () const noexcept
 
handle_type release () noexcept(std::is_nothrow_move_constructible_v< handle_type >)
 

Types

◆ const_iterator

template<typename T >
using ozo::basic_result< T >::const_iterator = <implementation defined>

Constant iterator on row in the result.

Random access iterator. Provides access to a ozo::row 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::row object.

◆ iterator

template<typename T >
using ozo::basic_result< T >::iterator = const_iterator

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

Member Function Documentation

◆ at()

template<typename T >
row ozo::basic_result< T >::at ( int  i) const

Get row by index with range check.

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

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

References ozo::basic_result< T >::size().

◆ begin()

template<typename T >
const_iterator ozo::basic_result< T >::begin ( ) const
noexcept

Iterator on the first row of the result.

Returns
const_iterator — iterator on the first row

References ozo::basic_result< T >::native_handle().

Referenced by ozo::basic_result< T >::end(), and ozo::basic_result< T >::operator[]().

◆ empty()

template<typename T >
bool ozo::basic_result< T >::empty ( ) const
noexcept

Determine whether the result is empty.

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

References ozo::basic_result< T >::size().

◆ end()

template<typename T >
const_iterator ozo::basic_result< T >::end ( ) const
noexcept

Iterator on end of row sequence.

Returns
const_iterator — iterator on end of row sequence

References ozo::basic_result< T >::begin(), and ozo::basic_result< T >::size().

◆ native_handle()

template<typename T >
native_handle_type ozo::basic_result< T >::native_handle ( ) const
noexcept

Get the native libpq handle representation.

This function may be used to obtain the underlying representation of the handle. This is intended to allow access to native handle functionality that is not otherwise provided.

Returns
native_handle_type — native handle representation

Referenced by ozo::basic_result< T >::begin(), and ozo::basic_result< T >::size().

◆ operator[]()

template<typename T >
row ozo::basic_result< T >::operator[] ( int  i) const
noexcept

Get row by 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 a row.
Returns
ozo::row — proxy object to a row.

References ozo::basic_result< T >::begin().

◆ release()

template<typename T >
handle_type ozo::basic_result< T >::release ( )
noexcept

Releases ownership of the native connection handle object.

This function may be used to obtain the underlying result handle. After calling this function, valid() returns false.

Returns
handle_type — result handle object

◆ size()

template<typename T >
std::size_t ozo::basic_result< T >::size ( ) const
noexcept

Get count of rows.

Returns
std::size_t — count of rows.

References ozo::basic_result< T >::native_handle().

Referenced by ozo::basic_result< T >::at(), ozo::basic_result< T >::empty(), and ozo::basic_result< T >::end().

◆ valid()

template<typename T >
bool ozo::basic_result< T >::valid ( ) const
noexcept

Checks if object contains result handle.