| 1 | #pragma once |
| 2 | |
| 3 | #include <sqlite3.h> |
| 4 | #include <string> |
| 5 | |
| 6 | class ProcessRowCallback { |
| 7 | public: |
| 8 | virtual ~ProcessRowCallback() {}; |
| 9 | virtual void ProcessRow(sqlite3_stmt* stmt) = 0; |
| 10 | }; |
| 11 | |
| 12 | class SQLConnection |
| 13 | { |
| 14 | public: |
| 15 | void BeginTransaction(); |
| 16 | void EndTransaction(); |
| 17 | protected: |
| 18 | SQLConnection(std::string name); |
| 19 | ~SQLConnection(); |
| 20 | bool Open(std::string& file); |
| 21 | bool Query(std::string query, ProcessRowCallback& callback); |
| 22 | bool Execute(std::string query); |
| 23 | int GetVersion(); |
| 24 | bool SetVersion(int newVersion); |
| 25 | sqlite3* m_db; |
| 26 | std::string m_name; |
| 27 | |
| 28 | private: |
| 29 | bool EnsureVersionTable(); |
| 30 | }; |