Represents a single row of a database result set.
More...
#include <ResultSet.hpp>
|
| | 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).
|
| |
Represents a single row of a database result set.
◆ Row() [1/2]
◆ Row() [2/2]
| database::Row::Row |
( |
std::vector< std::string > |
values, |
|
|
std::shared_ptr< std::unordered_map< std::string, size_t > > |
col_map |
|
) |
| |
|
inline |
◆ 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_name | The 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
-
| index | The 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()
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: