|
VSQLite++ 0.3
|
Forward-only cursor over the rows produced by a prepared statement. More...
#include <result.hpp>

Public Member Functions | |
| ~result () | |
| Destroys the cursor but leaves the underlying statement intact if it is still shared. | |
| bool | next_row () |
| Advances to the next row. | |
| bool | end () const |
| Checks whether next_row already consumed the last row. | |
| void | reset () |
| Resets the cursor to the beginning without re-binding parameters. | |
| int | get_changes () |
| Returns the number of rows affected by the statement. | |
| int | get_column_count () |
| Returns the number of columns exposed by the current statement. | |
| type | get_column_type (int idx) |
Reports the SQLite storage class for the value at index idx. | |
| std::string | get_column_decltype (int idx) |
Returns the declared type of the column at index idx. | |
| variant_t | get_variant (int index) |
| Materializes the current value as variant_t. | |
| size_t | get_binary_size (int idx) |
Reports the number of bytes stored in column idx. | |
| void | get_binary (int idx, void *buf, size_t buf_size) |
| Copies a blob column into the caller-provided buffer. | |
| void | get_binary (int idx, std::vector< unsigned char > &vec) |
| Retrieves a blob column into a std::vector<unsigned char>. | |
| std::span< const unsigned char > | get_binary_span (int idx) |
| Returns a span that references the blob contents without copying. | |
| std::string | get_column_name (int idx) |
| Returns the UTF-8 column name declared in the statement. | |
| bool | is_null (int idx) |
Tests whether the value at column idx is SQL NULL. | |
| template<typename T> | |
| T | get (int idx) |
Extracts the column at idx into an arbitrary C++ type. | |
| template<typename... Ts> | |
| std::tuple< Ts... > | get_tuple (int start_column=0) |
| Collects a contiguous slice of columns into a std::tuple. | |
Private Types | |
| typedef std::shared_ptr< result_construct_params_private > | construct_params |
Private Member Functions | |
| result (construct_params) | |
| result (result const &)=delete | |
| result & | operator= (result const &)=delete |
| void | access_check (int) |
| int | get_int (int idx) |
| std::int64_t | get_int64 (int idx) |
| std::string | get_string (int idx) |
| std::string_view | get_string_view (int idx) |
| double | get_double (int idx) |
Private Attributes | |
| construct_params | m_params |
| int | m_columns |
Friends | |
| struct | query |
Forward-only cursor over the rows produced by a prepared statement.
Instances are created and owned by query and encapsulate the currently bound statement plus its execution state. The cursor is non-copyable, but it keeps the underlying resources alive through shared ownership until both the query and the result go out of scope.
Definition at line 75 of file result.hpp.
|
private |
Definition at line 77 of file result.hpp.
|
private |
Referenced by operator=(), and result().
|
privatedelete |
| sqlite::v2::result::~result | ( | ) |
Destroys the cursor but leaves the underlying statement intact if it is still shared.
|
private |
|
inline |
Checks whether next_row already consumed the last row.
| std::runtime_error | if the result is no longer valid. |
Definition at line 101 of file result.hpp.
References sqlite::v2::detail::end(), and m_params.

| T sqlite::v2::result::get | ( | int | idx | ) |
Extracts the column at idx into an arbitrary C++ type.
Supported conversions include:
| idx | Zero-based column index. |
| T | Desired destination type. |
| database_exception | or std::out_of_range when idx is invalid. |
| buffer_too_small_exception | if the requested type requires more space than available. |
Definition at line 261 of file result.hpp.
References sqlite::v2::detail::always_false_v, sqlite::v2::blob, get(), get_binary(), get_binary_span(), get_double(), get_int(), get_int64(), get_string(), get_string_view(), sqlite::v2::detail::is_byte_span_v, sqlite::v2::detail::is_byte_vector_v, sqlite::v2::detail::is_duration_v, is_null(), sqlite::v2::detail::is_optional_v, sqlite::v2::detail::is_time_point_v, and sqlite::v2::detail::is_unsigned_char_span_v.
Referenced by sqlite::v2::query::result_range::row_view::get(), sqlite::v2::query::result_range::row_view::get(), and get().

| void sqlite::v2::result::get_binary | ( | int | idx, |
| std::vector< unsigned char > & | vec ) |
Retrieves a blob column into a std::vector<unsigned char>.
| idx | Zero-based column index. |
| vec | Destination buffer that will be resized to match the blob length. |
| void sqlite::v2::result::get_binary | ( | int | idx, |
| void * | buf, | ||
| size_t | buf_size ) |
Copies a blob column into the caller-provided buffer.
| idx | Zero-based column index. |
| buf | Destination memory. |
| buf_size | Capacity of buf in bytes. |
| buffer_too_small_exception | when buf_size is smaller than the blob. |
Referenced by get().
| size_t sqlite::v2::result::get_binary_size | ( | int | idx | ) |
Reports the number of bytes stored in column idx.
| idx | Zero-based column index. |
| std::span< const unsigned char > sqlite::v2::result::get_binary_span | ( | int | idx | ) |
Returns a span that references the blob contents without copying.
The span becomes invalid as soon as the cursor advances or resets.
Referenced by get().
| int sqlite::v2::result::get_changes | ( | ) |
Returns the number of rows affected by the statement.
Mirrors sqlite3_changes() and therefore only applies to INSERT, UPDATE, or DELETE statements. To count the rows returned by a SELECT, issue a separate SELECT COUNT(*) ... query.
| int sqlite::v2::result::get_column_count | ( | ) |
Returns the number of columns exposed by the current statement.
| std::string sqlite::v2::result::get_column_decltype | ( | int | idx | ) |
Returns the declared type of the column at index idx.
The result mirrors sqlite3_column_decltype and therefore reflects the schema's declared affinity (e.g. "INTEGER" or "TEXT").
| std::string sqlite::v2::result::get_column_name | ( | int | idx | ) |
Returns the UTF-8 column name declared in the statement.
| idx | Zero-based column index. |
| type sqlite::v2::result::get_column_type | ( | int | idx | ) |
Reports the SQLite storage class for the value at index idx.
| idx | Zero-based column index. |
| std::out_of_range | when idx is outside [0, get_column_count()). |
|
private |
Referenced by get().
|
private |
Referenced by get().
|
private |
Referenced by get().
|
private |
Referenced by get().
|
private |
Referenced by get().
| std::tuple< Ts... > sqlite::v2::result::get_tuple | ( | int | start_column = 0 | ) |
Collects a contiguous slice of columns into a std::tuple.
| start_column | First column to include; defaults to 0. |
| Ts | Types to extract, matched positionally from start_column. |
| database_exception | when the tuple would exceed the column count. |
Definition at line 304 of file result.hpp.
References m_columns, and sqlite::v2::detail::tuple_from_row().

| variant_t sqlite::v2::result::get_variant | ( | int | index | ) |
Materializes the current value as variant_t.
| index | Zero-based column index. |
| bool sqlite::v2::result::is_null | ( | int | idx | ) |
Tests whether the value at column idx is SQL NULL.
| idx | Zero-based column index. |
Referenced by get().
| bool sqlite::v2::result::next_row | ( | ) |
Advances to the next row.
| std::runtime_error | if the underlying statement was already destroyed. |
|
inline |
Resets the cursor to the beginning without re-binding parameters.
Use this when you need to re-iterate the same result set after calling next_row.
| std::runtime_error | if the result is no longer valid. |
Definition at line 113 of file result.hpp.
References m_params, and sqlite::v2::detail::reset().

|
friend |
|
private |
Definition at line 248 of file result.hpp.
Referenced by get_tuple().
|
private |
Definition at line 247 of file result.hpp.