Merge pull request #51 from portwaypoint/master

Added support for extension loading
This commit is contained in:
Sébastien Rombauts 2015-05-13 12:23:35 +02:00
commit e8af4f6738
2 changed files with 32 additions and 0 deletions

View File

@ -336,6 +336,25 @@ public:
apApp, apFunc, apStep, apFinal, apDestroy); 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: private:
/// @{ Database must be non-copyable /// @{ Database must be non-copyable
Database(const Database&); Database(const Database&);

View File

@ -151,5 +151,18 @@ void Database::createFunction(const char* apFuncName,
check(ret); 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 } // namespace SQLite