1#ifndef NGEN_GEOPACKAGE_SQLITE_H
2#define NGEN_GEOPACKAGE_SQLITE_H
18 using std::runtime_error::runtime_error;
20 sqlite_error(
const std::string& origin_func,
int code,
const std::string& extra =
"");
35 sqlite3_finalize(stmt);
39 using sqlite_t = std::unique_ptr<sqlite3, deleter>;
40 using stmt_t = std::unique_ptr<sqlite3_stmt, deleter>;
52 bool done() const noexcept;
80 int find(const
std::
string& name) const noexcept;
91 const
std::span<const
int>
types() const noexcept;
107 template<typename Tp>
113 sqlite3_stmt*
ptr_() const noexcept;
176 std::array<std::string,
sizeof...(params)> binds = { params... };
177 return query(statement, binds);
Definition ngen_sqlite.hpp:24
iterator query(const std::string &statement, const std::span< const std::string > binds={}) const
Query the SQLite Database and get the result.
Definition ngen_sqlite.cpp:220
sqlite3 * connection() const noexcept
Return the originating sqlite3 database pointer.
Definition ngen_sqlite.cpp:193
bool contains(const std::string &table) const
Check if SQLite database contains a given table.
Definition ngen_sqlite.cpp:198
std::unique_ptr< sqlite3_stmt, deleter > stmt_t
Definition ngen_sqlite.hpp:40
std::unique_ptr< sqlite3, deleter > sqlite_t
Definition ngen_sqlite.hpp:39
sqlite_t conn_
Definition ngen_sqlite.hpp:181
iterator query(const std::string &statement, const Ts &... params) const
Query the SQLite Database with a bound statement and get the result.
Definition ngen_sqlite.hpp:174
conjunction< std::is_convertible< From, To >::value... > all_is_convertible
Checks that all types {From} are convertible to {T}.
Definition traits.hpp:41
Definition DomainLayer.hpp:13
Deleter used to provide smart pointer support for sqlite3 structs.
Definition ngen_sqlite.hpp:27
void operator()(sqlite3_stmt *stmt)
Definition ngen_sqlite.hpp:33
void operator()(sqlite3 *db)
Definition ngen_sqlite.hpp:28
Definition ngen_sqlite.hpp:44
const std::span< const int > types() const noexcept
Get a span of column types.
Definition ngen_sqlite.cpp:120
int ncol_
Definition ngen_sqlite.hpp:120
int find(const std::string &name) const noexcept
Return the column index for a named column.
Definition ngen_sqlite.cpp:107
stmt_t stmt_
Definition ngen_sqlite.hpp:116
const std::span< const std::string > columns() const noexcept
Get a span of column names.
Definition ngen_sqlite.cpp:114
bool done() const noexcept
Check if a row iterator is finished.
Definition ngen_sqlite.cpp:51
int num_columns() const noexcept
Get the number of columns within this iterator.
Definition ngen_sqlite.cpp:102
sqlite3_stmt * ptr_() const noexcept
Definition ngen_sqlite.cpp:46
int current_row() const noexcept
Get the current row index for the iterator.
Definition ngen_sqlite.cpp:97
iterator & next()
Step into the next row of a SQLite query.
Definition ngen_sqlite.cpp:56
std::vector< int > types_
Definition ngen_sqlite.hpp:123
Tp get(int col) const
Get a column value from a row iterator by index.
std::vector< std::string > names_
Definition ngen_sqlite.hpp:122
int done_
Definition ngen_sqlite.hpp:119
void handle_get_index_(int col) const
Definition ngen_sqlite.cpp:126
iterator & restart()
Restart an iteration to its initial state.
Definition ngen_sqlite.cpp:89
int step_
Definition ngen_sqlite.hpp:118
Definition ngen_sqlite.hpp:17
sqlite_error(const std::string &origin_func, int code, const std::string &extra="")
error codes: https://www.sqlite.org/rescode.html
Definition ngen_sqlite.cpp:12