ThinSQLite++ can be used in SQLite++ extensions.
To use it in an extension you need to either:
- Include
<sqlite3ext.h> and specify SQLITE_EXTENSION_INIT3 before including any of ThinSQLite++ headers. For example: #include <sqlite3ext.h>
SQLITE_EXTENSION_INIT3
#include <thinsqlitepp/database.hpp>
- Define
THINSQLITEPP_BUILDING_EXTENSION to 1 using your build system (or in code before including any ThinSQLite++ headers). For example: #define THINSQLITEPP_BUILDING_EXTENSION 1
#include <thinsqlitepp/database.hpp>
Either way achieves the same effect.
The extension's entry point should look similar to the below:
SQLITE_EXTENSION_INIT1
extern "C"
#if defined(_WIN32)
__declspec(dllexport)
#elif defined(__GNUC__)
[[gnu::visibility("default")]]
#endif
SQLITE_EXTENSION_INIT2(pApi);
try{
}
*pzErrMsg =
const_cast<char *
>(ex.
error().extract_message().release());
}
}
}
}
Database Connection.
Definition database_iface.hpp:108
Exception used to report any SQLite errors.
Definition exception_iface.hpp:166
int extended_error_code() const noexcept
Returns full extended error code of the stored error.
Definition exception_iface.hpp:201
const class error & error() const &noexcept
Returns the stored error.
Definition exception_iface.hpp:211
ThinSQLite++ namespace.
Definition backup_iface.hpp:17
Note that the first parameter of the sqlite3_extension_init can safely be declared as thinsqlitepp::database * rather than sqlite3 *. This is due to the fact that ThinSQLite++ classes are fake wrappers