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

Classes

struct  bind_parameters
 
struct  bind_parameters< TUP, 1 >
 
struct  constraints_info_impl
 
struct  constraints_info_impl< H, T... >
 
struct  constraints_info_impl<>
 
class  DefaultDatabaseOpenPolicy
 

Functions

template<typename... T>
std::string constraints_info ()
 
template<typename T , typename... Constraints>
std::string column_info (column< T, Constraints... > const &col)
 
std::string columns ()
 
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< Tuple >::value)> fillData (Tuple &, int const ncols[[gnu::unused]], int const currentcol[[gnu::unused]], char **)
 
template<std::size_t I, typename Tuple >
std::enable_if_t<(I< std::tuple_size< Tuple >::value)> 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 (char const *s)
 
std::string maybe_quote (std::string 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)
 
std::string concatenate ()
 
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 105 of file create_table.h.

References constraints_info(), and string.

Referenced by columns().

106  {
107  std::string info{col.name() + col.sqlite_type()};
108  info += constraints_info<Constraints...>();
109  return info;
110  }
const XML_Char XML_Encoding * info
Definition: expat.h:530
Int_t col[ntarg]
Definition: Style.C:29
std::string constraints_info()
Definition: create_table.h:98
enum BeamMode string
std::string cet::sqlite::detail::columns ( )
inline

Definition at line 113 of file create_table.h.

References string, and T.

114  {
115  return "";
116  }
template<typename H , typename... T>
std::string cet::sqlite::detail::columns ( H const &  h,
T const &...  t 
)
inline

Definition at line 120 of file create_table.h.

References column_info(), string, T, and submit_hadd::u.

Referenced by create_table_ddl().

121  {
122  return (sizeof...(T) != 0u) ? column_info(h) + ", " + columns(t...) :
123  column_info(h);
124  }
std::string column_info(column< T, Constraints... > const &col)
Definition: create_table.h:105
std::string columns(H const &h, T const &...t)
Definition: create_table.h:120
double T
Definition: Xdiff_gwt.C:5
std::string cet::sqlite::detail::concatenate ( )
inline

Definition at line 139 of file select.h.

References string, and T.

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

140  {
141  return "";
142  }
template<typename H , typename... T>
std::string cet::sqlite::detail::concatenate ( H const &  h,
T const &...  t 
)

Definition at line 146 of file select.h.

References string, T, and submit_hadd::u.

147  {
148  return sizeof...(t) != 0u ? std::string{h} + "," + concatenate(t...) :
149  std::string{h};
150  }
std::string concatenate(H const &h, T const &...t)
Definition: select.h:146
enum BeamMode string
template<typename... T>
std::string cet::sqlite::detail::constraints_info ( )

Definition at line 98 of file create_table.h.

References string, and T.

Referenced by column_info().

99  {
100  return constraints_info_impl<T...>::generate_snippet();
101  }
template<typename T >
auto cet::sqlite::detail::convertTo ( std::string const &  arg)
inline

Definition at line 32 of file convert.h.

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

Definition at line 81 of file convert.h.

References stan::test::unit::stod().

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

Definition at line 75 of file convert.h.

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

Definition at line 39 of file convert.h.

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

Definition at line 45 of file convert.h.

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

Definition at line 87 of file convert.h.

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

Definition at line 51 of file convert.h.

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

Definition at line 57 of file convert.h.

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

Definition at line 63 of file convert.h.

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

Definition at line 69 of file convert.h.

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

Definition at line 127 of file create_table.h.

References string.

Referenced by create_table_as_ddl(), and create_table_ddl().

128  {
129  return "CREATE TABLE "s + tablename;
130  }
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 144 of file create_table.h.

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

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

145  {
146  std::string ddl{create_table(tablename)};
147  ddl += " AS ";
148  ddl += stmt.ddl_;
149  return ddl;
150  }
std::string create_table(std::string const &tablename)
Definition: create_table.h:127
enum BeamMode string
template<typename... Cols>
std::string cet::sqlite::detail::create_table_ddl ( std::string const &  tablename,
Cols const &...  cols 
)

Definition at line 134 of file create_table.h.

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

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

135  {
136  std::string ddl{create_table(tablename)};
137  ddl += "( ";
138  ddl += columns(cols...);
139  ddl += " )";
140  return ddl;
141  }
std::string create_table(std::string const &tablename)
Definition: create_table.h:127
std::string columns(H const &h, T const &...t)
Definition: create_table.h:120
const int cols[3]
enum BeamMode string
template<std::size_t I, typename Tuple >
std::enable_if_t<(I == std::tuple_size<Tuple>::value)> cet::sqlite::detail::fillData ( Tuple &  ,
int const ncols [[gnu::unused],
int const currentcol]  [[gnu::unused],
char **   
)

Definition at line 16 of file get_result.h.

References ana::assert(), and ncols.

20  {
21  assert(currentcol == ncols);
22  }
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<Tuple>::value)> cet::sqlite::detail::fillData ( Tuple &  data,
int const  ncols,
int  currentcol,
char **  results 
)

Definition at line 26 of file get_result.h.

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

27  {
28  assert(currentcol != ncols);
29  using ET = std::tuple_element_t<I, Tuple>;
30  std::get<I>(data) = detail::convertTo<ET>(results[currentcol]);
31  fillData<I + 1>(data, ncols, ++currentcol, results);
32  }
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 36 of file get_result.h.

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

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

37  {
38  assert(ncols >= 1);
39  auto j = static_cast<cet::sqlite::query_result<Args...>*>(data);
40  if (j->columns.empty()) {
41  for (int i{}; i < ncols; ++i)
42  j->columns.push_back(cnames[i]);
43  }
44 
45  assert(sizeof...(Args) == ncols);
46  std::tuple<Args...> rowdata;
47  int currentCol{};
48  fillData<0u>(rowdata, ncols, currentCol, results);
49  j->data.emplace_back(rowdata);
50  return 0;
51  }
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 ( char const *  s)
inline

Definition at line 48 of file insert.h.

References string.

Referenced by values_str_impl().

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

Definition at line 54 of file insert.h.

References T.

55  {
56  return "\"" + s + "\"";
57  }
const XML_Char * s
Definition: expat.h:262
template<typename T >
T cet::sqlite::detail::maybe_quote ( T const &  t)

Definition at line 61 of file insert.h.

References confusionMatrixTree::t.

62  {
63  return t;
64  }
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 83 of file insert.h.

References values_str_impl().

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

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

Definition at line 67 of file insert.h.

References T.

Referenced by values_str(), and values_str_impl().

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

Definition at line 72 of file insert.h.

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

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