#include "compiledsql.h" #include CompiledSQL::CompiledSQL(SQLite::Database& db): m_stmt{}, m_db{db}, m_isSelect{} { } void CompiledSQL::init(const std::string& stmt) { if (m_stmt) { m_stmt->reset(); } else { if ( #if __cplusplus >= 202002 stmt.starts_with("SELECT ") #else boost::algorithm::starts_with(stmt, "SELECT ") #endif ) { m_isSelect = true; } else { m_isSelect = false; } m_stmt = std::make_shared(m_db, stmt); } } bool CompiledSQL::execute() { if (m_isSelect) { return m_stmt->executeStep(); } else { return m_stmt->exec(); } }