From 95143f4028efb896348008dc4cf4ce2d5925f720 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 6 Sep 2012 14:36:20 +0200 Subject: Add ability to specify SQLite vfs module in database constructor --- odb/sqlite/connection.cxx | 6 +++++- odb/sqlite/database.cxx | 4 ++++ odb/sqlite/database.hxx | 10 +++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'odb/sqlite') diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 38f622d..22955b4 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -48,8 +48,12 @@ namespace odb if ((f & SQLITE_OPEN_FULLMUTEX) == 0) f |= SQLITE_OPEN_NOMUTEX; + const string& vfs (db.vfs ()); + sqlite3* h (0); - int e (sqlite3_open_v2 (n.c_str (), &h, f, 0)); + int e ( + sqlite3_open_v2 ( + n.c_str (), &h, f, (vfs.empty () ? 0 : vfs.c_str ()))); handle_.reset (h); if (e != SQLITE_OK) diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 74c32d1..bf2d8dd 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -29,10 +29,12 @@ namespace odb database (const string& name, int flags, bool foreign_keys, + const string& vfs, transfer_ptr factory) : name_ (name), flags_ (flags), foreign_keys_ (foreign_keys), + vfs_ (vfs), factory_ (factory.transfer ()) { if (!factory_) @@ -47,9 +49,11 @@ namespace odb bool erase, int flags, bool foreign_keys, + const string& vfs, transfer_ptr factory) : flags_ (flags), foreign_keys_ (foreign_keys), + vfs_ (vfs), factory_ (factory.transfer ()) { using namespace details; diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx index 021a5df..042fb29 100644 --- a/odb/sqlite/database.hxx +++ b/odb/sqlite/database.hxx @@ -38,6 +38,7 @@ namespace odb database (const std::string& name, int flags = SQLITE_OPEN_READWRITE, bool foreign_keys = true, + const std::string& vfs = "", details::transfer_ptr = details::transfer_ptr ()); @@ -60,13 +61,13 @@ namespace odb bool erase = false, int flags = SQLITE_OPEN_READWRITE, bool foreign_keys = true, + const std::string& vfs = "", details::transfer_ptr = details::transfer_ptr ()); static void print_usage (std::ostream&); - public: const std::string& name () const @@ -86,6 +87,12 @@ namespace odb return foreign_keys_; } + const std::string& + vfs () const + { + return vfs_; + } + // Transactions. // public: @@ -133,6 +140,7 @@ namespace odb std::string name_; int flags_; bool foreign_keys_; + std::string vfs_; details::unique_ptr factory_; }; } -- cgit v1.1