diff options
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() +}; |