diff options
Diffstat (limited to 'frontend/DB.h')
-rw-r--r-- | frontend/DB.h | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/frontend/DB.h b/frontend/DB.h index f6907bc..0164e34 100644 --- a/frontend/DB.h +++ b/frontend/DB.h @@ -21,34 +21,37 @@ 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 DBQueryRowRange { +public: + DBQueryRowRange(DBStatement & stmt); + +private: + class DBQueryRowIterator { + public: + DBQueryRowIterator(DBQueryRowRange & parent); + + public: + DBQueryRow & operator * () const; + DBQueryRowIterator & operator ++ (); + bool operator != (const DBQueryRowIterator &) const; + + private: + bool end = false; + DBQueryRowRange & parent; + }; + +public: + DBQueryRowIterator begin(); + DBQueryRowIterator end(); + +private: + DBStatement & parent; + DBQueryRow row; +}; class DBStatement { friend class DBQueryRow; + friend class DBQueryRowRange; public: DBStatement(DB &, const std::string & query); @@ -60,7 +63,7 @@ public: public: void execute(); DBQueryRow row(); - // DBQueryRowRange rows(); + DBQueryRowRange rows(); private: std::unique_ptr<sqlite3_stmt, std::function<void(sqlite3_stmt*)>> stmt; |