From efcea3a80da7c4479d5fe168435ecc9fd06bdc72 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sun, 14 Sep 2025 00:16:10 -0400 Subject: Squashed 'subprojects/boost-sqlite/' content from commit 3378e35 git-subtree-dir: subprojects/boost-sqlite git-subtree-split: 3378e353705271e569cf4ba15c467b840a39798c --- doc/reference/extension.adoc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 doc/reference/extension.adoc (limited to 'doc/reference/extension.adoc') diff --git a/doc/reference/extension.adoc b/doc/reference/extension.adoc new file mode 100644 index 0000000..7ee2500 --- /dev/null +++ b/doc/reference/extension.adoc @@ -0,0 +1,36 @@ +== `sqlite/extension.hpp` + +=== `BOOST_SQLITE_EXTENSION` + + This macro can be used to create an sqlite extension. + +.Definition +[source,cpp] +---- +#define BOOST_SQLITE_EXTENSION(Name, Conn) +---- + +Name:: The name of the module. +Conn:: The parameter name of the connection. + + +NOTE: When defining BOOST_SQLITE_COMPILE_EXTENSION (was is done in extension.hpp) +sqlite will use an inline namespace to avoid symbol clashes. + +You must link against `Boost::sqlite_ext` and not `Boost::sqlite` and should not mix both in the same binary. + +.Example +[source,cpp] +---- +BOOST_SQLITE_EXTENSION(extension, conn) +{ + create_scalar_function( + conn, "assert", + [](boost::sqlite::context<>, boost::span sp) + { + if (sp.front().get_int() == 0) + throw std::logic_error("assertion failed"); + }); +} +---- + -- cgit v1.2.3