7 namespace horizon::SQLite {
10 noncopyable() =
default;
11 ~noncopyable() =
default;
13 noncopyable(noncopyable &&) =
default;
14 noncopyable &operator=(noncopyable &&) =
default;
16 noncopyable(noncopyable
const &) =
delete;
17 noncopyable &operator=(noncopyable
const &) =
delete;
20 class Query : noncopyable {
22 Query(
class Database &d,
const std::string &sql);
23 Query(
class Database &d,
const char *sql,
int size = -1);
26 template <
class T> T get(
int idx)
const
31 template <
class T>
struct convert {
35 template <
class... Ts> std::tuple<Ts...> get_columns(
typename convert<Ts>::to_int... idxs)
const
37 return std::make_tuple(get(idxs, Ts())...);
40 void bind(
int idx,
const std::string &v,
bool copy =
true);
41 void bind(
const char *name,
const std::string &v,
bool copy =
true);
42 void bind(
int idx,
int v);
43 void bind(
const char *name,
int v);
51 std::string get(
int idx, std::string)
const;
52 int get(
int idx,
int)
const;
55 class Error :
public std::runtime_error {
57 Error(
int a_rc,
const char *what) : std::runtime_error(what), rc(a_rc)
67 Database(
const std::string &filename,
int flags = SQLITE_OPEN_READONLY,
int timeout_ms = 0);
69 void execute(
const std::string &query);
70 void execute(
const char *query);
71 int get_user_version();
74 sqlite3 *db =
nullptr;