From c899bc6842fd19614c536f73aede71c5473c964d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 17 Nov 2024 19:52:21 +0100 Subject: [PATCH] Remove statement::define_for_row() and call it from describe() It looks like this function must always be called after a (successful) call to describe() and it is not called from anywhere else, so it seems wrong to both require and allow calling it independently -- just call it from describe() itself. No real changes, this function has never been part of public API, so hopefully nobody was using it. --- include/soci/statement.h | 1 - src/core/statement.cpp | 19 ++++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/soci/statement.h b/include/soci/statement.h index b1dbc4269..137722a5b 100644 --- a/include/soci/statement.h +++ b/include/soci/statement.h @@ -134,7 +134,6 @@ class SOCI_DECL statement_impl void exchange_for_row(into_container const &ic) { intosForRow_.exchange(ic); } void exchange_for_row(into_type_ptr const & i) { intosForRow_.exchange(i); } - void define_for_row(); template void into_row() diff --git a/src/core/statement.cpp b/src/core/statement.cpp index 6f5f3cd09..bfb9c2e8e 100644 --- a/src/core/statement.cpp +++ b/src/core/statement.cpp @@ -232,15 +232,6 @@ void statement_impl::define_and_bind() } } -void statement_impl::define_for_row() -{ - std::size_t const isize = intosForRow_.size(); - for (std::size_t i = 0; i != isize; ++i) - { - intosForRow_[i]->define(*this, definePositionForRow_); - } -} - void statement_impl::undefine_and_bind() { std::size_t const isize = intos_.size(); @@ -298,7 +289,6 @@ bool statement_impl::execute(bool withDataExchange) if (row_ != NULL && alreadyDescribed_ == false) { describe(); - define_for_row(); } int num = 0; @@ -330,7 +320,6 @@ bool statement_impl::execute(bool withDataExchange) if (row_ != NULL && alreadyDescribed_ == false) { describe(); - define_for_row(); } bool gotData = false; @@ -787,6 +776,14 @@ void statement_impl::describe() } alreadyDescribed_ = true; + + // Calling bind_into() above could have added row into elements, so + // initialize them. + std::size_t const isize = intosForRow_.size(); + for (std::size_t i = 0; i != isize; ++i) + { + intosForRow_[i]->define(*this, definePositionForRow_); + } } } // namespace details