19 result = sqlite3_value_int(&value) != 0;
24 result = sqlite3_value_int(&value);
29 result = std::max({}, sqlite3_value_int(&value));
34 if (
sizeof(
long) ==
sizeof(
int))
35 result = sqlite3_value_int(&value);
37 result = sqlite3_value_int64(&value);
42 if (
sizeof(
unsigned long) ==
sizeof(
int))
43 result = std::max({}, sqlite3_value_int(&value));
45 result = std::max({}, sqlite3_value_int64(&value));
50 result = sqlite3_value_int64(&value);
55 result = std::max({}, sqlite3_value_int64(&value));
60 result = sqlite3_value_double(&value);
65 result =
static_cast<float>(sqlite3_value_double(&value));
70 const auto* text =
reinterpret_cast<const char*
>(sqlite3_value_text(&value));
71 const auto length = sqlite3_value_bytes(&value);
73 result.assign(text, length);
78 const auto* text =
reinterpret_cast<const char*
>(sqlite3_value_text(&value));
79 const auto length = sqlite3_value_bytes(&value);
81 result = std::string_view(text, length);
86 sqlite3_result_int(context, value ? 1 : 0);
91 sqlite3_result_int(context, value);
96 sqlite3_result_int(context, value);
101 if (
sizeof(
long) ==
sizeof(
int))
102 sqlite3_result_int(context, value);
104 sqlite3_result_int64(context, value);
109 if (
sizeof(
long) ==
sizeof(
int))
110 sqlite3_result_int(context, value);
112 sqlite3_result_int64(context, value);
117 sqlite3_result_int64(context, value);
122 sqlite3_result_int64(context, value);
127 sqlite3_result_double(context, value);
132 sqlite3_result_double(context, value);
137 sqlite3_result_text(context, value.c_str(), value.size(), SQLITE_TRANSIENT);
141 sqlite3_context* context,
const std::string_view& value)
143 sqlite3_result_text(context, value.data(), value.size(), SQLITE_TRANSIENT);
147 sqlite3_context* context,
const std::string_view& error)
149 sqlite3_result_error(context, error.data(), error.size());
156 *
this = std::move(rhs);
172 sqlite3_create_function(
174 nullptr,
nullptr,
nullptr);
180 sqlite3_create_function (
186 sqlite3_context* context,
int argc, sqlite3_value**
argv)
188 auto* function =
static_cast<ScalarFunction*
>(sqlite3_user_data(context));
194 sqlite3_create_function (
200 sqlite3_context* context,
int argc, sqlite3_value**
argv)
214 *
this = std::move(rhs);
221 std::swap(mStepFunctor, rhs.mStepFunctor);
222 std::swap(mFinalFunctor, rhs.mFinalFunctor);
231 sqlite3_create_function (
233 nullptr,
nullptr,
nullptr);
A class representing an aggregate function in a SQLite database.
details::SQLiteFunctor mFinalFunctor
AggregateFunction & operator=(const AggregateFunction &)=delete
void Register(std::size_t arity)
static void CallStepFunction(sqlite3_context *context, int argc, sqlite3_value **argv)
details::SQLiteFunctorWithArgs mStepFunctor
static void CallFinalFunction(sqlite3_context *context)
AggregateFunction()=default
A class representing a scalar function in a SQLite database.
details::SQLiteFunctorWithArgs mFunctor
static void CallFunction(sqlite3_context *context, int argc, sqlite3_value **argv)
void Register(std::size_t arity)
ScalarFunction & operator=(const ScalarFunction &)=delete
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
void FromSQLiteValue(sqlite3_value &value, bool &result)
void SetSQLiteFunctionError(sqlite3_context *context, const std::string_view &error)
void SetSQLiteFunctionResult(sqlite3_context *context, bool value)