From a815a04a419e9aa780f233d30e4df9d263611d4a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 29 Dec 2015 03:26:08 +0000 Subject: Move SqlWriter to its own files --- libdbpp/connection.cpp | 5 ----- libdbpp/connection.h | 7 +------ libdbpp/sqlWriter.cpp | 7 +++++++ libdbpp/sqlWriter.h | 24 ++++++++++++++++++++++++ libdbpp/tablepatch.cpp | 1 + libdbpp/unittests/testPatch.cpp | 1 + 6 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 libdbpp/sqlWriter.cpp create mode 100644 libdbpp/sqlWriter.h 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 +#include + +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 #include #include 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 #include #include +#include #include class Mock : public PQ::Mock { -- cgit v1.2.3