// file : odb/mssql/database.ixx // license : ODB NCUEL; see accompanying LICENSE file #include // move() #include namespace odb { namespace mssql { #ifdef ODB_CXX11 inline database:: database (database&& db) // Has to be inline. : odb::database (std::move (db)), user_ (std::move (db.user_)), password_ (std::move (db.password_)), db_ (std::move (db.db_)), protocol_ (db.protocol_), host_ (std::move (db.host_)), instance_ (std::move (db.instance_)), port_ (db.port_), server_ (std::move (db.server_)), driver_ (std::move (db.driver_)), extra_connect_string_ (std::move (db.extra_connect_string_)), transaction_isolation_ (db.transaction_isolation_), connect_string_ (std::move (db.connect_string_)), auto_environment_ (std::move (db.auto_environment_)), environment_ (db.environment_), factory_ (std::move (db.factory_)) { factory_->database (*this); // New database instance. } #endif inline connection_ptr database:: connection () { // Go through the virtual connection_() function instead of // directly to allow overriding. // return connection_ptr ( static_cast (connection_ ())); } template inline typename object_traits::id_type database:: persist (T& obj) { return persist_ (obj); } template inline typename object_traits::id_type database:: persist (const T& obj) { return persist_ (obj); } template inline typename object_traits::id_type database:: persist (T* p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); return persist_ (pobj); } template class P> inline typename object_traits::id_type database:: persist (const P& p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); return persist_ (pobj); } template class P> inline typename object_traits::id_type database:: persist (const P& p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); return persist_ (pobj); } template class P> inline typename object_traits::id_type database:: persist (P& p) { const P& cr (p); return persist (cr); } template class P> inline typename object_traits::id_type database:: persist (P& p) { const P& cr (p); return persist (cr); } template inline typename object_traits::id_type database:: persist (const typename object_traits::pointer_type& pobj) { return persist_ (pobj); } template inline void database:: persist (I b, I e, bool cont) { persist_ (b, e, cont); } template inline typename object_traits::pointer_type database:: load (const typename object_traits::id_type& id) { return load_ (id); } template inline void database:: load (const typename object_traits::id_type& id, T& obj) { return load_ (id, obj); } template inline void database:: load (T& obj, section& s) { return load_ (obj, s); } template inline typename object_traits::pointer_type database:: find (const typename object_traits::id_type& id) { return find_ (id); } template inline bool database:: find (const typename object_traits::id_type& id, T& obj) { return find_ (id, obj); } template inline void database:: reload (T& obj) { reload_ (obj); } template inline void database:: reload (T* p) { reload (*p); } template class P> inline void database:: reload (const P& p) { reload (odb::pointer_traits< P >::get_ref (p)); } template class P> inline void database:: reload (const P& p) { reload (odb::pointer_traits< P >::get_ref (p)); } template class P> inline void database:: reload (P& p) { reload (odb::pointer_traits< P >::get_ref (p)); } template class P> inline void database:: reload (P& p) { reload (odb::pointer_traits< P >::get_ref (p)); } template inline void database:: reload (const typename object_traits::pointer_type& pobj) { typedef typename object_traits::pointer_type pointer_type; reload (odb::pointer_traits::get_ref (pobj)); } template inline void database:: update (T& obj) { update_ (obj); } template inline void database:: update (T* p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); update_ (pobj); } template class P> inline void database:: update (const P& p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); update_ (pobj); } template class P> inline void database:: update (const P& p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); update_ (pobj); } template class P> inline void database:: update (P& p) { const P& cr (p); update (cr); } template class P> inline void database:: update (P& p) { const P& cr (p); update (cr); } template inline void database:: update (const typename object_traits::pointer_type& pobj) { update_ (pobj); } template inline void database:: update (I b, I e, bool cont) { update_ (b, e, cont); } template inline void database:: update (const T& obj, const section& s) { update_ (obj, s); } template inline void database:: erase (const typename object_traits::id_type& id) { return erase_ (id); } template inline void database:: erase (T& obj) { return erase_ (obj); } template inline void database:: erase (T* p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); erase_ (pobj); } template class P> inline void database:: erase (const P& p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); erase_ (pobj); } template class P> inline void database:: erase (const P& p) { typedef typename object_traits::pointer_type object_pointer; // The passed pointer should be the same or implicit-convertible // to the object pointer. This way we make sure the object pointer // does not assume ownership of the passed object. // const object_pointer& pobj (p); erase_ (pobj); } template class P> inline void database:: erase (P& p) { const P& cr (p); erase (cr); } template class P> inline void database:: erase (P& p) { const P& cr (p); erase (cr); } template inline void database:: erase (const typename object_traits::pointer_type& pobj) { erase_ (pobj); } template inline void database:: erase (I idb, I ide, bool cont) { erase_id_ (idb, ide, cont); } template inline void database:: erase (I ob, I oe, bool cont) { erase_object_ (ob, oe, cont); } template inline unsigned long long database:: erase_query () { // T is always object_type. // return erase_query (mssql::query_base ()); } template inline unsigned long long database:: erase_query (const char* q) { // T is always object_type. // return erase_query (mssql::query_base (q)); } template inline unsigned long long database:: erase_query (const std::string& q) { // T is always object_type. // return erase_query (mssql::query_base (q)); } template inline unsigned long long database:: erase_query (const mssql::query_base& q) { // T is always object_type. // return object_traits_impl::erase_query (*this, q); } template inline unsigned long long database:: erase_query (const odb::query_base& q) { // Translate to native query. // return erase_query (mssql::query_base (q)); } template inline result database:: query () { return query (mssql::query_base ()); } template inline result database:: query (const char* q) { return query (mssql::query_base (q)); } template inline result database:: query (const std::string& q) { return query (mssql::query_base (q)); } template inline result database:: query (const mssql::query_base& q) { // T is always object_type. We also don't need to check for transaction // here; object_traits::query () does this. // return query_::call (*this, q); } template inline result database:: query (const odb::query_base& q) { // Translate to native query. // return query (mssql::query_base (q)); } template inline typename result::pointer_type database:: query_one () { return query_one (mssql::query_base ()); } template inline bool database:: query_one (T& o) { return query_one (mssql::query_base (), o); } template inline T database:: query_value () { return query_value (mssql::query_base ()); } template inline typename result::pointer_type database:: query_one (const char* q) { return query_one (mssql::query_base (q)); } template inline bool database:: query_one (const char* q, T& o) { return query_one (mssql::query_base (q), o); } template inline T database:: query_value (const char* q) { return query_value (mssql::query_base (q)); } template inline typename result::pointer_type database:: query_one (const std::string& q) { return query_one (mssql::query_base (q)); } template inline bool database:: query_one (const std::string& q, T& o) { return query_one (mssql::query_base (q), o); } template inline T database:: query_value (const std::string& q) { return query_value (mssql::query_base (q)); } template inline typename result::pointer_type database:: query_one (const mssql::query_base& q) { // T is always object_type. We also don't need to check for transaction // here; object_traits::query () does this. // return query_one_ (q); } template inline bool database:: query_one (const mssql::query_base& q, T& o) { // T is always object_type. We also don't need to check for transaction // here; object_traits::query () does this. // return query_one_ (q, o); } template inline T database:: query_value (const mssql::query_base& q) { // T is always object_type. We also don't need to check for transaction // here; object_traits::query () does this. // return query_value_ (q); } template inline typename result::pointer_type database:: query_one (const odb::query_base& q) { // Translate to native query. // return query_one (mssql::query_base (q)); } template inline bool database:: query_one (const odb::query_base& q, T& o) { // Translate to native query. // return query_one (mssql::query_base (q), o); } template inline T database:: query_value (const odb::query_base& q) { // Translate to native query. // return query_value (mssql::query_base (q)); } template inline prepared_query database:: prepare_query (const char* n, const char* q) { return prepare_query (n, mssql::query_base (q)); } template inline prepared_query database:: prepare_query (const char* n, const std::string& q) { return prepare_query (n, mssql::query_base (q)); } template inline prepared_query database:: prepare_query (const char* n, const mssql::query_base& q) { // Throws if not in transaction. // mssql::connection& c (transaction::current ().connection (*this)); return c.prepare_query (n, q); } template inline prepared_query database:: prepare_query (const char* n, const odb::query_base& q) { // Translate to native query. // return prepare_query (n, mssql::query_base (q)); } } }