diff --git a/include/Connection.hpp b/include/Connection.hpp index 7d7ce32..7995f42 100644 --- a/include/Connection.hpp +++ b/include/Connection.hpp @@ -4,6 +4,7 @@ #include #include +#include "Iterator.hpp" #include "Result.hpp" #include "dynamic/CreateTable.hpp" #include "dynamic/Insert.hpp" @@ -15,12 +16,11 @@ namespace sqlgen { /// database connections. struct Connection { /// Executes a statement. - /// TODO: Abstract away the different statements using a lambda function. + /// TODO: Abstract away the different statements using rfl::TaggedUnion. virtual Result execute(const CreateTable& _stmt) = 0; /// Reads the results of a SelectFrom statement. - virtual Result>> read( - const dynamic::SelectFrom& _query) = 0; + virtual Result read(const dynamic::SelectFrom& _query) = 0; /// Writes data into a table. Each vector in data MUST have the same length as /// _stmt.columns. diff --git a/include/Iterator.hpp b/include/Iterator.hpp new file mode 100644 index 0000000..dfcf751 --- /dev/null +++ b/include/Iterator.hpp @@ -0,0 +1,25 @@ +#ifndef SQLGEN_ITERATOR_HPP_ +#define SQLGEN_ITERATOR_HPP_ + +#include +#include + +#include "Result.hpp" + +namespace sqlgen { + +/// Abstract base class for an iterator to be returned by Connection::read(...). +struct Iterator { + /// Whether the end of the available data has been reached. + virtual bool end() const = 0; + + /// Returns the next batch of rows. + /// If _batch_size is greater than the number of rows left, returns all + /// of the rows left. + virtual Result>> next( + const size_t _batch_size) = 0; +}; + +} // namespace sqlgen + +#endif