From 13b215e2206380d856137dedf522c9141a58e9e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 21 Nov 2014 08:16:49 +0200 Subject: Add support for stopping after a failed batch --- odb/database.hxx | 20 ++++++++++---------- odb/database.ixx | 20 ++++++++++---------- odb/database.txx | 20 ++++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/odb/database.hxx b/odb/database.hxx index 3163c46..0de867f 100644 --- a/odb/database.hxx +++ b/odb/database.hxx @@ -87,7 +87,7 @@ namespace odb // template void - persist (I begin, I end); + persist (I begin, I end, bool continue_failed = true); // Load an object. Throw object_not_persistent if not found. // @@ -180,7 +180,7 @@ namespace odb // template void - update (I begin, I end); + update (I begin, I end, bool continue_failed = true); // Update a section of an object. Throws section_not_loaded exception // if section is not loaded. Note also that this function does not @@ -229,14 +229,14 @@ namespace odb // template void - erase (I id_begin, I id_end); + erase (I id_begin, I id_end, bool continue_failed = true); // Can be a range of references or pointers (including smart pointers) // to objects. // template void - erase (I obj_begin, I obj_end); + erase (I obj_begin, I obj_end, bool continue_failed = true); // Erase multiple objects matching a query predicate. // @@ -523,15 +523,15 @@ namespace odb template void - persist_ (I, I); + persist_ (I, I, bool); template void - persist_ (I, I, details::meta::no ptr); + persist_ (I, I, bool, details::meta::no ptr); template void - persist_ (I, I, details::meta::yes ptr); + persist_ (I, I, bool, details::meta::yes ptr); template typename object_traits::pointer_type @@ -567,7 +567,7 @@ namespace odb template void - update_ (I, I); + update_ (I, I, bool); template void @@ -587,11 +587,11 @@ namespace odb template void - erase_id_ (I, I); + erase_id_ (I, I, bool); template void - erase_object_ (I, I); + erase_object_ (I, I, bool); template typename object_traits::pointer_type diff --git a/odb/database.ixx b/odb/database.ixx index 7c4b322..43dae6a 100644 --- a/odb/database.ixx +++ b/odb/database.ixx @@ -237,9 +237,9 @@ namespace odb template inline void database:: - persist (I b, I e) + persist (I b, I e, bool cont) { - persist_ (b, e); + persist_ (b, e, cont); } template @@ -405,9 +405,9 @@ namespace odb template inline void database:: - update (I b, I e) + update (I b, I e, bool cont) { - update_ (b, e); + update_ (b, e, cont); } template @@ -501,16 +501,16 @@ namespace odb template inline void database:: - erase (I idb, I ide) + erase (I idb, I ide, bool cont) { - erase_id_ (idb, ide); + erase_id_ (idb, ide, cont); } template inline void database:: - erase (I ob, I oe) + erase (I ob, I oe, bool cont) { - erase_object_ (ob, oe); + erase_object_ (ob, oe, cont); } template @@ -722,7 +722,7 @@ namespace odb // template inline void database:: - persist_ (I b, I e) + persist_ (I b, I e, bool cont) { // Sun CC with non-standard STL does not have iterator_traits. // @@ -737,7 +737,7 @@ namespace odb typedef object_pointer_traits opt; persist_ ( - b, e, typename opt::result_type ()); + b, e, cont, typename opt::result_type ()); } template diff --git a/odb/database.txx b/odb/database.txx index ba10891..4329754 100644 --- a/odb/database.txx +++ b/odb/database.txx @@ -77,7 +77,7 @@ namespace odb template void database:: - persist_ (I b, I e, details::meta::no /*ptr*/) + persist_ (I b, I e, bool cont, details::meta::no /*ptr*/) { // T can be const T while object_type will always be T. // @@ -87,7 +87,7 @@ namespace odb multiple_exceptions mex (typeid (object_already_persistent)); try { - while (b != e) + while (b != e && (cont || mex.empty ())) { std::size_t n (0); T* a[object_traits::batch]; // T instead of persist_type for cache. @@ -158,7 +158,7 @@ namespace odb template void database:: - persist_ (I b, I e, details::meta::yes /*ptr*/) + persist_ (I b, I e, bool cont, details::meta::yes /*ptr*/) { // T can be const T while object_type will always be T. // @@ -170,7 +170,7 @@ namespace odb multiple_exceptions mex (typeid (object_already_persistent)); try { - while (b != e) + while (b != e && (cont || mex.empty ())) { std::size_t n (0); typename persist_type::type* a[object_traits::batch]; @@ -269,7 +269,7 @@ namespace odb template void database:: - update_ (I b, I e) + update_ (I b, I e, bool cont) { // Sun CC with non-standard STL does not have iterator_traits. // @@ -294,7 +294,7 @@ namespace odb multiple_exceptions mex (typeid (object_not_persistent)); try { - while (b != e) + while (b != e && (cont || mex.empty ())) { std::size_t n (0); const object_type* a[object_traits::batch]; @@ -344,7 +344,7 @@ namespace odb template void database:: - erase_id_ (I b, I e) + erase_id_ (I b, I e, bool cont) { // T is explicitly specified by the caller, so assume it is object type. // @@ -355,7 +355,7 @@ namespace odb multiple_exceptions mex (typeid (object_not_persistent)); try { - while (b != e) + while (b != e && (cont || mex.empty ())) { std::size_t n (0); const id_type* a[object_traits::batch]; @@ -388,7 +388,7 @@ namespace odb template void database:: - erase_object_ (I b, I e) + erase_object_ (I b, I e, bool cont) { // Sun CC with non-standard STL does not have iterator_traits. // @@ -413,7 +413,7 @@ namespace odb multiple_exceptions mex (typeid (object_not_persistent)); try { - while (b != e) + while (b != e && (cont || mex.empty ())) { std::size_t n (0); const object_type* a[object_traits::batch]; -- cgit v1.1