pg_async
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
tip::db::pg::resultset Class Reference

#include <resultset.hpp>

Classes

class  const_field_iterator
 
class  const_row_iterator
 
class  field
 
class  row
 

Public Types

typedef std::shared_ptr
< detail::result_impl > 
result_impl_ptr
 
Size types definitions
typedef uinteger size_type
 
typedef integer difference_type
 
Row container concept
typedef const_row_iterator const_iterator
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 
typedef row value_type
 
typedef const value_type reference
 
typedef const_iterator pointer
 
Field iterators
typedef std::reverse_iterator
< const_field_iterator
const_reverse_field_iterator
 

Public Member Functions

 resultset ()
 Construct an empty resultset. More...
 
 resultset (result_impl_ptr)
 Constructs a resultset with the pointer to internal implementation Used internally by the library. More...
 
Row-wise container interface
size_type size () const
 
bool empty () const
 
const_iterator begin () const
 
const_iterator end () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
reference front () const
 
reference back () const
 
reference operator[] (size_type index) const
 
reference at (size_type index) const
 
Result checking
 operator bool () const
 
bool operator! () const
 
Column-related interface
size_type columns_size () const
 
row_description_type const & row_description () const
 
size_type index_of_name (std::string const &name) const
 
field_description const & field (size_type col_index) const
 
field_description const & field (std::string const &name) const
 
std::string const & field_name (size_type col_index) const
 

Static Public Attributes

static const size_type npos
 Not-a-position constant. More...
 

Friends

class row
 
class field
 

Detailed Description

Result set. Provide access to rows via indexing operators (random access) and bidirectional iteration access via iterators. Access to field definitions.

void
handle_results(transaction_ptr tran, resultset res, bool complete)
{
if (complete) { // This is the last callback for the command
// C++11 style iteration
for (resultset::row const& row : res) {
for (resultset::field const& field : row) {
}
}
// Oldschool iteration
for (resultset::const_iterator row = res.begin(); row != res.end(); ++row) {
// Do something with the row
for (resultset::const_field_iterator f = row.begin(); f != row.end(); ++f) {
}
}
}
}

Definition at line 56 of file resultset.hpp.

Member Typedef Documentation

Definition at line 73 of file resultset.hpp.

Definition at line 83 of file resultset.hpp.

Definition at line 74 of file resultset.hpp.

Definition at line 61 of file resultset.hpp.

Definition at line 78 of file resultset.hpp.

Definition at line 77 of file resultset.hpp.

typedef std::shared_ptr<detail::result_impl> tip::db::pg::resultset::result_impl_ptr

Shared pointer to internal implementation

Definition at line 66 of file resultset.hpp.

Definition at line 60 of file resultset.hpp.

Definition at line 76 of file resultset.hpp.

Constructor & Destructor Documentation

tip::db::pg::resultset::resultset ( )

Construct an empty resultset.

tip::db::pg::resultset::resultset ( result_impl_ptr  )

Constructs a resultset with the pointer to internal implementation Used internally by the library.

Parameters
Sharedpointer to result set

Member Function Documentation

reference tip::db::pg::resultset::at ( size_type  index) const

Assess a row by index (range checking) In case of index out-of-range will throw an exception

Parameters
indexindex of the row
Returns
row object
reference tip::db::pg::resultset::back ( ) const

Get the last row in the result set. Will raise an assertion if the result set is empty.

Returns
const_iterator tip::db::pg::resultset::begin ( ) const

Iterator to the beginning of rows sequence

size_type tip::db::pg::resultset::columns_size ( ) const

Column count

bool tip::db::pg::resultset::empty ( ) const

Is the result set empty

const_iterator tip::db::pg::resultset::end ( ) const

Iterator past the end of rows sequence.

Get the field description of field by it's index.

Parameters
col_indexfield index, must be in range of [0..columns_size)
Returns
constant reference to the field description
Exceptions
out_of_rangeexception
field_description const& tip::db::pg::resultset::field ( std::string const &  name) const

Get the field description of field by it's name.

Parameters
namename of the field. must be present in the result set.
Returns
constant reference to the field description
Exceptions
out_of_rangeexception
std::string const& tip::db::pg::resultset::field_name ( size_type  col_index) const

Get the name of field by it's index

Parameters
col_indexfield index, must be in range of [0..columns_size)
Returns
the name of the field.
Exceptions
out_of_rangeexception
reference tip::db::pg::resultset::front ( ) const

Get the first row in the result set. Will raise an assertion if the result set is empty.

Returns
size_type tip::db::pg::resultset::index_of_name ( std::string const &  name) const

Get the index of field with name

Parameters
namethe field name
Returns
if found, index in the range of [0..columns_size). If not found - npos
tip::db::pg::resultset::operator bool ( ) const
inline

Syntactic sugar operator for checking the result set

void result_callback(resultset r)
{
if (r) {
// Do something with the result
}
}

Definition at line 165 of file resultset.hpp.

Here is the call graph for this function:

bool tip::db::pg::resultset::operator! ( ) const
inline

Syntactic sugar operator for checking the result set

void result_callback(resultset r)
{
if (!r) {
// Handle the situation of an empty result set
}
}

Definition at line 181 of file resultset.hpp.

reference tip::db::pg::resultset::operator[] ( size_type  index) const

Access a row by index. In case of index out-of-range situation will rase an assertion

Parameters
indexindex of the row
Returns
row object
const_reverse_iterator tip::db::pg::resultset::rbegin ( ) const

Iterator to the beginning of rows sequence in reverse order

const_reverse_iterator tip::db::pg::resultset::rend ( ) const

Iterator past the end of of rows sequence in reverse order

row_description_type const& tip::db::pg::resultset::row_description ( ) const
size_type tip::db::pg::resultset::size ( ) const

Number of rows

Friends And Related Function Documentation

friend class field
friend

Definition at line 693 of file resultset.hpp.

friend class row
friend

Definition at line 692 of file resultset.hpp.

Member Data Documentation

const size_type tip::db::pg::resultset::npos
static

Not-a-position constant.

Definition at line 90 of file resultset.hpp.


The documentation for this class was generated from the following file: