relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
Loading...
Searching...
No Matches
relx::result::Row Class Reference

Represents a single row from a database result. More...

#include <relx/results/result.hpp>

Public Member Functions

 Row (std::vector< Cell > cells, std::vector< std::string > column_names={})
 Constructs a row with cells and column names.
 
ResultProcessingResult< const Cell * > get_cell (size_t index) const
 Get a cell by index.
 
ResultProcessingResult< const Cell * > get_cell (const std::string &name) const
 Get a cell by column name.
 
template<typename T >
ResultProcessingResult< T > get (size_t index) const
 Get a typed value by index.
 
template<typename T >
ResultProcessingResult< T > get (size_t index, bool allow_numeric_bools) const
 Get a typed value by index with allow_numeric_bools.
 
template<typename T >
ResultProcessingResult< T > get (const std::string &name) const
 Get a typed value by column name.
 
template<typename T >
ResultProcessingResult< T > get (const std::string &name, bool allow_numeric_bools) const
 Get a typed value by column name with allow_numeric_bools.
 
template<typename T , typename ColType >
ResultProcessingResult< T > get (const ColType &column) const
 Get a typed value using a schema column object.
 
template<typename T , typename ColType >
ResultProcessingResult< T > get (const ColType &column, bool allow_numeric_bools) const
 Get a typed value using a schema column object with allow_numeric_bools.
 
template<auto MemberPtr>
auto get () const
 Get a typed value using a member pointer.
 
template<auto MemberPtr>
auto get_optional () const
 Get an optional typed value using a member pointer.
 
size_t size () const
 Get the number of cells in this row.
 
const std::vector< std::string > & column_names () const
 Get the column names.
 
std::string to_string () const
 

Detailed Description

Represents a single row from a database result.

Definition at line 349 of file result.hpp.

Constructor & Destructor Documentation

◆ Row()

relx::result::Row::Row ( std::vector< Cell cells,
std::vector< std::string >  column_names = {} 
)
inlineexplicit

Constructs a row with cells and column names.

Parameters
cellsThe raw cell values
column_namesThe column names (optional)

Definition at line 354 of file result.hpp.

Member Function Documentation

◆ column_names()

const std::vector< std::string > & relx::result::Row::column_names ( ) const
inline

Get the column names.

Returns
The column names (may be empty)

Definition at line 531 of file result.hpp.

◆ get() [1/7]

template<auto MemberPtr>
auto relx::result::Row::get ( ) const
inline

Get a typed value using a member pointer.

Template Parameters
MemberPtrPointer to a class member
Returns
The parsed value

Definition at line 497 of file result.hpp.

◆ get() [2/7]

template<typename T , typename ColType >
ResultProcessingResult< T > relx::result::Row::get ( const ColType &  column) const
inline

Get a typed value using a schema column object.

Template Parameters
TThe target C++ type
ColTypeThe column type
Parameters
columnThe column object
Returns
The parsed value

Definition at line 440 of file result.hpp.

◆ get() [3/7]

template<typename T , typename ColType >
ResultProcessingResult< T > relx::result::Row::get ( const ColType &  column,
bool  allow_numeric_bools 
) const
inline

Get a typed value using a schema column object with allow_numeric_bools.

Template Parameters
TThe target C++ type
ColTypeThe column type
Parameters
columnThe column object
allow_numeric_boolsWhether to allow integers (0/1) to be converted to booleans
Returns
The parsed value

Definition at line 451 of file result.hpp.

◆ get() [4/7]

template<typename T >
ResultProcessingResult< T > relx::result::Row::get ( const std::string &  name) const
inline

Get a typed value by column name.

Template Parameters
TThe target C++ type
Parameters
nameThe name of the column
Returns
The parsed value

Definition at line 416 of file result.hpp.

◆ get() [5/7]

template<typename T >
ResultProcessingResult< T > relx::result::Row::get ( const std::string &  name,
bool  allow_numeric_bools 
) const
inline

Get a typed value by column name with allow_numeric_bools.

Template Parameters
TThe target C++ type
Parameters
nameThe name of the column
allow_numeric_boolsWhether to allow integers (0/1) to be converted to booleans
Returns
The parsed value

Definition at line 426 of file result.hpp.

◆ get() [6/7]

template<typename T >
ResultProcessingResult< T > relx::result::Row::get ( size_t  index) const
inline

Get a typed value by index.

Template Parameters
TThe target C++ type
Parameters
indexThe zero-based index of the cell
Returns
The parsed value

Definition at line 393 of file result.hpp.

◆ get() [7/7]

template<typename T >
ResultProcessingResult< T > relx::result::Row::get ( size_t  index,
bool  allow_numeric_bools 
) const
inline

Get a typed value by index with allow_numeric_bools.

Template Parameters
TThe target C++ type
Parameters
indexThe zero-based index of the cell
allow_numeric_boolsWhether to allow integers (0/1) to be converted to booleans
Returns
The parsed value

Definition at line 403 of file result.hpp.

◆ get_cell() [1/2]

ResultProcessingResult< const Cell * > relx::result::Row::get_cell ( const std::string &  name) const
inline

Get a cell by column name.

Parameters
nameThe name of the column
Returns
The cell for the specified column

Definition at line 370 of file result.hpp.

◆ get_cell() [2/2]

ResultProcessingResult< const Cell * > relx::result::Row::get_cell ( size_t  index) const
inline

Get a cell by index.

Parameters
indexThe zero-based index of the cell
Returns
The cell at the specified index

Definition at line 360 of file result.hpp.

◆ get_optional()

template<auto MemberPtr>
auto relx::result::Row::get_optional ( ) const
inline

Get an optional typed value using a member pointer.

Template Parameters
MemberPtrPointer to a class member
Returns
The parsed value as an optional

Definition at line 513 of file result.hpp.

◆ size()

size_t relx::result::Row::size ( ) const
inline

Get the number of cells in this row.

Returns
The number of cells

Definition at line 527 of file result.hpp.

◆ to_string()

std::string relx::result::Row::to_string ( ) const
inline

Definition at line 533 of file result.hpp.


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