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
commit5f60d6859c6269b6a8fedbbf44973e8e9f28340c (patch)
tree5dbad7a5394803146eacab5d0e73bb43d3d2c763
parent2f26329e52cb5b312c8f0ba4da9264afdd78743a (diff)
Add support for using C++11 std::unique_ptr to pass connection factory
-rw-r--r--odb/oracle/database.cxx14
-rw-r--r--odb/oracle/database.hxx20
2 files changed, 21 insertions, 13 deletions
diff --git a/odb/oracle/database.cxx b/odb/oracle/database.cxx
index 9a0c4d7..a8abb53 100644
--- a/odb/oracle/database.cxx
+++ b/odb/oracle/database.cxx
@@ -18,6 +18,8 @@ namespace odb
{
namespace oracle
{
+ using odb::details::transfer_ptr;
+
database::
database (const string& user,
const string& password,
@@ -25,7 +27,7 @@ namespace odb
ub2 charset,
ub2 ncharset,
OCIEnv* environment,
- auto_ptr<connection_factory> factory)
+ transfer_ptr<connection_factory> factory)
: user_ (user),
password_ (password),
db_ (db),
@@ -33,7 +35,7 @@ namespace odb
charset_ (charset),
ncharset_ (ncharset_),
environment_ (environment),
- factory_ (factory)
+ factory_ (factory.transfer ())
{
if (environment_ == 0)
{
@@ -64,7 +66,7 @@ namespace odb
ub2 charset,
ub2 ncharset,
OCIEnv* environment,
- auto_ptr<connection_factory> factory)
+ transfer_ptr<connection_factory> factory)
: user_ (user),
password_ (password),
service_ (service),
@@ -73,7 +75,7 @@ namespace odb
charset_ (charset),
ncharset_ (ncharset),
environment_ (environment),
- factory_ (factory)
+ factory_ (factory.transfer ())
{
if (environment_ == 0)
{
@@ -122,12 +124,12 @@ namespace odb
ub2 charset,
ub2 ncharset,
OCIEnv* environment,
- auto_ptr<connection_factory> factory)
+ transfer_ptr<connection_factory> factory)
: port_ (0),
charset_ (charset),
ncharset_ (ncharset),
environment_ (environment),
- factory_ (factory)
+ factory_ (factory.transfer ())
{
if (environment_ == 0)
{
diff --git a/odb/oracle/database.hxx b/odb/oracle/database.hxx
index dcb5c92..d51d073 100644
--- a/odb/oracle/database.hxx
+++ b/odb/oracle/database.hxx
@@ -8,10 +8,12 @@
#include <odb/pre.hxx>
#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/oracle/version.hxx>
#include <odb/oracle/forward.hxx>
@@ -38,8 +40,8 @@ namespace odb
ub2 charset = 0,
ub2 ncharset = 0,
OCIEnv* environment = 0,
- std::auto_ptr<connection_factory> factory =
- std::auto_ptr<connection_factory> (0));
+ details::transfer_ptr<connection_factory> =
+ details::transfer_ptr<connection_factory> ());
database (const std::string& user,
const std::string& password,
@@ -49,8 +51,8 @@ namespace odb
ub2 charset = 0,
ub2 ncharset = 0,
OCIEnv* environment = 0,
- std::auto_ptr<connection_factory> 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:
@@ -74,8 +76,8 @@ namespace odb
ub2 charset = 0,
ub2 ncharset = 0,
OCIEnv* environment = 0,
- 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&);
@@ -186,7 +188,11 @@ namespace odb
auto_handle<OCIEnv> auto_environment_;
OCIEnv* environment_;
+#ifdef ODB_CXX11
+ std::unique_ptr<connection_factory> factory_;
+#else
std::auto_ptr<connection_factory> factory_;
+#endif
};
}
}