#include <userver/storages/postgres/row.hpp>
Data row in a result set This class is a mere accessor to underlying result set data buffer, must not be used outside of result set life scope.
Mimics field container
Public Member Functions | |
Field container interface | |
size_type | Size () const |
Number of fields. | |
Forward iteration | |
const_iterator | cbegin () const |
const_iterator | begin () const |
const_iterator | cend () const |
const_iterator | end () const |
Reverse iteration | |
const_reverse_iterator | crbegin () const |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | crend () const |
const_reverse_iterator | rend () const |
reference | operator[] (size_type index) const |
Field access by index. | |
reference | operator[] (const std::string &name) const |
Field access field by name. | |
Field container concept | |
using | size_type = std::size_t |
using | const_iterator = ConstFieldIterator |
using | const_reverse_iterator = ReverseConstFieldIterator |
using | value_type = Field |
using | reference = Field |
using | pointer = const_iterator |
size_type | RowIndex () const |
RowDescription | GetDescription () const |
Access to row's data | |
class | ResultSet |
template<typename T, typename Tag> | |
class | TypedResultSet |
template<typename T> | |
void | To (T &&val) const |
template<typename T> | |
void | To (T &&val, RowTag) const |
template<typename T> | |
void | To (T &&val, FieldTag) const |
template<typename... T> | |
void | To (T &&... val) const |
Read fields into variables in order of their appearance in the row. | |
template<typename T, typename... Y> | |
auto | As () const |
Parse values from the row and return the result. | |
template<typename T> | |
T | As (RowTag) const |
Returns T initialized with values of the row. | |
template<typename T> | |
T | As (FieldTag) const |
Returns T initialized with a single column value of the row. | |
template<typename... T> | |
void | To (const std::initializer_list< std::string > &names, T &&... val) const |
Read fields into variables in order of their names in the first argument. | |
template<typename... T> | |
std::tuple< T... > | As (const std::initializer_list< std::string > &names) const |
template<typename... T> | |
void | To (const std::initializer_list< size_type > &indexes, T &&... val) const |
template<typename... T> | |
std::tuple< T... > | As (const std::initializer_list< size_type > &indexes) const |
size_type | IndexOfName (const std::string &) const |
FieldView | GetFieldView (size_type index) const |
Row (detail::ResultWrapperPtr res, size_type row) | |
Iteration support | |
bool | IsValid () const |
int | Compare (const Row &rhs) const |
std::ptrdiff_t | Distance (const Row &rhs) const |
Row & | Advance (std::ptrdiff_t) |
|
inlineprotected |
auto storages::postgres::Row::As | ( | ) | const |
Parse values from the row and return the result.
If there are more than one type arguments to the function, it will return a tuple of those types.
If there is a single type argument to the function, it will read the first and the only column of the row or the whole row to the row type (depending on C++ to PosgreSQL mapping presence) and return plain value of this type.
std::tuple< T... > storages::postgres::Row::As | ( | const std::initializer_list< size_type > & | indexes | ) | const |
std::tuple< T... > storages::postgres::Row::As | ( | const std::initializer_list< std::string > & | names | ) | const |
|
inline |
Returns T initialized with a single column value of the row.
|
inline |
Returns T initialized with values of the row.
|
inline |
|
inline |
|
inline |
reference storages::postgres::Row::operator[] | ( | const std::string & | name | ) | const |
Field access field by name.
FieldNameDoesntExist | if the result set doesn't contain such a field |
reference storages::postgres::Row::operator[] | ( | size_type | index | ) | const |
Field access by index.
FieldIndexOutOfBounds | if index is out of bounds |
|
inline |
|
inline |
void storages::postgres::Row::To | ( | const std::initializer_list< size_type > & | indexes, |
T &&... | val ) const |
void storages::postgres::Row::To | ( | const std::initializer_list< std::string > & | names, |
T &&... | val ) const |
void storages::postgres::Row::To | ( | T &&... | val | ) | const |
void storages::postgres::Row::To | ( | T && | val | ) | const |
Read the contents of the row to a user's row type or read the first column into the value.
If the user tries to read the first column into a variable, it must be the only column in the result set. If the result set contains more than one column, the function will throw NonSingleColumnResultSet. If the result set is OK to contain more than one columns, the first column value should be accessed via row[0].To/As
.
If the type is a 'row' type, the function will read the fields of the row into the type's data members.
If the type can be treated as both a row type and a composite type (the type is mapped to a PostgreSQL type), the function will treat the type as a type for the first (and the only) column.
To read the all fields of the row as a row type, the To(T&&, RowTag) should be used.
void storages::postgres::Row::To | ( | T && | val, |
FieldTag | ) const |
void storages::postgres::Row::To | ( | T && | val, |
RowTag | ) const |
|
friend |