#include <userver/storages/postgres/result_set.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
Definition at line 399 of file result_set.hpp.
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 > | |
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) |
Definition at line 404 of file result_set.hpp.
Definition at line 405 of file result_set.hpp.
Definition at line 409 of file result_set.hpp.
Definition at line 408 of file result_set.hpp.
using storages::postgres::Row::size_type = std::size_t |
Definition at line 403 of file result_set.hpp.
Definition at line 407 of file result_set.hpp.
|
inlineprotected |
Definition at line 536 of file result_set.hpp.
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.
Definition at line 864 of file result_set.hpp.
std::tuple< T... > storages::postgres::Row::As | ( | const std::initializer_list< size_type > & | indexes | ) | const |
Definition at line 903 of file result_set.hpp.
std::tuple< T... > storages::postgres::Row::As | ( | const std::initializer_list< std::string > & | names | ) | const |
Definition at line 884 of file result_set.hpp.
|
inline |
Returns T initialized with a single column value of the row.
Definition at line 507 of file result_set.hpp.
|
inline |
Returns T initialized with values of the row.
Definition at line 498 of file result_set.hpp.
|
inline |
Definition at line 423 of file result_set.hpp.
|
inline |
Definition at line 425 of file result_set.hpp.
|
inline |
Definition at line 414 of file result_set.hpp.
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 |
Definition at line 430 of file result_set.hpp.
|
inline |
Definition at line 432 of file result_set.hpp.
|
inline |
Definition at line 412 of file result_set.hpp.
void storages::postgres::Row::To | ( | const std::initializer_list< size_type > & | indexes, |
T &&... | val ) const |
Read fields into variables in order of their indexes in the first argument
Definition at line 894 of file result_set.hpp.
void storages::postgres::Row::To | ( | const std::initializer_list< std::string > & | names, |
T &&... | val ) const |
Read fields into variables in order of their names in the first argument.
Definition at line 875 of file result_set.hpp.
void storages::postgres::Row::To | ( | T &&... | val | ) | const |
Read fields into variables in order of their appearance in the row.
Definition at line 855 of file result_set.hpp.
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.
Definition at line 815 of file result_set.hpp.
void storages::postgres::Row::To | ( | T && | val, |
FieldTag | ) const |
Function to disambiguate reading the first column to a user's composite type (PostgreSQL composite type in the row initializes user's type). The same as calling To(T&& val) for a T mapped to a PostgreSQL type.
Definition at line 840 of file result_set.hpp.
void storages::postgres::Row::To | ( | T && | val, |
RowTag | ) const |
Function to disambiguate reading the row to a user's row type (values of the row initialize user's type data members)
Definition at line 820 of file result_set.hpp.
|
friend |
Definition at line 532 of file result_set.hpp.