Added support for extension loading

This commit is contained in:
Richard Jones 2015-05-08 09:47:12 +01:00
parent 318f742b5c
commit 368049a613
2 changed files with 32 additions and 0 deletions

View File

@ -336,6 +336,25 @@ public:
apApp, apFunc, apStep, apFinal, apDestroy);
}
/**
* @brief Load a module into the current sqlite database instance.
*
* This is the equivalent of the sqlite3_load_extension call, but additionally enables
* module loading support prior to loading the requested module.
*
* @see http://www.sqlite.org/c3ref/load_extension.html
*
* @note UTF-8 text encoding assumed.
*
* @param[in] apExtensionName Name of the shared library containing extension
* @param[in] apEntryPointName Name of the entry point (NULL to let sqlite work it out)
*
* @throw SQLite::Exception in case of error
*/
void loadExtension(const char* apExtensionName,
const char *apEntryPointName);
private:
/// @{ Database must be non-copyable
Database(const Database&);

View File

@ -151,5 +151,18 @@ void Database::createFunction(const char* apFuncName,
check(ret);
}
// Load an extension into the sqlite database. Only affects the current connection.
// Parameter details can be found here: http://www.sqlite.org/c3ref/load_extension.html
void Database::loadExtension(const char* apExtensionName,
const char *apEntryPointName)
{
int ret = sqlite3_enable_load_extension(mpSQLite, 1);
check(ret);
ret = sqlite3_load_extension(mpSQLite, apExtensionName, apEntryPointName, 0);
check(ret);
}
} // namespace SQLite