#pragma once #include #include #include class DB; class DBStatement; class DBQueryRow { public: DBQueryRow(DBStatement &); public: template 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 { friend class DBQueryRow; public: DBStatement(DB &, const std::string & query); public: DBStatement & unbind(); DBStatement & bind(const std::string & text); DBStatement & bind(const int & number); public: void execute(); DBQueryRow row(); // DBQueryRowRange rows(); private: std::unique_ptr> stmt; int param_index = 1; DB & parent; }; class DB { friend class DBStatement; public: DB(const std::string & path); DBStatement prepare(const std::string & query); private: std::unique_ptr> db = NULL; };