bind_parameters.h
Go to the documentation of this file.
1 #ifndef cetlib_sqlite_detail_bind_parameters_h
2 #define cetlib_sqlite_detail_bind_parameters_h
3 
4 //=======================================================================
5 // The bind_one_* functions are intended to be for internal use only.
6 // They provide a means of binding a C++ type to the corresponding
7 // SQLite type through the sqlite3_bind_* API.
8 //=======================================================================
9 
10 #include "sqlite3.h"
11 
12 #include <string>
13 #include <tuple>
14 
15 namespace cet::sqlite::detail {
16 
18  std::size_t const idx,
19  double const v);
20  void bind_one_parameter(sqlite3_stmt* s, std::size_t const idx, int const v);
22  std::size_t const idx,
23  std::uint32_t const v);
25  std::size_t const idx,
26  sqlite_int64 const v);
28  std::size_t const idx,
29  std::string const& v);
30  void bind_one_null(sqlite3_stmt* s, std::size_t const idx);
31 
32  template <class TUP, size_t N>
33  struct bind_parameters {
34  static void
35  bind(sqlite3_stmt* s, TUP const& t)
36  {
38  if (auto& param = std::get<N - 1>(t))
39  bind_one_parameter(s, N, *param);
40  else
41  bind_one_null(s, N);
42  }
43  };
44 
45  template <class TUP>
46  struct bind_parameters<TUP, 1> {
47  static void
48  bind(sqlite3_stmt* s, TUP const& t)
49  {
50  if (auto& param = std::get<0>(t))
51  bind_one_parameter(s, 1, *param);
52  else
53  bind_one_null(s, 1);
54  }
55  };
56 
57 } // cet::sqlite::detail
58 
59 #endif /* cetlib_sqlite_detail_bind_parameters_h */
60 
61 // Local Variables:
62 // mode: c++
63 // End:
std::string string
Definition: nybbler.cc:12
struct sqlite3_stmt sqlite3_stmt
void bind_one_parameter(sqlite3_stmt *s, std::size_t const idx, double const v)
static void bind(sqlite3_stmt *s, TUP const &t)
static void bind(sqlite3_stmt *s, TUP const &t)
static QCString * s
Definition: config.cpp:1042
void bind_one_null(sqlite3_stmt *s, std::size_t const idx)