aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-03-01 12:34:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-03-01 12:34:41 +0200
commit89ceaaf470d19d475d665b87a1fbe66009d0912b (patch)
tree0551879da61af0efee4d99721185027ecc93aa3e
parent88d2a5bf72dc8dabce16428ab8c6d37df5dd6cce (diff)
Add support for using C++11 std::unique_ptr to pass connection factory
-rw-r--r--odb/sqlite/database.cxx12
-rw-r--r--odb/sqlite/database.hxx17
2 files changed, 20 insertions, 9 deletions
diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx
index 6bd3636..cd62a1c 100644
--- a/odb/sqlite/database.cxx
+++ b/odb/sqlite/database.cxx
@@ -18,6 +18,8 @@ namespace odb
{
namespace sqlite
{
+ using odb::details::transfer_ptr;
+
database::
~database ()
{
@@ -27,11 +29,11 @@ namespace odb
database (const string& name,
int flags,
bool foreign_keys,
- auto_ptr<connection_factory> factory)
+ transfer_ptr<connection_factory> factory)
: name_ (name),
flags_ (flags),
foreign_keys_ (foreign_keys),
- factory_ (factory)
+ factory_ (factory.transfer ())
{
if (factory_.get () == 0)
factory_.reset (new connection_pool_factory ());
@@ -45,8 +47,10 @@ namespace odb
bool erase,
int flags,
bool foreign_keys,
- std::auto_ptr<connection_factory> factory)
- : flags_ (flags), foreign_keys_ (foreign_keys), factory_ (factory)
+ transfer_ptr<connection_factory> factory)
+ : flags_ (flags),
+ foreign_keys_ (foreign_keys),
+ factory_ (factory.transfer ())
{
using namespace details;
diff --git a/odb/sqlite/database.hxx b/odb/sqlite/database.hxx
index ba0e2c2..d2bf61f 100644
--- a/odb/sqlite/database.hxx
+++ b/odb/sqlite/database.hxx
@@ -10,10 +10,12 @@
#include <sqlite3.h>
#include <string>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr, std::unique_ptr
#include <iosfwd> // std::ostream
#include <odb/database.hxx>
+#include <odb/details/config.hxx> // ODB_CXX11
+#include <odb/details/transfer-ptr.hxx>
#include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx>
@@ -36,8 +38,8 @@ namespace odb
database (const std::string& name,
int flags = SQLITE_OPEN_READWRITE,
bool foreign_keys = true,
- std::auto_ptr<connection_factory> =
- std::auto_ptr<connection_factory> (0));
+ details::transfer_ptr<connection_factory> =
+ details::transfer_ptr<connection_factory> ());
// Extract the database parameters from the command line. The
// following options are recognized:
@@ -58,8 +60,8 @@ namespace odb
bool erase = false,
int flags = SQLITE_OPEN_READWRITE,
bool foreign_keys = true,
- std::auto_ptr<connection_factory> =
- std::auto_ptr<connection_factory> (0));
+ details::transfer_ptr<connection_factory> =
+ details::transfer_ptr<connection_factory> ());
static void
print_usage (std::ostream&);
@@ -131,7 +133,12 @@ namespace odb
std::string name_;
int flags_;
bool foreign_keys_;
+
+#ifdef ODB_CXX11
+ std::unique_ptr<connection_factory> factory_;
+#else
std::auto_ptr<connection_factory> factory_;
+#endif
};
}
}