From cbf1ba38794ab6a323441dcc3b0e5e942f7ab386 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 1 Jan 2023 14:53:05 +0100 Subject: Added CompiledSQL class, Test coverage --- compiledsql.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 compiledsql.h (limited to 'compiledsql.h') 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 + +#include + +class CompiledSQL +{ +public: + CompiledSQL(SQLite::Database& db); + + void init(const std::string& stmt); + + template + void bind(int index, T value) + { + m_stmt->bind(index, value); + } + + bool execute(); + + template + T getColumn(const int index) + { + return m_stmt->getColumn(index); + } + +private: + std::shared_ptr m_stmt; + SQLite::Database& m_db; + bool m_isSelect; // In SQLite, SELECT statements will be handled w/ executeStep(), others w/ exec() +}; -- cgit v1.2.3