From f1eb2b71c64ee539bb1a6e0d765f6d449dfb02df Mon Sep 17 00:00:00 2001 From: "Dr. Patrick Urbanke" Date: Wed, 19 Mar 2025 07:09:14 +0100 Subject: [PATCH] Added an abstract base class for the connection --- include/Connection.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 include/Connection.hpp diff --git a/include/Connection.hpp b/include/Connection.hpp new file mode 100644 index 0000000..b52b85e --- /dev/null +++ b/include/Connection.hpp @@ -0,0 +1,29 @@ +#ifndef SQLGEN_CONNECTION_HPP_ +#define SQLGEN_CONNECTION_HPP_ + +#include +#include + +#include "Result.hpp" +#include "dynamic/Insert.hpp" +#include "dynamic/SelectFrom.hpp" + +namespace sqlgen { + +/// Abstract base class to be implemented by the different +/// database connections. +struct Connection { + /// Reads the results of a SelectFrom statement. + 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. + virtual Result write( + const dynamic::Insert& _stmt, + const std::vector>& _data) = 0; +}; + +} // namespace sqlgen + +#endif