32#ifndef GUARD_SQLITE_RESULT_HPP_INCLUDED
33#define GUARD_SQLITE_RESULT_HPP_INCLUDED
103 throw std::runtime_error(
"Invalid memory access");
115 throw std::runtime_error(
"Invalid memory access");
226 template <
typename T> T
get(
int idx);
236 template <
typename... Ts> std::tuple<Ts...>
get_tuple(
int start_column = 0);
255 template <
typename... Ts, std::size_t... Index>
257 return std::tuple<Ts...>(res.template get<Ts>(start +
static_cast<int>(Index))...);
270 auto micros = std::chrono::microseconds{
get_int64(idx)};
271 return std::chrono::duration_cast<decayed>(micros);
273 auto micros = std::chrono::microseconds{
get_int64(idx)};
274 auto duration = std::chrono::duration_cast<typename decayed::duration>(micros);
275 return decayed(duration);
276 }
else if constexpr (std::is_enum_v<decayed>) {
277 return static_cast<decayed
>(
get_int64(idx));
278 }
else if constexpr (std::is_integral_v<decayed> && !std::is_same_v<decayed, bool>) {
279 return static_cast<decayed
>(
get_int64(idx));
280 }
else if constexpr (std::is_same_v<decayed, bool>) {
282 }
else if constexpr (std::is_floating_point_v<decayed>) {
284 }
else if constexpr (std::is_same_v<decayed, std::string>) {
286 }
else if constexpr (std::is_same_v<decayed, std::string_view>) {
289 std::vector<unsigned char> buffer;
296 auto ptr =
reinterpret_cast<std::byte
const *
>(
blob.data());
297 return std::span<const std::byte>(ptr,
blob.size());
300 "Unsupported type for sqlite::result::get<T>");
305 if (start_column < 0 || start_column +
static_cast<int>(
sizeof...(Ts)) >
m_columns) {
Exception hierarchy mirroring common SQLite failure categories.
Defines the VSQLITE_DEPRECATED attribute for compilers supported by VSQLite++.
void reset(result_construct_params_private &)
std::remove_cvref_t< T > decay_t
bool end(result_construct_params_private const &)
constexpr bool is_time_point_v
constexpr bool is_byte_vector_v
constexpr bool is_optional_v
constexpr bool is_unsigned_char_span_v
constexpr bool always_false_v
constexpr bool is_duration_v
std::tuple< Ts... > tuple_from_row(result &res, int start, std::index_sequence< Index... >)
constexpr bool is_byte_span_v
std::shared_ptr< result > result_type
Shared-pointer alias used by legacy APIs that transfer result ownership.
std::variant< unknown_t, int, std::int64_t, long double, std::string, null_t, blob_ref_t > variant_t
Generic runtime failure raised for most SQLite errors.
query should be used to execute SQL queries An object of this class is not copyable
Forward-only cursor over the rows produced by a prepared statement.
bool end() const
Checks whether next_row already consumed the last row.
std::string_view get_string_view(int idx)
int get_changes()
Returns the number of rows affected by the statement.
double get_double(int idx)
void get_binary(int idx, void *buf, size_t buf_size)
Copies a blob column into the caller-provided buffer.
variant_t get_variant(int index)
Materializes the current value as variant_t.
~result()
Destroys the cursor but leaves the underlying statement intact if it is still shared.
T get(int idx)
Extracts the column at idx into an arbitrary C++ type.
type get_column_type(int idx)
Reports the SQLite storage class for the value at index idx.
bool is_null(int idx)
Tests whether the value at column idx is SQL NULL.
result(result const &)=delete
std::string get_column_decltype(int idx)
Returns the declared type of the column at index idx.
void get_binary(int idx, std::vector< unsigned char > &vec)
Retrieves a blob column into a std::vector<unsigned char>.
bool next_row()
Advances to the next row.
std::span< const unsigned char > get_binary_span(int idx)
Returns a span that references the blob contents without copying.
int get_column_count()
Returns the number of columns exposed by the current statement.
std::string get_column_name(int idx)
Returns the UTF-8 column name declared in the statement.
std::string get_string(int idx)
std::tuple< Ts... > get_tuple(int start_column=0)
Collects a contiguous slice of columns into a std::tuple.
size_t get_binary_size(int idx)
Reports the number of bytes stored in column idx.
result & operator=(result const &)=delete
void reset()
Resets the cursor to the beginning without re-binding parameters.
construct_params m_params
std::int64_t get_int64(int idx)
std::shared_ptr< result_construct_params_private > construct_params