From eefce9502a96b49d30aa330e5faefe007312d4d4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 9 Apr 2018 13:43:22 +0100 Subject: C++17 Apply C++17 changes to command options. --- libdbpp/command_fwd.h | 2 ++ libdbpp/connection.cpp | 2 +- libdbpp/connection.h | 8 +++++--- libdbpp/unittests/mockdb.cpp | 6 +++--- libdbpp/unittests/mockdb.h | 6 +++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libdbpp/command_fwd.h b/libdbpp/command_fwd.h index 36776d2..bf7133d 100644 --- a/libdbpp/command_fwd.h +++ b/libdbpp/command_fwd.h @@ -8,6 +8,8 @@ namespace DB { typedef std::map CommandOptionsMap; class CommandOptions; + typedef std::shared_ptr CommandOptionsPtr; + typedef std::shared_ptr CommandOptionsCPtr; class Command; typedef std::shared_ptr CommandPtr; class ModifyCommand; diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp index e771854..276c4ed 100644 --- a/libdbpp/connection.cpp +++ b/libdbpp/connection.cpp @@ -28,7 +28,7 @@ DB::Connection::~Connection() } void -DB::Connection::execute(const std::string & sql, const CommandOptions * opts) +DB::Connection::execute(const std::string & sql, const CommandOptionsCPtr & opts) { modify(sql, opts)->execute(true); } diff --git a/libdbpp/connection.h b/libdbpp/connection.h index 7d27a22..4a424a7 100644 --- a/libdbpp/connection.h +++ b/libdbpp/connection.h @@ -19,6 +19,8 @@ namespace AdHoc { namespace DB { class Command; class CommandOptions; + typedef std::shared_ptr CommandOptionsPtr; + typedef std::shared_ptr CommandOptionsCPtr; class SelectCommand; typedef std::shared_ptr SelectCommandPtr; class ModifyCommand; @@ -115,15 +117,15 @@ namespace DB { /// @endcond /// Straight up execute a statement (no access to result set) - virtual void execute(const std::string & sql, const CommandOptions * = nullptr); + virtual void execute(const std::string & sql, const CommandOptionsCPtr & = nullptr); /// Execute a script from a stream. /// @param f the script. /// @param s the location of the script. virtual void executeScript(std::istream & f, const boost::filesystem::path & s); /// Create a new select command with the given SQL. - virtual SelectCommandPtr select(const std::string & sql, const CommandOptions * = nullptr) = 0; + virtual SelectCommandPtr select(const std::string & sql, const CommandOptionsCPtr & = nullptr) = 0; /// Create a new modify command with the given SQL. - virtual ModifyCommandPtr modify(const std::string & sql, const CommandOptions * = nullptr) = 0; + virtual ModifyCommandPtr modify(const std::string & sql, const CommandOptionsCPtr & = nullptr) = 0; /// Begin a bulk upload operation. /// @param table the target table. diff --git a/libdbpp/unittests/mockdb.cpp b/libdbpp/unittests/mockdb.cpp index 6b5a7cc..d831b57 100644 --- a/libdbpp/unittests/mockdb.cpp +++ b/libdbpp/unittests/mockdb.cpp @@ -38,7 +38,7 @@ MockDb::bulkUpdateStyle() const } void -MockDb::execute(const std::string & sql, const DB::CommandOptions *) +MockDb::execute(const std::string & sql, const DB::CommandOptionsCPtr &) { if (sql.substr(0, 3) == "Not") { throw DB::Error(); @@ -47,13 +47,13 @@ MockDb::execute(const std::string & sql, const DB::CommandOptions *) } DB::SelectCommandPtr -MockDb::select(const std::string &, const DB::CommandOptions *) +MockDb::select(const std::string &, const DB::CommandOptionsCPtr &) { return nullptr; } DB::ModifyCommandPtr -MockDb::modify(const std::string &, const DB::CommandOptions *) +MockDb::modify(const std::string &, const DB::CommandOptionsCPtr &) { return nullptr; } diff --git a/libdbpp/unittests/mockdb.h b/libdbpp/unittests/mockdb.h index 53fd451..41d63e1 100644 --- a/libdbpp/unittests/mockdb.h +++ b/libdbpp/unittests/mockdb.h @@ -15,9 +15,9 @@ class MockDb : public DB::Connection { DB::BulkDeleteStyle bulkDeleteStyle() const override; DB::BulkUpdateStyle bulkUpdateStyle() const override; - void execute(const std::string & sql, const DB::CommandOptions *) override; - DB::SelectCommandPtr select(const std::string &, const DB::CommandOptions *) override; - DB::ModifyCommandPtr modify(const std::string &, const DB::CommandOptions *) override; + void execute(const std::string & sql, const DB::CommandOptionsCPtr &) override; + DB::SelectCommandPtr select(const std::string &, const DB::CommandOptionsCPtr &) override; + DB::ModifyCommandPtr modify(const std::string &, const DB::CommandOptionsCPtr &) override; mutable std::vector executed; }; -- cgit v1.2.3