userver: storages::postgres::Field Class Reference
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
storages::postgres::Field Class Reference

Accessor to a single field in a result set's row. More...

#include <userver/storages/postgres/result_set.hpp>

+ Inheritance diagram for storages::postgres::Field:

Public Types

using size_type = std::size_t
 

Public Member Functions

size_type RowIndex () const
 
size_type FieldIndex () const
 
Field metadata
std::string_view Name () const
 Field name as named in query.
 
FieldDescription Description () const
 
Oid GetTypeOid () const
 

Data access

class Row
 
bool IsNull () const
 
template<typename T >
size_type To (T &&val) const
 
template<typename T >
void Coalesce (T &val, const T &default_val) const
 
template<typename T >
std::decay< T >::type As () const
 
template<typename T >
std::decay< T >::type Coalesce (const T &default_val) const
 
const io::TypeBufferCategory & GetTypeBufferCategories () const
 
 Field (detail::ResultWrapperPtr res, size_type row, size_type col)
 
template<typename T >
size_type ReadNullable (const io::FieldBuffer &fb, T &&val, std::true_type) const
 
template<typename T >
size_type ReadNullable (const io::FieldBuffer &buffer, T &&val, std::false_type) const
 

Iteration support

bool IsValid () const
 
int Compare (const Field &rhs) const
 
std::ptrdiff_t Distance (const Field &rhs) const
 
FieldAdvance (std::ptrdiff_t)
 

Detailed Description

Accessor to a single field in a result set's row.

Definition at line 228 of file result_set.hpp.

Member Typedef Documentation

◆ size_type

using storages::postgres::Field::size_type = std::size_t

Definition at line 230 of file result_set.hpp.

Constructor & Destructor Documentation

◆ Field()

storages::postgres::Field::Field ( detail::ResultWrapperPtr  res,
size_type  row,
size_type  col 
)
inlineprotected

Definition at line 295 of file result_set.hpp.

Member Function Documentation

◆ As()

template<typename T >
std::decay< T >::type storages::postgres::Field::As ( ) const
inline

Convert the field's buffer into a C++ type.

Exceptions
FieldValueIsNullIf the field is null and the C++ type is not nullable.

Definition at line 273 of file result_set.hpp.

◆ Coalesce() [1/2]

template<typename T >
std::decay< T >::type storages::postgres::Field::Coalesce ( const T &  default_val) const
inline

Convert the field's buffer into a C++ type. If the field is null, return default value.

Definition at line 282 of file result_set.hpp.

◆ Coalesce() [2/2]

template<typename T >
void storages::postgres::Field::Coalesce ( T &  val,
const T &  default_val 
) const
inline

Read the field's buffer into user-provided variable. If the field is null, set the variable to the default value.

Definition at line 262 of file result_set.hpp.

◆ FieldIndex()

size_type storages::postgres::Field::FieldIndex ( ) const
inline

Definition at line 233 of file result_set.hpp.

◆ ReadNullable() [1/2]

template<typename T >
size_type storages::postgres::Field::ReadNullable ( const io::FieldBuffer buffer,
T &&  val,
std::false_type   
) const
inlineprotected

Definition at line 311 of file result_set.hpp.

◆ ReadNullable() [2/2]

template<typename T >
size_type storages::postgres::Field::ReadNullable ( const io::FieldBuffer fb,
T &&  val,
std::true_type   
) const
inlineprotected

Definition at line 299 of file result_set.hpp.

◆ RowIndex()

size_type storages::postgres::Field::RowIndex ( ) const
inline

Definition at line 232 of file result_set.hpp.

◆ To()

template<typename T >
size_type storages::postgres::Field::To ( T &&  val) const
inline

Read the field's buffer into user-provided variable.

Exceptions
FieldValueIsNullIf the field is null and the C++ type is not nullable.

Definition at line 252 of file result_set.hpp.

Friends And Related Symbol Documentation

◆ Row

friend class Row
friend

Definition at line 293 of file result_set.hpp.


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