// file : odb/database.ixx // copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::string namespace odb { inline database:: database () : tracer_ (0) { } inline connection_ptr database:: connection () { return connection_ptr (connection_ ()); } inline void database:: tracer (tracer_type& t) { tracer_ = &t; } inline void database:: tracer (tracer_type* t) { tracer_ = t; } inline database::tracer_type* database:: tracer () const { return tracer_; } 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:: 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* 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:: 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_ (const typename object_traits::pointer_type& pobj) { typedef typename object_traits::pointer_type pointer_type; typedef pointer_traits pointer_traits; erase (pointer_traits::get_ref (pobj)); } template inline unsigned long long database:: erase_query () { // T is always object_type. // return erase_query (odb::query ()); } template inline unsigned long long database:: erase_query (const char* q) { // T is always object_type. // return erase_query (odb::query (q)); } template inline unsigned long long database:: erase_query (const std::string& q) { // T is always object_type. // return erase_query (odb::query (q)); } template inline result database:: query (bool cache) { return query (odb::query (), cache); } template inline result database:: query (const char* q, bool cache) { return query (odb::query (q), cache); } template inline result database:: query (const std::string& q, bool cache) { return query (odb::query (q), cache); } inline unsigned long long database:: execute (const char* statement) { return execute (statement, std::strlen (statement)); } inline unsigned long long database:: execute (const std::string& statement) { return execute (statement.c_str (), statement.size ()); } }