From c42afafb8c812a11c2f6922acc1559c63215756f Mon Sep 17 00:00:00 2001 From: Eric Hardisty Date: Thu, 22 Mar 2018 21:12:36 -0400 Subject: [PATCH] Move from boost::shared_ptr to std::shared_ptr --- CMakeLists.txt | 3 ++- README.md | 4 ++-- src/Channel.cpp | 8 ++++---- src/SimpleAmqpClient/BasicMessage.h | 12 ++++++------ src/SimpleAmqpClient/Channel.h | 23 +++++++++++++---------- src/SimpleAmqpClient/Envelope.h | 13 ++++++------- src/SimpleAmqpClient/TableImpl.h | 4 ++-- src/TableImpl.cpp | 4 ++-- 8 files changed, 37 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b01606a..d40f346c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.1) PROJECT(SimpleAmqpClient) @@ -117,6 +117,7 @@ SET(SAC_LIB_SRCS ADD_LIBRARY(SimpleAmqpClient ${SAC_LIB_SRCS}) TARGET_LINK_LIBRARIES(SimpleAmqpClient ${Rabbitmqc_LIBRARY} ${Boost_LIBRARIES} ${SOCKET_LIBRARY}) +TARGET_COMPILE_FEATURES(SimpleAmqpClient PUBLIC cxx_std_11) if (WIN32) set_target_properties(SimpleAmqpClient PROPERTIES VERSION ${SAC_VERSION} OUTPUT_NAME SimpleAmqpClient.${SAC_SOVERSION}) diff --git a/README.md b/README.md index 57df4677..927e5722 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,9 @@ instance of this class. AmqpClient::Channel::ptr_t connection = AmqpClient::Channel::Create("localhost"); -All classes have a typedef ptr_t which is equivalent to boost::shared_ptr<> of the +All classes have a typedef ptr_t which is equivalent to std::shared_ptr<> of the containing class. All classes also have a Create() method does the job creating a new -ptr_t using boost::make_shared<>(). It is recommended that you use these methods +ptr_t using std::make_shared<>(). It is recommended that you use these methods to construct objects in the library. Commands dealing with declaring/binding/unbinding/deleting exchanges and queues are diff --git a/src/Channel.cpp b/src/Channel.cpp index a7fbfc46..2bab0042 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -72,8 +72,8 @@ Channel::ptr_t Channel::CreateFromUri(const std::string &uri, int frame_max) { amqp_connection_info info; amqp_default_connection_info(&info); - boost::shared_ptr uri_dup = - boost::shared_ptr(strdup(uri.c_str()), free); + std::shared_ptr uri_dup = + std::shared_ptr(strdup(uri.c_str()), free); if (0 != amqp_parse_url(uri_dup.get(), &info)) { throw BadUriException(); @@ -91,8 +91,8 @@ Channel::ptr_t Channel::CreateSecureFromUri( amqp_connection_info info; amqp_default_connection_info(&info); - boost::shared_ptr uri_dup = - boost::shared_ptr(strdup(uri.c_str()), free); + std::shared_ptr uri_dup = + std::shared_ptr(strdup(uri.c_str()), free); if (0 != amqp_parse_url(uri_dup.get(), &info)) { throw BadUriException(); diff --git a/src/SimpleAmqpClient/BasicMessage.h b/src/SimpleAmqpClient/BasicMessage.h index f84d1b35..03a4742d 100644 --- a/src/SimpleAmqpClient/BasicMessage.h +++ b/src/SimpleAmqpClient/BasicMessage.h @@ -32,10 +32,10 @@ #include "SimpleAmqpClient/Util.h" #include -#include #include -#include #include + +#include #include #ifdef _MSC_VER @@ -54,14 +54,14 @@ class BasicMessageImpl; class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { public: - typedef boost::shared_ptr ptr_t; + typedef std::shared_ptr ptr_t; enum delivery_mode_t { dm_nonpersistent = 1, dm_persistent = 2 }; /** * Create a new empty BasicMessage object */ - static ptr_t Create() { return boost::make_shared(); } + static ptr_t Create() { return std::make_shared(); } /** * Create a new BasicMessage object @@ -70,7 +70,7 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { * @returns a new BasicMessage object */ static ptr_t Create(const std::string &body) { - return boost::make_shared(body); + return std::make_shared(body); } /** @@ -85,7 +85,7 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { */ static ptr_t Create(amqp_bytes_t_ &body, amqp_basic_properties_t_ *properties) { - return boost::make_shared(body, properties); + return std::make_shared(body, properties); } BasicMessage(); diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index a5be51a1..1b85a708 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -34,10 +34,10 @@ #include "SimpleAmqpClient/Util.h" #include -#include #include -#include #include + +#include #include #include @@ -58,7 +58,7 @@ class ChannelImpl; */ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { public: - typedef boost::shared_ptr ptr_t; + typedef std::shared_ptr ptr_t; static const std::string EXCHANGE_TYPE_DIRECT; static const std::string EXCHANGE_TYPE_FANOUT; @@ -87,8 +87,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { const std::string &username = "guest", const std::string &password = "guest", const std::string &vhost = "/", int frame_max = 131072) { - return boost::make_shared(host, port, username, password, vhost, - frame_max); + return std::make_shared(host, port, username, password, vhost, + frame_max); } protected: @@ -141,8 +141,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { ssl_params.path_to_client_cert = path_to_client_cert; ssl_params.verify_hostname = verify_hostname; - return boost::make_shared(host, port, username, password, vhost, - frame_max, ssl_params); + return std::make_shared(host, port, username, password, vhost, + frame_max, ssl_params); } /** @@ -532,12 +532,15 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * overload * doesn't require the Envelope object to Acknowledge * - * Note that ack'ing multiple message is scoped messages delivered on a given AMQP channel. - * SimpleAmqpClient uses one channel per consumer, so multiple ack means all un-ack'd messages + * Note that ack'ing multiple message is scoped messages delivered on a given + * AMQP channel. + * SimpleAmqpClient uses one channel per consumer, so multiple ack means all + * un-ack'd messages * up to and including the current message id for a given consumer. * * @param delivery_info - * @param multiple if true, ack all messages up to this delivery tag, if false ack only this delivery tag + * @param multiple if true, ack all messages up to this delivery tag, if false + * ack only this delivery tag */ void BasicAck(const Envelope::DeliveryInfo &info, bool multiple); diff --git a/src/SimpleAmqpClient/Envelope.h b/src/SimpleAmqpClient/Envelope.h index a7f38725..8b97fc07 100644 --- a/src/SimpleAmqpClient/Envelope.h +++ b/src/SimpleAmqpClient/Envelope.h @@ -32,10 +32,9 @@ #include "SimpleAmqpClient/Util.h" #include -#include #include -#include +#include #include #ifdef _MSC_VER @@ -47,7 +46,7 @@ namespace AmqpClient { class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { public: - typedef boost::shared_ptr ptr_t; + typedef std::shared_ptr ptr_t; /** * Creates an new envelope object @@ -59,7 +58,7 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { * @param redelivered a flag indicating whether the message consumed as a * result of a redelivery * @param routing_key the routing key that the message was published with - * @returns a boost::shared_ptr to an envelope object + * @returns a std::shared_ptr to an envelope object */ static ptr_t Create(const BasicMessage::ptr_t message, const std::string &consumer_tag, @@ -67,9 +66,9 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { const std::string &exchange, bool redelivered, const std::string &routing_key, const boost::uint16_t delivery_channel) { - return boost::make_shared(message, consumer_tag, delivery_tag, - exchange, redelivered, routing_key, - delivery_channel); + return std::make_shared(message, consumer_tag, delivery_tag, + exchange, redelivered, routing_key, + delivery_channel); } explicit Envelope(const BasicMessage::ptr_t message, diff --git a/src/SimpleAmqpClient/TableImpl.h b/src/SimpleAmqpClient/TableImpl.h index a8d323b5..b8ebdb7b 100644 --- a/src/SimpleAmqpClient/TableImpl.h +++ b/src/SimpleAmqpClient/TableImpl.h @@ -31,9 +31,9 @@ #include "SimpleAmqpClient/Table.h" #include -#include #include +#include #include #include @@ -42,7 +42,7 @@ namespace AmqpClient { namespace Detail { -typedef boost::shared_ptr amqp_pool_ptr_t; +typedef std::shared_ptr amqp_pool_ptr_t; struct void_t {}; diff --git a/src/TableImpl.cpp b/src/TableImpl.cpp index a74e60d2..2175e416 100644 --- a/src/TableImpl.cpp +++ b/src/TableImpl.cpp @@ -193,7 +193,7 @@ amqp_table_t TableValueImpl::CreateAmqpTable(const Table &table, return AMQP_EMPTY_TABLE; } - pool = boost::shared_ptr(new amqp_pool_t, free_pool); + pool = std::shared_ptr(new amqp_pool_t, free_pool); init_amqp_pool(pool.get(), 1024); return CreateAmqpTableInner(table, *pool.get()); @@ -298,7 +298,7 @@ amqp_table_t TableValueImpl::CopyTable(const amqp_table_t &table, return AMQP_EMPTY_TABLE; } - pool = boost::shared_ptr(new amqp_pool_t, free_pool); + pool = std::shared_ptr(new amqp_pool_t, free_pool); init_amqp_pool(pool.get(), 1024); return CopyTableInner(table, *pool.get());