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

#include <resultset.hpp>

Inheritance diagram for tip::db::pg::resultset::field:
Inheritance graph
[legend]
Collaboration diagram for tip::db::pg::resultset::field:
Collaboration graph
[legend]

Public Member Functions

size_type row_index () const
 Index of owner row. More...
 
row::size_type field_index () const
 Index of field in the row. More...
 
std::string const & name () const
 Name of field. More...
 
field_description const & description () const
 Field description. More...
 
bool is_null () const
 Is field value null. More...
 
bool empty () const
 Is field value empty (not null) More...
 
template<typename T >
bool to (T &val) const
 
template<typename T >
bool to (boost::optional< T > &val) const
 
template<typename T >
std::decay< T >::type as () const
 
template<typename T >
std::decay< T >::type coalesce (T const &default_val)
 

Protected Member Functions

 field (result_pointer res, size_type row, row::size_type col)
 

Protected Attributes

result_pointer result_
 
size_type row_index_
 
row::size_type field_index_
 

Friends

class resultset
 
class row
 

Detailed Description

Represents a single field in the result set. Provides access to underlying data and functions for converting the data into various datatypes.

Definition at line 331 of file resultset.hpp.

Constructor & Destructor Documentation

tip::db::pg::resultset::field::field ( result_pointer  res,
size_type  row,
row::size_type  col 
)
inlineprotected

Definition at line 454 of file resultset.hpp.

Member Function Documentation

template<typename T >
std::decay<T>::type tip::db::pg::resultset::field::as ( ) const
inline

Cast the field value to the type requested.

Template Parameters
Trequested data type
Returns
field buffer as requested data type
Exceptions
tip::db::pg::value_is_nullif the value is null and the type requested is not 'nullable'.

Definition at line 404 of file resultset.hpp.

Here is the call graph for this function:

template<typename T >
std::decay<T>::type tip::db::pg::resultset::field::coalesce ( T const &  default_val)
inline

Cast the field value to the type requested. If the field is null value passed as the parameter to the function will be returned.

Template Parameters
Trequested data type
Parameters
default_valValue to return if the field is null
Returns

Definition at line 419 of file resultset.hpp.

Here is the call graph for this function:

field_description const& tip::db::pg::resultset::field::description ( ) const

Field description.

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

Is field value empty (not null)

row::size_type tip::db::pg::resultset::field::field_index ( ) const
inline

Index of field in the row.

<

Definition at line 337 of file resultset.hpp.

bool tip::db::pg::resultset::field::is_null ( ) const

Is field value null.

std::string const& tip::db::pg::resultset::field::name ( ) const

Name of field.

size_type tip::db::pg::resultset::field::row_index ( ) const
inline

Index of owner row.

<

Definition at line 334 of file resultset.hpp.

template<typename T >
bool tip::db::pg::resultset::field::to ( T &  val) const
inline

Parse the value buffer to the type specified by value passed as target. Will throw a value_is_null exception if the field is null.

Template Parameters
Ttype of target variable
Parameters
valTarget variable for the field value.
Returns
true if parsing the buffer was a success.
Exceptions
tip::db::pg::value_is_null

Definition at line 362 of file resultset.hpp.

Here is the call graph for this function:

template<typename T >
bool tip::db::pg::resultset::field::to ( boost::optional< T > &  val) const
inline

Parse the value buffer to the type specified by value passed as target. boost::optional is used as to specify a 'nullable' type concept.

Template Parameters
Ttype of target variable.
Parameters
valTarget variable for the field value.
Returns
true if parsing the buffer was a success.
Exceptions
tip::db::pg::value_is_null

Definition at line 381 of file resultset.hpp.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class resultset
friend

Definition at line 452 of file resultset.hpp.

friend class row
friend

Definition at line 453 of file resultset.hpp.

Member Data Documentation

row::size_type tip::db::pg::resultset::field::field_index_
protected

Definition at line 459 of file resultset.hpp.

result_pointer tip::db::pg::resultset::field::result_
protected

Definition at line 457 of file resultset.hpp.

size_type tip::db::pg::resultset::field::row_index_
protected

Definition at line 458 of file resultset.hpp.


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