summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbpp/connection.cpp5
-rw-r--r--libdbpp/connection.h7
-rw-r--r--libdbpp/sqlWriter.cpp7
-rw-r--r--libdbpp/sqlWriter.h24
-rw-r--r--libdbpp/tablepatch.cpp1
-rw-r--r--libdbpp/unittests/testPatch.cpp1
6 files changed, 34 insertions, 11 deletions
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp
index 7a287d2..79f7d32 100644
--- a/libdbpp/connection.cpp
+++ b/libdbpp/connection.cpp
@@ -75,11 +75,6 @@ DB::TablePatch::TablePatch() :
{
}
-void
-DB::SqlWriter::bindParams(DB::Command *, unsigned int &)
-{
-}
-
std::string
DB::TransactionRequired::message() const throw()
{
diff --git a/libdbpp/connection.h b/libdbpp/connection.h
index 8328fe0..ac18c24 100644
--- a/libdbpp/connection.h
+++ b/libdbpp/connection.h
@@ -16,6 +16,7 @@ namespace AdHoc {
namespace DB {
class Command;
+ class SqlWriter;
class SelectCommand;
class ModifyCommand;
@@ -46,12 +47,6 @@ namespace DB {
unsigned int inserts;
};
- class DLL_PUBLIC SqlWriter {
- public:
- virtual void writeSql(AdHoc::Buffer &) = 0;
- virtual void bindParams(Command *, unsigned int &);
- };
-
/// Base class for database connectivity errors.
class DLL_PUBLIC ConnectionError : public Error {
public:
diff --git a/libdbpp/sqlWriter.cpp b/libdbpp/sqlWriter.cpp
new file mode 100644
index 0000000..d940ebf
--- /dev/null
+++ b/libdbpp/sqlWriter.cpp
@@ -0,0 +1,7 @@
+#include "sqlWriter.h"
+
+void
+DB::SqlWriter::bindParams(DB::Command *, unsigned int &)
+{
+}
+
diff --git a/libdbpp/sqlWriter.h b/libdbpp/sqlWriter.h
new file mode 100644
index 0000000..ca268c0
--- /dev/null
+++ b/libdbpp/sqlWriter.h
@@ -0,0 +1,24 @@
+#ifndef DB_SQLWRITER_H
+#define DB_SQLWRITER_H
+
+#include <visibility.h>
+#include <buffer.h>
+
+namespace DB {
+ class Command;
+
+ /// Base class of dynamic SQL constructors.
+ class DLL_PUBLIC SqlWriter {
+ public:
+ /// Append your SQL to the buffer.
+ /// @param buffer The buffer
+ virtual void writeSql(AdHoc::Buffer & buffer) = 0;
+ /// Bind your parameters (offset should be increment 1 per bind made)
+ /// @param cmd Command to bind to.
+ /// @param offset The current bind offset.
+ virtual void bindParams(Command * cmd, unsigned int & offset);
+ };
+}
+
+#endif
+
diff --git a/libdbpp/tablepatch.cpp b/libdbpp/tablepatch.cpp
index 98ad1fa..1aea416 100644
--- a/libdbpp/tablepatch.cpp
+++ b/libdbpp/tablepatch.cpp
@@ -1,6 +1,7 @@
#include "connection.h"
#include "modifycommand.h"
#include "selectcommand.h"
+#include "sqlWriter.h"
#include <buffer.h>
#include <safeMapFind.h>
#include <scopeExit.h>
diff --git a/libdbpp/unittests/testPatch.cpp b/libdbpp/unittests/testPatch.cpp
index 9d9434c..a393f8c 100644
--- a/libdbpp/unittests/testPatch.cpp
+++ b/libdbpp/unittests/testPatch.cpp
@@ -5,6 +5,7 @@
#include <definedDirs.h>
#include <pq-mock.h>
#include <command.h>
+#include <sqlWriter.h>
#include <buffer.h>
class Mock : public PQ::Mock {