From 8d4d2568f356cb9beb1553bf58ad69c1c800b996 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Aug 2014 09:37:06 +0200 Subject: Implement bulk database operation support for Oracle and SQL Server --- odb/database.ixx | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) (limited to 'odb/database.ixx') diff --git a/odb/database.ixx b/odb/database.ixx index 739db03..43dae6a 100644 --- a/odb/database.ixx +++ b/odb/database.ixx @@ -3,11 +3,74 @@ // license : GNU GPL v2; see accompanying LICENSE file #include // std::strlen() +#include // std::move +#include #include +#include namespace odb { + template + struct object_pointer_traits + { + typedef details::meta::no result_type; + typedef T object_type; + static const T& get_ref (const T& x) {return x;} + }; + + template + struct object_pointer_traits + { + typedef details::meta::yes result_type; + typedef T object_type; + static const T& get_ref (const T* p) {return *p;} + }; + + template + struct object_pointer_traits + { + typedef details::meta::yes result_type; + typedef T object_type; + static const T& get_ref (const T* p) {return *p;} + }; + + template class P> + struct object_pointer_traits > + { + typedef details::meta::yes result_type; + typedef T object_type; + static const T& get_ref (const P& p) { + return pointer_traits >::get_ref (p);} + }; + + template class P> + struct object_pointer_traits > + { + typedef details::meta::yes result_type; + typedef T object_type; + static const T& get_ref (const P& p) { + return pointer_traits >::get_ref (p);} + }; + + template class P> + struct object_pointer_traits > + { + typedef details::meta::yes result_type; + typedef T object_type; + static const T& get_ref (const P& p) { + return pointer_traits >::get_ref (p);} + }; + + template class P> + struct object_pointer_traits > + { + typedef details::meta::yes result_type; + typedef T object_type; + static const T& get_ref (const P& p) { + return pointer_traits >::get_ref (p);} + }; + inline database:: database (database_id id) : id_ (id), tracer_ (0), schema_version_seq_ (1) @@ -99,6 +162,13 @@ namespace odb 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; @@ -165,6 +235,13 @@ namespace odb 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) @@ -326,6 +403,13 @@ namespace odb 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) @@ -415,6 +499,20 @@ namespace odb 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 () @@ -622,6 +720,26 @@ namespace odb // Implementations (i.e., the *_() functions). // + template + inline void database:: + persist_ (I b, I e, bool cont) + { + // Sun CC with non-standard STL does not have iterator_traits. + // +#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC + typedef typename std::iterator_traits::value_type value_type; +#else + // Assume iterator is just a pointer. + // + typedef typename object_pointer_traits::object_type value_type; +#endif + + typedef object_pointer_traits opt; + + persist_ ( + b, e, cont, typename opt::result_type ()); + } + template inline typename object_traits::pointer_type database:: find_ (const typename object_traits::id_type& id) -- cgit v1.1