diff options
-rw-r--r-- | odb/mssql/database.cxx | 22 | ||||
-rw-r--r-- | odb/mssql/database.hxx | 28 |
2 files changed, 29 insertions, 21 deletions
diff --git a/odb/mssql/database.cxx b/odb/mssql/database.cxx index 5ab692c..b70ef24 100644 --- a/odb/mssql/database.cxx +++ b/odb/mssql/database.cxx @@ -18,6 +18,8 @@ namespace odb { namespace mssql { + using odb::details::transfer_ptr; + database:: database (const std::string& user, const std::string& password, @@ -26,7 +28,7 @@ namespace odb const std::string& driver, const std::string& extra_connect_string, SQLHENV environment, - std::auto_ptr<connection_factory> factory) + transfer_ptr<connection_factory> factory) : user_ (user), password_ (password), db_ (db), @@ -36,7 +38,7 @@ namespace odb driver_ (driver), extra_connect_string_ (extra_connect_string), environment_ (environment), - factory_ (factory) + factory_ (factory.transfer ()) { init (); } @@ -51,7 +53,7 @@ namespace odb const std::string& driver, const std::string& extra_connect_string, SQLHENV environment, - std::auto_ptr<connection_factory> factory) + transfer_ptr<connection_factory> factory) : user_ (user), password_ (password), db_ (db), @@ -62,7 +64,7 @@ namespace odb driver_ (driver), extra_connect_string_ (extra_connect_string), environment_ (environment), - factory_ (factory) + factory_ (factory.transfer ()) { init (); } @@ -76,7 +78,7 @@ namespace odb const std::string& driver, const std::string& extra_connect_string, SQLHENV environment, - std::auto_ptr<connection_factory> factory) + transfer_ptr<connection_factory> factory) : user_ (user), password_ (password), db_ (db), @@ -86,7 +88,7 @@ namespace odb driver_ (driver), extra_connect_string_ (extra_connect_string), environment_ (environment), - factory_ (factory) + factory_ (factory.transfer ()) { init (); } @@ -94,12 +96,12 @@ namespace odb database:: database (const string& connect_string, SQLHENV environment, - auto_ptr<connection_factory> factory) + transfer_ptr<connection_factory> factory) : protocol_ (protocol_auto), port_ (0), connect_string_ (connect_string), environment_ (environment), - factory_ (factory) + factory_ (factory.transfer ()) { init (); } @@ -110,12 +112,12 @@ namespace odb bool erase, const std::string& extra_connect_string, SQLHENV environment, - auto_ptr<connection_factory> factory) + transfer_ptr<connection_factory> factory) : protocol_ (protocol_auto), port_ (0), extra_connect_string_ (extra_connect_string), environment_ (environment), - factory_ (factory) + factory_ (factory.transfer ()) { using namespace details; diff --git a/odb/mssql/database.hxx b/odb/mssql/database.hxx index 5be36b4..3ad09a9 100644 --- a/odb/mssql/database.hxx +++ b/odb/mssql/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/mssql/mssql-fwd.hxx> #include <odb/mssql/version.hxx> @@ -54,8 +56,8 @@ namespace odb const std::string& driver = "", const std::string& extra_connect_string = "", SQLHENV environment = 0, - std::auto_ptr<connection_factory> factory = - std::auto_ptr<connection_factory> (0)); + details::transfer_ptr<connection_factory> = + details::transfer_ptr<connection_factory> ()); // By default connect to the default instance on localhost using // default protocol and the latest available SQL Server Native @@ -72,8 +74,8 @@ namespace odb const std::string& driver = "", const std::string& extra_connect_string = "", SQLHENV environment = 0, - std::auto_ptr<connection_factory> factory = - std::auto_ptr<connection_factory> (0)); + details::transfer_ptr<connection_factory> = + details::transfer_ptr<connection_factory> ()); // Connect using TCP/IP to the specified host and port. If port is // 0, use the default port (1433). @@ -86,16 +88,16 @@ namespace odb const std::string& driver = "", const std::string& extra_connect_string = "", SQLHENV environment = 0, - std::auto_ptr<connection_factory> factory = - std::auto_ptr<connection_factory> (0)); + details::transfer_ptr<connection_factory> = + details::transfer_ptr<connection_factory> ()); // Connect using a custom SQL Server Native Client ODBC driver // conection string. // database (const std::string& connect_string, SQLHENV 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: @@ -117,8 +119,8 @@ namespace odb bool erase = false, const std::string& extra_connect_string = "", SQLHENV 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&); @@ -251,7 +253,11 @@ namespace odb auto_handle<SQL_HANDLE_ENV> auto_environment_; SQLHENV environment_; +#ifdef ODB_CXX11 + std::unique_ptr<connection_factory> factory_; +#else std::auto_ptr<connection_factory> factory_; +#endif }; } } |