boost_sqlite 1
A sqlite C++ library
Loading...
Searching...
No Matches
boost::sqlite::context< Args > Struct Template Reference

A context that can be passed into scalar functions. More...

#include <include/boost/sqlite/function.hpp>

Public Member Functions

template<std::size_t Idx>
auto get () -> element< Idx > &
 Returns the value in the context at position Idx. Throws if the value isn't set.
 
connection get_connection () const
 Returns the connection of the context.
 
template<std::size_t Idx>
auto get_if () -> element< Idx > *
 Returns the value in the context at position Idx. Returns nullptr .value isn't set.
 
template<std::size_t Idx>
void set (element< Idx > value)
 Set the value in the context at position Idx
 
void set_error (cstring_ref message, int code=SQLITE_ERROR)
 Set the an error through the context, instead of throwing it.
 
template<typename T >
auto set_result (T &&val)
 Set the result through the context, instead of returning it.
 

Detailed Description

template<typename ... Args>
struct boost::sqlite::context< Args >

A context that can be passed into scalar functions.

Template Parameters
ArgsThe argument that can be stored in the context.
extern sqlite::connection conn;
sqlite::create_function(
conn, "my_sum,,
[](sqlite::context<std::size_t> ctx,
boost::span<sqlite::value, 1u> args) -> std::size_t
{
auto value = args[0].get_int64();
auto p = ctx.get_if<0>();
if (p != nullptr) // increment the counter
return (*p) += value;
else // set the initial value
ctx.set<0>(value);
return value;
});
main object for a connection to a database.

Definition at line 53 of file function.hpp.


The documentation for this struct was generated from the following files: