Classes | Functions
cet::sqlite::detail Namespace Reference

Classes

struct  bind_parameters
 
struct  bind_parameters< TUP, 1 >
 
class  DefaultDatabaseOpenPolicy
 

Functions

template<typename T , typename... Constraints>
std::string column_info (column< T, Constraints... > const &col)
 
template<typename H , typename... T>
std::string columns (H const &h, T const &...t)
 
std::string create_table (std::string const &tablename)
 
template<typename... Cols>
std::string create_table_ddl (std::string const &tablename, Cols const &...cols)
 
std::string create_table_as_ddl (std::string const &tablename, SelectStmt const &stmt)
 
void bind_one_parameter (sqlite3_stmt *s, std::size_t const idx, double const v)
 
void bind_one_parameter (sqlite3_stmt *s, std::size_t const idx, int const v)
 
void bind_one_parameter (sqlite3_stmt *s, std::size_t const idx, std::uint32_t const v)
 
void bind_one_parameter (sqlite3_stmt *s, std::size_t const idx, sqlite_int64 const v)
 
void bind_one_parameter (sqlite3_stmt *s, std::size_t const idx, std::string const &v)
 
void bind_one_null (sqlite3_stmt *s, std::size_t const idx)
 
template<typename T >
auto convertTo (std::string const &arg)
 
template<>
auto convertTo< int > (std::string const &arg)
 
template<>
auto convertTo< long > (std::string const &arg)
 
template<>
auto convertTo< long long > (std::string const &arg)
 
template<>
auto convertTo< unsigned > (std::string const &arg)
 
template<>
auto convertTo< unsigned long > (std::string const &arg)
 
template<>
auto convertTo< unsigned long long > (std::string const &arg)
 
template<>
auto convertTo< float > (std::string const &arg)
 
template<>
auto convertTo< double > (std::string const &arg)
 
template<>
auto convertTo< long double > (std::string const &arg)
 
template<std::size_t I, typename Tuple >
std::enable_if_t<(I==std::tuple_size_v< Tuple >)> fillData (Tuple &, int const ncols[[maybe_unused]], int const currentcol[[maybe_unused]], char **)
 
template<std::size_t I, typename Tuple >
std::enable_if_t<(I< std::tuple_size_v< Tuple >)> fillData (Tuple &data, int const ncols, int currentcol, char **results)
 
template<typename... Args>
int get_result (void *data, int ncols, char **results, char **cnames)
 
void normalize_statement (std::string &to_replace)
 
std::string normalized_statement (std::string to_replace)
 
std::string maybe_quote (std::string const &s)
 
std::string maybe_quote (char const *s)
 
template<typename T >
T maybe_quote (T const &t)
 
void values_str_impl (std::ostream &)
 
template<typename H , typename... T>
void values_str_impl (std::ostream &os, H const &h, T const &...t)
 
template<typename... Args>
std::string values_str (Args const &...args)
 
template<typename H , typename... T>
std::string concatenate (H const &h, T const &...t)
 

Function Documentation

void cet::sqlite::detail::bind_one_null ( sqlite3_stmt *  s,
std::size_t const  idx 
)
void cet::sqlite::detail::bind_one_parameter ( sqlite3_stmt *  s,
std::size_t const  idx,
double const  v 
)
void cet::sqlite::detail::bind_one_parameter ( sqlite3_stmt *  s,
std::size_t const  idx,
int const  v 
)
void cet::sqlite::detail::bind_one_parameter ( sqlite3_stmt *  s,
std::size_t const  idx,
std::uint32_t const  v 
)
void cet::sqlite::detail::bind_one_parameter ( sqlite3_stmt *  s,
std::size_t const  idx,
sqlite_int64 const  v 
)
void cet::sqlite::detail::bind_one_parameter ( sqlite3_stmt *  s,
std::size_t const  idx,
std::string const &  v 
)
template<typename T , typename... Constraints>
std::string cet::sqlite::detail::column_info ( column< T, Constraints... > const &  col)

Definition at line 74 of file create_table.h.

References string, and T.

Referenced by columns().

75  {
76  std::string info{col.name() + col.sqlite_type()};
77  info += (Constraints::snippet() + ... + ""s);
78  return info;
79  }
const XML_Char XML_Encoding * info
Definition: expat.h:530
const XML_Char * s
Definition: expat.h:262
Int_t col[ntarg]
Definition: Style.C:29
enum BeamMode string
template<typename H , typename... T>
std::string cet::sqlite::detail::columns ( H const &  h,
T const &...  t 
)
inline

Definition at line 83 of file create_table.h.

References column_info(), and string.

Referenced by create_table_ddl().

84  {
85  return (column_info(h) + ... + (", " + column_info(t)));
86  }
std::string column_info(column< T, Constraints... > const &col)
Definition: create_table.h:74
template<typename H , typename... T>
std::string cet::sqlite::detail::concatenate ( H const &  h,
T const &...  t 
)

Definition at line 138 of file select.h.

References string, and T.

Referenced by models::CVN(), models::Inception(), cet::sqlite::select(), and cet::sqlite::select_distinct().

139  {
140  return (std::string{h} + ... + ("," + std::string{t}));
141  }
enum BeamMode string
template<typename T >
auto cet::sqlite::detail::convertTo ( std::string const &  arg)
inline

Definition at line 30 of file convert.h.

31  {
32  return arg;
33  }
template<>
auto cet::sqlite::detail::convertTo< double > ( std::string const &  arg)
inline

Definition at line 79 of file convert.h.

80  {
81  return std::stod(arg);
82  }
template<>
auto cet::sqlite::detail::convertTo< float > ( std::string const &  arg)
inline

Definition at line 73 of file convert.h.

74  {
75  return std::stof(arg);
76  }
template<>
auto cet::sqlite::detail::convertTo< int > ( std::string const &  arg)
inline

Definition at line 37 of file convert.h.

38  {
39  return std::stoi(arg);
40  }
template<>
auto cet::sqlite::detail::convertTo< long > ( std::string const &  arg)
inline

Definition at line 43 of file convert.h.

44  {
45  return std::stol(arg);
46  }
template<>
auto cet::sqlite::detail::convertTo< long double > ( std::string const &  arg)
inline

Definition at line 85 of file convert.h.

86  {
87  return std::stold(arg);
88  }
template<>
auto cet::sqlite::detail::convertTo< long long > ( std::string const &  arg)
inline

Definition at line 49 of file convert.h.

50  {
51  return std::stoll(arg);
52  }
template<>
auto cet::sqlite::detail::convertTo< unsigned > ( std::string const &  arg)
inline

Definition at line 55 of file convert.h.

56  {
57  return std::stoul(arg);
58  }
template<>
auto cet::sqlite::detail::convertTo< unsigned long > ( std::string const &  arg)
inline

Definition at line 61 of file convert.h.

62  {
63  return std::stoul(arg);
64  }
template<>
auto cet::sqlite::detail::convertTo< unsigned long long > ( std::string const &  arg)
inline

Definition at line 67 of file convert.h.

68  {
69  return std::stoull(arg);
70  }
std::string cet::sqlite::detail::create_table ( std::string const &  tablename)
inline

Definition at line 89 of file create_table.h.

References string.

Referenced by create_table_as_ddl(), and create_table_ddl().

90  {
91  return "CREATE TABLE "s + tablename;
92  }
const XML_Char * s
Definition: expat.h:262
std::string cet::sqlite::detail::create_table_as_ddl ( std::string const &  tablename,
SelectStmt const &  stmt 
)
inline

Definition at line 106 of file create_table.h.

References create_table(), cet::sqlite::SelectStmt::ddl_, and string.

Referenced by cet::sqlite::create_table_as().

107  {
108  std::string ddl{create_table(tablename)};
109  ddl += " AS ";
110  ddl += stmt.ddl_;
111  return ddl;
112  }
std::string create_table(std::string const &tablename)
Definition: create_table.h:89
enum BeamMode string
template<typename... Cols>
std::string cet::sqlite::detail::create_table_ddl ( std::string const &  tablename,
Cols const &...  cols 
)

Definition at line 96 of file create_table.h.

References columns(), create_table(), and string.

Referenced by cet::sqlite::create_table(), and cet::sqlite::createTableIfNeeded().

97  {
98  std::string ddl{create_table(tablename)};
99  ddl += "( ";
100  ddl += columns(cols...);
101  ddl += " )";
102  return ddl;
103  }
std::string create_table(std::string const &tablename)
Definition: create_table.h:89
std::string columns(H const &h, T const &...t)
Definition: create_table.h:83
const int cols[3]
enum BeamMode string
template<std::size_t I, typename Tuple >
std::enable_if_t<(I == std::tuple_size_v<Tuple>)> cet::sqlite::detail::fillData ( Tuple &  ,
int const ncols [[maybe_unused],
int const currentcol]  [[maybe_unused],
char **   
)

Definition at line 14 of file get_result.h.

References ana::assert(), and ncols.

18  {
19  assert(currentcol == ncols);
20  }
assert(nhit_max >=nhit_nbins)
Int_t ncols
Definition: plot.C:53
template<std::size_t I, typename Tuple >
std::enable_if_t<(I < std::tuple_size_v<Tuple>)> cet::sqlite::detail::fillData ( Tuple &  data,
int const  ncols,
int  currentcol,
char **  results 
)

Definition at line 24 of file get_result.h.

References ana::assert(), ncols, and makeDatasetsPage::results.

25  {
26  assert(currentcol != ncols);
27  using ET = std::tuple_element_t<I, Tuple>;
28  std::get<I>(data) = detail::convertTo<ET>(results[currentcol]);
29  fillData<I + 1>(data, ncols, ++currentcol, results);
30  }
const XML_Char const XML_Char * data
Definition: expat.h:268
assert(nhit_max >=nhit_nbins)
Int_t ncols
Definition: plot.C:53
template<typename... Args>
int cet::sqlite::detail::get_result ( void data,
int  ncols,
char **  results,
char **  cnames 
)

Definition at line 34 of file get_result.h.

References ana::assert(), MECModelEnuComparisons::i, calib::j, ncols, and makeDatasetsPage::results.

Referenced by cet::sqlite::query().

35  {
36  assert(ncols >= 1);
37  auto j = static_cast<cet::sqlite::query_result<Args...>*>(data);
38  if (j->columns.empty()) {
39  for (int i{}; i < ncols; ++i)
40  j->columns.push_back(cnames[i]);
41  }
42 
43  assert(sizeof...(Args) == ncols);
44  std::tuple<Args...> rowdata;
45  int currentCol{};
46  fillData<0u>(rowdata, ncols, currentCol, results);
47  j->data.emplace_back(rowdata);
48  return 0;
49  }
const XML_Char const XML_Char * data
Definition: expat.h:268
const double j
Definition: BetheBloch.cxx:29
assert(nhit_max >=nhit_nbins)
Int_t ncols
Definition: plot.C:53
std::string cet::sqlite::detail::maybe_quote ( std::string const &  s)
inline

Definition at line 47 of file insert.h.

References string.

Referenced by maybe_quote(), and values_str_impl().

48  {
49  return "\"" + s + "\"";
50  }
const XML_Char * s
Definition: expat.h:262
std::string cet::sqlite::detail::maybe_quote ( char const *  s)
inline

Definition at line 53 of file insert.h.

References maybe_quote(), string, and T.

54  {
55  return maybe_quote(std::string{s});
56  }
T maybe_quote(T const &t)
Definition: insert.h:60
const XML_Char * s
Definition: expat.h:262
enum BeamMode string
template<typename T >
T cet::sqlite::detail::maybe_quote ( T const &  t)

Definition at line 60 of file insert.h.

References confusionMatrixTree::t.

61  {
62  return t;
63  }
void cet::sqlite::detail::normalize_statement ( std::string to_replace)
std::string cet::sqlite::detail::normalized_statement ( std::string  to_replace)
template<typename... Args>
std::string cet::sqlite::detail::values_str ( Args const &...  args)

Definition at line 82 of file insert.h.

References values_str_impl().

Referenced by cet::sqlite::IncompleteInsert::values().

83  {
84  std::ostringstream oss;
85  values_str_impl(oss, args...);
86  return oss.str();
87  }
void values_str_impl(std::ostream &os, H const &h, T const &...t)
Definition: insert.h:71
void cet::sqlite::detail::values_str_impl ( std::ostream &  )
inline

Definition at line 66 of file insert.h.

References T.

Referenced by values_str(), and values_str_impl().

67  {}
template<typename H , typename... T>
void cet::sqlite::detail::values_str_impl ( std::ostream &  os,
H const &  h,
T const &...  t 
)

Definition at line 71 of file insert.h.

References maybe_quote(), string, T, submit_hadd::u, and values_str_impl().

72  {
73  if (sizeof...(T) != 0u) {
74  os << maybe_quote(h) << ',';
75  values_str_impl(os, t...);
76  } else
77  os << maybe_quote(h);
78  }
T maybe_quote(T const &t)
Definition: insert.h:60
void values_str_impl(std::ostream &os, H const &h, T const &...t)
Definition: insert.h:71
double T
Definition: Xdiff_gwt.C:5