bind_parameters.cc
Go to the documentation of this file.
3 
4 #include "sqlite3.h"
5 
6 using namespace cet::sqlite;
7 
8 namespace {
9  [[noreturn]] void
10  throw_bind_failure(std::string const& column_type, int const rc)
11  {
12  throw Exception{errors::SQLExecutionError} << "Failed to bind "
13  << column_type << ".\n"
14  << "Return code: " << rc << '\n';
15  }
16 }
17 
18 void
20  std::size_t const idx,
21  double const v)
22 {
23  int const rc{sqlite3_bind_double(s, idx, v)};
24  if (rc != SQLITE_OK)
25  throw_bind_failure("double", rc);
26 }
27 
28 void
30  std::size_t const idx,
31  int const v)
32 {
33  int const rc{sqlite3_bind_int(s, idx, v)};
34  if (rc != SQLITE_OK)
35  throw_bind_failure("int", rc);
36 }
37 
38 void
40  std::size_t const idx,
41  std::uint32_t const v)
42 {
43  int const rc{sqlite3_bind_int64(s, idx, v)};
44  if (rc != SQLITE_OK)
45  throw_bind_failure("int64", rc);
46 }
47 
48 void
50  std::size_t const idx,
51  sqlite_int64 const v)
52 {
53  int const rc{sqlite3_bind_int64(s, idx, v)};
54  if (rc != SQLITE_OK)
55  throw_bind_failure("int64", rc);
56 }
57 
58 void
60  std::size_t const idx,
61  std::string const& v)
62 {
63  int const rc{sqlite3_bind_text(s, idx, v.c_str(), v.size(), nullptr)};
64  if (rc != SQLITE_OK)
65  throw_bind_failure("text", rc);
66 }
67 
68 void
70 {
71  int const rc{sqlite3_bind_null(s, idx)};
72  if (rc != SQLITE_OK)
73  throw_bind_failure("null", rc);
74 }
std::string string
Definition: nybbler.cc:12
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:27
struct sqlite3_stmt sqlite3_stmt
void bind_one_parameter(sqlite3_stmt *s, std::size_t const idx, double const v)
static QCString * s
Definition: config.cpp:1042
void bind_one_null(sqlite3_stmt *s, std::size_t const idx)