diff options
Diffstat (limited to 'platform/default/sqlite3.hpp')
-rw-r--r-- | platform/default/sqlite3.hpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/platform/default/sqlite3.hpp b/platform/default/sqlite3.hpp index 29e8967db3..abe83a2d44 100644 --- a/platform/default/sqlite3.hpp +++ b/platform/default/sqlite3.hpp @@ -1,7 +1,9 @@ #pragma once #include <string> +#include <vector> #include <stdexcept> +#include <chrono> typedef struct sqlite3 sqlite3; typedef struct sqlite3_stmt sqlite3_stmt; @@ -38,11 +40,15 @@ public: ~Database(); Database &operator=(Database &&); - operator bool() const; + explicit operator bool() const; + void setBusyTimeout(std::chrono::milliseconds); void exec(const std::string &sql); Statement prepare(const char *query); + int64_t lastInsertRowid() const; + uint64_t changes() const; + private: sqlite3 *db = nullptr; }; @@ -60,14 +66,23 @@ public: ~Statement(); Statement &operator=(Statement &&); - operator bool() const; + explicit operator bool() const; template <typename T> void bind(int offset, T value); - void bind(int offset, const std::string &value, bool retain = true); + + // Text + void bind(int offset, const char *, std::size_t length, bool retain = true); + void bind(int offset, const std::string&, bool retain = true); + + // Blob + void bindBlob(int offset, const void *, std::size_t length, bool retain = true); + void bindBlob(int offset, const std::vector<uint8_t>&, bool retain = true); + template <typename T> T get(int offset); bool run(); void reset(); + void clearBindings(); private: sqlite3_stmt *stmt = nullptr; |