diff options
author | Roland Reichwein <mail@reichwein.it> | 2023-01-01 14:53:05 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2023-01-01 14:53:05 +0100 |
commit | cbf1ba38794ab6a323441dcc3b0e5e942f7ab386 (patch) | |
tree | c20619b90a1f9ca512aa5e1db9354178e2c2726d /compiledsql.h | |
parent | 1f679124bba936e7905c7f4c83186d0c961dca61 (diff) |
Added CompiledSQL class, Test coverage
Diffstat (limited to 'compiledsql.h')
-rw-r--r-- | compiledsql.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/compiledsql.h b/compiledsql.h new file mode 100644 index 0000000..923be83 --- /dev/null +++ b/compiledsql.h @@ -0,0 +1,34 @@ +// Helper Class for SQLite backed storage + +#pragma once + +#include <memory> + +#include <SQLiteCpp/SQLiteCpp.h> + +class CompiledSQL +{ +public: + CompiledSQL(SQLite::Database& db); + + void init(const std::string& stmt); + + template<typename T> + void bind(int index, T value) + { + m_stmt->bind(index, value); + } + + bool execute(); + + template<typename T> + T getColumn(const int index) + { + return m_stmt->getColumn(index); + } + +private: + std::shared_ptr<SQLite::Statement> m_stmt; + SQLite::Database& m_db; + bool m_isSelect; // In SQLite, SELECT statements will be handled w/ executeStep(), others w/ exec() +}; |