boost_sqlite 1
A sqlite C++ library
Loading...
Searching...
No Matches
extension.hpp
1//
2// Copyright (c) 2022 Klemens Morgenstern (klemens.morgenstern@gmx.net)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BOOST_SQLITE_EXTENSION_HPP
9#define BOOST_SQLITE_EXTENSION_HPP
10
11#define BOOST_SQLITE_COMPILE_EXTENSION 1
12#include <boost/sqlite/detail/config.hpp>
13#include <boost/sqlite/connection.hpp>
14#include <boost/sqlite/detail/catch.hpp>
15#include <boost/config.hpp>
16
17
47#define BOOST_SQLITE_EXTENSION(Name, Conn) \
48void sqlite_##Name##_impl (boost::sqlite::connection Conn); \
49extern "C" BOOST_SYMBOL_EXPORT \
50int sqlite3_##Name##_init( \
51 sqlite3 *db, \
52 char **pzErrMsg, \
53 const sqlite3_api_routines *pApi) \
54{ \
55 using boost::sqlite::sqlite3_api; \
56 SQLITE_EXTENSION_INIT2(pApi); \
57 \
58 BOOST_SQLITE_TRY \
59 { \
60 sqlite_##Name##_impl(boost::sqlite::connection{db, false}); \
61 return SQLITE_OK; \
62 } \
63 BOOST_SQLITE_CATCH_ASSIGN_STR_AND_RETURN(*pzErrMsg); \
64} \
65void sqlite_##Name##_impl(boost::sqlite::connection Conn)
66
67#endif //BOOST_SQLITE_EXTENSION_HPP