• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SRombauts / SQLiteCpp / #613698365

22 Nov 2023 10:24AM UTC coverage: 98.238%. First build
#613698365

travis-ci

669 of 681 relevant lines covered (98.24%)

29.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/include/SQLiteCpp/ExecuteMany.h
1
/**
2
 * @file    ExecuteMany.h
3
 * @ingroup SQLiteCpp
4
 * @brief   Convenience function to execute a Statement with multiple Parameter sets
5
 *
6
 * Copyright (c) 2019 Maximilian Bachmann (contact@maxbachmann.de)
7
 * Copyright (c) 2019-2025 Sebastien Rombauts (sebastien.rombauts@gmail.com)
8
 *
9
 * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
10
 * or copy at http://opensource.org/licenses/MIT)
11
 */
12
#pragma once
13

14
#if (__cplusplus >= 201402L) || ( defined(_MSC_VER) && (_MSC_VER >= 1900) ) // c++14: Visual Studio 2015
15

16
#include <SQLiteCpp/Statement.h>
17
#include <SQLiteCpp/VariadicBind.h>
18

19
/// @cond
20
#include <tuple>
21
#include <utility>
22
#include <initializer_list>
23

24
namespace SQLite
25
{
26

27
/// @endcond
28

29
/**
30
 * \brief Convenience function to execute a Statement with multiple Parameter sets once for each parameter set given.
31
 *
32
 *
33
 * This feature requires a c++14 capable compiler.
34
 *
35
 * \code{.cpp}
36
 * execute_many(db, "INSERT INTO test VALUES (?, ?)",
37
 *   1,
38
 *   std::make_tuple(2),
39
 *   std::make_tuple(3, "three")
40
 * );
41
 * \endcode
42
 * @param aDatabase Database to use
43
 * @param apQuery   Query to use with all parameter sets
44
 * @param aArg      first tuple with parameters
45
 * @param aParams   the following tuples with parameters
46
 */
47
template <typename Arg, typename... Types>
48
void execute_many(Database& aDatabase, const char* apQuery, Arg&& aArg, Types&&... aParams)
1✔
49
{
50
    SQLite::Statement query(aDatabase, apQuery);
2✔
51
    bind_exec(query, std::forward<Arg>(aArg));
1✔
52
    (void)std::initializer_list<int>
2✔
53
    {
54
        ((void)reset_bind_exec(query, std::forward<Types>(aParams)), 0)...
2✔
55
    };
56
}
1✔
57

58
/**
59
 * \brief Convenience function to reset a statement and call bind_exec to 
60
 * bind new values to the statement and execute it
61
 *
62
 * This feature requires a c++14 capable compiler.
63
 *
64
 * @param apQuery   Query to use
65
 * @param aTuple    Tuple to bind
66
 */
67
template <typename TupleT>
68
void reset_bind_exec(Statement& apQuery, TupleT&& aTuple)
2✔
69
{
70
    apQuery.reset();
2✔
71
    bind_exec(apQuery, std::forward<TupleT>(aTuple));
2✔
72
}
2✔
73

74
/**
75
 * \brief Convenience function to bind values a the statement and execute it
76
 *
77
 * This feature requires a c++14 capable compiler.
78
 *
79
 * @param apQuery   Query to use
80
 * @param aTuple    Tuple to bind
81
 */
82
template <typename TupleT>
83
void bind_exec(Statement& apQuery, TupleT&& aTuple)
3✔
84
{
85
    SQLite::bind(apQuery, std::forward<TupleT>(aTuple));
3✔
86
    while (apQuery.executeStep()) {}
3✔
87
}
3✔
88

89
}  // namespace SQLite
90

91
#endif // c++14
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc