forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.14'
Change-Id: I214b8d59e8ff7fe0511cd6116ec7725ddc4376ee
This commit is contained in:
@@ -37,9 +37,10 @@
|
||||
#include <utils/span.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
using std::int64_t;
|
||||
|
||||
@@ -319,6 +320,40 @@ public:
|
||||
return statement.template fetchValue<Type>(0);
|
||||
}
|
||||
|
||||
template<int ResultTypeCount = 1, typename Callable, typename... QueryTypes>
|
||||
void readCallback(Callable &&callable, const QueryTypes &...queryValues)
|
||||
{
|
||||
BaseStatement::checkColumnCount(ResultTypeCount);
|
||||
|
||||
Resetter resetter{*this};
|
||||
|
||||
bindValues(queryValues...);
|
||||
|
||||
while (BaseStatement::next()) {
|
||||
auto control = callCallable<ResultTypeCount>(callable);
|
||||
|
||||
if (control == CallbackControl::Abort)
|
||||
break;
|
||||
}
|
||||
|
||||
resetter.reset();
|
||||
}
|
||||
|
||||
template<int ResultTypeCount = 1, typename Container, typename... QueryTypes>
|
||||
void readTo(Container &container, const QueryTypes &...queryValues)
|
||||
{
|
||||
BaseStatement::checkColumnCount(ResultTypeCount);
|
||||
|
||||
Resetter resetter{*this};
|
||||
|
||||
bindValues(queryValues...);
|
||||
|
||||
while (BaseStatement::next())
|
||||
pushBackToContainer<ResultTypeCount>(container);
|
||||
|
||||
resetter.reset();
|
||||
}
|
||||
|
||||
protected:
|
||||
~StatementImplementation() = default;
|
||||
|
||||
@@ -401,6 +436,30 @@ private:
|
||||
return assignValue<ResultOptionalType>(std::make_integer_sequence<int, ResultTypeCount>{});
|
||||
}
|
||||
|
||||
template<typename Callable, int... ColumnIndices>
|
||||
CallbackControl callCallable(Callable &&callable, std::integer_sequence<int, ColumnIndices...>)
|
||||
{
|
||||
return std::invoke(callable, ValueGetter(*this, ColumnIndices)...);
|
||||
}
|
||||
|
||||
template<int ResultTypeCount, typename Callable>
|
||||
CallbackControl callCallable(Callable &&callable)
|
||||
{
|
||||
return callCallable(callable, std::make_integer_sequence<int, ResultTypeCount>{});
|
||||
}
|
||||
|
||||
template<typename Container, int... ColumnIndices>
|
||||
void pushBackToContainer(Container &container, std::integer_sequence<int, ColumnIndices...>)
|
||||
{
|
||||
container.push_back(Container::value_type(ValueGetter(*this, ColumnIndices)...));
|
||||
}
|
||||
|
||||
template<int ResultTypeCount, typename Container>
|
||||
void pushBackToContainer(Container &container)
|
||||
{
|
||||
pushBackToContainer(container, std::make_integer_sequence<int, ResultTypeCount>{});
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
void bindValuesByIndex(int index, const ValueType &value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user