summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-29 03:43:45 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-29 06:00:07 +0000
commita9f6a2aca701adfa5e9186c938c37a9465909069 (patch)
tree07483cf0c656f576601b8bd479abb15e65578b15
parentMove TablePatch to its own files (diff)
downloadlibdbpp-a9f6a2aca701adfa5e9186c938c37a9465909069.tar.bz2
libdbpp-a9f6a2aca701adfa5e9186c938c37a9465909069.tar.xz
libdbpp-a9f6a2aca701adfa5e9186c938c37a9465909069.zip
Add briefer, smart pointer functions for getting new command instances
-rw-r--r--libdbpp/connection.cpp14
-rw-r--r--libdbpp/connection.h4
2 files changed, 18 insertions, 0 deletions
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp
index aaa7591..6c36d45 100644
--- a/libdbpp/connection.cpp
+++ b/libdbpp/connection.cpp
@@ -1,5 +1,6 @@
#include "connection.h"
#include "modifycommand.h"
+#include "selectcommand.h"
#include "error.h"
#include <factory.impl.h>
#include <buffer.h>
@@ -28,6 +29,19 @@ DB::Connection::execute(const std::string & sql) const
cmd->execute(true);
}
+
+DB::SelectCommandPtr
+DB::Connection::select(const std::string & sql)
+{
+ return DB::SelectCommandPtr(newSelectCommand(sql));
+}
+
+DB::ModifyCommandPtr
+DB::Connection::modify(const std::string & sql)
+{
+ return DB::ModifyCommandPtr(newModifyCommand(sql));
+}
+
void
DB::Connection::executeScript(std::istream & f, const boost::filesystem::path & s) const
{
diff --git a/libdbpp/connection.h b/libdbpp/connection.h
index 7ee1bc9..8430b3d 100644
--- a/libdbpp/connection.h
+++ b/libdbpp/connection.h
@@ -117,8 +117,12 @@ namespace DB {
virtual void executeScript(std::istream & f, const boost::filesystem::path & s) const;
/// Create a new select command with the given SQL.
virtual SelectCommand * newSelectCommand(const std::string & sql) const = 0;
+ /// Create a new select command with the given SQL [smart pointer].
+ virtual boost::shared_ptr<SelectCommand> select(const std::string & sql);
/// Create a new modify command with the given SQL.
virtual ModifyCommand * newModifyCommand(const std::string & sql) const = 0;
+ /// Create a new modify command with the given SQL [smart pointer].
+ virtual boost::shared_ptr<ModifyCommand> modify(const std::string & sql);
/// Begin a bulk upload operation.
/// @param table the target table.