Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
Loading...
Searching...
No Matches
database::Row Class Reference

Represents a single row of a database result set. More...

#include <ResultSet.hpp>

Public Member Functions

 Row ()=default
 
 Row (std::vector< std::string > values, std::shared_ptr< std::unordered_map< std::string, size_t > > col_map)
 
std::optional< std::string > get (size_t index) const
 Gets a column value by index.
 
std::optional< std::string > get (const std::string &col_name) const
 Gets a column value by column name.
 
int as_int (const std::string &col_name, int default_val=0) const
 Helper to get a column value as an integer.
 
nlohmann::json to_json () const
 Serializes the row to a JSON object automatically. Tries to parse numbers and booleans from strings if possible (Task 52).
 

Detailed Description

Represents a single row of a database result set.

Constructor & Destructor Documentation

◆ Row() [1/2]

database::Row::Row ( )
default

◆ Row() [2/2]

database::Row::Row ( std::vector< std::string >  values,
std::shared_ptr< std::unordered_map< std::string, size_t > >  col_map 
)
inline

Member Function Documentation

◆ as_int()

int database::Row::as_int ( const std::string &  col_name,
int  default_val = 0 
) const
inline

Helper to get a column value as an integer.

◆ get() [1/2]

std::optional< std::string > database::Row::get ( const std::string &  col_name) const
inline

Gets a column value by column name.

Parameters
col_nameThe name of the column.
Returns
An optional containing the string value, or std::nullopt if not found or NULL.

◆ get() [2/2]

std::optional< std::string > database::Row::get ( size_t  index) const
inline

Gets a column value by index.

Parameters
indexThe zero-based column index.
Returns
An optional containing the string value, or std::nullopt if index is out of bounds or value is NULL.

◆ to_json()

nlohmann::json database::Row::to_json ( ) const
inline

Serializes the row to a JSON object automatically. Tries to parse numbers and booleans from strings if possible (Task 52).


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