diff options
Diffstat (limited to 'frontend/DB.h')
-rw-r--r-- | frontend/DB.h | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/frontend/DB.h b/frontend/DB.h index 5c88940..77b3f7a 100644 --- a/frontend/DB.h +++ b/frontend/DB.h @@ -5,9 +5,49 @@ #include <sqlite3.h> class DB; +class DBStatement; + +class DBQueryRow { +public: + DBQueryRow(DBStatement &); + +public: + template <typename T> + T col(int index); + +private: + DBStatement & parent; +}; + +// class DBQueryRowRange { +// public: +// DBQueryRowRange(); +// +// private: +// class DBQueryRowIterator { +// public: +// DBQueryRowIterator(DBQueryRow & row); +// +// public: +// DBQueryRow & operator * () const; +// DBQueryRowIterator & operator ++ (); +// bool operator != (const DBQueryRowIterator &) const; +// +// private: +// DBQueryRow & row; +// }; +// +// public: +// DBQueryRowIterator begin() const; +// DBQueryRowIterator end() const; +// +// private: +// DBQueryRow row; +// }; class DBStatement { - std::unique_ptr<sqlite3_stmt, std::function<void(sqlite3_stmt*)>> stmt; + friend class DBQueryRow; + public: DBStatement(DB &, const std::string & query); @@ -17,10 +57,13 @@ public: DBStatement & bind(const int & number); public: void execute(); + DBQueryRow row(); + // DBQueryRowRange rows(); private: + std::unique_ptr<sqlite3_stmt, std::function<void(sqlite3_stmt*)>> stmt; int param_index = 1; - DB & db; + DB & parent; }; class DB { |