// Helper Class for SQLite backed storage #pragma once #include #include class CompiledSQL { public: CompiledSQL(SQLite::Database& db, const std::string& stmt); // index 1-based as in SQLite template void bind(int index, T value) { m_stmt->bind(index, value); } bool execute(); // index 0-based as in SQLite template T getColumn(const int index) { return m_stmt->getColumn(index); } class Guard { public: Guard(CompiledSQL& cs); ~Guard(); private: CompiledSQL& m_cs; }; private: SQLite::Database& m_db; std::string m_query; std::shared_ptr m_stmt; bool m_isSelect; // In SQLite, SELECT statements will be handled w/ executeStep(), others w/ exec() };