SQL result representation. More...
#include <resultSet.hpp>
Public Member Functions | |
| ResultSet () noexcept | |
| virtual | ~ResultSet () noexcept |
| template<typename T> | |
| bool | get (std::size_t idx, T &out) |
| template<typename T> | |
| bool | get (const std::string field, T &out) |
| template<typename T> | |
| std::optional< T > | get (std::size_t idx) |
| template<typename T> | |
| const std::optional< T > | get (const std::string field) |
| virtual bool | next ()=0 |
Protected Member Functions | |
| virtual bool | getValue (std::size_t idx, std::string &out)=0 |
| virtual std::optional< std::string > | getValue (std::size_t idx)=0 |
| virtual const anch::date::DateFormatter & | getDateFormatter ()=0 |
| virtual const anch::date::DateFormatter & | getTimeFormatter ()=0 |
| virtual const anch::date::DateFormatter & | getTimestampFormatter ()=0 |
| const anch::date::DateFormatter & | getDefaultDateFormatter () |
| const anch::date::DateFormatter & | getDefaultTimeFormatter () |
| const anch::date::DateFormatter & | getDefaultTimestampFormatter () |
Protected Attributes | |
| std::map< std::string, std::size_t > | _fields |
SQL result representation.
The ResultSet has to be used with while(res.hasNext()) {res.next(); [...]}.
Field getter is templated. Specializations are included in library. If you need other conversions, you can implement them in your own program.
|
noexcept |
ResultSet default constructor
|
virtualnoexcept |
|
inline |
Get field value by field name.
| T | expected type |
| field | the field name |
| SqlException | any error |
|
inline |
Get field value by field name.
The output parameter will be set only if SQL result is not NULL.
| T | expected type |
| field | the field name |
| out | the result |
true if result is NULL, false otherwise | std::optional< T > anch::sql::ResultSet::get | ( | std::size_t | idx | ) |
Get field value by index.
| T | expected type |
| idx | the index |
| SqlException | any error |
| bool anch::sql::ResultSet::get | ( | std::size_t | idx, |
| T & | out ) |
Get field value by index.
The output parameter will be set only if SQL result is not NULL.
| T | expected type |
| idx | the index |
| out | the result |
true if result is NULL, false otherwise| SqlException | any error |
|
protectedpure virtual |
Retrieve SQL date formatter
Implemented in anch::sql::MySQLPreparedStatementResultSet, anch::sql::MySQLResultSet, anch::sql::PostgreSQLResultSet, and anch::sql::SQLite3ResultSet.
|
protected |
Retrieve SQL date formatter
|
protected |
Retrieve SQL time formatter
|
protected |
Retrieve SQL timestamp formatter
|
protectedpure virtual |
Retrieve SQL time formatter
Implemented in anch::sql::MySQLPreparedStatementResultSet, anch::sql::MySQLResultSet, anch::sql::PostgreSQLResultSet, and anch::sql::SQLite3ResultSet.
|
protectedpure virtual |
Retrieve SQL timestamp formatter
Implemented in anch::sql::MySQLPreparedStatementResultSet, anch::sql::MySQLResultSet, anch::sql::PostgreSQLResultSet, and anch::sql::SQLite3ResultSet.
|
protectedpure virtual |
Retrieve string value from result set according to SQL database engine.
| idx | the field index |
| SqlException | any error |
Implemented in anch::sql::MySQLPreparedStatementResultSet, anch::sql::MySQLResultSet, anch::sql::PostgreSQLResultSet, and anch::sql::SQLite3ResultSet.
|
protectedpure virtual |
Retrieve string value from result set according to SQL database engine.
| idx | the field index |
| out | the result |
| SqlException | any error |
Implemented in anch::sql::MySQLPreparedStatementResultSet, anch::sql::MySQLResultSet, anch::sql::PostgreSQLResultSet, and anch::sql::SQLite3ResultSet.
|
pure virtual |
Retrieve next row
true if next row exists, false otherwise| SqlException | any error |
Implemented in anch::sql::MySQLPreparedStatementResultSet, anch::sql::MySQLResultSet, anch::sql::PostgreSQLResultSet, and anch::sql::SQLite3ResultSet.
|
protected |
Result set fields