forked from qt-creator/qt-creator
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:
@@ -178,14 +178,15 @@ public:
|
|||||||
template<typename... ValueType>
|
template<typename... ValueType>
|
||||||
void bindValues(const ValueType&... values)
|
void bindValues(const ValueType&... values)
|
||||||
{
|
{
|
||||||
bindValuesByIndex(1, values...);
|
int index = 0;
|
||||||
|
(BaseStatement::bind(++index, values), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... ValueType>
|
template<typename... ValueType>
|
||||||
void write(const ValueType&... values)
|
void write(const ValueType&... values)
|
||||||
{
|
{
|
||||||
Resetter resetter{*this};
|
Resetter resetter{*this};
|
||||||
bindValuesByIndex(1, values...);
|
bindValues(values...);
|
||||||
BaseStatement::next();
|
BaseStatement::next();
|
||||||
resetter.reset();
|
resetter.reset();
|
||||||
}
|
}
|
||||||
@@ -380,19 +381,6 @@ private:
|
|||||||
return callCallable(callable, std::make_integer_sequence<int, ResultCount>{});
|
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)
|
void setMaximumResultCount(std::size_t count)
|
||||||
{
|
{
|
||||||
m_maximumResultCount = std::max(m_maximumResultCount, count);
|
m_maximumResultCount = std::max(m_maximumResultCount, count);
|
||||||
|
|||||||
Reference in New Issue
Block a user