From 9381bece0459fab204fceb09349091e838f1e940 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Oct 2014 11:22:05 +0200 Subject: Initial bulk erase implementation --- odb/database.txx | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'odb/database.txx') diff --git a/odb/database.txx b/odb/database.txx index 8c89394..8003345 100644 --- a/odb/database.txx +++ b/odb/database.txx @@ -279,6 +279,51 @@ namespace odb throw section_not_in_object (); } + template + void database:: + erase_ (I b, I e) + { + // T is explicitly specified by the caller, so assume it is object type. + // + typedef T object_type; + typedef object_traits_impl object_traits; + typedef typename object_traits::id_type id_type; + + multiple_exceptions mex; + try + { + while (b != e) + { + std::size_t n (0); + const id_type* a[object_traits::batch]; + + for (; b != e && n < object_traits::batch; ++n) + // Compiler error pointing here? Perhaps the object id type + // and the sequence element type don't match? + // + a[n] = &(*b++); + + object_traits::erase (*this, a, n, &mex); + + if (mex.fatal ()) + break; + + mex.delta (n); + } + } + catch (const odb::exception& ex) + { + mex.insert (ex, true); + } + + if (!mex.empty ()) + { + mex.prepare (); + throw mex; + } + } + + template struct database::query_ { -- cgit v1.1