Skip to content

Commit e8af4f6

Browse files
committed
Merge pull request SRombauts#51 from portwaypoint/master
Added support for extension loading
2 parents 318f742 + 368049a commit e8af4f6

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

include/SQLiteCpp/Database.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,25 @@ class Database
336336
apApp, apFunc, apStep, apFinal, apDestroy);
337337
}
338338

339+
340+
/**
341+
* @brief Load a module into the current sqlite database instance.
342+
*
343+
* This is the equivalent of the sqlite3_load_extension call, but additionally enables
344+
* module loading support prior to loading the requested module.
345+
*
346+
* @see http://www.sqlite.org/c3ref/load_extension.html
347+
*
348+
* @note UTF-8 text encoding assumed.
349+
*
350+
* @param[in] apExtensionName Name of the shared library containing extension
351+
* @param[in] apEntryPointName Name of the entry point (NULL to let sqlite work it out)
352+
*
353+
* @throw SQLite::Exception in case of error
354+
*/
355+
void loadExtension(const char* apExtensionName,
356+
const char *apEntryPointName);
357+
339358
private:
340359
/// @{ Database must be non-copyable
341360
Database(const Database&);

src/Database.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,18 @@ void Database::createFunction(const char* apFuncName,
151151
check(ret);
152152
}
153153

154+
// Load an extension into the sqlite database. Only affects the current connection.
155+
// Parameter details can be found here: http://www.sqlite.org/c3ref/load_extension.html
156+
void Database::loadExtension(const char* apExtensionName,
157+
const char *apEntryPointName)
158+
{
159+
int ret = sqlite3_enable_load_extension(mpSQLite, 1);
160+
161+
check(ret);
162+
163+
ret = sqlite3_load_extension(mpSQLite, apExtensionName, apEntryPointName, 0);
164+
165+
check(ret);
166+
}
154167

155168
} // namespace SQLite

0 commit comments

Comments
 (0)