summaryrefslogtreecommitdiff
path: root/subprojects/boost-sqlite/doc/reference/extension.adoc
blob: 7ee250074e39d5000b4a6a0cbfafd4f7dfb8eece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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<boost::sqlite::value, 1u> sp)
    {
        if (sp.front().get_int() == 0)
          throw std::logic_error("assertion failed");
    });
}
----