diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-06 14:36:20 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-06 14:36:20 +0200 |
commit | 95143f4028efb896348008dc4cf4ce2d5925f720 (patch) | |
tree | 219ebd633f19251ddd8c2a53f889e659ee00bcc4 | |
parent | 158b06969b0c8438afda841b63c5fec7ed186725 (diff) |
Add ability to specify SQLite vfs module in database constructor
-rw-r--r-- | odb/sqlite/connection.cxx | 6 | ||||
-rw-r--r-- | odb/sqlite/database.cxx | 4 | ||||
-rw-r--r-- | odb/sqlite/database.hxx | 10 |
3 files changed, 18 insertions, 2 deletions
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<connection_factory> 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<connection_factory> 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<connection_factory> = details::transfer_ptr<connection_factory> ()); @@ -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<connection_factory> = details::transfer_ptr<connection_factory> ()); 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<connection_factory> factory_; }; } |