53template<
typename ... Args>
56 template<std::
size_t N>
57 using element = mp11::mp_take_c<mp11::mp_list<Args...>, N>;
60 template<std::
size_t Idx>
61 void set(element<Idx>
value)
63 sqlite3_set_auxdata(ctx_, Idx, *
static_cast<void**
>(&
value),
67 delete_(
static_cast<element<Idx> *
>(ptr));
72 template<std::
size_t Idx>
73 auto get() -> element<Idx> &
75 using type = element<Idx> ;
76 auto p =
static_cast<type*
>(sqlite3_get_auxdata(ctx_, Idx));
78 detail::throw_invalid_argument(
"argument not set",
79 BOOST_CURRENT_LOCATION);
84 template<std::
size_t Idx>
85 auto get_if() -> element<Idx> *
87 using type = element<Idx> ;
88 return static_cast<type*
>(sqlite3_get_auxdata(ctx_, Idx));
92 explicit context(sqlite3_context * ctx) noexcept : ctx_(ctx) {}
96 auto set_result(T && val)
97#if !defined(BOOST_SQLITE_GENERATING_DOCS)
98 ->
decltype(detail::set_result(
static_cast<sqlite3_context*
>(
nullptr), std::forward<T>(val)))
101 detail::set_result(ctx_, std::forward<T>(val));
104 void set_error(
cstring_ref message,
int code = SQLITE_ERROR)
106 sqlite3_result_error(ctx_, message.c_str(), code);
109 connection get_connection()
const
111 return connection{sqlite3_context_db_handle(ctx_),
false};
115 sqlite3_context * ctx_;
209template<
typename Func>
210auto create_scalar_function(
214 ->
typename std::enable_if<
217 detail::create_scalar_function(
218 static_cast<sqlite3*
>(
nullptr), name,
219 std::declval<Func>())
220 ),
int>::value>::type
222 system::error_code ec;
223 create_scalar_function(conn, name, std::forward<Func>(func), ec);
225 detail::throw_error_code(ec,
226 BOOST_CURRENT_LOCATION);
279template<
typename Func>
280void create_aggregate_function(
284 system::error_code & ec,
287 using func_type =
typename std::decay<Func>::type;
288 auto res = detail::create_aggregate_function(
289 conn.handle(), name, std::forward<Func>(func),
290 callable_traits::has_void_return<
decltype(&func_type::step)>{}
294 BOOST_SQLITE_ASSIGN_EC(ec, res);
295 ei.set_message(sqlite3_errmsg(conn.handle()));
367template<
typename Func>
368void create_window_function(
372 system::error_code & ec)
374 using func_type =
typename std::decay<Func>::type;
375 auto res = detail::create_window_function(
376 conn.handle(), name, std::forward<Func>(func),
377 callable_traits::has_void_return<
decltype(&func_type::step)>{});
379 BOOST_SQLITE_ASSIGN_EC(ec, res);
A context that can be passed into scalar functions.