Sqlite: Simplify the binding with fold expressions

Makes the life of the compiler easier too.

Change-Id: I079ed042e0fd4c359415d123b89ad39341a35468
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Tapani Mattila <tapani.mattila@qt.io>
This commit is contained in:
Marco Bubke
2021-04-04 23:12:04 +02:00
parent f4c3c49920
commit 47672714a3

View File

@@ -178,14 +178,15 @@ public:
template<typename... ValueType>
void bindValues(const ValueType&... values)
{
bindValuesByIndex(1, values...);
int index = 0;
(BaseStatement::bind(++index, values), ...);
}
template<typename... ValueType>
void write(const ValueType&... values)
{
Resetter resetter{*this};
bindValuesByIndex(1, values...);
bindValues(values...);
BaseStatement::next();
resetter.reset();
}
@@ -380,19 +381,6 @@ private:
return callCallable(callable, std::make_integer_sequence<int, ResultCount>{});
}
template<typename ValueType>
void bindValuesByIndex(int index, const ValueType &value)
{
BaseStatement::bind(index, value);
}
template<typename ValueType, typename... ValueTypes>
void bindValuesByIndex(int index, const ValueType &value, const ValueTypes &...values)
{
BaseStatement::bind(index, value);
bindValuesByIndex(index + 1, values...);
}
void setMaximumResultCount(std::size_t count)
{
m_maximumResultCount = std::max(m_maximumResultCount, count);