ThinSQLite++
A thin, safe and convenient modern C++ wrapper for SQLite API.
|
SQL Function Context Object. More...
Public Member Functions | |
~context () noexcept=delete | |
Contexts are never destroyed by user code. | |
void * | aggregate_context (int size) noexcept |
Allocate memory for aggregate function context. | |
class database & | database () const noexcept |
Retrieve database connection for the context. | |
void | error (const std::string_view &value) noexcept |
Cause the implemented SQL function to throw an SQL exception. | |
void | error (const std::u8string_view &value) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | error (int error_code) noexcept |
Changes the error code returned by function evaluation. | |
void | error_nomem () noexcept |
Causes the implemented SQL function to throw an SQL exception indicating that a memory allocation failed. | |
void | error_toobig () noexcept |
Causes the implemented SQL function to throw an SQL exception indicating that a string or BLOB is too long to represent. | |
void | result (std::nullptr_t) noexcept |
Return NULL from the implemented SQL function. | |
void | result (int value) noexcept |
Return an int from the implemented SQL function. | |
void | result (int64_t value) noexcept |
Return an int64_t from implemented SQL function. | |
void | result (double value) noexcept |
Return a double from implemented SQL function. | |
void | result (const std::string_view &value) noexcept |
Return a string by value from the implemented SQL function. | |
void | result (const std::u8string_view &value) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | result_reference (const std::string_view &value) noexcept |
Return a string by reference from the implemented SQL function. | |
void | result_reference (const std::u8string_view &value) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | result_reference (const std::string_view &value, void(*unref)(const char *)) noexcept |
Return a string by reference from the implemented SQL function. | |
void | result_reference (const std::u8string_view &value, void(*unref)(const char8_t *)) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | result (const blob_view &value) noexcept |
Return a blob by value from the implemented SQL function. | |
void | result_reference (const blob_view &value) noexcept |
Return a blob by reference from the implemented SQL function. | |
void | result_reference (const blob_view &value, void(*unref)(const std::byte *) noexcept) noexcept |
Return a blob by reference from the implemented SQL function. | |
void | result (const zero_blob &value) noexcept |
Return a blob of zeroes from the implemented SQL function. | |
template<class T > | |
void | result (T *ptr, const char *type, void(*destroy)(T *)) noexcept |
| |
template<class T > | |
void | result (std::unique_ptr< T > ptr) noexcept |
Return a custom pointer from the implemented SQL function. | |
void | result (const value &val) noexcept |
Return a copy of the passed value from the implemented SQL function. | |
void | result_subtype (unsigned value) noexcept |
Sets the subtype of the result of the implemented SQL function. | |
template<class T > | |
T * | get_auxdata (int arg) const noexcept |
Get auxiliary data associated with argument values. | |
template<class T > | |
void | set_auxdata (int arg, T *data, void(*destroy)(T *) noexcept) noexcept |
Associate auxiliary data with argument values. | |
template<class T > | |
T * | user_data () noexcept |
Return the function's user data. | |
bool | vtab_nochange () const noexcept |
Return if a value being fetched as part of an UPDATE operation during which the column value will not change. | |
void | operator delete (void *) noexcept |
Operator delete for a fake pointer is no-op. | |
sqlite3_context * | c_ptr () const noexcept |
Access the real underlying SQLite type. | |
Static Public Member Functions | |
static context * | from (sqlite3_context *obj) noexcept |
Create fake pointer from the underlying SQLite one. | |
SQL Function Context Object.
This is a fake wrapper class for sqlite3_context.
#include <thinsqlitepp/context.hpp>
|
inlinenoexcept |
Allocate memory for aggregate function context.
Equivalent to sqlite3_aggregate_context
Retrieve database connection for the context.
Equivalent to sqlite3_aggregate_context
|
inlinenoexcept |
Cause the implemented SQL function to throw an SQL exception.
Equivalent to sqlite3_result_error
|
inlinenoexcept |
Changes the error code returned by function evaluation.
Equivalent to sqlite3_result_error_code
This call is useful to propagate SQLite error codes out of function evaluation. Note that calling error(const std::string_view &) after this call will reset error code to SQLITE_ERROR
|
inlinenoexcept |
Causes the implemented SQL function to throw an SQL exception indicating that a memory allocation failed.
Equivalent to sqlite3_result_error_nomem
|
inlinenoexcept |
Causes the implemented SQL function to throw an SQL exception indicating that a string or BLOB is too long to represent.
Equivalent to sqlite3_result_error_toobig
|
inlinenoexcept |
Return NULL from the implemented SQL function.
Equivalent to sqlite3_result_null
|
inlinenoexcept |
Return an int from the implemented SQL function.
Equivalent to sqlite3_result_int
|
inlinenoexcept |
Return an int64_t from implemented SQL function.
Equivalent to sqlite3_result_int64
|
inlinenoexcept |
Return a double from implemented SQL function.
Equivalent to sqlite3_result_double
|
inlinenoexcept |
Return a string by value from the implemented SQL function.
Equivalent to ::sqlite3_result_text(..., SQLITE_TRANSIENT)
The string content is copied and does not need to persist.
|
inlinenoexcept |
Return a string by reference from the implemented SQL function.
Equivalent to ::sqlite3_result_text(..., SQLITE_STATIC)
The string content is used by reference and so must be present in memory as long as SQLite library remain used.
|
inlinenoexcept |
Return a string by reference from the implemented SQL function.
Equivalent to ::sqlite3_result_text(..., unref)
The string content is used by reference.
value | reference to string to return |
unref | called when the reference is no longer needed. Its argument will be the pointer returned from value.data() |
|
inlinenoexcept |
Return a blob by value from the implemented SQL function.
Equivalent to ::sqlite3_result_blob(..., SQLITE_TRANSIENT)
The blob content is copied and does not need to persist.
|
inlinenoexcept |
Return a blob by reference from the implemented SQL function.
Equivalent to ::sqlite3_result_blob(..., SQLITE_STATIC)
The blob content is used by reference and so must be present in memory as long as SQLite library remain used.
|
inlinenoexcept |
Return a blob by reference from the implemented SQL function.
Equivalent to ::sqlite3_result_blob(..., unref)
The blob content is used by reference.
value | reference to blob to return |
unref | called when the reference is no longer needed. Its argument is the pointer returned from value.data() |
|
inlinenoexcept |
Return a blob of zeroes from the implemented SQL function.
Equivalent to sqlite3_result_zeroblob()
|
inlinenoexcept |
|
inlinenoexcept |
Return a custom pointer from the implemented SQL function.
Equivalent to sqlite3_result_pointer()
This is a safer overload of result(T * , const char * , void( * )(T * )) that takes a pointer via std::unique_ptr ownership transfer. The inferred "type" for sqlite3_result_pointer is typeid(T).name()
.
|
inlinenoexcept |
Return a copy of the passed value from the implemented SQL function.
Equivalent to sqlite3_result_value
|
inlinenoexcept |
Sets the subtype of the result of the implemented SQL function.
Equivalent to sqlite3_result_subtype
|
inlinenoexcept |
Get auxiliary data associated with argument values.
Equivalent to sqlite3_get_auxdata
T | type of the data |
|
inlinenoexcept |
Associate auxiliary data with argument values.
Equivalent to sqlite3_set_auxdata
T | type of the data |
|
inlinenoexcept |
Return the function's user data.
Equivalent to sqlite3_user_data
User data can be associated with a function during creation.
|
inlinenoexcept |
Return if a value being fetched as part of an UPDATE operation during which the column value will not change.
Equivalent to sqlite3_vtab_nochange