From dd9229d14296fce3ec70a616075581c22725f594 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 3 Aug 2020 01:32:22 +0000 Subject: [PATCH 01/39] lib: refactor Channel ctor and Create funcs This does a better job of hiding implementation details and better prevents users from accidentially taking a dependency on the internal implementation details about how the Channel constructor works. This may be a breaking change for those that have used one of the existing constructors directly instead of one of the Create factory functions. This sets the groundwork for an upcoming API improvement of this interface. --- src/Channel.cpp | 132 +++++++++++++++++++++++------ src/ChannelImpl.cpp | 101 ++++++++++++---------- src/SimpleAmqpClient/Channel.h | 117 ++++++------------------- src/SimpleAmqpClient/ChannelImpl.h | 5 +- 4 files changed, 188 insertions(+), 167 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 46562c57..30806048 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -143,6 +143,80 @@ const std::string Channel::EXCHANGE_TYPE_DIRECT("direct"); const std::string Channel::EXCHANGE_TYPE_FANOUT("fanout"); const std::string Channel::EXCHANGE_TYPE_TOPIC("topic"); +struct Channel::SSLConnectionParams { + std::string path_to_ca_cert; + std::string path_to_client_key; + std::string path_to_client_cert; + bool verify_hostname; + bool verify_peer; +}; + +Channel::ptr_t Channel::Create(const std::string &host, int port, + const std::string &username, + const std::string &password, + const std::string &vhost, int frame_max) { + return boost::make_shared( + OpenChannel(host, port, username, password, vhost, frame_max, false)); +} + +Channel::ptr_t Channel::CreateSaslExternal(const std::string &host, int port, + const std::string &identity, + const std::string &vhost, + int frame_max) { + return boost::make_shared( + OpenChannel(host, port, identity, "", vhost, frame_max, true)); +} + +Channel::ptr_t Channel::CreateSecure(const std::string &path_to_ca_cert, + const std::string &host, + const std::string &path_to_client_key, + const std::string &path_to_client_cert, + int port, const std::string &username, + const std::string &password, + const std::string &vhost, int frame_max, + bool verify_hostname_and_peer) { + return CreateSecure(path_to_ca_cert, host, path_to_client_key, + path_to_client_cert, port, username, password, vhost, + frame_max, verify_hostname_and_peer, + verify_hostname_and_peer); +} + +Channel::ptr_t Channel::CreateSecure(const std::string &path_to_ca_cert, + const std::string &host, + const std::string &path_to_client_key, + const std::string &path_to_client_cert, + int port, const std::string &username, + const std::string &password, + const std::string &vhost, int frame_max, + bool verify_hostname, bool verify_peer) { + SSLConnectionParams ssl_params; + ssl_params.path_to_ca_cert = path_to_ca_cert; + ssl_params.path_to_client_key = path_to_client_key; + ssl_params.path_to_client_cert = path_to_client_cert; + ssl_params.verify_hostname = verify_hostname; + ssl_params.verify_peer = verify_peer; + + return boost::make_shared(OpenSecureChannel( + host, port, username, password, vhost, frame_max, ssl_params, false)); +} + +Channel::ptr_t Channel::CreateSecureSaslExternal( + const std::string &path_to_ca_cert, const std::string &host, + const std::string &path_to_client_key, + const std::string &path_to_client_cert, int port, + const std::string &identity, const std::string &vhost, int frame_max, + bool verify_hostname, bool verify_peer) { + SSLConnectionParams ssl_params; + ssl_params.path_to_ca_cert = path_to_ca_cert; + ssl_params.path_to_client_key = path_to_client_key; + ssl_params.path_to_client_cert = path_to_client_cert; + ssl_params.verify_hostname = verify_hostname; + ssl_params.verify_peer = verify_peer; + + return boost::make_shared(OpenSecureChannel( + host, port, identity, "", vhost, frame_max, ssl_params, true)); +} + Channel::ptr_t Channel::CreateFromUri(const std::string &uri, int frame_max) { amqp_connection_info info; amqp_default_connection_info(&info); @@ -183,42 +257,46 @@ Channel::ptr_t Channel::CreateSecureFromUri( "CreateSecureFromUri only supports SSL-enabled URIs."); } -Channel::Channel(const std::string &host, int port, const std::string &username, - const std::string &password, const std::string &vhost, - int frame_max, bool sasl_external) - : m_impl(new Detail::ChannelImpl) { - m_impl->m_connection = amqp_new_connection(); +Channel::ChannelImpl *Channel::OpenChannel(const std::string &host, int port, + const std::string &username, + const std::string &password, + const std::string &vhost, + int frame_max, bool sasl_external) { + ChannelImpl *impl = new ChannelImpl; + impl->m_connection = amqp_new_connection(); - if (NULL == m_impl->m_connection) { + if (NULL == impl->m_connection) { throw std::bad_alloc(); } try { - amqp_socket_t *socket = amqp_tcp_socket_new(m_impl->m_connection); + amqp_socket_t *socket = amqp_tcp_socket_new(impl->m_connection); int sock = amqp_socket_open(socket, host.c_str(), port); - m_impl->CheckForError(sock); + impl->CheckForError(sock); - m_impl->DoLogin(username, password, vhost, frame_max, sasl_external); + impl->DoLogin(username, password, vhost, frame_max, sasl_external); } catch (...) { - amqp_destroy_connection(m_impl->m_connection); + amqp_destroy_connection(impl->m_connection); + delete impl; throw; } - m_impl->SetIsConnected(true); + impl->SetIsConnected(true); + return impl; } #ifdef SAC_SSL_SUPPORT_ENABLED -Channel::Channel(const std::string &host, int port, const std::string &username, - const std::string &password, const std::string &vhost, - int frame_max, const SSLConnectionParams &ssl_params, - bool sasl_external) - : m_impl(new Detail::ChannelImpl) { - m_impl->m_connection = amqp_new_connection(); - if (NULL == m_impl->m_connection) { +Channel::ChannelImpl *Channel::OpenSecureChannel( + const std::string &host, int port, const std::string &username, + const std::string &password, const std::string &vhost, int frame_max, + const SSLConnectionParams &ssl_params, bool sasl_external) { + Channel::ChannelImpl *impl = new ChannelImpl; + impl->m_connection = amqp_new_connection(); + if (NULL == impl->m_connection) { throw std::bad_alloc(); } - amqp_socket_t *socket = amqp_ssl_socket_new(m_impl->m_connection); + amqp_socket_t *socket = amqp_ssl_socket_new(impl->m_connection); if (NULL == socket) { throw std::bad_alloc(); } @@ -254,23 +332,27 @@ Channel::Channel(const std::string &host, int port, const std::string &username, status, "Error setting client certificate for socket"); } - m_impl->DoLogin(username, password, vhost, frame_max, sasl_external); + impl->DoLogin(username, password, vhost, frame_max, sasl_external); } catch (...) { - amqp_destroy_connection(m_impl->m_connection); + amqp_destroy_connection(impl->m_connection); + delete impl; throw; } - m_impl->SetIsConnected(true); + impl->SetIsConnected(true); + return impl; } #else -Channel::Channel(const std::string &, int, const std::string &, - const std::string &, const std::string &, int, - const SSLConnectionParams &, bool) { +Channel::ChannelImpl *Channel::OpenSecureChannel( + const std::string &, int, const std::string &, const std::string &, + const std::string &, int, const SSLConnectionParams &, bool) { throw std::logic_error( "SSL support has not been compiled into SimpleAmqpClient"); } #endif +Channel::Channel(ChannelImpl *impl) : m_impl(impl) {} + Channel::~Channel() { amqp_connection_close(m_impl->m_connection, AMQP_REPLY_SUCCESS); amqp_destroy_connection(m_impl->m_connection); diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index 627b8de7..eb276ca3 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -57,7 +57,6 @@ #define BROKER_HEARTBEAT 0 namespace AmqpClient { -namespace Detail { namespace { @@ -108,20 +107,22 @@ void SetMessageProperties(BasicMessage &mes, mes.ClusterId(BytesToString(props.cluster_id)); } if (0 != (props._flags & AMQP_BASIC_HEADERS_FLAG)) { - mes.HeaderTable(TableValueImpl::CreateTable(props.headers)); + mes.HeaderTable(Detail::TableValueImpl::CreateTable(props.headers)); } } } // namespace -ChannelImpl::ChannelImpl() : m_last_used_channel(0), m_is_connected(false) { +Channel::ChannelImpl::ChannelImpl() + : m_last_used_channel(0), m_is_connected(false) { m_channels.push_back(CS_Used); } -ChannelImpl::~ChannelImpl() {} +Channel::ChannelImpl::~ChannelImpl() {} -void ChannelImpl::DoLogin(const std::string &username, - const std::string &password, const std::string &vhost, - int frame_max, bool sasl_external) { +void Channel::ChannelImpl::DoLogin(const std::string &username, + const std::string &password, + const std::string &vhost, int frame_max, + bool sasl_external) { amqp_table_entry_t capabilties[1]; amqp_table_entry_t capability_entry; amqp_table_t client_properties; @@ -155,7 +156,7 @@ void ChannelImpl::DoLogin(const std::string &username, m_brokerVersion = ComputeBrokerVersion(m_connection); } -amqp_channel_t ChannelImpl::GetNextChannelId() { +amqp_channel_t Channel::ChannelImpl::GetNextChannelId() { channel_state_list_t::iterator unused_channel = std::find(m_channels.begin(), m_channels.end(), CS_Closed); @@ -175,7 +176,7 @@ amqp_channel_t ChannelImpl::GetNextChannelId() { return unused_channel - m_channels.begin(); } -amqp_channel_t ChannelImpl::CreateNewChannel() { +amqp_channel_t Channel::ChannelImpl::CreateNewChannel() { amqp_channel_t new_channel = GetNextChannelId(); static const boost::array OPEN_OK = { @@ -195,7 +196,7 @@ amqp_channel_t ChannelImpl::CreateNewChannel() { return new_channel; } -amqp_channel_t ChannelImpl::GetChannel() { +amqp_channel_t Channel::ChannelImpl::GetChannel() { if (CS_Open == m_channels.at(m_last_used_channel)) { m_channels[m_last_used_channel] = CS_Used; return m_last_used_channel; @@ -214,16 +215,16 @@ amqp_channel_t ChannelImpl::GetChannel() { return it - m_channels.begin(); } -void ChannelImpl::ReturnChannel(amqp_channel_t channel) { +void Channel::ChannelImpl::ReturnChannel(amqp_channel_t channel) { m_channels.at(channel) = CS_Open; m_last_used_channel = channel; } -bool ChannelImpl::IsChannelOpen(amqp_channel_t channel) { +bool Channel::ChannelImpl::IsChannelOpen(amqp_channel_t channel) { return CS_Closed != m_channels.at(channel); } -void ChannelImpl::FinishCloseChannel(amqp_channel_t channel) { +void Channel::ChannelImpl::FinishCloseChannel(amqp_channel_t channel) { m_channels.at(channel) = CS_Closed; amqp_channel_close_ok_t close_ok; @@ -231,14 +232,14 @@ void ChannelImpl::FinishCloseChannel(amqp_channel_t channel) { AMQP_CHANNEL_CLOSE_OK_METHOD, &close_ok)); } -void ChannelImpl::FinishCloseConnection() { +void Channel::ChannelImpl::FinishCloseConnection() { SetIsConnected(false); amqp_connection_close_ok_t close_ok; amqp_send_method(m_connection, 0, AMQP_CONNECTION_CLOSE_OK_METHOD, &close_ok); } -void ChannelImpl::CheckRpcReply(amqp_channel_t channel, - const amqp_rpc_reply_t &reply) { +void Channel::ChannelImpl::CheckRpcReply(amqp_channel_t channel, + const amqp_rpc_reply_t &reply) { switch (reply.reply_type) { case AMQP_RESPONSE_NORMAL: return; @@ -263,13 +264,13 @@ void ChannelImpl::CheckRpcReply(amqp_channel_t channel, } } -void ChannelImpl::CheckForError(int ret) { +void Channel::ChannelImpl::CheckForError(int ret) { if (ret < 0) { throw AmqpLibraryException::CreateException(ret); } } -MessageReturnedException ChannelImpl::CreateMessageReturnedException( +MessageReturnedException Channel::ChannelImpl::CreateMessageReturnedException( amqp_basic_return_t &return_method, amqp_channel_t channel) { const int reply_code = return_method.reply_code; const std::string reply_text((char *)return_method.reply_text.bytes, @@ -283,7 +284,7 @@ MessageReturnedException ChannelImpl::CreateMessageReturnedException( routing_key); } -BasicMessage::ptr_t ChannelImpl::ReadContent(amqp_channel_t channel) { +BasicMessage::ptr_t Channel::ChannelImpl::ReadContent(amqp_channel_t channel) { amqp_frame_t frame; GetNextFrameOnChannel(channel, frame); @@ -332,8 +333,8 @@ BasicMessage::ptr_t ChannelImpl::ReadContent(amqp_channel_t channel) { return message; } -void ChannelImpl::CheckFrameForClose(amqp_frame_t &frame, - amqp_channel_t channel) { +void Channel::ChannelImpl::CheckFrameForClose(amqp_frame_t &frame, + amqp_channel_t channel) { if (frame.frame_type == AMQP_FRAME_METHOD) { switch (frame.payload.method.id) { case AMQP_CHANNEL_CLOSE_METHOD: @@ -351,12 +352,13 @@ void ChannelImpl::CheckFrameForClose(amqp_frame_t &frame, } } -void ChannelImpl::AddConsumer(const std::string &consumer_tag, - amqp_channel_t channel) { +void Channel::ChannelImpl::AddConsumer(const std::string &consumer_tag, + amqp_channel_t channel) { m_consumer_channel_map.insert(std::make_pair(consumer_tag, channel)); } -amqp_channel_t ChannelImpl::RemoveConsumer(const std::string &consumer_tag) { +amqp_channel_t Channel::ChannelImpl::RemoveConsumer( + const std::string &consumer_tag) { std::map::iterator it = m_consumer_channel_map.find(consumer_tag); if (it == m_consumer_channel_map.end()) { @@ -370,7 +372,7 @@ amqp_channel_t ChannelImpl::RemoveConsumer(const std::string &consumer_tag) { return result; } -amqp_channel_t ChannelImpl::GetConsumerChannel( +amqp_channel_t Channel::ChannelImpl::GetConsumerChannel( const std::string &consumer_tag) { std::map::const_iterator it = m_consumer_channel_map.find(consumer_tag); @@ -380,7 +382,8 @@ amqp_channel_t ChannelImpl::GetConsumerChannel( return it->second; } -std::vector ChannelImpl::GetAllConsumerChannels() const { +std::vector Channel::ChannelImpl::GetAllConsumerChannels() + const { std::vector ret; for (consumer_map_t::const_iterator it = m_consumer_channel_map.begin(); it != m_consumer_channel_map.end(); ++it) { @@ -390,18 +393,20 @@ std::vector ChannelImpl::GetAllConsumerChannels() const { return ret; } -bool ChannelImpl::CheckForQueuedMessageOnChannel(amqp_channel_t channel) const { +bool Channel::ChannelImpl::CheckForQueuedMessageOnChannel( + amqp_channel_t channel) const { frame_queue_t::const_iterator it = std::find_if(m_frame_queue.begin(), m_frame_queue.end(), - boost::bind(&ChannelImpl::is_method_on_channel, _1, + boost::bind(&Channel::ChannelImpl::is_method_on_channel, _1, AMQP_BASIC_DELIVER_METHOD, channel)); if (it == m_frame_queue.end()) { return false; } - it = std::find_if(it + 1, m_frame_queue.end(), - boost::bind(&ChannelImpl::is_on_channel, _1, channel)); + it = std::find_if( + it + 1, m_frame_queue.end(), + boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel)); if (it == m_frame_queue.end()) { return false; @@ -414,8 +419,9 @@ bool ChannelImpl::CheckForQueuedMessageOnChannel(amqp_channel_t channel) const { uint64_t body_received = 0; while (body_received < body_length) { - it = std::find_if(it + 1, m_frame_queue.end(), - boost::bind(&ChannelImpl::is_on_channel, _1, channel)); + it = std::find_if( + it + 1, m_frame_queue.end(), + boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel)); if (it == m_frame_queue.end()) { return false; @@ -429,7 +435,7 @@ bool ChannelImpl::CheckForQueuedMessageOnChannel(amqp_channel_t channel) const { return true; } -void ChannelImpl::AddToFrameQueue(const amqp_frame_t &frame) { +void Channel::ChannelImpl::AddToFrameQueue(const amqp_frame_t &frame) { m_frame_queue.push_back(frame); if (CheckForQueuedMessageOnChannel(frame.channel)) { @@ -444,8 +450,8 @@ void ChannelImpl::AddToFrameQueue(const amqp_frame_t &frame) { } } -bool ChannelImpl::GetNextFrameFromBroker(amqp_frame_t &frame, - boost::chrono::microseconds timeout) { +bool Channel::ChannelImpl::GetNextFrameFromBroker( + amqp_frame_t &frame, boost::chrono::microseconds timeout) { struct timeval *tvp = NULL; struct timeval tv_timeout; memset(&tv_timeout, 0, sizeof(tv_timeout)); @@ -477,12 +483,12 @@ bool ChannelImpl::GetNextFrameFromBroker(amqp_frame_t &frame, return true; } -bool ChannelImpl::GetNextFrameOnChannel(amqp_channel_t channel, - amqp_frame_t &frame, - boost::chrono::microseconds timeout) { - frame_queue_t::iterator it = - std::find_if(m_frame_queue.begin(), m_frame_queue.end(), - boost::bind(&ChannelImpl::is_on_channel, _1, channel)); +bool Channel::ChannelImpl::GetNextFrameOnChannel( + amqp_channel_t channel, amqp_frame_t &frame, + boost::chrono::microseconds timeout) { + frame_queue_t::iterator it = std::find_if( + m_frame_queue.begin(), m_frame_queue.end(), + boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel)); if (m_frame_queue.end() != it) { frame = *it; @@ -501,15 +507,17 @@ bool ChannelImpl::GetNextFrameOnChannel(amqp_channel_t channel, return GetNextFrameFromBrokerOnChannel(channels, frame, timeout); } -void ChannelImpl::MaybeReleaseBuffersOnChannel(amqp_channel_t channel) { +void Channel::ChannelImpl::MaybeReleaseBuffersOnChannel( + amqp_channel_t channel) { if (m_frame_queue.end() == - std::find_if(m_frame_queue.begin(), m_frame_queue.end(), - boost::bind(&ChannelImpl::is_on_channel, _1, channel))) { + std::find_if( + m_frame_queue.begin(), m_frame_queue.end(), + boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel))) { amqp_maybe_release_buffers_on_channel(m_connection, channel); } } -void ChannelImpl::CheckIsConnected() { +void Channel::ChannelImpl::CheckIsConnected() { if (!m_is_connected) { throw ConnectionClosedException(); } @@ -526,7 +534,7 @@ bool bytesEqual(amqp_bytes_t r, amqp_bytes_t l) { } } // namespace -boost::uint32_t ChannelImpl::ComputeBrokerVersion( +boost::uint32_t Channel::ChannelImpl::ComputeBrokerVersion( amqp_connection_state_t state) { const amqp_table_t *properties = amqp_get_server_properties(state); const amqp_bytes_t version = amqp_cstring_bytes("version"); @@ -560,5 +568,4 @@ boost::uint32_t ChannelImpl::ComputeBrokerVersion( (version_patch & 0xFF); } -} // namespace Detail } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 4e6a9db3..4b1ae5f3 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -51,10 +51,6 @@ namespace AmqpClient { -namespace Detail { -class ChannelImpl; -} - /** * A single channel multiplexed in an AMQP connection * @@ -89,10 +85,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { static ptr_t Create(const std::string &host = "127.0.0.1", int port = 5672, 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, false); - } + const std::string &vhost = "/", int frame_max = 131072); /** * Creates a new channel object @@ -115,27 +108,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { int port = 5672, const std::string &identity = "guest", const std::string &vhost = "/", - int frame_max = 131072) { - return boost::make_shared(host, port, identity, "", vhost, - frame_max, true); - } - - protected: - /// A POD carrier of SSL connection parameters - struct SSLConnectionParams { - /// CA certificate filepath - std::string path_to_ca_cert; - /// Client key filepath - std::string path_to_client_key; - /// Client certificate filepath - std::string path_to_client_cert; - /// Whether to ignore server hostname mismatch - bool verify_hostname; - /// Wehter to verify the certificate - bool verify_peer; - }; + int frame_max = 131072); - public: /** * Creates a new channel object, using TLS * @@ -166,12 +140,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { const std::string &password = "guest", const std::string &vhost = "/", int frame_max = 131072, - bool verify_hostname_and_peer = true) { - return CreateSecure(path_to_ca_cert, host, path_to_client_key, - path_to_client_cert, port, username, password, vhost, - frame_max, verify_hostname_and_peer, - verify_hostname_and_peer); - } + bool verify_hostname_and_peer = true); /** * Creates a new channel object @@ -205,17 +174,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { const std::string &username, const std::string &password, const std::string &vhost, int frame_max, - bool verify_hostname, bool verify_peer) { - SSLConnectionParams ssl_params; - ssl_params.path_to_ca_cert = path_to_ca_cert; - ssl_params.path_to_client_key = path_to_client_key; - ssl_params.path_to_client_cert = path_to_client_cert; - ssl_params.verify_hostname = verify_hostname; - ssl_params.verify_peer = verify_peer; - - return boost::make_shared(host, port, username, password, vhost, - frame_max, ssl_params, false); - } + bool verify_hostname, bool verify_peer); /** * Creates a new channel object @@ -247,18 +206,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { const std::string &path_to_client_cert, int port, const std::string &identity, const std::string &vhost, int frame_max, - bool verify_hostname, - bool verify_peer) { - SSLConnectionParams ssl_params; - ssl_params.path_to_ca_cert = path_to_ca_cert; - ssl_params.path_to_client_key = path_to_client_key; - ssl_params.path_to_client_cert = path_to_client_cert; - ssl_params.verify_hostname = verify_hostname; - ssl_params.verify_peer = verify_peer; - - return boost::make_shared(host, port, identity, "", vhost, - frame_max, ssl_params, true); - } + bool verify_hostname, bool verify_peer); /** * Create a new Channel object from an AMQP URI @@ -293,41 +241,11 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { bool verify_hostname = true, int frame_max = 131072); - /** - * Constructor. Synchronously connects and logs in to the broker. - * - * @param host The hostname or IP address of the AMQP broker - * @param port The port to connect to the AMQP broker on - * @param username The username used to authenticate with the AMQP broker - * @param password The password corresponding to the username used to - * authenticate with the AMQP broker - * @param vhost The virtual host on the AMQP we should connect to - * @param frame_max Request that the server limit the maximum size of any - * frame to this value - */ - explicit Channel(const std::string &host, int port, - const std::string &username, const std::string &password, - const std::string &vhost, int frame_max, bool sasl_external); - - /** - * Constructor. Synchronously connects and logs in to the broker. - * - * @param host The hostname or IP address of the AMQP broker - * @param port The port to connect to the AMQP broker on - * @param username The username used to authenticate with the AMQP broker - * @param password The password corresponding to the username used to - * authenticate with the AMQP broker - * @param vhost The virtual host on the AMQP we should connect to - * @param frame_max Request that the server limit the maximum size of any - * frame to this value - * @param ssl_params TLS config - */ - explicit Channel(const std::string &host, int port, - const std::string &username, const std::string &password, - const std::string &vhost, int frame_max, - const SSLConnectionParams &ssl_params, bool sasl_external); + private: + class ChannelImpl; public: + explicit Channel(ChannelImpl *impl); virtual ~Channel(); /** @@ -900,9 +818,24 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { */ bool BasicConsumeMessage(Envelope::ptr_t &envelope, int timeout = -1); - protected: + private: + static ChannelImpl *OpenChannel(const std::string &host, int port, + const std::string &username, + const std::string &password, + const std::string &vhost, int frame_max, + bool sasl_external); + + struct SSLConnectionParams; + + static ChannelImpl *OpenSecureChannel(const std::string &host, int port, + const std::string &username, + const std::string &password, + const std::string &vhost, int frame_max, + const SSLConnectionParams &ssl_params, + bool sasl_external); + /// PIMPL idiom - boost::scoped_ptr m_impl; + boost::scoped_ptr m_impl; }; } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index f58cca88..62af935c 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -36,6 +36,7 @@ #include "SimpleAmqpClient/AmqpException.h" #include "SimpleAmqpClient/BasicMessage.h" +#include "SimpleAmqpClient/Channel.h" #include "SimpleAmqpClient/ConsumerCancelledException.h" #include "SimpleAmqpClient/Envelope.h" #include "SimpleAmqpClient/MessageReturnedException.h" @@ -47,9 +48,8 @@ #include namespace AmqpClient { -namespace Detail { -class ChannelImpl : boost::noncopyable { +class Channel::ChannelImpl : boost::noncopyable { public: ChannelImpl(); virtual ~ChannelImpl(); @@ -365,6 +365,5 @@ class ChannelImpl : boost::noncopyable { bool m_is_connected; }; -} // namespace Detail } // namespace AmqpClient #endif // SIMPLEAMQPCLIENT_CHANNELIMPL_H From 38c13a34d1ba09d886083894d95a7e33be22bc61 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 3 Aug 2020 04:00:56 +0000 Subject: [PATCH 02/39] lib: update Channel::CreateSecureFromUri docs Correct the verify_hostname parameter to be verify_hostname_and_peer, and update docs to reflect what its actually doing. --- src/Channel.cpp | 5 +++-- src/SimpleAmqpClient/Channel.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 30806048..18dbb80f 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -235,7 +235,7 @@ Channel::ptr_t Channel::CreateFromUri(const std::string &uri, int frame_max) { Channel::ptr_t Channel::CreateSecureFromUri( const std::string &uri, const std::string &path_to_ca_cert, const std::string &path_to_client_key, - const std::string &path_to_client_cert, bool verify_hostname, + const std::string &path_to_client_cert, bool verify_hostname_and_peer, int frame_max) { amqp_connection_info info; amqp_default_connection_info(&info); @@ -251,7 +251,8 @@ Channel::ptr_t Channel::CreateSecureFromUri( return CreateSecure(path_to_ca_cert, std::string(info.host), path_to_client_key, path_to_client_cert, info.port, std::string(info.user), std::string(info.password), - std::string(info.vhost), frame_max, verify_hostname); + std::string(info.vhost), frame_max, + verify_hostname_and_peer); } throw std::runtime_error( "CreateSecureFromUri only supports SSL-enabled URIs."); diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 4b1ae5f3..70a80fc3 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -229,7 +229,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * @param path_to_client_key Path to client key file * @param path_to_client_cert Path to client certificate file * @param verify_hostname Verify the hostname against the certificate when - * opening the SSL connection. + * opening the SSL connection and the certificate chain that is sent by the + * broker. * @param frame_max requests that the broker limit the maximum size of * any frame to this value * @returns a new Channel object @@ -238,7 +239,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { const std::string &path_to_ca_cert, const std::string &path_to_client_key = "", const std::string &path_to_client_cert = "", - bool verify_hostname = true, + bool verify_hostname_and_peer = true, int frame_max = 131072); private: From b1b973195d6fc03f618d1a8d084892e0b6c0cf4a Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 3 Aug 2020 04:05:36 +0000 Subject: [PATCH 03/39] lib: make CreateFromUri when SSL URI is specified Instead of silently trying to connect without SSL, throw an exception to make the failure explicit. --- src/Channel.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 18dbb80f..2cf5e0fb 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -227,6 +227,10 @@ Channel::ptr_t Channel::CreateFromUri(const std::string &uri, int frame_max) { if (0 != amqp_parse_url(uri_dup.get(), &info)) { throw BadUriException(); } + if (info.ssl) { + throw std::runtime_error( + "CreateFromUri only supports non-SSL-enabled URIs"); + } return Create(std::string(info.host), info.port, std::string(info.user), std::string(info.password), std::string(info.vhost), frame_max); @@ -246,16 +250,16 @@ Channel::ptr_t Channel::CreateSecureFromUri( if (0 != amqp_parse_url(uri_dup.get(), &info)) { throw BadUriException(); } + if (!info.ssl) { + throw std::runtime_error( + "CreateSecureFromUri only supports SSL-enabled URIs"); + } - if (info.ssl) { return CreateSecure(path_to_ca_cert, std::string(info.host), path_to_client_key, path_to_client_cert, info.port, std::string(info.user), std::string(info.password), std::string(info.vhost), frame_max, verify_hostname_and_peer); - } - throw std::runtime_error( - "CreateSecureFromUri only supports SSL-enabled URIs."); } Channel::ChannelImpl *Channel::OpenChannel(const std::string &host, int port, From 427139ea6c63c58f783b99cb2994c20f8411bbe9 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 3 Aug 2020 15:34:44 +0000 Subject: [PATCH 04/39] build: restore GNUInstallDirs include (#265, #266) Include was mistakenly removed due to bad merge, this restores that. Fixed: #265 Fixed: #266 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd329928..7baeb4ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,6 +190,8 @@ if (BUILD_API_DOCS) ) endif () +include(GNUInstallDirs) + install(TARGETS SimpleAmqpClient RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} From f9fb520011477b3bc512defb99e0b0f598d76870 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 3 Aug 2020 15:56:54 +0000 Subject: [PATCH 05/39] Update ChangeLog and version for v2.5.1 release --- CMakeLists.txt | 2 +- ChangeLog.md | 5 +++++ src/SimpleAmqpClient/Version.h | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7baeb4ca..efefbfcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) # 4. If any interfaces have been removed since the last public release, then set age to 0. set(SAC_SOVERSION_CURRENT 7) -set(SAC_SOVERSION_REVISION 0) +set(SAC_SOVERSION_REVISION 1) set(SAC_SOVERSION_AGE 0) math(EXPR SAC_SOVERSION_MAJOR "${SAC_SOVERSION_CURRENT} - ${SAC_SOVERSION_AGE}") diff --git a/ChangeLog.md b/ChangeLog.md index 9ffc90b7..bf879cc6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,8 @@ +# Changes since v2.5.0 (v2.5.1) + + - fix: restore GNUInstallDirs that was mistakenly removed. + - refactor of Channel constructors + # Changes since v2.4 (v2.5) NOTE: this release requires rabbitmq-c v0.8.0 or better. diff --git a/src/SimpleAmqpClient/Version.h b/src/SimpleAmqpClient/Version.h index ce36e03e..d495ffaa 100644 --- a/src/SimpleAmqpClient/Version.h +++ b/src/SimpleAmqpClient/Version.h @@ -29,7 +29,7 @@ */ #define SIMPLEAMQPCLIENT_VERSION_MAJOR 2 -#define SIMPLEAMQPCLIENT_VERSION_MINOR 6 -#define SIMPLEAMQPCLIENT_VERSION_PATCH 0 +#define SIMPLEAMQPCLIENT_VERSION_MINOR 5 +#define SIMPLEAMQPCLIENT_VERSION_PATCH 1 #endif // SIMPLEAMQPCLIENT_VERSION_H From aa9981d1d777855b79a4779e4b2cac3b3463023e Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 3 Aug 2020 16:02:24 +0000 Subject: [PATCH 06/39] Increment version to v2.6 (take 2) v2.5.1 was release to correct a problem with install directories on Debian. --- src/SimpleAmqpClient/Version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SimpleAmqpClient/Version.h b/src/SimpleAmqpClient/Version.h index d495ffaa..ce36e03e 100644 --- a/src/SimpleAmqpClient/Version.h +++ b/src/SimpleAmqpClient/Version.h @@ -29,7 +29,7 @@ */ #define SIMPLEAMQPCLIENT_VERSION_MAJOR 2 -#define SIMPLEAMQPCLIENT_VERSION_MINOR 5 -#define SIMPLEAMQPCLIENT_VERSION_PATCH 1 +#define SIMPLEAMQPCLIENT_VERSION_MINOR 6 +#define SIMPLEAMQPCLIENT_VERSION_PATCH 0 #endif // SIMPLEAMQPCLIENT_VERSION_H From f009117442b74507f177415cad7db2bd5d3052c2 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 6 Aug 2020 06:39:32 +0000 Subject: [PATCH 07/39] lib: add missing headers to SimpleAmqpClient.h --- src/SimpleAmqpClient/SimpleAmqpClient.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SimpleAmqpClient/SimpleAmqpClient.h b/src/SimpleAmqpClient/SimpleAmqpClient.h index 0d804419..6185c3a3 100644 --- a/src/SimpleAmqpClient/SimpleAmqpClient.h +++ b/src/SimpleAmqpClient/SimpleAmqpClient.h @@ -32,7 +32,9 @@ /// This "include all" header file re-exports all of SimpleAmqpClient public API #include "SimpleAmqpClient/AmqpException.h" +#include "SimpleAmqpClient/AmqpLibraryException.h" #include "SimpleAmqpClient/AmqpResponseLibraryException.h" +#include "SimpleAmqpClient/BadUriException.h" #include "SimpleAmqpClient/BasicMessage.h" #include "SimpleAmqpClient/Channel.h" #include "SimpleAmqpClient/ConnectionClosedException.h" @@ -41,6 +43,7 @@ #include "SimpleAmqpClient/Envelope.h" #include "SimpleAmqpClient/MessageRejectedException.h" #include "SimpleAmqpClient/MessageReturnedException.h" +#include "SimpleAmqpClient/Table.h" #include "SimpleAmqpClient/Version.h" #endif // SIMPLEAMQPCLIENT_SIMPLEAMQPCLIENT_H From 09ad35db2e1977e8a51c4aead66727be1e9bbc7c Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 3 Aug 2020 05:57:49 +0000 Subject: [PATCH 08/39] lib: Add Channel::Open factory func API The intent is for this to replace the Channel::Create overload-set which is already hard to read, and even harder to expand. All new features needed as a part of this API will be added here, and the Create API will deprecated, and removed in v3. --- src/Channel.cpp | 256 +++++++++++++++++++++++---------- src/SimpleAmqpClient/Channel.h | 76 +++++++++- testing/connected_test.h | 9 +- testing/test_channels.cpp | 5 +- testing/test_connect.cpp | 62 ++++++++ testing/test_get.cpp | 5 +- testing/test_publish.cpp | 5 +- 7 files changed, 336 insertions(+), 82 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 2cf5e0fb..6f6ad13a 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -143,28 +143,128 @@ const std::string Channel::EXCHANGE_TYPE_DIRECT("direct"); const std::string Channel::EXCHANGE_TYPE_FANOUT("fanout"); const std::string Channel::EXCHANGE_TYPE_TOPIC("topic"); -struct Channel::SSLConnectionParams { - std::string path_to_ca_cert; - std::string path_to_client_key; - std::string path_to_client_cert; - bool verify_hostname; - bool verify_peer; -}; +Channel::OpenOpts Channel::OpenOpts::FromUri(const std::string &uri) { + amqp_connection_info info; + amqp_default_connection_info(&info); + + boost::shared_ptr uri_dup = + boost::shared_ptr(strdup(uri.c_str()), free); + + if (0 != amqp_parse_url(uri_dup.get(), &info)) { + throw BadUriException(); + } + + OpenOpts opts; + opts.host = info.host; + opts.vhost = info.vhost; + opts.port = info.port; + opts.auth = OpenOpts::BasicAuth(info.user, info.password); + if (info.ssl) { + opts.tls_params = OpenOpts::TLSParams(); + } + return opts; +} + +bool Channel::OpenOpts::BasicAuth::operator==(const BasicAuth &o) const { + return username == o.username && password == o.password; +} + +bool Channel::OpenOpts::ExternalSaslAuth::operator==( + const ExternalSaslAuth &o) const { + return identity == o.identity; +} + +bool Channel::OpenOpts::TLSParams::operator==(const TLSParams &o) const { + return client_key_path == o.client_key_path && + client_cert_path == o.client_cert_path && + ca_cert_path == o.ca_cert_path && + verify_hostname == o.verify_hostname && verify_peer == o.verify_peer; +} + +bool Channel::OpenOpts::operator==(const OpenOpts &o) const { + return host == o.host && vhost == o.vhost && port == o.port && + frame_max == o.frame_max && auth == o.auth && + tls_params == o.tls_params; +} + +Channel::ptr_t Channel::Open(const OpenOpts &opts) { + if (opts.host.empty()) { + throw std::runtime_error("opts.host is not specified, it is required"); + } + if (opts.vhost.empty()) { + throw std::runtime_error("opts.vhost is not specified, it is required"); + } + if (opts.port <= 0) { + throw std::runtime_error( + "opts.port is not valid, it must be a positive number"); + } + if (opts.auth.empty()) { + throw std::runtime_error("opts.auth is not specified, it is required"); + } + if (!opts.tls_params.is_initialized()) { + switch (opts.auth.which()) { + case 0: { + const OpenOpts::BasicAuth &auth = + boost::get(opts.auth); + return boost::make_shared( + OpenChannel(opts.host, opts.port, auth.username, auth.password, + opts.vhost, opts.frame_max, false)); + } + case 1: { + const OpenOpts::ExternalSaslAuth &auth = + boost::get(opts.auth); + return boost::make_shared( + OpenChannel(opts.host, opts.port, auth.identity, "", opts.vhost, + opts.frame_max, true)); + } + default: + throw std::logic_error("Unhandled auth type"); + } + } + switch (opts.auth.which()) { + case 0: { + const OpenOpts::BasicAuth &auth = + boost::get(opts.auth); + return boost::make_shared(OpenSecureChannel( + opts.host, opts.port, auth.username, auth.password, opts.vhost, + opts.frame_max, opts.tls_params.get(), false)); + } + case 1: { + const OpenOpts::ExternalSaslAuth &auth = + boost::get(opts.auth); + return boost::make_shared( + OpenSecureChannel(opts.host, opts.port, auth.identity, "", opts.vhost, + opts.frame_max, opts.tls_params.get(), true)); + } + default: + throw std::logic_error("Unhandled auth type"); + } +} Channel::ptr_t Channel::Create(const std::string &host, int port, const std::string &username, const std::string &password, const std::string &vhost, int frame_max) { - return boost::make_shared( - OpenChannel(host, port, username, password, vhost, frame_max, false)); + OpenOpts opts; + opts.host = host; + opts.vhost = vhost; + opts.port = port; + opts.frame_max = frame_max; + opts.auth = OpenOpts::BasicAuth(username, password); + return Open(opts); } Channel::ptr_t Channel::CreateSaslExternal(const std::string &host, int port, const std::string &identity, const std::string &vhost, int frame_max) { - return boost::make_shared( - OpenChannel(host, port, identity, "", vhost, frame_max, true)); + OpenOpts opts; + opts.host = host; + opts.vhost = vhost; + opts.port = port; + opts.frame_max = frame_max; + opts.auth = OpenOpts::ExternalSaslAuth(identity); + return Open(opts); } Channel::ptr_t Channel::CreateSecure(const std::string &path_to_ca_cert, @@ -175,10 +275,22 @@ Channel::ptr_t Channel::CreateSecure(const std::string &path_to_ca_cert, const std::string &password, const std::string &vhost, int frame_max, bool verify_hostname_and_peer) { - return CreateSecure(path_to_ca_cert, host, path_to_client_key, - path_to_client_cert, port, username, password, vhost, - frame_max, verify_hostname_and_peer, - verify_hostname_and_peer); + OpenOpts::TLSParams params; + params.client_key_path = path_to_client_key; + params.client_cert_path = path_to_client_cert; + params.ca_cert_path = path_to_ca_cert; + params.verify_hostname = verify_hostname_and_peer; + params.verify_peer = verify_hostname_and_peer; + + OpenOpts opts; + opts.host = host; + opts.vhost = vhost; + opts.port = port; + opts.frame_max = frame_max; + opts.auth = OpenOpts::BasicAuth(username, password); + opts.tls_params = params; + + return Open(opts); } Channel::ptr_t Channel::CreateSecure(const std::string &path_to_ca_cert, @@ -189,15 +301,22 @@ Channel::ptr_t Channel::CreateSecure(const std::string &path_to_ca_cert, const std::string &password, const std::string &vhost, int frame_max, bool verify_hostname, bool verify_peer) { - SSLConnectionParams ssl_params; - ssl_params.path_to_ca_cert = path_to_ca_cert; - ssl_params.path_to_client_key = path_to_client_key; - ssl_params.path_to_client_cert = path_to_client_cert; - ssl_params.verify_hostname = verify_hostname; - ssl_params.verify_peer = verify_peer; - - return boost::make_shared(OpenSecureChannel( - host, port, username, password, vhost, frame_max, ssl_params, false)); + OpenOpts::TLSParams params; + params.client_key_path = path_to_client_key; + params.client_cert_path = path_to_client_cert; + params.ca_cert_path = path_to_ca_cert; + params.verify_hostname = verify_hostname; + params.verify_peer = verify_peer; + + OpenOpts opts; + opts.host = host; + opts.vhost = vhost; + opts.port = port; + opts.frame_max = frame_max; + opts.auth = OpenOpts::BasicAuth(username, password); + opts.tls_params = params; + + return Open(opts); } Channel::ptr_t Channel::CreateSecureSaslExternal( @@ -206,34 +325,32 @@ Channel::ptr_t Channel::CreateSecureSaslExternal( const std::string &path_to_client_cert, int port, const std::string &identity, const std::string &vhost, int frame_max, bool verify_hostname, bool verify_peer) { - SSLConnectionParams ssl_params; - ssl_params.path_to_ca_cert = path_to_ca_cert; - ssl_params.path_to_client_key = path_to_client_key; - ssl_params.path_to_client_cert = path_to_client_cert; - ssl_params.verify_hostname = verify_hostname; - ssl_params.verify_peer = verify_peer; - - return boost::make_shared(OpenSecureChannel( - host, port, identity, "", vhost, frame_max, ssl_params, true)); + OpenOpts::TLSParams params; + params.client_key_path = path_to_client_key; + params.client_cert_path = path_to_client_cert; + params.ca_cert_path = path_to_ca_cert; + params.verify_hostname = verify_hostname; + params.verify_peer = verify_peer; + + OpenOpts opts; + opts.host = host; + opts.vhost = vhost; + opts.port = port; + opts.frame_max = frame_max; + opts.auth = OpenOpts::ExternalSaslAuth(identity); + opts.tls_params = params; + + return Open(opts); } 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); - - if (0 != amqp_parse_url(uri_dup.get(), &info)) { - throw BadUriException(); - } - if (info.ssl) { + OpenOpts opts = OpenOpts::FromUri(uri); + if (opts.tls_params.is_initialized()) { throw std::runtime_error( "CreateFromUri only supports non-SSL-enabled URIs"); } - - return Create(std::string(info.host), info.port, std::string(info.user), - std::string(info.password), std::string(info.vhost), frame_max); + opts.frame_max = frame_max; + return Open(opts); } Channel::ptr_t Channel::CreateSecureFromUri( @@ -241,25 +358,21 @@ Channel::ptr_t Channel::CreateSecureFromUri( const std::string &path_to_client_key, const std::string &path_to_client_cert, bool verify_hostname_and_peer, 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); - - if (0 != amqp_parse_url(uri_dup.get(), &info)) { - throw BadUriException(); - } - if (!info.ssl) { + OpenOpts opts = OpenOpts::FromUri(uri); + if (!opts.tls_params.is_initialized()) { throw std::runtime_error( "CreateSecureFromUri only supports SSL-enabled URIs"); } - return CreateSecure(path_to_ca_cert, std::string(info.host), - path_to_client_key, path_to_client_cert, info.port, - std::string(info.user), std::string(info.password), - std::string(info.vhost), frame_max, - verify_hostname_and_peer); + OpenOpts::TLSParams params; + opts.tls_params->client_key_path = path_to_client_key; + opts.tls_params->client_cert_path = path_to_client_cert; + opts.tls_params->ca_cert_path = path_to_ca_cert; + opts.tls_params->verify_hostname = verify_hostname_and_peer; + opts.tls_params->verify_peer = verify_hostname_and_peer; + opts.frame_max = frame_max; + + return Open(opts); } Channel::ChannelImpl *Channel::OpenChannel(const std::string &host, int port, @@ -294,7 +407,7 @@ Channel::ChannelImpl *Channel::OpenChannel(const std::string &host, int port, Channel::ChannelImpl *Channel::OpenSecureChannel( const std::string &host, int port, const std::string &username, const std::string &password, const std::string &vhost, int frame_max, - const SSLConnectionParams &ssl_params, bool sasl_external) { + const OpenOpts::TLSParams &tls_params, bool sasl_external) { Channel::ChannelImpl *impl = new ChannelImpl; impl->m_connection = amqp_new_connection(); if (NULL == impl->m_connection) { @@ -306,25 +419,24 @@ Channel::ChannelImpl *Channel::OpenSecureChannel( throw std::bad_alloc(); } #if AMQP_VERSION >= 0x00080001 - amqp_ssl_socket_set_verify_peer(socket, ssl_params.verify_peer); - amqp_ssl_socket_set_verify_hostname(socket, ssl_params.verify_hostname); + amqp_ssl_socket_set_verify_peer(socket, tls_params.verify_peer); + amqp_ssl_socket_set_verify_hostname(socket, tls_params.verify_hostname); #else - amqp_ssl_socket_set_verify(socket, ssl_params.verify_hostname); + amqp_ssl_socket_set_verify(socket, tls_params.verify_hostname); #endif try { int status = - amqp_ssl_socket_set_cacert(socket, ssl_params.path_to_ca_cert.c_str()); + amqp_ssl_socket_set_cacert(socket, tls_params.ca_cert_path.c_str()); if (status) { throw AmqpLibraryException::CreateException( status, "Error setting CA certificate for socket"); } - if (ssl_params.path_to_client_key != "" && - ssl_params.path_to_client_cert != "") { - status = amqp_ssl_socket_set_key(socket, - ssl_params.path_to_client_cert.c_str(), - ssl_params.path_to_client_key.c_str()); + if (tls_params.client_key_path != "" && tls_params.client_cert_path != "") { + status = + amqp_ssl_socket_set_key(socket, tls_params.client_cert_path.c_str(), + tls_params.client_key_path.c_str()); if (status) { throw AmqpLibraryException::CreateException( status, "Error setting client certificate for socket"); @@ -350,7 +462,7 @@ Channel::ChannelImpl *Channel::OpenSecureChannel( #else Channel::ChannelImpl *Channel::OpenSecureChannel( const std::string &, int, const std::string &, const std::string &, - const std::string &, int, const SSLConnectionParams &, bool) { + const std::string &, int, const OpenOpts::TLSParams &, bool) { throw std::logic_error( "SSL support has not been compiled into SimpleAmqpClient"); } diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 70a80fc3..903a03f6 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -30,9 +30,11 @@ #include #include +#include #include #include #include +#include #include #include @@ -67,6 +69,76 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { EXCHANGE_TYPE_FANOUT; ///< `"fanout"` string constant static const std::string EXCHANGE_TYPE_TOPIC; ///< `"topic"` string constant + struct SIMPLEAMQPCLIENT_EXPORT OpenOpts { + /// Use username and password to authenticate with the broker. + struct SIMPLEAMQPCLIENT_EXPORT BasicAuth { + std::string username; + std::string password; + + BasicAuth() {} + BasicAuth(const std::string &username, const std::string &password) + : username(username), password(password) {} + bool operator==(const BasicAuth &) const; + }; + + /// Use External SASL method to authenticate with the broker. + struct SIMPLEAMQPCLIENT_EXPORT ExternalSaslAuth { + std::string identity; + + ExternalSaslAuth() {} + explicit ExternalSaslAuth(const std::string &identity) + : identity(identity) {} + bool operator==(const ExternalSaslAuth &) const; + }; + + /// Parameters + struct SIMPLEAMQPCLIENT_EXPORT TLSParams { + std::string client_key_path; ///< Path to client key. + std::string client_cert_path; ///< Path to client cert. + std::string ca_cert_path; ///< Path to CA cert. + bool verify_hostname; ///< Verify host matches certificate. Default: true + bool verify_peer; ///< Verify presented certificate. Default: true + + TLSParams() : verify_hostname(true), verify_peer(true) {} + bool operator==(const TLSParams &) const; + }; + + std::string host; ///< Broker hostname. Required. + std::string vhost; ///< Virtualhost on the broker. Default '/', required. + int port; ///< Port to connect to, default is 5672. + int frame_max; ///< Max frame size in bytes. Default 128KB. + /// One of BasicAuth or ExternalSaslAuth is required. + boost::variant auth; + /// Connect using TLS/SSL when set, otherwise use an unencrypted channel. + boost::optional tls_params; + + /** + * Create an OpenOpts struct from a URI. + * + * URIs look like amqp[s]://[username[:password]@]host[:port]/[vhost]. + * Unspecified parts of the URL will take default values: + * - username: guest + * - password: guest + * - host: localhost + * - port: 5672 for 'amqp', and 5671 for 'amqps' + * - vhost: '/' + * + * NOTE: for TLS/SSL connections, additional configuration is required. + */ + static OpenOpts FromUri(const std::string &uri); + + OpenOpts() : vhost("/"), port(5672), frame_max(131072) {} + bool operator==(const OpenOpts &) const; + }; + + /** + * Open a new channel to the broker. + * + * See documentation for \ref OpenOpts for details on what can be + * passed into this function. + */ + static ptr_t Open(const OpenOpts &opts); + /** * Creates a new channel object * @@ -826,13 +898,11 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { const std::string &vhost, int frame_max, bool sasl_external); - struct SSLConnectionParams; - static ChannelImpl *OpenSecureChannel(const std::string &host, int port, const std::string &username, const std::string &password, const std::string &vhost, int frame_max, - const SSLConnectionParams &ssl_params, + const OpenOpts::TLSParams &tls_params, bool sasl_external); /// PIMPL idiom diff --git a/testing/connected_test.h b/testing/connected_test.h index b5fb4a10..e1a0c51d 100644 --- a/testing/connected_test.h +++ b/testing/connected_test.h @@ -35,10 +35,17 @@ using namespace AmqpClient; class connected_test : public ::testing::Test { public: - virtual void SetUp() { channel = Channel::Create(GetBrokerHost()); } + virtual void SetUp() { channel = Channel::Open(GetTestOpenOpts()); } Channel::ptr_t channel; + static Channel::OpenOpts GetTestOpenOpts() { + Channel::OpenOpts ret; + ret.host = GetBrokerHost(); + ret.auth = Channel::OpenOpts::BasicAuth("guest", "guest"); + return ret; + } + static std::string GetBrokerHost() { const char *host = getenv("AMQP_BROKER"); if (NULL != host) { diff --git a/testing/test_channels.cpp b/testing/test_channels.cpp index 3d6a3355..6db997e1 100644 --- a/testing/test_channels.cpp +++ b/testing/test_channels.cpp @@ -132,8 +132,9 @@ TEST_F(connected_test, channel_consume_success_timeout) { } TEST(test_channels, big_message) { - Channel::ptr_t channel = Channel::Create(connected_test::GetBrokerHost(), - 5672, "guest", "guest", "/", 4096); + Channel::OpenOpts opts = connected_test::GetTestOpenOpts(); + opts.frame_max = 4096; + Channel::ptr_t channel = Channel::Open(opts); BasicMessage::ptr_t message = BasicMessage::Create(std::string(4099, 'a')); std::string queue = channel->DeclareQueue(""); diff --git a/testing/test_connect.cpp b/testing/test_connect.cpp index cf6d7e69..08455587 100644 --- a/testing/test_connect.cpp +++ b/testing/test_connect.cpp @@ -42,12 +42,26 @@ TEST(connecting_test, connect_badhost) { std::runtime_error); } +TEST(connecting_test, open_badhost) { + Channel::OpenOpts opts = connected_test::GetTestOpenOpts(); + opts.host = "HostDoesNotExist"; + EXPECT_THROW(Channel::ptr_t channel = Channel::Open(opts), + std::runtime_error); +} + TEST(connecting_test, connect_badauth) { EXPECT_THROW(Channel::ptr_t channel = Channel::Create( connected_test::GetBrokerHost(), 5672, "baduser", "badpass"), AccessRefusedException); } +TEST(connecting_test, open_badauth) { + Channel::OpenOpts opts = connected_test::GetTestOpenOpts(); + opts.auth = Channel::OpenOpts::BasicAuth("baduser", "badpass"); + EXPECT_THROW(Channel::ptr_t channel = Channel::Open(opts), + AccessRefusedException); +} + TEST(connecting_test, connect_badframesize) { // AMQP Spec says we have a minimum frame size of 4096 EXPECT_THROW( @@ -56,6 +70,14 @@ TEST(connecting_test, connect_badframesize) { AmqpResponseLibraryException); } +TEST(connecting_test, open_badframesize) { + // AMQP Spec says we have a minimum frame size of 4096 + Channel::OpenOpts opts = connected_test::GetTestOpenOpts(); + opts.frame_max = 400; + EXPECT_THROW(Channel::ptr_t channel = Channel::Open(opts), + AmqpResponseLibraryException); +} + TEST(connecting_test, connect_badvhost) { EXPECT_THROW(Channel::ptr_t channel = Channel::Create(connected_test::GetBrokerHost(), 5672, @@ -63,7 +85,47 @@ TEST(connecting_test, connect_badvhost) { NotAllowedException); } +TEST(connecting_test, open_badvhost) { + Channel::OpenOpts opts = connected_test::GetTestOpenOpts(); + opts.vhost = "bad_vhost"; + EXPECT_THROW(Channel::ptr_t channel = Channel::Open(opts), + NotAllowedException); +} + TEST(connecting_test, connect_using_uri) { std::string host_uri = "amqp://" + connected_test::GetBrokerHost(); Channel::ptr_t channel = Channel::CreateFromUri(host_uri); } + +TEST(connecting_test, openopts_from_uri) { + Channel::OpenOpts expected; + expected.host = "host"; + expected.vhost = "vhost"; + expected.port = 123; + expected.auth = Channel::OpenOpts::BasicAuth("user", "pass"); + + EXPECT_EQ(expected, + Channel::OpenOpts::FromUri("amqp://user:pass@host:123/vhost")); +} + +TEST(connecting_test, openopts_from_uri_defaults) { + Channel::OpenOpts expected; + expected.host = "host"; + expected.vhost = "/"; + expected.port = 5672; + expected.auth = Channel::OpenOpts::BasicAuth("guest", "guest"); + EXPECT_EQ(expected, Channel::OpenOpts::FromUri("amqp://host")); +} + +TEST(connecting_test, openopts_from_amqps_uri) { + Channel::OpenOpts expected; + expected.host = "host"; + expected.vhost = "vhost"; + expected.port = 123; + expected.auth = Channel::OpenOpts::BasicAuth("user", "pass"); + expected.tls_params = Channel::OpenOpts::TLSParams(); +} + +TEST(connecting_test, openopts_fromuri_bad) { + EXPECT_THROW(Channel::OpenOpts::FromUri("not-a-valid-uri"), BadUriException); +} diff --git a/testing/test_get.cpp b/testing/test_get.cpp index c6a51f48..005781aa 100644 --- a/testing/test_get.cpp +++ b/testing/test_get.cpp @@ -50,8 +50,9 @@ TEST_F(connected_test, get_empty) { TEST(test_get, get_big) { // Smallest frame size allowed by AMQP - Channel::ptr_t channel = Channel::Create(connected_test::GetBrokerHost(), - 5672, "guest", "guest", "/", 4096); + Channel::OpenOpts opts = connected_test::GetTestOpenOpts(); + opts.frame_max = 4096; + Channel::ptr_t channel = Channel::Open(opts); // Create a message with a body larger than a single frame BasicMessage::ptr_t message = BasicMessage::Create(std::string(4099, 'a')); std::string queue = channel->DeclareQueue(""); diff --git a/testing/test_publish.cpp b/testing/test_publish.cpp index 3c7ac456..978c6507 100644 --- a/testing/test_publish.cpp +++ b/testing/test_publish.cpp @@ -38,8 +38,9 @@ TEST_F(connected_test, publish_success) { TEST(test_publish, publish_large_message) { // Smallest frame size allowed by AMQP - Channel::ptr_t channel = Channel::Create(connected_test::GetBrokerHost(), - 5672, "guest", "guest", "/", 4096); + Channel::OpenOpts opts = connected_test::GetTestOpenOpts(); + opts.frame_max = 4096; + Channel::ptr_t channel = Channel::Open(opts); // Create a message with a body larger than a single frame BasicMessage::ptr_t message = BasicMessage::Create(std::string(4099, 'a')); From bdc3fd65fa4186e575166b664376680b04574d77 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Fri, 7 Aug 2020 05:52:51 +0000 Subject: [PATCH 09/39] lib: add missing dllexport markings --- src/SimpleAmqpClient/BadUriException.h | 4 +++- src/SimpleAmqpClient/ConnectionClosedException.h | 5 ++++- src/SimpleAmqpClient/ConsumerCancelledException.h | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/SimpleAmqpClient/BadUriException.h b/src/SimpleAmqpClient/BadUriException.h index efd0ea38..96d35e3b 100644 --- a/src/SimpleAmqpClient/BadUriException.h +++ b/src/SimpleAmqpClient/BadUriException.h @@ -30,13 +30,15 @@ #include +#include "SimpleAmqpClient/Util.h" + /// @file SimpleAmqpClient/BadUriException.h /// Defines AmqpClient::BadUriException namespace AmqpClient { /** "URI is malformed" exception */ -class BadUriException : public std::runtime_error { +class SIMPLEAMQPCLIENT_EXPORT BadUriException : public std::runtime_error { public: explicit BadUriException() : std::runtime_error("URI is malformed") {} }; diff --git a/src/SimpleAmqpClient/ConnectionClosedException.h b/src/SimpleAmqpClient/ConnectionClosedException.h index 452a2c6a..257d0bad 100644 --- a/src/SimpleAmqpClient/ConnectionClosedException.h +++ b/src/SimpleAmqpClient/ConnectionClosedException.h @@ -30,6 +30,8 @@ #include +#include "SimpleAmqpClient/Util.h" + /// @file SimpleAmqpClient/ConnectionClosedException.h /// Defines AmqpClient::ConnectionClosedException @@ -38,7 +40,8 @@ namespace AmqpClient { /** * "Connection is closed" exception */ -class ConnectionClosedException : public std::runtime_error { +class SIMPLEAMQPCLIENT_EXPORT ConnectionClosedException + : public std::runtime_error { public: /// Constructor explicit ConnectionClosedException() diff --git a/src/SimpleAmqpClient/ConsumerCancelledException.h b/src/SimpleAmqpClient/ConsumerCancelledException.h index 3ddba3ae..5631c318 100644 --- a/src/SimpleAmqpClient/ConsumerCancelledException.h +++ b/src/SimpleAmqpClient/ConsumerCancelledException.h @@ -31,6 +31,8 @@ #include #include +#include "SimpleAmqpClient/Util.h" + /// @file SimpleAmqpClient/ConsumerCancelledException.h /// Defines AmqpClient::ConsumerCancelledException @@ -43,7 +45,8 @@ namespace AmqpClient { * subscribed queue is being deleted, or when a client issues basic.cancel * request. */ -class ConsumerCancelledException : public std::runtime_error { +class SIMPLEAMQPCLIENT_EXPORT ConsumerCancelledException + : public std::runtime_error { public: /// Constructor explicit ConsumerCancelledException(const std::string &consumer_tag) throw() From 706d42eca37bd345d30620087f720441ddd172ad Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 10 Aug 2020 05:52:33 +0000 Subject: [PATCH 10/39] lib: Mark Channel::Create* functions as deprecated These are being replaced by the Channel::Open function and all new functionality will be added there. The deprecated functions will be removed in a future version. --- src/SimpleAmqpClient/Channel.h | 10 ++++++++++ src/SimpleAmqpClient/Util.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 903a03f6..190a152f 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -154,6 +154,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * frame to this value * @return a new Channel object pointer */ + SAC_DEPRECATED("Channel::Create is deprecated. Use Channel::Open.") static ptr_t Create(const std::string &host = "127.0.0.1", int port = 5672, const std::string &username = "guest", const std::string &password = "guest", @@ -176,6 +177,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * frame to this value * @return a new Channel object pointer */ + SAC_DEPRECATED( + "Channel::CreateSaslExternal is deprecated. Use Channel::Open.") static ptr_t CreateSaslExternal(const std::string &host = "127.0.0.1", int port = 5672, const std::string &identity = "guest", @@ -203,6 +206,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * * @return a new Channel object pointer */ + SAC_DEPRECATED("Channel::CreateSecure is deprecated. Use Channel::Open.") static ptr_t CreateSecure(const std::string &path_to_ca_cert = "", const std::string &host = "127.0.0.1", const std::string &path_to_client_key = "", @@ -239,6 +243,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * * @return a new Channel object pointer */ + SAC_DEPRECATED("Channel::CreateSecure is deprecated. Use Channel::Open.") static ptr_t CreateSecure(const std::string &path_to_ca_cert, const std::string &host, const std::string &path_to_client_key, @@ -272,6 +277,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * * @return a new Channel object pointer */ + SAC_DEPRECATED( + "Channel::CreateSecureSaslExternal is deprecated. Use Channel::Open.") static ptr_t CreateSecureSaslExternal(const std::string &path_to_ca_cert, const std::string &host, const std::string &path_to_client_key, @@ -289,6 +296,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * any frame to this value * @returns a new Channel object */ + SAC_DEPRECATED("Channel::CreateFromUri is deprecated. Use Channel::Open.") static ptr_t CreateFromUri(const std::string &uri, int frame_max = 131072); /** @@ -307,6 +315,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * any frame to this value * @returns a new Channel object */ + SAC_DEPRECATED( + "Channel::CreateSecureFromUri is deprecated. Use Channel::Open.") static ptr_t CreateSecureFromUri(const std::string &uri, const std::string &path_to_ca_cert, const std::string &path_to_client_key = "", diff --git a/src/SimpleAmqpClient/Util.h b/src/SimpleAmqpClient/Util.h index a1d66f52..ca6b84ee 100644 --- a/src/SimpleAmqpClient/Util.h +++ b/src/SimpleAmqpClient/Util.h @@ -38,4 +38,12 @@ #define SIMPLEAMQPCLIENT_EXPORT #endif +#if defined(__GNUC__) || defined(__clang__) +#define SAC_DEPRECATED(msg) __attribute__((deprecated(msg))) +#elif defined(_MSC_VER) +#define SAC_DEPRECATED(msg) __declspec(deprecated(msg)) +#else +#define SAC_DEPRECATED(msg) +#endif + #endif // SIMPLEAMQPCLIENT_UTIL_H From ad67f5fc6b3b597d946f2226b8ebe93d3d6fd3b7 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 29 Aug 2020 04:39:45 +0000 Subject: [PATCH 11/39] lib: switch to StringToBytes from amqp_cstring_bytes The latter is somewhat more efficient as it doesn't need to call strlen, thus its O(1) instead of O(N) on string size. Its also a pre-req for moving to boost::string_ref --- CMakeLists.txt | 2 ++ src/Channel.cpp | 56 ++++++++++++++++-------------------- src/SimpleAmqpClient/Bytes.h | 17 +++++++++++ 3 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 src/SimpleAmqpClient/Bytes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index efefbfcc..db091858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,8 @@ set(SAC_LIB_SRCS src/SimpleAmqpClient/AmqpException.h src/AmqpException.cpp + src/SimpleAmqpClient/Bytes.h + src/SimpleAmqpClient/Channel.h src/Channel.cpp diff --git a/src/Channel.cpp b/src/Channel.cpp index 6f6ad13a..e5e8de18 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -51,6 +51,7 @@ #include "SimpleAmqpClient/AmqpLibraryException.h" #include "SimpleAmqpClient/AmqpResponseLibraryException.h" #include "SimpleAmqpClient/BadUriException.h" +#include "SimpleAmqpClient/Bytes.h" #include "SimpleAmqpClient/Channel.h" #include "SimpleAmqpClient/ChannelImpl.h" #include "SimpleAmqpClient/ConsumerCancelledException.h" @@ -64,13 +65,6 @@ namespace AmqpClient { namespace { -amqp_bytes_t StringToBytes(const std::string &str) { - amqp_bytes_t ret; - ret.bytes = reinterpret_cast(const_cast(str.data())); - ret.len = str.length(); - return ret; -} - amqp_basic_properties_t CreateAmqpProperties(const BasicMessage &mes, Detail::amqp_pool_ptr_t &pool) { amqp_basic_properties_t ret; @@ -495,8 +489,8 @@ void Channel::DeclareExchange(const std::string &exchange_name, m_impl->CheckIsConnected(); amqp_exchange_declare_t declare = {}; - declare.exchange = amqp_cstring_bytes(exchange_name.c_str()); - declare.type = amqp_cstring_bytes(exchange_type.c_str()); + declare.exchange = StringToBytes(exchange_name); + declare.type = StringToBytes(exchange_type); declare.passive = passive; declare.durable = durable; declare.auto_delete = auto_delete; @@ -518,7 +512,7 @@ void Channel::DeleteExchange(const std::string &exchange_name, bool if_unused) { m_impl->CheckIsConnected(); amqp_exchange_delete_t del = {}; - del.exchange = amqp_cstring_bytes(exchange_name.c_str()); + del.exchange = StringToBytes(exchange_name); del.if_unused = if_unused; del.nowait = false; @@ -542,9 +536,9 @@ void Channel::BindExchange(const std::string &destination, m_impl->CheckIsConnected(); amqp_exchange_bind_t bind = {}; - bind.destination = amqp_cstring_bytes(destination.c_str()); - bind.source = amqp_cstring_bytes(source.c_str()); - bind.routing_key = amqp_cstring_bytes(routing_key.c_str()); + bind.destination = StringToBytes(destination); + bind.source = StringToBytes(source); + bind.routing_key = StringToBytes(routing_key); bind.nowait = false; Detail::amqp_pool_ptr_t table_pool; @@ -570,9 +564,9 @@ void Channel::UnbindExchange(const std::string &destination, m_impl->CheckIsConnected(); amqp_exchange_unbind_t unbind = {}; - unbind.destination = amqp_cstring_bytes(destination.c_str()); - unbind.source = amqp_cstring_bytes(source.c_str()); - unbind.routing_key = amqp_cstring_bytes(routing_key.c_str()); + unbind.destination = StringToBytes(destination); + unbind.source = StringToBytes(source); + unbind.routing_key = StringToBytes(routing_key); unbind.nowait = false; Detail::amqp_pool_ptr_t table_pool; @@ -622,7 +616,7 @@ std::string Channel::DeclareQueueWithCounts(const std::string &queue_name, m_impl->CheckIsConnected(); amqp_queue_declare_t declare = {}; - declare.queue = amqp_cstring_bytes(queue_name.c_str()); + declare.queue = StringToBytes(queue_name); declare.passive = passive; declare.durable = durable; declare.exclusive = exclusive; @@ -655,7 +649,7 @@ void Channel::DeleteQueue(const std::string &queue_name, bool if_unused, m_impl->CheckIsConnected(); amqp_queue_delete_t del = {}; - del.queue = amqp_cstring_bytes(queue_name.c_str()); + del.queue = StringToBytes(queue_name); del.if_unused = if_unused; del.if_empty = if_empty; del.nowait = false; @@ -679,9 +673,9 @@ void Channel::BindQueue(const std::string &queue_name, m_impl->CheckIsConnected(); amqp_queue_bind_t bind = {}; - bind.queue = amqp_cstring_bytes(queue_name.c_str()); - bind.exchange = amqp_cstring_bytes(exchange_name.c_str()); - bind.routing_key = amqp_cstring_bytes(routing_key.c_str()); + bind.queue = StringToBytes(queue_name); + bind.exchange = StringToBytes(exchange_name); + bind.routing_key = StringToBytes(routing_key); bind.nowait = false; Detail::amqp_pool_ptr_t table_pool; @@ -707,9 +701,9 @@ void Channel::UnbindQueue(const std::string &queue_name, m_impl->CheckIsConnected(); amqp_queue_unbind_t unbind = {}; - unbind.queue = amqp_cstring_bytes(queue_name.c_str()); - unbind.exchange = amqp_cstring_bytes(exchange_name.c_str()); - unbind.routing_key = amqp_cstring_bytes(routing_key.c_str()); + unbind.queue = StringToBytes(queue_name); + unbind.exchange = StringToBytes(exchange_name); + unbind.routing_key = StringToBytes(routing_key); Detail::amqp_pool_ptr_t table_pool; unbind.arguments = @@ -726,7 +720,7 @@ void Channel::PurgeQueue(const std::string &queue_name) { m_impl->CheckIsConnected(); amqp_queue_purge_t purge = {}; - purge.queue = amqp_cstring_bytes(queue_name.c_str()); + purge.queue = StringToBytes(queue_name); purge.nowait = false; amqp_frame_t frame = m_impl->DoRpc(AMQP_QUEUE_PURGE_METHOD, &purge, PURGE_OK); @@ -794,8 +788,8 @@ void Channel::BasicPublish(const std::string &exchange_name, amqp_basic_properties_t properties = CreateAmqpProperties(*message, pool); m_impl->CheckForError(amqp_basic_publish( - m_impl->m_connection, channel, amqp_cstring_bytes(exchange_name.c_str()), - amqp_cstring_bytes(routing_key.c_str()), mandatory, immediate, + m_impl->m_connection, channel, StringToBytes(exchange_name), + StringToBytes(routing_key), mandatory, immediate, &properties, StringToBytes(message->Body()))); // If we've done things correctly we can get one of 4 things back from the @@ -851,7 +845,7 @@ bool Channel::BasicGet(Envelope::ptr_t &envelope, const std::string &queue, m_impl->CheckIsConnected(); amqp_basic_get_t get = {}; - get.queue = amqp_cstring_bytes(queue.c_str()); + get.queue = StringToBytes(queue); get.no_ack = no_ack; amqp_channel_t channel = m_impl->GetChannel(); @@ -927,8 +921,8 @@ std::string Channel::BasicConsume(const std::string &queue, {AMQP_BASIC_CONSUME_OK_METHOD}}; amqp_basic_consume_t consume = {}; - consume.queue = amqp_cstring_bytes(queue.c_str()); - consume.consumer_tag = amqp_cstring_bytes(consumer_tag.c_str()); + consume.queue = StringToBytes(queue); + consume.consumer_tag = StringToBytes(consumer_tag); consume.no_local = no_local; consume.no_ack = no_ack; consume.exclusive = exclusive; @@ -976,7 +970,7 @@ void Channel::BasicCancel(const std::string &consumer_tag) { {AMQP_BASIC_CANCEL_OK_METHOD}}; amqp_basic_cancel_t cancel = {}; - cancel.consumer_tag = amqp_cstring_bytes(consumer_tag.c_str()); + cancel.consumer_tag = StringToBytes(consumer_tag); cancel.nowait = false; m_impl->DoRpcOnChannel(channel, AMQP_BASIC_CANCEL_METHOD, &cancel, CANCEL_OK); diff --git a/src/SimpleAmqpClient/Bytes.h b/src/SimpleAmqpClient/Bytes.h new file mode 100644 index 00000000..817fb935 --- /dev/null +++ b/src/SimpleAmqpClient/Bytes.h @@ -0,0 +1,17 @@ +#ifndef SIMPLEAMQPCLIENT_BYTES_H +#define SIMPLEAMQPCLIENT_BYTES_H + +#include +#include + +namespace AmqpClient { + +amqp_bytes_t StringToBytes(const std::string& str) { + amqp_bytes_t ret; + ret.bytes = reinterpret_cast(const_cast(str.data())); + ret.len = str.length(); + return ret; +} + +} // namespace AmqpClient +#endif // SIMPLEAMQPCLIENT_BYTES_H From 4704a82c45846870725aa4387a11f8ef6f7c1ace Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sun, 30 Aug 2020 07:21:45 +0000 Subject: [PATCH 12/39] lib: correct format issue --- src/Channel.cpp | 4 ++-- src/SimpleAmqpClient/Bytes.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index e5e8de18..7fea7c1f 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -789,8 +789,8 @@ void Channel::BasicPublish(const std::string &exchange_name, m_impl->CheckForError(amqp_basic_publish( m_impl->m_connection, channel, StringToBytes(exchange_name), - StringToBytes(routing_key), mandatory, immediate, - &properties, StringToBytes(message->Body()))); + StringToBytes(routing_key), mandatory, immediate, &properties, + StringToBytes(message->Body()))); // If we've done things correctly we can get one of 4 things back from the // broker diff --git a/src/SimpleAmqpClient/Bytes.h b/src/SimpleAmqpClient/Bytes.h index 817fb935..44e71980 100644 --- a/src/SimpleAmqpClient/Bytes.h +++ b/src/SimpleAmqpClient/Bytes.h @@ -2,6 +2,7 @@ #define SIMPLEAMQPCLIENT_BYTES_H #include + #include namespace AmqpClient { From 4818655450f385d7a9b68c3ebc60dc71fe42e2a3 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Thu, 5 Nov 2020 11:28:16 +0100 Subject: [PATCH 13/39] Fix setting of flags in CreateAmqpProperties(). We cannot just replace the entire `ret._flags` variable when setting certain message properties. We need to OR the variable with the corresponding flag. Otherwise, setting e.g. message expiration resets all the previously set flags, such as for priority or delivery mode. Many flags are ORed correctly (e.g. priority or delivery mode), but some are not. This commit fixes that. The bug that this commit fixes was introduced in commit 938b102f8fc85e5113b3e55700b8af9b71d9f01d. --- src/Channel.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 7fea7c1f..40279cd7 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -97,36 +97,36 @@ amqp_basic_properties_t CreateAmqpProperties(const BasicMessage &mes, } if (mes.ExpirationIsSet()) { ret.expiration = StringToBytes(mes.Expiration()); - ret._flags = AMQP_BASIC_EXPIRATION_FLAG; + ret._flags |= AMQP_BASIC_EXPIRATION_FLAG; } if (mes.MessageIdIsSet()) { ret.message_id = StringToBytes(mes.MessageId()); - ret._flags = AMQP_BASIC_MESSAGE_ID_FLAG; + ret._flags |= AMQP_BASIC_MESSAGE_ID_FLAG; } if (mes.TimestampIsSet()) { ret.timestamp = mes.Timestamp(); - ret._flags = AMQP_BASIC_TIMESTAMP_FLAG; + ret._flags |= AMQP_BASIC_TIMESTAMP_FLAG; } if (mes.TypeIsSet()) { ret.type = StringToBytes(mes.Type()); - ret._flags = AMQP_BASIC_TYPE_FLAG; + ret._flags |= AMQP_BASIC_TYPE_FLAG; } if (mes.UserIdIsSet()) { ret.user_id = StringToBytes(mes.UserId()); - ret._flags = AMQP_BASIC_USER_ID_FLAG; + ret._flags |= AMQP_BASIC_USER_ID_FLAG; } if (mes.AppIdIsSet()) { ret.app_id = StringToBytes(mes.AppId()); - ret._flags = AMQP_BASIC_APP_ID_FLAG; + ret._flags |= AMQP_BASIC_APP_ID_FLAG; } if (mes.ClusterIdIsSet()) { ret.cluster_id = StringToBytes(mes.ClusterId()); - ret._flags = AMQP_BASIC_CLUSTER_ID_FLAG; + ret._flags |= AMQP_BASIC_CLUSTER_ID_FLAG; } if (mes.HeaderTableIsSet()) { ret.headers = Detail::TableValueImpl::CreateAmqpTable(mes.HeaderTable(), pool); - ret._flags = AMQP_BASIC_HEADERS_FLAG; + ret._flags |= AMQP_BASIC_HEADERS_FLAG; } return ret; } From 5a2b98543278f4ea75d40f98b97356cb0e1efcb8 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 9 Nov 2020 05:36:01 +0000 Subject: [PATCH 14/39] Add vscode-related files to .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index bc47d742..afd1bddc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ *~ .*.sw? +.cache/ +.vscode/ +build/ CMakeCache.txt cmake_install.cmake CMakeFiles/ @@ -13,4 +16,5 @@ Debug/ ipch/ install_manifest.txt .ycm_extra_conf.py* +compile_commands.json *.orig From f2b7498266187c683eda226806fe5a6724ce75ef Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 5 Nov 2020 07:07:51 +0000 Subject: [PATCH 15/39] dev: Add codespaces configuration --- .devcontainer/Dockerfile | 11 +++++++++++ .devcontainer/base.Dockerfile | 12 +++++++++++ .devcontainer/devcontainer.json | 35 +++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/base.Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..989db84a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,11 @@ + +# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 +ARG VARIANT=buster +FROM mcr.microsoft.com/vscode/devcontainers/cpp:dev-${VARIANT} + +# [Optional] Uncomment this section to install additional packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends lsb-release wget software-properties-common \ + && bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" \ + && apt-get -y install --no-install-recommends clang-format-11 clang-tidy-11 ninja-build rabbitmq-server \ + libssl-dev librabbitmq-dev libboost-dev libboost-chrono-dev libboost-system-dev diff --git a/.devcontainer/base.Dockerfile b/.devcontainer/base.Dockerfile new file mode 100644 index 00000000..1eb2f58c --- /dev/null +++ b/.devcontainer/base.Dockerfile @@ -0,0 +1,12 @@ +# [Choice] Debian / Ubuntu version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 +ARG VARIANT=buster +FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT} + +# Install needed packages. Use a separate RUN statement to add your own dependencies. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install build-essential cmake cppcheck valgrind clang lldb llvm gdb \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..8a88560f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +{ + "name": "C++", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 + "args": { "VARIANT": "ubuntu-20.04" } + }, + "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + + // Set *default* container specific settings.json values on container create. + "settings": { + "clangd.path": "clangd-11", + "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json", + "workbench.colorTheme": "Solarized Dark", + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + // "ms-vscode.cpptools", + "ms-vscode.cmake-tools", + "vscodevim.vim", + "llvm-vs-code-extensions.vscode-clangd", + "twxs.cmake", + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "gcc -v", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} From ba5baa86c2bb5cf0e84c8e2d6d4c42fb3d358a57 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Mon, 9 Nov 2020 08:04:41 +0000 Subject: [PATCH 16/39] lib: add Channel::CheckExchangeExists API --- src/Channel.cpp | 20 ++++++++++++++++++++ src/SimpleAmqpClient/Channel.h | 8 ++++++++ testing/test_exchange.cpp | 9 +++++++++ 3 files changed, 37 insertions(+) diff --git a/src/Channel.cpp b/src/Channel.cpp index 40279cd7..3964cd47 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -48,6 +48,7 @@ #include #include +#include "SimpleAmqpClient/AmqpException.h" #include "SimpleAmqpClient/AmqpLibraryException.h" #include "SimpleAmqpClient/AmqpResponseLibraryException.h" #include "SimpleAmqpClient/BadUriException.h" @@ -473,6 +474,25 @@ int Channel::GetSocketFD() const { return amqp_get_sockfd(m_impl->m_connection); } +bool Channel::CheckExchangeExists(const std::string &exchange_name) { + const boost::array DECLARE_OK = { + {AMQP_EXCHANGE_DECLARE_OK_METHOD}}; + + amqp_exchange_declare_t declare = {}; + declare.exchange = StringToBytes(exchange_name); + declare.passive = true; + declare.nowait = false; + + try { + amqp_frame_t frame = + m_impl->DoRpc(AMQP_EXCHANGE_DECLARE_METHOD, &declare, DECLARE_OK); + m_impl->MaybeReleaseBuffersOnChannel(frame.channel); + } catch (NotFoundException e) { + return false; + } + return true; +} + void Channel::DeclareExchange(const std::string &exchange_name, const std::string &exchange_type, bool passive, bool durable, bool auto_delete) { diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 190a152f..657ca7fb 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -344,6 +344,14 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { */ int GetSocketFD() const; + /** + * Checks to see if an exchange exists on the broker. + * + * @param exchange_name the name of the exchange to check for. + * @returns true if the exchange exists on the broker, false otherwise. + */ + bool CheckExchangeExists(const std::string &exchange_name); + /** * Declares an exchange * diff --git a/testing/test_exchange.cpp b/testing/test_exchange.cpp index b63cbf47..25264ccf 100644 --- a/testing/test_exchange.cpp +++ b/testing/test_exchange.cpp @@ -51,6 +51,11 @@ TEST_F(connected_test, declare_exchange_topic) { channel->DeleteExchange("declare_topic"); } +TEST_F(connected_test, check_exchange_exists_succeeds) { + channel->DeclareExchange("declare_exists"); + EXPECT_TRUE(channel->CheckExchangeExists("declare_exists")); +} + TEST_F(connected_test, declare_exchange_passive_good) { channel->DeclareExchange("declare_passive", Channel::EXCHANGE_TYPE_DIRECT); channel->DeclareExchange("declare_passive", Channel::EXCHANGE_TYPE_DIRECT, @@ -59,6 +64,10 @@ TEST_F(connected_test, declare_exchange_passive_good) { channel->DeleteExchange("declare_passive"); } +TEST_F(connected_test, check_exchange_exists_fails) { + EXPECT_FALSE(channel->CheckExchangeExists("declare_notexist")); +} + TEST_F(connected_test, declare_exchange_passive_notexist) { EXPECT_THROW(channel->DeclareExchange("declare_passive_notexist", Channel::EXCHANGE_TYPE_DIRECT, true), From 3274e1b8eb37f5d5bcd361dc52b8fde9be9b3bfa Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Fri, 13 Nov 2020 04:06:42 +0000 Subject: [PATCH 17/39] lib: convert Channel::CheckExchangeExists to use boost::string_ref Prepare for an easier transition to std::string_view. --- src/Channel.cpp | 4 ++-- src/SimpleAmqpClient/Bytes.h | 8 ++++++++ src/SimpleAmqpClient/Channel.h | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 3964cd47..5c4620f6 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -474,12 +474,12 @@ int Channel::GetSocketFD() const { return amqp_get_sockfd(m_impl->m_connection); } -bool Channel::CheckExchangeExists(const std::string &exchange_name) { +bool Channel::CheckExchangeExists(boost::string_ref exchange_name) { const boost::array DECLARE_OK = { {AMQP_EXCHANGE_DECLARE_OK_METHOD}}; amqp_exchange_declare_t declare = {}; - declare.exchange = StringToBytes(exchange_name); + declare.exchange = StringRefToBytes(exchange_name); declare.passive = true; declare.nowait = false; diff --git a/src/SimpleAmqpClient/Bytes.h b/src/SimpleAmqpClient/Bytes.h index 44e71980..8f351773 100644 --- a/src/SimpleAmqpClient/Bytes.h +++ b/src/SimpleAmqpClient/Bytes.h @@ -2,6 +2,7 @@ #define SIMPLEAMQPCLIENT_BYTES_H #include +#include #include @@ -14,5 +15,12 @@ amqp_bytes_t StringToBytes(const std::string& str) { return ret; } +amqp_bytes_t StringRefToBytes(boost::string_ref str) { + amqp_bytes_t ret; + ret.bytes = reinterpret_cast(const_cast(str.data())); + ret.len = str.length(); + return ret; +} + } // namespace AmqpClient #endif // SIMPLEAMQPCLIENT_BYTES_H diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 657ca7fb..deded1f0 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -350,7 +351,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * @param exchange_name the name of the exchange to check for. * @returns true if the exchange exists on the broker, false otherwise. */ - bool CheckExchangeExists(const std::string &exchange_name); + bool CheckExchangeExists(boost::string_ref exchange_name); /** * Declares an exchange From e474a062da90e92e459f32a69d2680c975d3a3b2 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Fri, 13 Nov 2020 04:20:42 +0000 Subject: [PATCH 18/39] lib: Add Channel::CheckQueueExists API --- src/Channel.cpp | 19 +++++++++++++++++++ src/SimpleAmqpClient/Channel.h | 9 +++++++++ testing/test_queue.cpp | 9 +++++++++ 3 files changed, 37 insertions(+) diff --git a/src/Channel.cpp b/src/Channel.cpp index 5c4620f6..e64efaa0 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -598,6 +598,25 @@ void Channel::UnbindExchange(const std::string &destination, m_impl->MaybeReleaseBuffersOnChannel(frame.channel); } +bool Channel::CheckQueueExists(boost::string_ref queue_name) { + const boost::array DECLARE_OK = { + {AMQP_QUEUE_DECLARE_OK_METHOD}}; + + amqp_queue_declare_t declare = {}; + declare.queue = StringRefToBytes(queue_name); + declare.passive = true; + declare.nowait = false; + + try { + amqp_frame_t frame = + m_impl->DoRpc(AMQP_QUEUE_DECLARE_METHOD, &declare, DECLARE_OK); + m_impl->MaybeReleaseBuffersOnChannel(frame.channel); + } catch (NotFoundException e) { + return false; + } + return true; +} + std::string Channel::DeclareQueue(const std::string &queue_name, bool passive, bool durable, bool exclusive, bool auto_delete) { diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index deded1f0..ee65bef5 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -447,6 +447,15 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { */ void UnbindExchange(const std::string &destination, const std::string &source, const std::string &routing_key, const Table &arguments); + + /** + * Checks to see if a queue exists on the broker. + * + * @param queue_name the name of the exchange to check for. + * @returns true if the exchange exists on the broker, false otherwise. + */ + bool CheckQueueExists(boost::string_ref queue_name); + /** * Declare a queue * diff --git a/testing/test_queue.cpp b/testing/test_queue.cpp index f393728b..f157697c 100644 --- a/testing/test_queue.cpp +++ b/testing/test_queue.cpp @@ -40,6 +40,11 @@ TEST_F(connected_test, queue_declare_named) { channel->DeleteQueue(queue); } +TEST_F(connected_test, check_queue_exists_success) { + channel->DeclareQueue("declare_queue_passive"); + EXPECT_TRUE(channel->CheckQueueExists("declare_queue_passive")); +} + TEST_F(connected_test, queue_declare_passive) { std::string queue = channel->DeclareQueue("declare_queue_passive"); channel->DeclareQueue("declare_queue_passive", true); @@ -47,6 +52,10 @@ TEST_F(connected_test, queue_declare_passive) { channel->DeleteQueue(queue); } +TEST_F(connected_test, check_queue_exists_fail) { + EXPECT_FALSE(channel->CheckQueueExists("declare_queue_notexist")); +} + TEST_F(connected_test, queue_declare_passive_fail) { EXPECT_THROW(channel->DeclareQueue("declare_queue_notexist", true), ChannelException); From f1344fbd6db841ebe2846b6efeeabb12254c26f0 Mon Sep 17 00:00:00 2001 From: Maxim Lyuzin Date: Mon, 27 Dec 2021 06:38:10 +0300 Subject: [PATCH 19/39] Add "Build procedure for Windows" (#302) Add instructions for building and installing SimpleAmqpClient dependancies. --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 46ed8760..3be3d9fb 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Installing ---------------- Known to work in the following environments: +- Windows 10 (MSVC 2019, Win64) - Windows 7 (MSVC 10, Win64, Win32). Likely to work in others, but has not been tested - Linux (RHEL 6.0, GCC-4.4.5, 32 and 64 bit). Likely to work on other configurations, but has not been tested - Mac OS X (10.7, 10.6, gcc-4.2, 32 and 64-bit). Likely to work on older version, but has not been tested @@ -41,6 +42,22 @@ Notes: + The test google-test based test suite can be enabled by passing `-DENABLE_TESTING=ON` to cmake +### Build procedure for Windows + +Boost libraries are needed, so you can install them using nuget: +``` +nuget install boost_chrono-vc142 -Version 1.77.0 +nuget install boost_system-vc142 -Version 1.77.0 +nuget install boost -Version 1.77.0 +``` +To build and install succesfully, [rabbitmq-c](https://github.com/alanxz/rabbitmq-c) should be built **as shared library**. + +Let *boost_chrono* and *boost_system* be in same directory ```C:\boost```, [rabbitmq-c](https://github.com/alanxz/rabbitmq-c) be on ```C:\rabbitmq-c```, +SSL be OFF, and VS2019 is used, than CMake CLI is: +``` +cd cmake -G "Visual Studio 16" -A x64 -DBoost_INCLUDE_DIR="C:/boost.XX.XX.X.X/lib/native/include" -DBOOST_ROOT="C:/boost.X.XX.X.X" -DBOOST_LIBRARYDIR="C:/boost" -DRabbitmqc_INCLUDE_DIR="C:/rabbitmq-c/include" -DRabbitmqc_LIBRARY="C:/rabbitmq-c/lib/rabbitmq.4.lib" -DBoost_USE_STATIC_LIBS=ON -DBUILD_STATIC_LIBS=ON -DENABLE_SSL_SUPPORT=OFF .. +``` + Using the library ----------------- From 6369b99711ce0ada3e55a1a66cb45dbc005b5e8c Mon Sep 17 00:00:00 2001 From: p487morgan <34686666+p487morgan@users.noreply.github.com> Date: Mon, 25 Jul 2022 16:54:09 +0100 Subject: [PATCH 20/39] Optionally set ca cert path (#309) Co-authored-by: Paul Morgan --- src/Channel.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index e64efaa0..8950786f 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -421,11 +421,14 @@ Channel::ChannelImpl *Channel::OpenSecureChannel( #endif try { - int status = - amqp_ssl_socket_set_cacert(socket, tls_params.ca_cert_path.c_str()); - if (status) { - throw AmqpLibraryException::CreateException( - status, "Error setting CA certificate for socket"); + int status; + if (tls_params.ca_cert_path != "") { + status = + amqp_ssl_socket_set_cacert(socket, tls_params.ca_cert_path.c_str()); + if (status) { + throw AmqpLibraryException::CreateException( + status, "Error setting CA certificate for socket"); + } } if (tls_params.client_key_path != "" && tls_params.client_cert_path != "") { From ac77fa0f3c2f2f853da47b751c0cc81a71bae1d4 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 27 Jun 2020 05:15:41 +0000 Subject: [PATCH 21/39] lib: compile SimpleAmqpClient as C++17 --- .travis.yml | 2 +- CMakeLists.txt | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30529ead..d22f2a44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,6 +50,6 @@ before_script: # Run the Build script script: - - cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="${FLAGS}" -DCMAKE_INSTALL_PREFIX=../_install -DENABLE_TESTING=ON -DRabbitmqc_DIR=${RABBITMQ_C_DIR} .. + - cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror ${FLAGS}" -DCMAKE_INSTALL_PREFIX=../_install -DENABLE_TESTING=ON -DRabbitmqc_DIR=${RABBITMQ_C_DIR} .. - cmake --build . --target install - AMQP_BROKER=localhost ASAN_OPTIONS=detect_leaks=1 ctest -V . diff --git a/CMakeLists.txt b/CMakeLists.txt index db091858..6468d107 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.5) project(SimpleAmqpClient LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 98) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -68,15 +68,6 @@ if (CMAKE_GENERATOR MATCHES ".*(Make|Ninja).*" message(STATUS "CMAKE_BUILD_TYPE not specified. Using ${CMAKE_BUILD_TYPE} build") endif () -if (CMAKE_CXX_FLAGS STREQUAL "" - AND NOT DEFINED SAC_CXX_FLAGS_SET) - if (CMAKE_COMPILER_IS_GNUCXX - OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - SET(CMAKE_CXX_FLAGS "-Wall -Wextra" CACHE STRING "Flags used by the compiler during all build types." FORCE) - endif () - set(SAC_CXX_FLAGS_SET TRUE CACHE INTERNAL "Have the SAC default compiler flags been set?") -endif () - include_directories(BEFORE src ${CMAKE_CURRENT_BINARY_DIR}) From b00f7bf375cffcb4c02ddecec4709568c7fbdf0b Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 23 Jul 2020 03:29:40 +0000 Subject: [PATCH 22/39] ci: use gcc-7 and clang-8 under travis-ci This is to allow support for various C++17 features in use. --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d22f2a44..750b33f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,23 +8,24 @@ dist: xenial jobs: include: - - compiler: gcc - env: FLAGS="" - - compiler: clang - env: FLAGS="" - - compiler: clang - env: FLAGS="-g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer" - - compiler: clang - env: FLAGS="-g -O1 -fsanitize=thread -fno-omit-frame-pointer" + - env: CC=gcc-7 CXX=g++-7 FLAGS="" + - env: CC=clang-8 CXX=clang++-8 FLAGS="" + - env: CC=clang-8 CXX=clang++-8 FLAGS="-g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer" + - env: CC=clang-8 CXX=clang++-8 FLAGS="-g -O1 -fsanitize=thread -fno-omit-frame-pointer" addons: apt: sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-xenial-8 - sourceline: deb http://dl.bintray.com/rabbitmq-erlang/debian xenial erlang key_url: https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc - sourceline: deb https://dl.bintray.com/rabbitmq/debian xenial main key_url: https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc packages: + - gcc-7 + - g++-7 + - clang-8 - libboost-dev - libboost-chrono-dev - libboost-system-dev From 2ef475b4a312afb3df2b8f1f51f9a11361d01327 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 27 Jun 2020 05:20:36 +0000 Subject: [PATCH 23/39] test: update googletest to v1.10 Which likely has better support for c++17. --- third-party/googletest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/googletest b/third-party/googletest index 2fe3bd99..703bd9ca 160000 --- a/third-party/googletest +++ b/third-party/googletest @@ -1 +1 @@ -Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2 +Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e From 84bff8df7cf911394903e282d443f8333fd14911 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 27 Jun 2020 05:39:23 +0000 Subject: [PATCH 24/39] lib: switch away from boost::scoped_ptr Modern replacement is std::unique_ptr, mostly used just for PIMPL members. --- src/SimpleAmqpClient/BasicMessage.h | 4 ++-- src/SimpleAmqpClient/Channel.h | 5 ++--- src/SimpleAmqpClient/Table.h | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/SimpleAmqpClient/BasicMessage.h b/src/SimpleAmqpClient/BasicMessage.h index ffa8789f..305f5584 100644 --- a/src/SimpleAmqpClient/BasicMessage.h +++ b/src/SimpleAmqpClient/BasicMessage.h @@ -30,9 +30,9 @@ #include #include -#include #include #include +#include #include #include "SimpleAmqpClient/Table.h" @@ -342,7 +342,7 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { protected: struct Impl; /// PIMPL idiom - boost::scoped_ptr m_impl; + std::unique_ptr m_impl; }; } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index ee65bef5..621c8f5c 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -31,12 +31,11 @@ #include #include #include -#include #include #include #include #include -#include +======= #include #include "SimpleAmqpClient/BasicMessage.h" @@ -934,7 +933,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { bool sasl_external); /// PIMPL idiom - boost::scoped_ptr m_impl; + std::unique_ptr m_impl; }; } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/Table.h b/src/SimpleAmqpClient/Table.h index ee41af81..3bbee8af 100644 --- a/src/SimpleAmqpClient/Table.h +++ b/src/SimpleAmqpClient/Table.h @@ -29,9 +29,9 @@ */ #include -#include #include #include +#include #include #include @@ -489,7 +489,7 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { void Set(const Table &value); private: - boost::scoped_ptr m_impl; + std::unique_ptr m_impl; }; } // namespace AmqpClient From 5841f0c1c526e6407aa1ce5dba6b2a008ca62c3e Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 27 Jun 2020 06:11:18 +0000 Subject: [PATCH 25/39] lib: switch away from boost::noncopyable = delete'ing the copy and assignment operator is the new hotness on how to specify that a class is noncopyable. --- src/SimpleAmqpClient/BasicMessage.h | 7 +++++-- src/SimpleAmqpClient/Channel.h | 14 +++++++++----- src/SimpleAmqpClient/ChannelImpl.h | 8 ++++++-- src/SimpleAmqpClient/Envelope.h | 7 +++++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/SimpleAmqpClient/BasicMessage.h b/src/SimpleAmqpClient/BasicMessage.h index 305f5584..7a586b94 100644 --- a/src/SimpleAmqpClient/BasicMessage.h +++ b/src/SimpleAmqpClient/BasicMessage.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -51,7 +50,7 @@ namespace AmqpClient { /** * An AMQP BasicMessage */ -class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { +class SIMPLEAMQPCLIENT_EXPORT BasicMessage { public: /// A shared pointer to BasicMessage typedef boost::shared_ptr ptr_t; @@ -84,6 +83,10 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { BasicMessage(const std::string& body); public: + // Non-copyable + BasicMessage(const BasicMessage &) = delete; + BasicMessage &operator=(const BasicMessage &) = delete; + /** * Destructor */ diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 621c8f5c..638faae7 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -32,10 +32,10 @@ #include #include #include -#include -#include #include -======= +#include +#include +#include #include #include "SimpleAmqpClient/BasicMessage.h" @@ -58,7 +58,7 @@ namespace AmqpClient { * * Represents a logical AMQP channel multiplexed over a connection */ -class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { +class SIMPLEAMQPCLIENT_EXPORT Channel { public: /// a `shared_ptr` to Channel typedef boost::shared_ptr ptr_t; @@ -329,6 +329,10 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { public: explicit Channel(ChannelImpl *impl); + // Non-copyable + Channel(const Channel &) = delete; + Channel &operator=(const Channel &) = delete; + virtual ~Channel(); /** @@ -933,7 +937,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { bool sasl_external); /// PIMPL idiom - std::unique_ptr m_impl; + std::unique_ptr m_impl; }; } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index 62af935c..cac89c47 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -43,15 +43,19 @@ #define BOOST_BIND_GLOBAL_PLACEHOLDERS #include #include -#include #include #include namespace AmqpClient { -class Channel::ChannelImpl : boost::noncopyable { +class Channel::ChannelImpl { public: ChannelImpl(); + + // Non-copyable + ChannelImpl(const ChannelImpl &) = delete; + ChannelImpl &operator=(const ChannelImpl &) = delete; + virtual ~ChannelImpl(); typedef std::vector channel_list_t; diff --git a/src/SimpleAmqpClient/Envelope.h b/src/SimpleAmqpClient/Envelope.h index b112e307..3aa0bb7d 100644 --- a/src/SimpleAmqpClient/Envelope.h +++ b/src/SimpleAmqpClient/Envelope.h @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -50,7 +49,7 @@ namespace AmqpClient { /** * A "message envelope" object containing the message body and delivery metadata */ -class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { +class SIMPLEAMQPCLIENT_EXPORT Envelope { public: /// a `shared_ptr` pointer to Envelope typedef boost::shared_ptr ptr_t; @@ -99,6 +98,10 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { const boost::uint16_t delivery_channel); public: + // Non-copyable + Envelope(const Envelope &) = delete; + Envelope &operator=(const Envelope &) = delete; + /** * destructor */ From 9f4162eedd9678beffb36502ec46cdc8b9fcce53 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 18 Jul 2020 06:17:02 +0000 Subject: [PATCH 26/39] lib: switch to using Un-boostify switching away from boost/cstdint.hpp --- src/AmqpException.cpp | 43 ++-- src/BasicMessage.cpp | 14 +- src/Channel.cpp | 58 +++-- src/ChannelImpl.cpp | 24 +- src/Envelope.cpp | 4 +- src/MessageReturnedException.cpp | 2 +- src/SimpleAmqpClient/AmqpException.h | 213 ++++++++++-------- .../AmqpResponseLibraryException.h | 1 - src/SimpleAmqpClient/BasicMessage.h | 10 +- src/SimpleAmqpClient/Channel.h | 16 +- src/SimpleAmqpClient/ChannelImpl.h | 12 +- src/SimpleAmqpClient/Envelope.h | 22 +- .../MessageRejectedException.h | 9 +- .../MessageReturnedException.h | 8 +- src/SimpleAmqpClient/Table.h | 50 ++-- src/SimpleAmqpClient/TableImpl.h | 26 +-- src/Table.cpp | 67 +++--- src/TableImpl.cpp | 16 +- testing/test_queue.cpp | 10 +- testing/test_table.cpp | 29 +-- 20 files changed, 325 insertions(+), 309 deletions(-) diff --git a/src/AmqpException.cpp b/src/AmqpException.cpp index c1998cfd..10d5bff6 100644 --- a/src/AmqpException.cpp +++ b/src/AmqpException.cpp @@ -36,31 +36,28 @@ namespace AmqpClient { -const boost::uint16_t ContentTooLargeException::REPLY_CODE = +const std::uint16_t ContentTooLargeException::REPLY_CODE = AMQP_CONTENT_TOO_LARGE; -const boost::uint16_t NoRouteException::REPLY_CODE = AMQP_NO_ROUTE; -const boost::uint16_t NoConsumersException::REPLY_CODE = AMQP_NO_CONSUMERS; -const boost::uint16_t AccessRefusedException::REPLY_CODE = AMQP_ACCESS_REFUSED; -const boost::uint16_t NotFoundException::REPLY_CODE = AMQP_NOT_FOUND; -const boost::uint16_t ResourceLockedException::REPLY_CODE = - AMQP_RESOURCE_LOCKED; -const boost::uint16_t PreconditionFailedException::REPLY_CODE = +const std::uint16_t NoRouteException::REPLY_CODE = AMQP_NO_ROUTE; +const std::uint16_t NoConsumersException::REPLY_CODE = AMQP_NO_CONSUMERS; +const std::uint16_t AccessRefusedException::REPLY_CODE = AMQP_ACCESS_REFUSED; +const std::uint16_t NotFoundException::REPLY_CODE = AMQP_NOT_FOUND; +const std::uint16_t ResourceLockedException::REPLY_CODE = AMQP_RESOURCE_LOCKED; +const std::uint16_t PreconditionFailedException::REPLY_CODE = AMQP_PRECONDITION_FAILED; -const boost::uint16_t ConnectionForcedException::REPLY_CODE = +const std::uint16_t ConnectionForcedException::REPLY_CODE = AMQP_CONNECTION_FORCED; -const boost::uint16_t InvalidPathException::REPLY_CODE = AMQP_INVALID_PATH; -const boost::uint16_t FrameErrorException::REPLY_CODE = AMQP_FRAME_ERROR; -const boost::uint16_t SyntaxErrorException::REPLY_CODE = AMQP_SYNTAX_ERROR; -const boost::uint16_t CommandInvalidException::REPLY_CODE = - AMQP_COMMAND_INVALID; -const boost::uint16_t ChannelErrorException::REPLY_CODE = AMQP_CHANNEL_ERROR; -const boost::uint16_t UnexpectedFrameException::REPLY_CODE = +const std::uint16_t InvalidPathException::REPLY_CODE = AMQP_INVALID_PATH; +const std::uint16_t FrameErrorException::REPLY_CODE = AMQP_FRAME_ERROR; +const std::uint16_t SyntaxErrorException::REPLY_CODE = AMQP_SYNTAX_ERROR; +const std::uint16_t CommandInvalidException::REPLY_CODE = AMQP_COMMAND_INVALID; +const std::uint16_t ChannelErrorException::REPLY_CODE = AMQP_CHANNEL_ERROR; +const std::uint16_t UnexpectedFrameException::REPLY_CODE = AMQP_UNEXPECTED_FRAME; -const boost::uint16_t ResourceErrorException::REPLY_CODE = AMQP_RESOURCE_ERROR; -const boost::uint16_t NotAllowedException::REPLY_CODE = AMQP_NOT_ALLOWED; -const boost::uint16_t NotImplementedException::REPLY_CODE = - AMQP_NOT_IMPLEMENTED; -const boost::uint16_t InternalErrorException::REPLY_CODE = AMQP_INTERNAL_ERROR; +const std::uint16_t ResourceErrorException::REPLY_CODE = AMQP_RESOURCE_ERROR; +const std::uint16_t NotAllowedException::REPLY_CODE = AMQP_NOT_ALLOWED; +const std::uint16_t NotImplementedException::REPLY_CODE = AMQP_NOT_IMPLEMENTED; +const std::uint16_t InternalErrorException::REPLY_CODE = AMQP_INTERNAL_ERROR; void AmqpException::Throw(const amqp_rpc_reply_t &reply) { assert(reply.reply_type == AMQP_RESPONSE_SERVER_EXCEPTION); @@ -192,8 +189,8 @@ void AmqpException::Throw(const amqp_connection_close_t &reply) { AmqpException::AmqpException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : std::runtime_error(what), m_reply_text(reply_text), m_class_id(class_id), diff --git a/src/BasicMessage.cpp b/src/BasicMessage.cpp index badd8475..2ea3088f 100644 --- a/src/BasicMessage.cpp +++ b/src/BasicMessage.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -45,12 +46,12 @@ struct BasicMessage::Impl { boost::optional content_type; boost::optional content_encoding; boost::optional delivery_mode; - boost::optional priority; + boost::optional priority; boost::optional correlation_id; boost::optional reply_to; boost::optional expiration; boost::optional message_id; - boost::optional timestamp; + boost::optional timestamp; boost::optional type; boost::optional user_id; boost::optional app_id; @@ -122,11 +123,11 @@ bool BasicMessage::DeliveryModeIsSet() const { void BasicMessage::DeliveryModeClear() { m_impl->delivery_mode.reset(); } -boost::uint8_t BasicMessage::Priority() const { +std::uint8_t BasicMessage::Priority() const { return m_impl->priority.value_or(0); } -void BasicMessage::Priority(boost::uint8_t priority) { +void BasicMessage::Priority(std::uint8_t priority) { m_impl->priority = priority; } @@ -208,10 +209,11 @@ bool BasicMessage::MessageIdIsSet() const { void BasicMessage::MessageIdClear() { m_impl->message_id.reset(); } -boost::uint64_t BasicMessage::Timestamp() const { +std::uint64_t BasicMessage::Timestamp() const { return m_impl->timestamp.value_or(0); } -void BasicMessage::Timestamp(boost::uint64_t timestamp) { + +void BasicMessage::Timestamp(std::uint64_t timestamp) { m_impl->timestamp = timestamp; } diff --git a/src/Channel.cpp b/src/Channel.cpp index 8950786f..22823bee 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -38,8 +38,8 @@ #include #include -#include #include +#include #include #include #include @@ -507,7 +507,7 @@ void Channel::DeclareExchange(const std::string &exchange_name, const std::string &exchange_type, bool passive, bool durable, bool auto_delete, const Table &arguments) { - const boost::array DECLARE_OK = { + const boost::array DECLARE_OK = { {AMQP_EXCHANGE_DECLARE_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -530,7 +530,7 @@ void Channel::DeclareExchange(const std::string &exchange_name, } void Channel::DeleteExchange(const std::string &exchange_name, bool if_unused) { - const boost::array DELETE_OK = { + const boost::array DELETE_OK = { {AMQP_EXCHANGE_DELETE_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -554,7 +554,7 @@ void Channel::BindExchange(const std::string &destination, const std::string &source, const std::string &routing_key, const Table &arguments) { - const boost::array BIND_OK = { + const boost::array BIND_OK = { {AMQP_EXCHANGE_BIND_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -582,7 +582,7 @@ void Channel::UnbindExchange(const std::string &destination, const std::string &source, const std::string &routing_key, const Table &arguments) { - const boost::array UNBIND_OK = { + const boost::array UNBIND_OK = { {AMQP_EXCHANGE_UNBIND_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -630,16 +630,16 @@ std::string Channel::DeclareQueue(const std::string &queue_name, bool passive, std::string Channel::DeclareQueue(const std::string &queue_name, bool passive, bool durable, bool exclusive, bool auto_delete, const Table &arguments) { - boost::uint32_t message_count; - boost::uint32_t consumer_count; + std::uint32_t message_count; + std::uint32_t consumer_count; return DeclareQueueWithCounts(queue_name, message_count, consumer_count, passive, durable, exclusive, auto_delete, arguments); } std::string Channel::DeclareQueueWithCounts(const std::string &queue_name, - boost::uint32_t &message_count, - boost::uint32_t &consumer_count, + std::uint32_t &message_count, + std::uint32_t &consumer_count, bool passive, bool durable, bool exclusive, bool auto_delete) { return DeclareQueueWithCounts(queue_name, message_count, consumer_count, @@ -648,12 +648,12 @@ std::string Channel::DeclareQueueWithCounts(const std::string &queue_name, } std::string Channel::DeclareQueueWithCounts(const std::string &queue_name, - boost::uint32_t &message_count, - boost::uint32_t &consumer_count, + std::uint32_t &message_count, + std::uint32_t &consumer_count, bool passive, bool durable, bool exclusive, bool auto_delete, const Table &arguments) { - const boost::array DECLARE_OK = { + const boost::array DECLARE_OK = { {AMQP_QUEUE_DECLARE_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -686,7 +686,7 @@ std::string Channel::DeclareQueueWithCounts(const std::string &queue_name, void Channel::DeleteQueue(const std::string &queue_name, bool if_unused, bool if_empty) { - const boost::array DELETE_OK = { + const boost::array DELETE_OK = { {AMQP_QUEUE_DELETE_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -710,8 +710,7 @@ void Channel::BindQueue(const std::string &queue_name, const std::string &exchange_name, const std::string &routing_key, const Table &arguments) { - const boost::array BIND_OK = { - {AMQP_QUEUE_BIND_OK_METHOD}}; + const boost::array BIND_OK = {{AMQP_QUEUE_BIND_OK_METHOD}}; m_impl->CheckIsConnected(); amqp_queue_bind_t bind = {}; @@ -738,7 +737,7 @@ void Channel::UnbindQueue(const std::string &queue_name, const std::string &exchange_name, const std::string &routing_key, const Table &arguments) { - const boost::array UNBIND_OK = { + const boost::array UNBIND_OK = { {AMQP_QUEUE_UNBIND_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -757,7 +756,7 @@ void Channel::UnbindQueue(const std::string &queue_name, } void Channel::PurgeQueue(const std::string &queue_name) { - const boost::array PURGE_OK = { + const boost::array PURGE_OK = { {AMQP_QUEUE_PURGE_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -845,7 +844,7 @@ void Channel::BasicPublish(const std::string &exchange_name, // - channel.close - probably tried to publish to a non-existant exchange, in // any case error! // - connection.clsoe - something really bad happened - const boost::array PUBLISH_ACK = { + const boost::array PUBLISH_ACK = { {AMQP_BASIC_ACK_METHOD, AMQP_BASIC_RETURN_METHOD, AMQP_BASIC_NACK_METHOD}}; amqp_frame_t response; @@ -868,8 +867,7 @@ void Channel::BasicPublish(const std::string &exchange_name, response.payload.method.decoded)), channel); - const boost::array BASIC_ACK = { - {AMQP_BASIC_ACK_METHOD}}; + const boost::array BASIC_ACK = {{AMQP_BASIC_ACK_METHOD}}; m_impl->GetMethodOnChannel(channels, response, BASIC_ACK); m_impl->ReturnChannel(channel); m_impl->MaybeReleaseBuffersOnChannel(channel); @@ -882,7 +880,7 @@ void Channel::BasicPublish(const std::string &exchange_name, bool Channel::BasicGet(Envelope::ptr_t &envelope, const std::string &queue, bool no_ack) { - const boost::array GET_RESPONSES = { + const boost::array GET_RESPONSES = { {AMQP_BASIC_GET_OK_METHOD, AMQP_BASIC_GET_EMPTY_METHOD}}; m_impl->CheckIsConnected(); @@ -902,7 +900,7 @@ bool Channel::BasicGet(Envelope::ptr_t &envelope, const std::string &queue, amqp_basic_get_ok_t *get_ok = (amqp_basic_get_ok_t *)response.payload.method.decoded; - boost::uint64_t delivery_tag = get_ok->delivery_tag; + std::uint64_t delivery_tag = get_ok->delivery_tag; bool redelivered = (get_ok->redelivered == 0 ? false : true); std::string exchange((char *)get_ok->exchange.bytes, get_ok->exchange.len); std::string routing_key((char *)get_ok->routing_key.bytes, @@ -918,7 +916,7 @@ bool Channel::BasicGet(Envelope::ptr_t &envelope, const std::string &queue, } void Channel::BasicRecover(const std::string &consumer) { - const boost::array RECOVER_OK = { + const boost::array RECOVER_OK = { {AMQP_BASIC_RECOVER_OK_METHOD}}; m_impl->CheckIsConnected(); @@ -935,21 +933,21 @@ void Channel::BasicRecover(const std::string &consumer) { std::string Channel::BasicConsume(const std::string &queue, const std::string &consumer_tag, bool no_local, bool no_ack, bool exclusive, - boost::uint16_t message_prefetch_count) { + std::uint16_t message_prefetch_count) { return BasicConsume(queue, consumer_tag, no_local, no_ack, exclusive, message_prefetch_count, Table()); } std::string Channel::BasicConsume(const std::string &queue, const std::string &consumer_tag, bool no_local, bool no_ack, bool exclusive, - boost::uint16_t message_prefetch_count, + std::uint16_t message_prefetch_count, const Table &arguments) { m_impl->CheckIsConnected(); amqp_channel_t channel = m_impl->GetChannel(); // Set this before starting the consume as it may have been set by a previous // consumer - const boost::array QOS_OK = {{AMQP_BASIC_QOS_OK_METHOD}}; + const boost::array QOS_OK = {{AMQP_BASIC_QOS_OK_METHOD}}; amqp_basic_qos_t qos = {}; qos.prefetch_size = 0; @@ -959,7 +957,7 @@ std::string Channel::BasicConsume(const std::string &queue, m_impl->DoRpcOnChannel(channel, AMQP_BASIC_QOS_METHOD, &qos, QOS_OK); m_impl->MaybeReleaseBuffersOnChannel(channel); - const boost::array CONSUME_OK = { + const boost::array CONSUME_OK = { {AMQP_BASIC_CONSUME_OK_METHOD}}; amqp_basic_consume_t consume = {}; @@ -989,11 +987,11 @@ std::string Channel::BasicConsume(const std::string &queue, } void Channel::BasicQos(const std::string &consumer_tag, - boost::uint16_t message_prefetch_count) { + std::uint16_t message_prefetch_count) { m_impl->CheckIsConnected(); amqp_channel_t channel = m_impl->GetConsumerChannel(consumer_tag); - const boost::array QOS_OK = {{AMQP_BASIC_QOS_OK_METHOD}}; + const boost::array QOS_OK = {{AMQP_BASIC_QOS_OK_METHOD}}; amqp_basic_qos_t qos = {}; qos.prefetch_size = 0; @@ -1008,7 +1006,7 @@ void Channel::BasicCancel(const std::string &consumer_tag) { m_impl->CheckIsConnected(); amqp_channel_t channel = m_impl->GetConsumerChannel(consumer_tag); - const boost::array CANCEL_OK = { + const boost::array CANCEL_OK = { {AMQP_BASIC_CANCEL_OK_METHOD}}; amqp_basic_cancel_t cancel = {}; diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index eb276ca3..9a0066df 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -179,16 +179,16 @@ amqp_channel_t Channel::ChannelImpl::GetNextChannelId() { amqp_channel_t Channel::ChannelImpl::CreateNewChannel() { amqp_channel_t new_channel = GetNextChannelId(); - static const boost::array OPEN_OK = { + static const boost::array OPEN_OK = { {AMQP_CHANNEL_OPEN_OK_METHOD}}; amqp_channel_open_t channel_open = {}; - DoRpcOnChannel >( + DoRpcOnChannel >( new_channel, AMQP_CHANNEL_OPEN_METHOD, &channel_open, OPEN_OK); - static const boost::array CONFIRM_OK = { + static const boost::array CONFIRM_OK = { {AMQP_CONFIRM_SELECT_OK_METHOD}}; amqp_confirm_select_t confirm_select = {}; - DoRpcOnChannel >( + DoRpcOnChannel >( new_channel, AMQP_CONFIRM_SELECT_METHOD, &confirm_select, CONFIRM_OK); m_channels.at(new_channel) = CS_Open; @@ -457,7 +457,7 @@ bool Channel::ChannelImpl::GetNextFrameFromBroker( memset(&tv_timeout, 0, sizeof(tv_timeout)); if (timeout != boost::chrono::microseconds::max()) { - // boost::chrono::seconds.count() returns boost::int_atleast64_t, + // boost::chrono::seconds.count() returns std::int_atleast64_t, // long can be 32 or 64 bit depending on the platform/arch // unless the timeout is something absurd cast to long will be ok, but // lets guard against the case where someone does something silly @@ -534,7 +534,7 @@ bool bytesEqual(amqp_bytes_t r, amqp_bytes_t l) { } } // namespace -boost::uint32_t Channel::ChannelImpl::ComputeBrokerVersion( +std::uint32_t Channel::ChannelImpl::ComputeBrokerVersion( amqp_connection_state_t state) { const amqp_table_t *properties = amqp_get_server_properties(state); const amqp_bytes_t version = amqp_cstring_bytes("version"); @@ -558,12 +558,12 @@ boost::uint32_t Channel::ChannelImpl::ComputeBrokerVersion( if (version_components.size() != 3) { return 0; } - boost::uint32_t version_major = - boost::lexical_cast(version_components[0]); - boost::uint32_t version_minor = - boost::lexical_cast(version_components[1]); - boost::uint32_t version_patch = - boost::lexical_cast(version_components[2]); + std::uint32_t version_major = + boost::lexical_cast(version_components[0]); + std::uint32_t version_minor = + boost::lexical_cast(version_components[1]); + std::uint32_t version_patch = + boost::lexical_cast(version_components[2]); return (version_major & 0xFF) << 16 | (version_minor & 0xFF) << 8 | (version_patch & 0xFF); } diff --git a/src/Envelope.cpp b/src/Envelope.cpp index 3edceb4c..4d8d0617 100644 --- a/src/Envelope.cpp +++ b/src/Envelope.cpp @@ -32,10 +32,10 @@ namespace AmqpClient { Envelope::Envelope(const BasicMessage::ptr_t message, const std::string &consumer_tag, - const boost::uint64_t delivery_tag, + const std::uint64_t delivery_tag, const std::string &exchange, bool redelivered, const std::string &routing_key, - const boost::uint16_t delivery_channel) + const std::uint16_t delivery_channel) : m_message(message), m_consumerTag(consumer_tag), m_deliveryTag(delivery_tag), diff --git a/src/MessageReturnedException.cpp b/src/MessageReturnedException.cpp index 02719fd1..3e64d460 100644 --- a/src/MessageReturnedException.cpp +++ b/src/MessageReturnedException.cpp @@ -32,7 +32,7 @@ namespace AmqpClient { MessageReturnedException::MessageReturnedException( - BasicMessage::ptr_t message, boost::uint32_t reply_code, + BasicMessage::ptr_t message, std::uint32_t reply_code, const std::string &reply_text, const std::string &exchange, const std::string &routing_key) throw() : std::runtime_error( diff --git a/src/SimpleAmqpClient/AmqpException.h b/src/SimpleAmqpClient/AmqpException.h index e987ae33..e6eba22e 100644 --- a/src/SimpleAmqpClient/AmqpException.h +++ b/src/SimpleAmqpClient/AmqpException.h @@ -28,7 +28,7 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include #include @@ -84,8 +84,8 @@ class SIMPLEAMQPCLIENT_EXPORT AmqpException : public std::runtime_error { * @param [in] method_id the method id of the method that caused the error */ explicit AmqpException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw(); + std::uint16_t class_id, + std::uint16_t method_id) throw(); /** * Destructor @@ -109,34 +109,28 @@ class SIMPLEAMQPCLIENT_EXPORT AmqpException : public std::runtime_error { * * @returns the error code */ - virtual boost::uint16_t reply_code() const throw() = 0; + virtual std::uint16_t reply_code() const throw() = 0; /** * Get the class id of the method that caused the error * * @returns the class id */ - virtual boost::uint16_t class_id() const throw() { return m_class_id; } + virtual std::uint16_t class_id() const throw() { return m_class_id; } /** * Get the method id of the method that caused the error * * @returns the method id */ - virtual boost::uint16_t method_id() const throw() { return m_method_id; } - - /** - * Get the error string returned from the broker - * - * @returns the error string from the broker - */ + virtual std::uint16_t method_id() const throw() { return m_method_id; } virtual std::string reply_text() const throw() { return m_reply_text; } protected: /** @cond INTERNAL */ std::string m_reply_text; - boost::uint16_t m_class_id; - boost::uint16_t m_method_id; + std::uint16_t m_class_id; + std::uint16_t m_method_id; /** @endcond */ }; @@ -159,8 +153,8 @@ class SIMPLEAMQPCLIENT_EXPORT ConnectionException : public AmqpException { */ explicit ConnectionException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : AmqpException(what, reply_text, class_id, method_id) {} virtual bool is_soft_error() const throw() { return false; } @@ -184,8 +178,8 @@ class SIMPLEAMQPCLIENT_EXPORT ChannelException : public AmqpException { */ explicit ChannelException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : AmqpException(what, reply_text, class_id, method_id) {} virtual bool is_soft_error() const throw() { return true; } @@ -198,18 +192,18 @@ class SIMPLEAMQPCLIENT_EXPORT ConnectionForcedException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit ConnectionForcedException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -219,18 +213,18 @@ class SIMPLEAMQPCLIENT_EXPORT InvalidPathException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit InvalidPathException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -241,18 +235,18 @@ class SIMPLEAMQPCLIENT_EXPORT InvalidPathException class SIMPLEAMQPCLIENT_EXPORT FrameErrorException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit FrameErrorException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -264,17 +258,17 @@ class SIMPLEAMQPCLIENT_EXPORT SyntaxErrorException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit SyntaxErrorException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -286,18 +280,18 @@ class SIMPLEAMQPCLIENT_EXPORT CommandInvalidException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit CommandInvalidException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -309,17 +303,18 @@ class SIMPLEAMQPCLIENT_EXPORT ChannelErrorException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; + /** * Constructor */ explicit ChannelErrorException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -331,18 +326,18 @@ class SIMPLEAMQPCLIENT_EXPORT UnexpectedFrameException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit UnexpectedFrameException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -354,18 +349,18 @@ class SIMPLEAMQPCLIENT_EXPORT ResourceErrorException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit ResourceErrorException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -377,18 +372,18 @@ class SIMPLEAMQPCLIENT_EXPORT ResourceErrorException class SIMPLEAMQPCLIENT_EXPORT NotAllowedException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit NotAllowedException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -398,18 +393,18 @@ class SIMPLEAMQPCLIENT_EXPORT NotImplementedException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; /** * Constructor */ explicit NotImplementedException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -419,16 +414,18 @@ class SIMPLEAMQPCLIENT_EXPORT InternalErrorException : public ConnectionException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; - /** Constructor */ + /** + * Constructor + */ explicit InternalErrorException(const std::string &what, const std::string &reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ConnectionException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -440,16 +437,18 @@ class SIMPLEAMQPCLIENT_EXPORT ContentTooLargeException : public ChannelException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; + static const std::uint16_t REPLY_CODE; - /** Constructor */ + /** + * Constructor + */ explicit ContentTooLargeException(const std::string &what, const std::string reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ChannelException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -459,15 +458,18 @@ class SIMPLEAMQPCLIENT_EXPORT ContentTooLargeException class SIMPLEAMQPCLIENT_EXPORT NoRouteException : public ChannelException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; - /** Constructor */ + static const std::uint16_t REPLY_CODE; + + /** + * Constructor + */ explicit NoRouteException(const std::string &what, const std::string reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ChannelException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -478,15 +480,18 @@ class SIMPLEAMQPCLIENT_EXPORT NoRouteException : public ChannelException { class SIMPLEAMQPCLIENT_EXPORT NoConsumersException : public ChannelException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; - /** Constructor */ + static const std::uint16_t REPLY_CODE; + + /** + * Constructor + */ explicit NoConsumersException(const std::string &what, const std::string reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ChannelException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -496,15 +501,18 @@ class SIMPLEAMQPCLIENT_EXPORT NoConsumersException : public ChannelException { class SIMPLEAMQPCLIENT_EXPORT AccessRefusedException : public ChannelException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; - /** Constructor */ + static const std::uint16_t REPLY_CODE; + + /** + * Constructor + */ explicit AccessRefusedException(const std::string &what, const std::string reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ChannelException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -514,15 +522,18 @@ class SIMPLEAMQPCLIENT_EXPORT AccessRefusedException : public ChannelException { class SIMPLEAMQPCLIENT_EXPORT NotFoundException : public ChannelException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; - /** Constructor */ + static const std::uint16_t REPLY_CODE; + + /** + * Constructor + */ explicit NotFoundException(const std::string &what, const std::string reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ChannelException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -533,15 +544,18 @@ class SIMPLEAMQPCLIENT_EXPORT ResourceLockedException : public ChannelException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; - /** Constructor */ + static const std::uint16_t REPLY_CODE; + + /** + * Constructor + */ explicit ResourceLockedException(const std::string &what, const std::string reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ChannelException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; /** @@ -552,15 +566,18 @@ class SIMPLEAMQPCLIENT_EXPORT PreconditionFailedException : public ChannelException { public: /** reply code */ - static const boost::uint16_t REPLY_CODE; - /** Constructor */ + static const std::uint16_t REPLY_CODE; + + /** + * Constructor + */ explicit PreconditionFailedException(const std::string &what, const std::string reply_text, - boost::uint16_t class_id, - boost::uint16_t method_id) throw() + std::uint16_t class_id, + std::uint16_t method_id) throw() : ChannelException(what, reply_text, class_id, method_id) {} - virtual boost::uint16_t reply_code() const throw() { return REPLY_CODE; } + virtual std::uint16_t reply_code() const throw() { return REPLY_CODE; } }; } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/AmqpResponseLibraryException.h b/src/SimpleAmqpClient/AmqpResponseLibraryException.h index c76f127c..7ffa8bad 100644 --- a/src/SimpleAmqpClient/AmqpResponseLibraryException.h +++ b/src/SimpleAmqpClient/AmqpResponseLibraryException.h @@ -28,7 +28,6 @@ * ***** END LICENSE BLOCK ***** */ -#include #include #include diff --git a/src/SimpleAmqpClient/BasicMessage.h b/src/SimpleAmqpClient/BasicMessage.h index 7a586b94..6a5c8d3e 100644 --- a/src/SimpleAmqpClient/BasicMessage.h +++ b/src/SimpleAmqpClient/BasicMessage.h @@ -28,9 +28,9 @@ * ***** END LICENSE BLOCK ***** */ -#include #include #include +#include #include #include @@ -157,11 +157,11 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage { /** * Gets the priority property */ - boost::uint8_t Priority() const; + std::uint8_t Priority() const; /** * Sets the priority property */ - void Priority(boost::uint8_t priority); + void Priority(std::uint8_t priority); /** * Determines whether the priority property is set */ @@ -242,11 +242,11 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage { /** * Gets the timestamp property */ - boost::uint64_t Timestamp() const; + std::uint64_t Timestamp() const; /** * Sets the timestamp property */ - void Timestamp(boost::uint64_t timestamp); + void Timestamp(std::uint64_t timestamp); /** * Determines whether the timestamp property is set */ diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 638faae7..25b39cf8 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -28,12 +28,12 @@ * ***** END LICENSE BLOCK ***** */ -#include #include #include #include #include #include +#include #include #include #include @@ -530,8 +530,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { * broker is asked to create a unique queue by not providing a queue name. */ std::string DeclareQueueWithCounts(const std::string &queue_name, - boost::uint32_t &message_count, - boost::uint32_t &consumer_count, + std::uint32_t &message_count, + std::uint32_t &consumer_count, bool passive = false, bool durable = false, bool exclusive = true, bool auto_delete = true); @@ -561,8 +561,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { * broker is asked to create a unique queue by not providing a queue name. */ std::string DeclareQueueWithCounts(const std::string &queue_name, - boost::uint32_t &message_count, - boost::uint32_t &consumer_count, + std::uint32_t &message_count, + std::uint32_t &consumer_count, bool passive, bool durable, bool exclusive, bool auto_delete, const Table &arguments); @@ -775,7 +775,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { const std::string &consumer_tag = "", bool no_local = true, bool no_ack = true, bool exclusive = true, - boost::uint16_t message_prefetch_count = 1); + std::uint16_t message_prefetch_count = 1); /** * Starts consuming Basic messages on a queue @@ -803,7 +803,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { std::string BasicConsume(const std::string &queue, const std::string &consumer_tag, bool no_local, bool no_ack, bool exclusive, - boost::uint16_t message_prefetch_count, + std::uint16_t message_prefetch_count, const Table &arguments); /** @@ -819,7 +819,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { * broker will deliver. A value of 0 means no limit. */ void BasicQos(const std::string &consumer_tag, - boost::uint16_t message_prefetch_count); + std::uint16_t message_prefetch_count); /** * Cancels a previously created Consumer diff --git a/src/SimpleAmqpClient/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index cac89c47..8365331e 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -215,7 +215,7 @@ class Channel::ChannelImpl { } template - amqp_frame_t DoRpcOnChannel(amqp_channel_t channel, boost::uint32_t method_id, + amqp_frame_t DoRpcOnChannel(amqp_channel_t channel, std::uint32_t method_id, void *decoded, const ResponseListType &expected_responses) { CheckForError(amqp_send_method(m_connection, channel, method_id, decoded)); @@ -228,7 +228,7 @@ class Channel::ChannelImpl { } template - amqp_frame_t DoRpc(boost::uint32_t method_id, void *decoded, + amqp_frame_t DoRpc(std::uint32_t method_id, void *decoded, const ResponseListType &expected_responses) { amqp_channel_t channel = GetChannel(); amqp_frame_t ret = @@ -264,7 +264,7 @@ class Channel::ChannelImpl { template bool ConsumeMessageOnChannelInner(const ChannelListType channels, Envelope::ptr_t &message, int timeout) { - const boost::array DELIVER_OR_CANCEL = { + const boost::array DELIVER_OR_CANCEL = { {AMQP_BASIC_DELIVER_METHOD, AMQP_BASIC_CANCEL_METHOD}}; boost::chrono::microseconds real_timeout = @@ -302,7 +302,7 @@ class Channel::ChannelImpl { const std::string in_consumer_tag( (char *)deliver_method->consumer_tag.bytes, deliver_method->consumer_tag.len); - const boost::uint64_t delivery_tag = deliver_method->delivery_tag; + const std::uint64_t delivery_tag = deliver_method->delivery_tag; const bool redelivered = (deliver_method->redelivered == 0 ? false : true); MaybeReleaseBuffersOnChannel(deliver.channel); @@ -347,7 +347,7 @@ class Channel::ChannelImpl { amqp_connection_state_t m_connection; private: - static boost::uint32_t ComputeBrokerVersion( + static std::uint32_t ComputeBrokerVersion( const amqp_connection_state_t state); frame_queue_t m_frame_queue; @@ -362,7 +362,7 @@ class Channel::ChannelImpl { typedef std::vector channel_state_list_t; channel_state_list_t m_channels; - boost::uint32_t m_brokerVersion; + std::uint32_t m_brokerVersion; // A channel that is likely to be an CS_Open state amqp_channel_t m_last_used_channel; diff --git a/src/SimpleAmqpClient/Envelope.h b/src/SimpleAmqpClient/Envelope.h index 3aa0bb7d..5e6f8fee 100644 --- a/src/SimpleAmqpClient/Envelope.h +++ b/src/SimpleAmqpClient/Envelope.h @@ -28,9 +28,9 @@ * ***** END LICENSE BLOCK ***** */ -#include #include #include +#include #include #include "SimpleAmqpClient/BasicMessage.h" @@ -69,10 +69,10 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { */ static ptr_t Create(const BasicMessage::ptr_t message, const std::string &consumer_tag, - const boost::uint64_t delivery_tag, + const std::uint64_t delivery_tag, const std::string &exchange, bool redelivered, const std::string &routing_key, - const boost::uint16_t delivery_channel) { + const std::uint16_t delivery_channel) { return boost::make_shared(message, consumer_tag, delivery_tag, exchange, redelivered, routing_key, delivery_channel); @@ -92,10 +92,10 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { */ explicit Envelope(const BasicMessage::ptr_t message, const std::string &consumer_tag, - const boost::uint64_t delivery_tag, + const std::uint64_t delivery_tag, const std::string &exchange, bool redelivered, const std::string &routing_key, - const boost::uint16_t delivery_channel); + const std::uint16_t delivery_channel); public: // Non-copyable @@ -130,7 +130,7 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { * * @returns the delivery tag for a message */ - inline boost::uint64_t DeliveryTag() const { return m_deliveryTag; } + inline std::uint64_t DeliveryTag() const { return m_deliveryTag; } /** * Get the name of the exchange that the message was published to @@ -162,7 +162,7 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { /** * Get the delivery channel */ - inline boost::uint16_t DeliveryChannel() const { return m_deliveryChannel; } + inline std::uint16_t DeliveryChannel() const { return m_deliveryChannel; } /** * A POD carrier of delivery-tag @@ -179,9 +179,9 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { struct DeliveryInfo { /// A delivery tag, assigned by the broker to identify this delivery within /// a channel - boost::uint64_t delivery_tag; + std::uint64_t delivery_tag; /// An ID of the delivery channel - boost::uint16_t delivery_channel; + std::uint16_t delivery_channel; }; /** @@ -198,11 +198,11 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { private: const BasicMessage::ptr_t m_message; const std::string m_consumerTag; - const boost::uint64_t m_deliveryTag; + const std::uint64_t m_deliveryTag; const std::string m_exchange; const bool m_redelivered; const std::string m_routingKey; - const boost::uint16_t m_deliveryChannel; + const std::uint16_t m_deliveryChannel; }; } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/MessageRejectedException.h b/src/SimpleAmqpClient/MessageRejectedException.h index 8d4f8b40..2b1dcc1d 100644 --- a/src/SimpleAmqpClient/MessageRejectedException.h +++ b/src/SimpleAmqpClient/MessageRejectedException.h @@ -28,8 +28,7 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include +#include #include #include "SimpleAmqpClient/BasicMessage.h" @@ -48,17 +47,17 @@ namespace AmqpClient { class SIMPLEAMQPCLIENT_EXPORT MessageRejectedException : public std::runtime_error { public: - MessageRejectedException(uint64_t delivery_tag) + MessageRejectedException(std::uint64_t delivery_tag) : std::runtime_error( std::string("Message rejected: ") .append(boost::lexical_cast(delivery_tag))), m_delivery_tag(delivery_tag) {} /// `delivery_tag` getter - uint64_t GetDeliveryTag() { return m_delivery_tag; } + std::uint64_t GetDeliveryTag() { return m_delivery_tag; } private: - uint64_t m_delivery_tag; + std::uint64_t m_delivery_tag; }; } // namespace AmqpClient diff --git a/src/SimpleAmqpClient/MessageReturnedException.h b/src/SimpleAmqpClient/MessageReturnedException.h index 1b672725..eb39a6eb 100644 --- a/src/SimpleAmqpClient/MessageReturnedException.h +++ b/src/SimpleAmqpClient/MessageReturnedException.h @@ -28,7 +28,7 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include #include "SimpleAmqpClient/BasicMessage.h" @@ -49,7 +49,7 @@ class SIMPLEAMQPCLIENT_EXPORT MessageReturnedException public: /// Constructor. explicit MessageReturnedException(BasicMessage::ptr_t message, - boost::uint32_t reply_code, + std::uint32_t reply_code, const std::string &reply_text, const std::string &exchange, const std::string &routing_key) throw(); @@ -59,7 +59,7 @@ class SIMPLEAMQPCLIENT_EXPORT MessageReturnedException /// `message` getter BasicMessage::ptr_t message() const throw() { return m_message; } /// `reply_code` getter - boost::uint32_t reply_code() const throw() { return m_reply_code; } + std::uint32_t reply_code() const throw() { return m_reply_code; } /// `reply_text` getter std::string reply_text() const throw() { return m_reply_text; } /// Exchange name getter @@ -69,7 +69,7 @@ class SIMPLEAMQPCLIENT_EXPORT MessageReturnedException private: BasicMessage::ptr_t m_message; - boost::uint32_t m_reply_code; + std::uint32_t m_reply_code; std::string m_reply_text; std::string m_exchange; std::string m_routing_key; diff --git a/src/SimpleAmqpClient/Table.h b/src/SimpleAmqpClient/Table.h index 3bbee8af..807f6870 100644 --- a/src/SimpleAmqpClient/Table.h +++ b/src/SimpleAmqpClient/Table.h @@ -28,7 +28,7 @@ * ***** END LICENSE BLOCK ***** */ -#include +#include #include #include #include @@ -119,42 +119,42 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * * @param [in] value the value */ - TableValue(boost::uint8_t value); + TableValue(std::uint8_t value); /** * Construct a 1-byte signed integer value * * @param [in] value the value */ - TableValue(boost::int8_t value); + TableValue(std::int8_t value); /** * Construct a 2-byte unsigned integer value * * @param [in] value the value */ - TableValue(boost::uint16_t value); + TableValue(std::uint16_t value); /** * Construct a 2-byte signed integer value * * @param [in] value the value */ - TableValue(boost::int16_t value); + TableValue(std::int16_t value); /** * Construct a 4-byte unsigned integer value * * @param [in] value the value */ - TableValue(boost::uint32_t value); + TableValue(std::uint32_t value); /** * Construct a 4-byte signed integer value * * @param [in] value the value */ - TableValue(boost::int32_t value); + TableValue(std::int32_t value); private: /** @@ -163,7 +163,7 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * RabbitMQ does not support unsigned 64-bit values in tables, * however, timestamps are used for this. */ - TableValue(boost::uint64_t value); + TableValue(std::uint64_t value); public: /** @@ -180,7 +180,7 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * * @param [in] value the value */ - TableValue(boost::int64_t value); + TableValue(std::int64_t value); /** * Construct a single-precision floating point value @@ -266,49 +266,49 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * * @returns the value if its a VT_uint8 type, 0 otherwise */ - boost::uint8_t GetUint8() const; + std::uint8_t GetUint8() const; /** * Get the int8 value * * @returns the value if its a VT_int8 type, 0 otherwise */ - boost::int8_t GetInt8() const; + std::int8_t GetInt8() const; /** * Get the uint16 value * * @returns the value if its a VT_uint16 type, 0 otherwise */ - boost::uint16_t GetUint16() const; + std::uint16_t GetUint16() const; /** * Get the int16 value * * @returns the value if its a VT_int16 type, 0 otherwise */ - boost::int16_t GetInt16() const; + std::int16_t GetInt16() const; /** * Get the uint32 value * * @returns the value if its a VT_uint32 type, 0 otherwise */ - boost::uint32_t GetUint32() const; + std::uint32_t GetUint32() const; /** * Get the int32 value * * @returns the value if its a VT_int32 type, 0 otherwise */ - boost::int32_t GetInt32() const; + std::int32_t GetInt32() const; /** * Get the uint64 value * * @returns the value if its a VT_uint64 type, 0 otherwise */ - boost::uint64_t GetUint64() const; + std::uint64_t GetUint64() const; /** * Get the timestamp value @@ -322,7 +322,7 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * * @returns the value if its a VT_int64 type, 0 otherwise */ - boost::int64_t GetInt64() const; + std::int64_t GetInt64() const; /** * Get an integral number @@ -334,7 +334,7 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * @returns an integer number if the ValueType is VT_uint8, VT_int8, * VT_uint16, VT_int16, VT_uint32, VT_int32,or VT_int64 type, 0 otherwise. */ - boost::int64_t GetInteger() const; + std::int64_t GetInteger() const; /** * Get a float value @@ -395,42 +395,42 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * * @param [in] value the value */ - void Set(boost::uint8_t value); + void Set(std::uint8_t value); /** * Set the value as a int8_t * * @param [in] value the value */ - void Set(boost::int8_t value); + void Set(std::int8_t value); /** * Set the value as a uint16_t * * @param [in] value the value */ - void Set(boost::uint16_t value); + void Set(std::uint16_t value); /** * Set the value as a int16_t * * @param [in] value the value */ - void Set(boost::int16_t value); + void Set(std::int16_t value); /** * Set the value as a uint32_t * * @param [in] value the value */ - void Set(boost::uint32_t value); + void Set(std::uint32_t value); /** * Set the value as a int32_t * * @param [in] value the value */ - void Set(boost::int32_t value); + void Set(std::int32_t value); /** * Set the value as a timestamp. @@ -444,7 +444,7 @@ class SIMPLEAMQPCLIENT_EXPORT TableValue { * * @param [in] value the value */ - void Set(boost::int64_t value); + void Set(std::int64_t value); /** * Set the value as a float diff --git a/src/SimpleAmqpClient/TableImpl.h b/src/SimpleAmqpClient/TableImpl.h index b72bc665..51b6c525 100644 --- a/src/SimpleAmqpClient/TableImpl.h +++ b/src/SimpleAmqpClient/TableImpl.h @@ -30,10 +30,10 @@ #include -#include #include #include #include +#include #include #include @@ -50,10 +50,10 @@ inline bool operator==(const void_t &, const void_t &) { return true; } typedef std::vector array_t; -typedef boost::variant +typedef boost::variant value_t; class TableValueImpl { @@ -89,14 +89,14 @@ class TableValueImpl { amqp_field_value_t operator()(const void_t) const; amqp_field_value_t operator()(const bool value) const; - amqp_field_value_t operator()(const boost::uint8_t value) const; - amqp_field_value_t operator()(const boost::int8_t value) const; - amqp_field_value_t operator()(const boost::uint16_t value) const; - amqp_field_value_t operator()(const boost::int16_t value) const; - amqp_field_value_t operator()(const boost::uint32_t value) const; - amqp_field_value_t operator()(const boost::int32_t value) const; - amqp_field_value_t operator()(const boost::uint64_t value) const; - amqp_field_value_t operator()(const boost::int64_t value) const; + amqp_field_value_t operator()(const std::uint8_t value) const; + amqp_field_value_t operator()(const std::int8_t value) const; + amqp_field_value_t operator()(const std::uint16_t value) const; + amqp_field_value_t operator()(const std::int16_t value) const; + amqp_field_value_t operator()(const std::uint32_t value) const; + amqp_field_value_t operator()(const std::int32_t value) const; + amqp_field_value_t operator()(const std::uint64_t value) const; + amqp_field_value_t operator()(const std::int64_t value) const; amqp_field_value_t operator()(const float value) const; amqp_field_value_t operator()(const double value) const; amqp_field_value_t operator()(const std::string &value) const; diff --git a/src/Table.cpp b/src/Table.cpp index c28033f9..049f10d7 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -45,32 +46,32 @@ TableValue::TableValue() TableValue::TableValue(bool value) : m_impl(new Detail::TableValueImpl(value)) {} -TableValue::TableValue(boost::uint8_t value) +TableValue::TableValue(std::uint8_t value) : m_impl(new Detail::TableValueImpl(value)) {} -TableValue::TableValue(boost::int8_t value) +TableValue::TableValue(std::int8_t value) : m_impl(new Detail::TableValueImpl(value)) {} -TableValue::TableValue(boost::uint16_t value) +TableValue::TableValue(std::uint16_t value) : m_impl(new Detail::TableValueImpl(value)) {} -TableValue::TableValue(boost::int16_t value) +TableValue::TableValue(std::int16_t value) : m_impl(new Detail::TableValueImpl(value)) {} -TableValue::TableValue(boost::uint32_t value) +TableValue::TableValue(std::uint32_t value) : m_impl(new Detail::TableValueImpl(value)) {} -TableValue::TableValue(boost::int32_t value) +TableValue::TableValue(std::int32_t value) : m_impl(new Detail::TableValueImpl(value)) {} -TableValue::TableValue(boost::uint64_t value) +TableValue::TableValue(std::uint64_t value) : m_impl(new Detail::TableValueImpl(value)) {} TableValue TableValue::Timestamp(std::time_t ts) { - return TableValue(static_cast(ts)); + return TableValue(static_cast(ts)); } -TableValue::TableValue(boost::int64_t value) +TableValue::TableValue(std::int64_t value) : m_impl(new Detail::TableValueImpl(value)) {} TableValue::TableValue(float value) @@ -139,39 +140,39 @@ TableValue::ValueType TableValue::GetType() const { bool TableValue::GetBool() const { return boost::get(m_impl->m_value); } -boost::uint8_t TableValue::GetUint8() const { - return boost::get(m_impl->m_value); +std::uint8_t TableValue::GetUint8() const { + return boost::get(m_impl->m_value); } -boost::int8_t TableValue::GetInt8() const { - return boost::get(m_impl->m_value); +std::int8_t TableValue::GetInt8() const { + return boost::get(m_impl->m_value); } -boost::uint16_t TableValue::GetUint16() const { - return boost::get(m_impl->m_value); +std::uint16_t TableValue::GetUint16() const { + return boost::get(m_impl->m_value); } -boost::int16_t TableValue::GetInt16() const { - return boost::get(m_impl->m_value); +std::int16_t TableValue::GetInt16() const { + return boost::get(m_impl->m_value); } -boost::uint32_t TableValue::GetUint32() const { - return boost::get(m_impl->m_value); +std::uint32_t TableValue::GetUint32() const { + return boost::get(m_impl->m_value); } -boost::int32_t TableValue::GetInt32() const { - return boost::get(m_impl->m_value); +std::int32_t TableValue::GetInt32() const { + return boost::get(m_impl->m_value); } std::time_t TableValue::GetTimestamp() const { - return static_cast(boost::get(m_impl->m_value)); + return static_cast(boost::get(m_impl->m_value)); } -boost::int64_t TableValue::GetInt64() const { - return boost::get(m_impl->m_value); +std::int64_t TableValue::GetInt64() const { + return boost::get(m_impl->m_value); } -boost::int64_t TableValue::GetInteger() const { +std::int64_t TableValue::GetInteger() const { switch (m_impl->m_value.which()) { case VT_uint8: return GetUint8(); @@ -227,23 +228,23 @@ void TableValue::Set() { m_impl->m_value = Detail::void_t(); } void TableValue::Set(bool value) { m_impl->m_value = value; } -void TableValue::Set(boost::uint8_t value) { m_impl->m_value = value; } +void TableValue::Set(std::uint8_t value) { m_impl->m_value = value; } -void TableValue::Set(boost::int8_t value) { m_impl->m_value = value; } +void TableValue::Set(std::int8_t value) { m_impl->m_value = value; } -void TableValue::Set(boost::uint16_t value) { m_impl->m_value = value; } +void TableValue::Set(std::uint16_t value) { m_impl->m_value = value; } -void TableValue::Set(boost::int16_t value) { m_impl->m_value = value; } +void TableValue::Set(std::int16_t value) { m_impl->m_value = value; } -void TableValue::Set(boost::uint32_t value) { m_impl->m_value = value; } +void TableValue::Set(std::uint32_t value) { m_impl->m_value = value; } -void TableValue::Set(boost::int32_t value) { m_impl->m_value = value; } +void TableValue::Set(std::int32_t value) { m_impl->m_value = value; } void TableValue::SetTimestamp(std::time_t value) { - m_impl->m_value = static_cast(value); + m_impl->m_value = static_cast(value); } -void TableValue::Set(boost::int64_t value) { m_impl->m_value = value; } +void TableValue::Set(std::int64_t value) { m_impl->m_value = value; } void TableValue::Set(float value) { m_impl->m_value = value; } diff --git a/src/TableImpl.cpp b/src/TableImpl.cpp index a8610601..f9eb1cf3 100644 --- a/src/TableImpl.cpp +++ b/src/TableImpl.cpp @@ -64,7 +64,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::uint8_t value) const { + const std::uint8_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_U8; v.value.u8 = value; @@ -72,7 +72,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::int8_t value) const { + const std::int8_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_I8; v.value.i8 = value; @@ -80,7 +80,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::uint16_t value) const { + const std::uint16_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_U16; v.value.u16 = value; @@ -88,7 +88,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::int16_t value) const { + const std::int16_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_I16; v.value.i16 = value; @@ -96,7 +96,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::uint32_t value) const { + const std::uint32_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_U32; v.value.u32 = value; @@ -104,7 +104,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::int32_t value) const { + const std::int32_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_I32; v.value.i32 = value; @@ -112,7 +112,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::uint64_t value) const { + const std::uint64_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_TIMESTAMP; v.value.u64 = value; @@ -120,7 +120,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( } amqp_field_value_t TableValueImpl::generate_field_value::operator()( - const boost::int64_t value) const { + const std::int64_t value) const { amqp_field_value_t v; v.kind = AMQP_FIELD_KIND_I64; v.value.i64 = value; diff --git a/testing/test_queue.cpp b/testing/test_queue.cpp index f157697c..ac4e32ba 100644 --- a/testing/test_queue.cpp +++ b/testing/test_queue.cpp @@ -26,6 +26,8 @@ * ***** END LICENSE BLOCK ***** */ +#include + #include "connected_test.h" TEST_F(connected_test, queue_declare) { @@ -83,8 +85,8 @@ TEST_F(connected_test, queue_declare_notautodelete) { } TEST_F(connected_test, queue_declare_counts) { - boost::uint32_t message_count = 123; - boost::uint32_t consumer_count = 123; + std::uint32_t message_count = 123; + std::uint32_t consumer_count = 123; std::string queue = channel->DeclareQueueWithCounts( "queue_declare_counts", message_count, consumer_count); @@ -110,8 +112,8 @@ TEST_F(connected_test, queue_declare_counts) { } TEST_F(connected_test, queue_declare_counts_table) { - boost::uint32_t message_count = 123; - boost::uint32_t consumer_count = 123; + std::uint32_t message_count = 123; + std::uint32_t consumer_count = 123; Table qTable; diff --git a/testing/test_table.cpp b/testing/test_table.cpp index 5f02adf9..424ade68 100644 --- a/testing/test_table.cpp +++ b/testing/test_table.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "connected_test.h" @@ -123,8 +124,8 @@ TEST(table_value, bool_value) { } TEST(table_value, uint8_value) { - boost::uint8_t v1 = 1; - boost::uint8_t v2 = 2; + std::uint8_t v1 = 1; + std::uint8_t v2 = 2; TableValue value(v1); EXPECT_EQ(TableValue::VT_uint8, value.GetType()); @@ -168,8 +169,8 @@ TEST(table_value, uint8_value) { } TEST(table_value, int8_value) { - boost::int8_t v1 = 1; - boost::int8_t v2 = 2; + std::int8_t v1 = 1; + std::int8_t v2 = 2; TableValue value(v1); EXPECT_EQ(TableValue::VT_int8, value.GetType()); @@ -213,8 +214,8 @@ TEST(table_value, int8_value) { } TEST(table_value, uint16_value) { - boost::uint16_t v1 = 1; - boost::uint16_t v2 = 2; + std::uint16_t v1 = 1; + std::uint16_t v2 = 2; TableValue value(v1); EXPECT_EQ(TableValue::VT_uint16, value.GetType()); @@ -258,8 +259,8 @@ TEST(table_value, uint16_value) { } TEST(table_value, int16_value) { - boost::int16_t v1 = 1; - boost::int16_t v2 = 2; + std::int16_t v1 = 1; + std::int16_t v2 = 2; TableValue value(v1); EXPECT_EQ(TableValue::VT_int16, value.GetType()); @@ -303,8 +304,8 @@ TEST(table_value, int16_value) { } TEST(table_value, uint32_value) { - boost::uint32_t v1 = 1; - boost::uint32_t v2 = 2; + std::uint32_t v1 = 1; + std::uint32_t v2 = 2; TableValue value(v1); EXPECT_EQ(TableValue::VT_uint32, value.GetType()); @@ -348,8 +349,8 @@ TEST(table_value, uint32_value) { } TEST(table_value, int32_value) { - boost::int32_t v1 = 1; - boost::int32_t v2 = 2; + std::int32_t v1 = 1; + std::int32_t v2 = 2; TableValue value(v1); EXPECT_EQ(TableValue::VT_int32, value.GetType()); @@ -438,8 +439,8 @@ TEST(table_value, timestamp_value) { } TEST(table_value, int64_value) { - boost::int64_t v1 = 1; - boost::int64_t v2 = 2; + std::int64_t v1 = 1; + std::int64_t v2 = 2; TableValue value(v1); EXPECT_EQ(TableValue::VT_int64, value.GetType()); From 27fcca47b6be37ebda09a4b3c0eb5070f672d6cb Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 18 Jul 2020 07:22:45 +0000 Subject: [PATCH 27/39] lib: switch to std::array Un-boostify, and use initializer_lists. --- src/Channel.cpp | 62 ++++++++++++++---------------- src/ChannelImpl.cpp | 18 ++++----- src/SimpleAmqpClient/ChannelImpl.h | 9 ++--- testing/test_message.cpp | 7 ++-- 4 files changed, 44 insertions(+), 52 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index 22823bee..efc9245d 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -36,7 +36,7 @@ #include -#include +#include #include #include #include @@ -507,8 +507,8 @@ void Channel::DeclareExchange(const std::string &exchange_name, const std::string &exchange_type, bool passive, bool durable, bool auto_delete, const Table &arguments) { - const boost::array DECLARE_OK = { - {AMQP_EXCHANGE_DECLARE_OK_METHOD}}; + const std::array DECLARE_OK = { + AMQP_EXCHANGE_DECLARE_OK_METHOD}; m_impl->CheckIsConnected(); amqp_exchange_declare_t declare = {}; @@ -530,8 +530,8 @@ void Channel::DeclareExchange(const std::string &exchange_name, } void Channel::DeleteExchange(const std::string &exchange_name, bool if_unused) { - const boost::array DELETE_OK = { - {AMQP_EXCHANGE_DELETE_OK_METHOD}}; + const std::array DELETE_OK = { + AMQP_EXCHANGE_DELETE_OK_METHOD}; m_impl->CheckIsConnected(); amqp_exchange_delete_t del = {}; @@ -554,8 +554,7 @@ void Channel::BindExchange(const std::string &destination, const std::string &source, const std::string &routing_key, const Table &arguments) { - const boost::array BIND_OK = { - {AMQP_EXCHANGE_BIND_OK_METHOD}}; + const std::array BIND_OK = {AMQP_EXCHANGE_BIND_OK_METHOD}; m_impl->CheckIsConnected(); amqp_exchange_bind_t bind = {}; @@ -582,8 +581,8 @@ void Channel::UnbindExchange(const std::string &destination, const std::string &source, const std::string &routing_key, const Table &arguments) { - const boost::array UNBIND_OK = { - {AMQP_EXCHANGE_UNBIND_OK_METHOD}}; + const std::array UNBIND_OK = { + AMQP_EXCHANGE_UNBIND_OK_METHOD}; m_impl->CheckIsConnected(); amqp_exchange_unbind_t unbind = {}; @@ -653,8 +652,8 @@ std::string Channel::DeclareQueueWithCounts(const std::string &queue_name, bool passive, bool durable, bool exclusive, bool auto_delete, const Table &arguments) { - const boost::array DECLARE_OK = { - {AMQP_QUEUE_DECLARE_OK_METHOD}}; + const std::array DECLARE_OK = { + AMQP_QUEUE_DECLARE_OK_METHOD}; m_impl->CheckIsConnected(); amqp_queue_declare_t declare = {}; @@ -686,8 +685,7 @@ std::string Channel::DeclareQueueWithCounts(const std::string &queue_name, void Channel::DeleteQueue(const std::string &queue_name, bool if_unused, bool if_empty) { - const boost::array DELETE_OK = { - {AMQP_QUEUE_DELETE_OK_METHOD}}; + const std::array DELETE_OK = {AMQP_QUEUE_DELETE_OK_METHOD}; m_impl->CheckIsConnected(); amqp_queue_delete_t del = {}; @@ -710,7 +708,7 @@ void Channel::BindQueue(const std::string &queue_name, const std::string &exchange_name, const std::string &routing_key, const Table &arguments) { - const boost::array BIND_OK = {{AMQP_QUEUE_BIND_OK_METHOD}}; + const std::array BIND_OK = {AMQP_QUEUE_BIND_OK_METHOD}; m_impl->CheckIsConnected(); amqp_queue_bind_t bind = {}; @@ -737,8 +735,7 @@ void Channel::UnbindQueue(const std::string &queue_name, const std::string &exchange_name, const std::string &routing_key, const Table &arguments) { - const boost::array UNBIND_OK = { - {AMQP_QUEUE_UNBIND_OK_METHOD}}; + const std::array UNBIND_OK = {AMQP_QUEUE_UNBIND_OK_METHOD}; m_impl->CheckIsConnected(); amqp_queue_unbind_t unbind = {}; @@ -756,8 +753,7 @@ void Channel::UnbindQueue(const std::string &queue_name, } void Channel::PurgeQueue(const std::string &queue_name) { - const boost::array PURGE_OK = { - {AMQP_QUEUE_PURGE_OK_METHOD}}; + const std::array PURGE_OK = {AMQP_QUEUE_PURGE_OK_METHOD}; m_impl->CheckIsConnected(); amqp_queue_purge_t purge = {}; @@ -844,11 +840,10 @@ void Channel::BasicPublish(const std::string &exchange_name, // - channel.close - probably tried to publish to a non-existant exchange, in // any case error! // - connection.clsoe - something really bad happened - const boost::array PUBLISH_ACK = { - {AMQP_BASIC_ACK_METHOD, AMQP_BASIC_RETURN_METHOD, - AMQP_BASIC_NACK_METHOD}}; + const std::array PUBLISH_ACK = { + AMQP_BASIC_ACK_METHOD, AMQP_BASIC_RETURN_METHOD, AMQP_BASIC_NACK_METHOD}; amqp_frame_t response; - boost::array channels = {{channel}}; + std::array channels = {channel}; m_impl->GetMethodOnChannel(channels, response, PUBLISH_ACK); if (AMQP_BASIC_NACK_METHOD == response.payload.method.id) { @@ -867,7 +862,7 @@ void Channel::BasicPublish(const std::string &exchange_name, response.payload.method.decoded)), channel); - const boost::array BASIC_ACK = {{AMQP_BASIC_ACK_METHOD}}; + const std::array BASIC_ACK = {AMQP_BASIC_ACK_METHOD}; m_impl->GetMethodOnChannel(channels, response, BASIC_ACK); m_impl->ReturnChannel(channel); m_impl->MaybeReleaseBuffersOnChannel(channel); @@ -880,8 +875,8 @@ void Channel::BasicPublish(const std::string &exchange_name, bool Channel::BasicGet(Envelope::ptr_t &envelope, const std::string &queue, bool no_ack) { - const boost::array GET_RESPONSES = { - {AMQP_BASIC_GET_OK_METHOD, AMQP_BASIC_GET_EMPTY_METHOD}}; + const std::array GET_RESPONSES = { + AMQP_BASIC_GET_OK_METHOD, AMQP_BASIC_GET_EMPTY_METHOD}; m_impl->CheckIsConnected(); amqp_basic_get_t get = {}; @@ -916,8 +911,8 @@ bool Channel::BasicGet(Envelope::ptr_t &envelope, const std::string &queue, } void Channel::BasicRecover(const std::string &consumer) { - const boost::array RECOVER_OK = { - {AMQP_BASIC_RECOVER_OK_METHOD}}; + const std::array RECOVER_OK = { + AMQP_BASIC_RECOVER_OK_METHOD}; m_impl->CheckIsConnected(); amqp_basic_recover_t recover = {}; @@ -947,7 +942,7 @@ std::string Channel::BasicConsume(const std::string &queue, // Set this before starting the consume as it may have been set by a previous // consumer - const boost::array QOS_OK = {{AMQP_BASIC_QOS_OK_METHOD}}; + const std::array QOS_OK = {AMQP_BASIC_QOS_OK_METHOD}; amqp_basic_qos_t qos = {}; qos.prefetch_size = 0; @@ -957,8 +952,8 @@ std::string Channel::BasicConsume(const std::string &queue, m_impl->DoRpcOnChannel(channel, AMQP_BASIC_QOS_METHOD, &qos, QOS_OK); m_impl->MaybeReleaseBuffersOnChannel(channel); - const boost::array CONSUME_OK = { - {AMQP_BASIC_CONSUME_OK_METHOD}}; + const std::array CONSUME_OK = { + AMQP_BASIC_CONSUME_OK_METHOD}; amqp_basic_consume_t consume = {}; consume.queue = StringToBytes(queue); @@ -991,7 +986,7 @@ void Channel::BasicQos(const std::string &consumer_tag, m_impl->CheckIsConnected(); amqp_channel_t channel = m_impl->GetConsumerChannel(consumer_tag); - const boost::array QOS_OK = {{AMQP_BASIC_QOS_OK_METHOD}}; + const std::array QOS_OK = {AMQP_BASIC_QOS_OK_METHOD}; amqp_basic_qos_t qos = {}; qos.prefetch_size = 0; @@ -1006,8 +1001,7 @@ void Channel::BasicCancel(const std::string &consumer_tag) { m_impl->CheckIsConnected(); amqp_channel_t channel = m_impl->GetConsumerChannel(consumer_tag); - const boost::array CANCEL_OK = { - {AMQP_BASIC_CANCEL_OK_METHOD}}; + const std::array CANCEL_OK = {AMQP_BASIC_CANCEL_OK_METHOD}; amqp_basic_cancel_t cancel = {}; cancel.consumer_tag = StringToBytes(consumer_tag); @@ -1049,7 +1043,7 @@ bool Channel::BasicConsumeMessage(const std::string &consumer_tag, m_impl->CheckIsConnected(); amqp_channel_t channel = m_impl->GetConsumerChannel(consumer_tag); - boost::array channels = {{channel}}; + std::array channels = {channel}; return m_impl->ConsumeMessageOnChannel(channels, message, timeout); } diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index 9a0066df..9701be26 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -39,7 +39,6 @@ #include #include -#include #include "SimpleAmqpClient/AmqpException.h" #include "SimpleAmqpClient/AmqpLibraryException.h" @@ -51,6 +50,7 @@ #define BOOST_BIND_GLOBAL_PLACEHOLDERS #include +#include #include #include @@ -179,16 +179,16 @@ amqp_channel_t Channel::ChannelImpl::GetNextChannelId() { amqp_channel_t Channel::ChannelImpl::CreateNewChannel() { amqp_channel_t new_channel = GetNextChannelId(); - static const boost::array OPEN_OK = { - {AMQP_CHANNEL_OPEN_OK_METHOD}}; + static const std::array OPEN_OK = { + AMQP_CHANNEL_OPEN_OK_METHOD}; amqp_channel_open_t channel_open = {}; - DoRpcOnChannel >( + DoRpcOnChannel >( new_channel, AMQP_CHANNEL_OPEN_METHOD, &channel_open, OPEN_OK); - static const boost::array CONFIRM_OK = { - {AMQP_CONFIRM_SELECT_OK_METHOD}}; + static const std::array CONFIRM_OK = { + AMQP_CONFIRM_SELECT_OK_METHOD}; amqp_confirm_select_t confirm_select = {}; - DoRpcOnChannel >( + DoRpcOnChannel >( new_channel, AMQP_CONFIRM_SELECT_METHOD, &confirm_select, CONFIRM_OK); m_channels.at(new_channel) = CS_Open; @@ -439,7 +439,7 @@ void Channel::ChannelImpl::AddToFrameQueue(const amqp_frame_t &frame) { m_frame_queue.push_back(frame); if (CheckForQueuedMessageOnChannel(frame.channel)) { - boost::array channel = {{frame.channel}}; + std::array channel = {frame.channel}; Envelope::ptr_t envelope; if (!ConsumeMessageOnChannelInner(channel, envelope, -1)) { throw std::logic_error( @@ -503,7 +503,7 @@ bool Channel::ChannelImpl::GetNextFrameOnChannel( return true; } - boost::array channels = {{channel}}; + std::array channels = {channel}; return GetNextFrameFromBrokerOnChannel(channels, frame, timeout); } diff --git a/src/SimpleAmqpClient/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index 8365331e..157ca7ca 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -32,8 +32,6 @@ #include #include -#include - #include "SimpleAmqpClient/AmqpException.h" #include "SimpleAmqpClient/BasicMessage.h" #include "SimpleAmqpClient/Channel.h" @@ -41,6 +39,7 @@ #include "SimpleAmqpClient/Envelope.h" #include "SimpleAmqpClient/MessageReturnedException.h" #define BOOST_BIND_GLOBAL_PLACEHOLDERS +#include #include #include #include @@ -221,7 +220,7 @@ class Channel::ChannelImpl { CheckForError(amqp_send_method(m_connection, channel, method_id, decoded)); amqp_frame_t response; - boost::array channels = {{channel}}; + std::array channels = {channel}; GetMethodOnChannel(channels, response, expected_responses); return response; @@ -264,8 +263,8 @@ class Channel::ChannelImpl { template bool ConsumeMessageOnChannelInner(const ChannelListType channels, Envelope::ptr_t &message, int timeout) { - const boost::array DELIVER_OR_CANCEL = { - {AMQP_BASIC_DELIVER_METHOD, AMQP_BASIC_CANCEL_METHOD}}; + const std::array DELIVER_OR_CANCEL = { + AMQP_BASIC_DELIVER_METHOD, AMQP_BASIC_CANCEL_METHOD}; boost::chrono::microseconds real_timeout = (timeout >= 0 ? boost::chrono::milliseconds(timeout) diff --git a/testing/test_message.cpp b/testing/test_message.cpp index 54e57a22..8211926d 100644 --- a/testing/test_message.cpp +++ b/testing/test_message.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include "connected_test.h" @@ -103,13 +103,12 @@ TEST(basic_message, initial_message_replace2) { } TEST(basic_message, embedded_nulls) { - const boost::array message_data = { - {'a', 'b', 'c', 0, '1', '2', '3'}}; + const std::array message_data = {'a', 'b', 'c', 0, '1', '2', '3'}; const std::string body(message_data.data(), message_data.size()); BasicMessage::ptr_t message = BasicMessage::Create(body); EXPECT_EQ(body, message->Body()); - const boost::array message_data2 = { + const std::array message_data2 = { {'1', '2', '3', 0, 'a', 'b', 'c'}}; const std::string body2(message_data2.data(), message_data2.size()); message->Body(body2); From a2d3d7f66a96f7805c498eb646a52739c0ac5d04 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Wed, 22 Jul 2020 05:45:01 +0000 Subject: [PATCH 28/39] lib: switch away from boost::lexical_cast Un-boostify and use std::to_string and std::stoul instead. --- src/AmqpException.cpp | 9 +++++---- src/ChannelImpl.cpp | 11 ++++------- src/MessageReturnedException.cpp | 4 ++-- src/SimpleAmqpClient/MessageRejectedException.h | 3 ++- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/AmqpException.cpp b/src/AmqpException.cpp index 10d5bff6..387dc0b5 100644 --- a/src/AmqpException.cpp +++ b/src/AmqpException.cpp @@ -32,7 +32,8 @@ #include #include -#include +#include +#include namespace AmqpClient { @@ -74,7 +75,7 @@ void AmqpException::Throw(const amqp_rpc_reply_t &reply) { throw std::logic_error( std::string( "Programming error: unknown server exception class/method") - .append(boost::lexical_cast(reply.reply.id))); + .append(std::to_string(reply.reply.id))); } } @@ -121,7 +122,7 @@ void AmqpException::Throw(const amqp_channel_close_t &reply) { default: throw std::logic_error( std::string("Programming error: unknown channel reply code: ") - .append(boost::lexical_cast(reply.reply_code))); + .append(std::to_string(reply.reply_code))); } } @@ -183,7 +184,7 @@ void AmqpException::Throw(const amqp_connection_close_t &reply) { default: throw std::logic_error( std::string("Programming error: unknown connection reply code: ") - .append(boost::lexical_cast(reply.reply_code))); + .append(std::to_string(reply.reply_code))); } } diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index 9701be26..1b42ff47 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -51,8 +51,8 @@ #include #include +#include #include -#include #define BROKER_HEARTBEAT 0 @@ -558,12 +558,9 @@ std::uint32_t Channel::ChannelImpl::ComputeBrokerVersion( if (version_components.size() != 3) { return 0; } - std::uint32_t version_major = - boost::lexical_cast(version_components[0]); - std::uint32_t version_minor = - boost::lexical_cast(version_components[1]); - std::uint32_t version_patch = - boost::lexical_cast(version_components[2]); + std::uint32_t version_major = std::stoul(version_components[0]); + std::uint32_t version_minor = std::stoul(version_components[1]); + std::uint32_t version_patch = std::stoul(version_components[2]); return (version_major & 0xFF) << 16 | (version_minor & 0xFF) << 8 | (version_patch & 0xFF); } diff --git a/src/MessageReturnedException.cpp b/src/MessageReturnedException.cpp index 3e64d460..8ea9f83f 100644 --- a/src/MessageReturnedException.cpp +++ b/src/MessageReturnedException.cpp @@ -28,7 +28,7 @@ #include "SimpleAmqpClient/MessageReturnedException.h" -#include +#include namespace AmqpClient { MessageReturnedException::MessageReturnedException( @@ -37,7 +37,7 @@ MessageReturnedException::MessageReturnedException( const std::string &routing_key) throw() : std::runtime_error( std::string("Message returned. Reply code: ") - .append(boost::lexical_cast(reply_code)) + .append(std::to_string(reply_code)) .append(" ") .append(reply_text)), m_message(message), diff --git a/src/SimpleAmqpClient/MessageRejectedException.h b/src/SimpleAmqpClient/MessageRejectedException.h index 2b1dcc1d..8ef7bb7c 100644 --- a/src/SimpleAmqpClient/MessageRejectedException.h +++ b/src/SimpleAmqpClient/MessageRejectedException.h @@ -30,6 +30,7 @@ #include #include +#include #include "SimpleAmqpClient/BasicMessage.h" @@ -50,7 +51,7 @@ class SIMPLEAMQPCLIENT_EXPORT MessageRejectedException MessageRejectedException(std::uint64_t delivery_tag) : std::runtime_error( std::string("Message rejected: ") - .append(boost::lexical_cast(delivery_tag))), + .append(std::to_string(delivery_tag))), m_delivery_tag(delivery_tag) {} /// `delivery_tag` getter From 3a7e234e5ed390e1dd6bdced3bd3fa6686c63997 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Wed, 22 Jul 2020 06:00:27 +0000 Subject: [PATCH 29/39] lib: drop unused boost/limits.hpp Un-boostify, apparently this was not used. --- src/Channel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index efc9245d..3486652c 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -38,7 +38,6 @@ #include #include -#include #include #include #include From 64a1fac0042d207fb4c61e77649411e9039a62b1 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Wed, 22 Jul 2020 21:46:50 +0000 Subject: [PATCH 30/39] lib: drop unused boost/foreach.hpp Un-boostify, apparently unused. --- src/TableImpl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TableImpl.cpp b/src/TableImpl.cpp index f9eb1cf3..aa31be77 100644 --- a/src/TableImpl.cpp +++ b/src/TableImpl.cpp @@ -36,7 +36,6 @@ #include #include -#include #include #include #include From 4bd0514404fd86e04f7a5b18521e0b683c461ba8 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Wed, 22 Jul 2020 23:20:36 +0000 Subject: [PATCH 31/39] lib: switch boost::shared_ptr to std::shared_ptr Un-boostify! Will eventually follow-up and move uses of std::shared_ptr to use std::unique_ptr, where there are API touch-points. --- README.md | 4 ++-- src/Channel.cpp | 21 +++++++++++---------- src/SimpleAmqpClient/BasicMessage.h | 10 ++++------ src/SimpleAmqpClient/Channel.h | 6 ++---- src/SimpleAmqpClient/ChannelImpl.h | 1 + src/SimpleAmqpClient/Envelope.h | 15 +++++++-------- src/SimpleAmqpClient/TableImpl.h | 4 ++-- src/TableImpl.cpp | 5 +++-- 8 files changed, 32 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 3be3d9fb..665b706e 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,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 3486652c..b7191b4d 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -141,8 +142,8 @@ Channel::OpenOpts Channel::OpenOpts::FromUri(const std::string &uri) { 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(); @@ -200,14 +201,14 @@ Channel::ptr_t Channel::Open(const OpenOpts &opts) { case 0: { const OpenOpts::BasicAuth &auth = boost::get(opts.auth); - return boost::make_shared( + return std::make_shared( OpenChannel(opts.host, opts.port, auth.username, auth.password, opts.vhost, opts.frame_max, false)); } case 1: { const OpenOpts::ExternalSaslAuth &auth = boost::get(opts.auth); - return boost::make_shared( + return std::make_shared( OpenChannel(opts.host, opts.port, auth.identity, "", opts.vhost, opts.frame_max, true)); } @@ -219,14 +220,14 @@ Channel::ptr_t Channel::Open(const OpenOpts &opts) { case 0: { const OpenOpts::BasicAuth &auth = boost::get(opts.auth); - return boost::make_shared(OpenSecureChannel( + return std::make_shared(OpenSecureChannel( opts.host, opts.port, auth.username, auth.password, opts.vhost, opts.frame_max, opts.tls_params.get(), false)); } case 1: { const OpenOpts::ExternalSaslAuth &auth = boost::get(opts.auth); - return boost::make_shared( + return std::make_shared( OpenSecureChannel(opts.host, opts.port, auth.identity, "", opts.vhost, opts.frame_max, opts.tls_params.get(), true)); } @@ -477,8 +478,8 @@ int Channel::GetSocketFD() const { } bool Channel::CheckExchangeExists(boost::string_ref exchange_name) { - const boost::array DECLARE_OK = { - {AMQP_EXCHANGE_DECLARE_OK_METHOD}}; + const std::array DECLARE_OK = { + AMQP_EXCHANGE_DECLARE_OK_METHOD}; amqp_exchange_declare_t declare = {}; declare.exchange = StringRefToBytes(exchange_name); @@ -600,8 +601,8 @@ void Channel::UnbindExchange(const std::string &destination, } bool Channel::CheckQueueExists(boost::string_ref queue_name) { - const boost::array DECLARE_OK = { - {AMQP_QUEUE_DECLARE_OK_METHOD}}; + const std::array DECLARE_OK = { + AMQP_QUEUE_DECLARE_OK_METHOD}; amqp_queue_declare_t declare = {}; declare.queue = StringRefToBytes(queue_name); diff --git a/src/SimpleAmqpClient/BasicMessage.h b/src/SimpleAmqpClient/BasicMessage.h index 6a5c8d3e..c6ed0d67 100644 --- a/src/SimpleAmqpClient/BasicMessage.h +++ b/src/SimpleAmqpClient/BasicMessage.h @@ -28,8 +28,6 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include #include #include #include @@ -52,8 +50,8 @@ namespace AmqpClient { */ class SIMPLEAMQPCLIENT_EXPORT BasicMessage { public: - /// A shared pointer to BasicMessage - typedef boost::shared_ptr ptr_t; + /// A std::shared_ptr to BasicMessage + typedef std::shared_ptr ptr_t; /// With durable queues, messages can be requested to persist or not enum delivery_mode_t { @@ -65,7 +63,7 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage { /** * 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 with given body @@ -74,7 +72,7 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage { * @returns a new BasicMessage object */ static ptr_t Create(const std::string& body) { - return boost::make_shared(body); + return std::make_shared(body); } /// Construct empty BasicMessage diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index 25b39cf8..ca347b39 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -28,9 +28,7 @@ * ***** END LICENSE BLOCK ***** */ -#include #include -#include #include #include #include @@ -60,8 +58,8 @@ namespace AmqpClient { */ class SIMPLEAMQPCLIENT_EXPORT Channel { public: - /// a `shared_ptr` to Channel - typedef boost::shared_ptr ptr_t; + /// a `std::shared_ptr` to Channel + typedef std::shared_ptr ptr_t; static const std::string EXCHANGE_TYPE_DIRECT; ///< `"direct"` string constant diff --git a/src/SimpleAmqpClient/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index 157ca7ca..f6d41ae8 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -39,6 +39,7 @@ #include "SimpleAmqpClient/Envelope.h" #include "SimpleAmqpClient/MessageReturnedException.h" #define BOOST_BIND_GLOBAL_PLACEHOLDERS +#include #include #include #include diff --git a/src/SimpleAmqpClient/Envelope.h b/src/SimpleAmqpClient/Envelope.h index 5e6f8fee..ff5a6c9e 100644 --- a/src/SimpleAmqpClient/Envelope.h +++ b/src/SimpleAmqpClient/Envelope.h @@ -28,9 +28,8 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include #include +#include #include #include "SimpleAmqpClient/BasicMessage.h" @@ -51,8 +50,8 @@ namespace AmqpClient { */ class SIMPLEAMQPCLIENT_EXPORT Envelope { public: - /// a `shared_ptr` pointer to Envelope - typedef boost::shared_ptr ptr_t; + /// a `std::shared_ptr` pointer to Envelope + typedef std::shared_ptr ptr_t; /** * Creates an new envelope object @@ -65,7 +64,7 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { * result of a redelivery * @param routing_key the routing key that the message was published with * @param delivery_channel channel ID of the delivery (see DeliveryInfo) - * @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, @@ -73,9 +72,9 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope { const std::string &exchange, bool redelivered, const std::string &routing_key, const std::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); } /** diff --git a/src/SimpleAmqpClient/TableImpl.h b/src/SimpleAmqpClient/TableImpl.h index 51b6c525..6d046de3 100644 --- a/src/SimpleAmqpClient/TableImpl.h +++ b/src/SimpleAmqpClient/TableImpl.h @@ -30,10 +30,10 @@ #include -#include #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 aa31be77..5fbe8b89 100644 --- a/src/TableImpl.cpp +++ b/src/TableImpl.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #ifdef _MSC_VER @@ -190,7 +191,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()); @@ -296,7 +297,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()); From 8c8d20ef0ed038db6d607aafefcc55d38fcff7e1 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 23 Jul 2020 00:55:54 +0000 Subject: [PATCH 32/39] lib: switch boost::variant to std::variant Unboostify! --- src/Channel.cpp | 22 +- src/SimpleAmqpClient/Channel.h | 4 +- src/SimpleAmqpClient/TableImpl.h | 12 +- src/Table.cpp | 45 +- src/TableImpl.cpp | 9 +- testing/test_table.cpp | 871 +++++++++++++++---------------- 6 files changed, 477 insertions(+), 486 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index b7191b4d..54fe7cca 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -193,21 +193,21 @@ Channel::ptr_t Channel::Open(const OpenOpts &opts) { throw std::runtime_error( "opts.port is not valid, it must be a positive number"); } - if (opts.auth.empty()) { + if (opts.auth.index()==0) { throw std::runtime_error("opts.auth is not specified, it is required"); } if (!opts.tls_params.is_initialized()) { - switch (opts.auth.which()) { - case 0: { + switch (opts.auth.index()) { + case 1: { const OpenOpts::BasicAuth &auth = - boost::get(opts.auth); + std::get(opts.auth); return std::make_shared( OpenChannel(opts.host, opts.port, auth.username, auth.password, opts.vhost, opts.frame_max, false)); } - case 1: { + case 2: { const OpenOpts::ExternalSaslAuth &auth = - boost::get(opts.auth); + std::get(opts.auth); return std::make_shared( OpenChannel(opts.host, opts.port, auth.identity, "", opts.vhost, opts.frame_max, true)); @@ -216,17 +216,17 @@ Channel::ptr_t Channel::Open(const OpenOpts &opts) { throw std::logic_error("Unhandled auth type"); } } - switch (opts.auth.which()) { - case 0: { + switch (opts.auth.index()) { + case 1: { const OpenOpts::BasicAuth &auth = - boost::get(opts.auth); + std::get(opts.auth); return std::make_shared(OpenSecureChannel( opts.host, opts.port, auth.username, auth.password, opts.vhost, opts.frame_max, opts.tls_params.get(), false)); } - case 1: { + case 2: { const OpenOpts::ExternalSaslAuth &auth = - boost::get(opts.auth); + std::get(opts.auth); return std::make_shared( OpenSecureChannel(opts.host, opts.port, auth.identity, "", opts.vhost, opts.frame_max, opts.tls_params.get(), true)); diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index ca347b39..df5d9033 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -29,12 +29,12 @@ */ #include -#include #include #include #include #include #include +#include #include "SimpleAmqpClient/BasicMessage.h" #include "SimpleAmqpClient/Envelope.h" @@ -106,7 +106,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { int port; ///< Port to connect to, default is 5672. int frame_max; ///< Max frame size in bytes. Default 128KB. /// One of BasicAuth or ExternalSaslAuth is required. - boost::variant auth; + std::variant auth; /// Connect using TLS/SSL when set, otherwise use an unencrypted channel. boost::optional tls_params; diff --git a/src/SimpleAmqpClient/TableImpl.h b/src/SimpleAmqpClient/TableImpl.h index 6d046de3..b114a6d1 100644 --- a/src/SimpleAmqpClient/TableImpl.h +++ b/src/SimpleAmqpClient/TableImpl.h @@ -30,11 +30,11 @@ #include -#include #include #include #include #include +#include #include #include "SimpleAmqpClient/Table.h" @@ -50,10 +50,9 @@ inline bool operator==(const void_t &, const void_t &) { return true; } typedef std::vector array_t; -typedef boost::variant +typedef std::variant value_t; class TableValueImpl { @@ -81,8 +80,7 @@ class TableValueImpl { amqp_pool_t &pool); public: - class generate_field_value - : public boost::static_visitor { + class generate_field_value { public: explicit generate_field_value(amqp_pool_t &p) : pool(p) {} virtual ~generate_field_value() {} diff --git a/src/Table.cpp b/src/Table.cpp index 049f10d7..a059dca4 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -29,13 +29,12 @@ #include "SimpleAmqpClient/Table.h" #include -#include -#include #include #include #include #include #include +#include #include "SimpleAmqpClient/TableImpl.h" @@ -135,45 +134,45 @@ bool TableValue::operator!=(const TableValue &l) const { TableValue::~TableValue() {} TableValue::ValueType TableValue::GetType() const { - return static_cast(m_impl->m_value.which()); + return static_cast(m_impl->m_value.index()); } -bool TableValue::GetBool() const { return boost::get(m_impl->m_value); } +bool TableValue::GetBool() const { return std::get(m_impl->m_value); } std::uint8_t TableValue::GetUint8() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::int8_t TableValue::GetInt8() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::uint16_t TableValue::GetUint16() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::int16_t TableValue::GetInt16() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::uint32_t TableValue::GetUint32() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::int32_t TableValue::GetInt32() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::time_t TableValue::GetTimestamp() const { - return static_cast(boost::get(m_impl->m_value)); + return static_cast(std::get(m_impl->m_value)); } std::int64_t TableValue::GetInt64() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::int64_t TableValue::GetInteger() const { - switch (m_impl->m_value.which()) { + switch (m_impl->m_value.index()) { case VT_uint8: return GetUint8(); case VT_int8: @@ -189,40 +188,36 @@ std::int64_t TableValue::GetInteger() const { case VT_int64: return GetInt64(); default: - throw boost::bad_get(); + throw std::bad_variant_access(); } } -float TableValue::GetFloat() const { - return boost::get(m_impl->m_value); -} +float TableValue::GetFloat() const { return std::get(m_impl->m_value); } double TableValue::GetDouble() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } double TableValue::GetReal() const { - switch (m_impl->m_value.which()) { + switch (m_impl->m_value.index()) { case VT_float: return GetFloat(); case VT_double: return GetDouble(); default: - throw boost::bad_get(); + throw std::bad_variant_access(); } } std::string TableValue::GetString() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } std::vector TableValue::GetArray() const { - return boost::get(m_impl->m_value); + return std::get(m_impl->m_value); } -Table TableValue::GetTable() const { - return boost::get(m_impl->m_value); -} +Table TableValue::GetTable() const { return std::get
(m_impl->m_value); } void TableValue::Set() { m_impl->m_value = Detail::void_t(); } diff --git a/src/TableImpl.cpp b/src/TableImpl.cpp index 5fbe8b89..ba81c9dd 100644 --- a/src/TableImpl.cpp +++ b/src/TableImpl.cpp @@ -36,10 +36,9 @@ #include #include -#include -#include #include #include +#include #ifdef _MSC_VER #pragma warning(disable : 4800) @@ -167,7 +166,7 @@ amqp_field_value_t TableValueImpl::generate_field_value::operator()( for (array_t::const_iterator it = value.begin(); it != value.end(); ++it, ++output_iterator) { *output_iterator = - boost::apply_visitor(generate_field_value(pool), it->m_impl->m_value); + std::visit(generate_field_value(pool), it->m_impl->m_value); } return v; } @@ -221,8 +220,8 @@ amqp_table_t TableValueImpl::CreateAmqpTableInner(const Table &table, std::copy(it->first.begin(), it->first.end(), (char *)output_it->key.bytes); - output_it->value = boost::apply_visitor( - TableValueImpl::generate_field_value(pool), it->second.m_impl->m_value); + output_it->value = std::visit(TableValueImpl::generate_field_value(pool), + it->second.m_impl->m_value); } return new_table; diff --git a/testing/test_table.cpp b/testing/test_table.cpp index 424ade68..c65690ec 100644 --- a/testing/test_table.cpp +++ b/testing/test_table.cpp @@ -27,10 +27,9 @@ */ #include -#include -#include #include #include +#include #include "connected_test.h" @@ -40,42 +39,42 @@ TEST(table_value, void_value) { TableValue value; EXPECT_EQ(TableValue::VT_void, value.GetType()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(); EXPECT_EQ(TableValue::VT_void, value.GetType()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, bool_value) { @@ -86,41 +85,41 @@ TEST(table_value, bool_value) { EXPECT_EQ(TableValue::VT_bool, value.GetType()); EXPECT_EQ(v1, value.GetBool()); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_bool, value.GetType()); EXPECT_EQ(v2, value.GetBool()); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, uint8_value) { @@ -132,40 +131,40 @@ TEST(table_value, uint8_value) { EXPECT_EQ(v1, value.GetUint8()); EXPECT_EQ(v1, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_uint8, value.GetType()); EXPECT_EQ(v2, value.GetUint8()); EXPECT_EQ(v2, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, int8_value) { @@ -177,40 +176,40 @@ TEST(table_value, int8_value) { EXPECT_EQ(v1, value.GetInt8()); EXPECT_EQ(v1, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_int8, value.GetType()); EXPECT_EQ(v2, value.GetInt8()); EXPECT_EQ(v2, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, uint16_value) { @@ -222,40 +221,40 @@ TEST(table_value, uint16_value) { EXPECT_EQ(v1, value.GetUint16()); EXPECT_EQ(v1, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_uint16, value.GetType()); EXPECT_EQ(v2, value.GetUint16()); EXPECT_EQ(v2, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, int16_value) { @@ -267,40 +266,40 @@ TEST(table_value, int16_value) { EXPECT_EQ(v1, value.GetInt16()); EXPECT_EQ(v1, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_int16, value.GetType()); EXPECT_EQ(v2, value.GetInt16()); EXPECT_EQ(v2, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, uint32_value) { @@ -312,40 +311,40 @@ TEST(table_value, uint32_value) { EXPECT_EQ(v1, value.GetUint32()); EXPECT_EQ(v1, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_uint32, value.GetType()); EXPECT_EQ(v2, value.GetUint32()); EXPECT_EQ(v2, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, int32_value) { @@ -357,40 +356,40 @@ TEST(table_value, int32_value) { EXPECT_EQ(v1, value.GetInt32()); EXPECT_EQ(v1, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_int32, value.GetType()); EXPECT_EQ(v2, value.GetInt32()); EXPECT_EQ(v2, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, timestamp_value) { @@ -401,41 +400,41 @@ TEST(table_value, timestamp_value) { EXPECT_EQ(TableValue::VT_timestamp, value.GetType()); EXPECT_EQ(v1, value.GetTimestamp()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.SetTimestamp(v2); EXPECT_EQ(TableValue::VT_timestamp, value.GetType()); EXPECT_EQ(v2, value.GetTimestamp()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, int64_value) { @@ -447,40 +446,40 @@ TEST(table_value, int64_value) { EXPECT_EQ(v1, value.GetInt64()); EXPECT_EQ(v1, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_int64, value.GetType()); EXPECT_EQ(v2, value.GetInt64()); EXPECT_EQ(v2, value.GetInteger()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, float_value) { @@ -492,40 +491,40 @@ TEST(table_value, float_value) { EXPECT_EQ(v1, value.GetFloat()); EXPECT_EQ(v1, value.GetReal()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_float, value.GetType()); EXPECT_EQ(v2, value.GetFloat()); EXPECT_EQ(v2, value.GetReal()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, double_value) { @@ -537,40 +536,40 @@ TEST(table_value, double_value) { EXPECT_EQ(v1, value.GetDouble()); EXPECT_EQ(v1, value.GetReal()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_double, value.GetType()); EXPECT_EQ(v2, value.GetDouble()); EXPECT_EQ(v2, value.GetReal()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, string_value) { @@ -581,41 +580,41 @@ TEST(table_value, string_value) { EXPECT_EQ(TableValue::VT_string, value.GetType()); EXPECT_EQ(v1, value.GetString()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_string, value.GetType()); EXPECT_EQ(v2, value.GetString()); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, array_value) { @@ -631,21 +630,21 @@ TEST(table_value, array_value) { EXPECT_TRUE(v1.size() == v1a.size()); EXPECT_TRUE(std::equal(v1.begin(), v1.end(), v1a.begin())); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_array, value.GetType()); @@ -653,21 +652,21 @@ TEST(table_value, array_value) { EXPECT_TRUE(v2.size() == v2a.size()); EXPECT_TRUE(std::equal(v2.begin(), v2.end(), v2a.begin())); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetTable(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetTable(), std::bad_variant_access); } TEST(table_value, table_value) { @@ -683,21 +682,21 @@ TEST(table_value, table_value) { EXPECT_TRUE(v1.size() == v1a.size()); EXPECT_TRUE(std::equal(v1.begin(), v1.end(), v1a.begin())); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); value.Set(v2); EXPECT_EQ(TableValue::VT_table, value.GetType()); @@ -705,21 +704,21 @@ TEST(table_value, table_value) { EXPECT_TRUE(v2.size() == v2a.size()); EXPECT_TRUE(std::equal(v2.begin(), v2.end(), v2a.begin())); - EXPECT_THROW(value.GetBool(), boost::bad_get); - EXPECT_THROW(value.GetUint8(), boost::bad_get); - EXPECT_THROW(value.GetInt8(), boost::bad_get); - EXPECT_THROW(value.GetUint16(), boost::bad_get); - EXPECT_THROW(value.GetInt16(), boost::bad_get); - EXPECT_THROW(value.GetUint32(), boost::bad_get); - EXPECT_THROW(value.GetInt32(), boost::bad_get); - EXPECT_THROW(value.GetTimestamp(), boost::bad_get); - EXPECT_THROW(value.GetInt64(), boost::bad_get); - EXPECT_THROW(value.GetInteger(), boost::bad_get); - EXPECT_THROW(value.GetFloat(), boost::bad_get); - EXPECT_THROW(value.GetDouble(), boost::bad_get); - EXPECT_THROW(value.GetReal(), boost::bad_get); - EXPECT_THROW(value.GetString(), boost::bad_get); - EXPECT_THROW(value.GetArray(), boost::bad_get); + EXPECT_THROW(value.GetBool(), std::bad_variant_access); + EXPECT_THROW(value.GetUint8(), std::bad_variant_access); + EXPECT_THROW(value.GetInt8(), std::bad_variant_access); + EXPECT_THROW(value.GetUint16(), std::bad_variant_access); + EXPECT_THROW(value.GetInt16(), std::bad_variant_access); + EXPECT_THROW(value.GetUint32(), std::bad_variant_access); + EXPECT_THROW(value.GetInt32(), std::bad_variant_access); + EXPECT_THROW(value.GetTimestamp(), std::bad_variant_access); + EXPECT_THROW(value.GetInt64(), std::bad_variant_access); + EXPECT_THROW(value.GetInteger(), std::bad_variant_access); + EXPECT_THROW(value.GetFloat(), std::bad_variant_access); + EXPECT_THROW(value.GetDouble(), std::bad_variant_access); + EXPECT_THROW(value.GetReal(), std::bad_variant_access); + EXPECT_THROW(value.GetString(), std::bad_variant_access); + EXPECT_THROW(value.GetArray(), std::bad_variant_access); } TEST(table_value, equality) { From 7e192fd07b3228ba447267917d492d94d4ca6ff9 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 23 Jul 2020 07:24:08 +0000 Subject: [PATCH 33/39] lib: switch boost::chrono to std::chrono Unboostify! --- CMakeLists.txt | 2 +- src/Channel.cpp | 1 - src/ChannelImpl.cpp | 28 ++++++------- src/SimpleAmqpClient/ChannelImpl.h | 65 ++++++++++++++---------------- 4 files changed, 46 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6468d107..7f4f9e34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ if(Boost_Dynamic_Linking_ENABLED) set(Boost_USE_STATIC_RUNTIME OFF) endif() -find_package(Boost 1.47.0 COMPONENTS chrono system REQUIRED) +find_package(Boost 1.47.0 REQUIRED) include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) diff --git a/src/Channel.cpp b/src/Channel.cpp index 54fe7cca..0cada225 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -37,7 +37,6 @@ #include #include -#include #include #include #include diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index 1b42ff47..7c046c35 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -51,8 +51,9 @@ #include #include -#include #include +#include +#include #define BROKER_HEARTBEAT 0 @@ -451,25 +452,24 @@ void Channel::ChannelImpl::AddToFrameQueue(const amqp_frame_t &frame) { } bool Channel::ChannelImpl::GetNextFrameFromBroker( - amqp_frame_t &frame, boost::chrono::microseconds timeout) { + amqp_frame_t &frame, std::chrono::microseconds timeout) { struct timeval *tvp = NULL; struct timeval tv_timeout; memset(&tv_timeout, 0, sizeof(tv_timeout)); - if (timeout != boost::chrono::microseconds::max()) { - // boost::chrono::seconds.count() returns std::int_atleast64_t, + if (timeout != std::chrono::microseconds::max()) { + // std::chrono::seconds.count() returns std::int_atleast64_t, // long can be 32 or 64 bit depending on the platform/arch // unless the timeout is something absurd cast to long will be ok, but // lets guard against the case where someone does something silly - assert( - boost::chrono::duration_cast(timeout).count() < - static_cast( - std::numeric_limits::max())); + assert(std::chrono::duration_cast(timeout).count() < + static_cast( + std::numeric_limits::max())); tv_timeout.tv_sec = static_cast( - boost::chrono::duration_cast(timeout).count()); + std::chrono::duration_cast(timeout).count()); tv_timeout.tv_usec = static_cast( - (timeout - boost::chrono::seconds(tv_timeout.tv_sec)).count()); + (timeout - std::chrono::seconds(tv_timeout.tv_sec)).count()); tvp = &tv_timeout; } @@ -485,10 +485,10 @@ bool Channel::ChannelImpl::GetNextFrameFromBroker( bool Channel::ChannelImpl::GetNextFrameOnChannel( amqp_channel_t channel, amqp_frame_t &frame, - boost::chrono::microseconds timeout) { - frame_queue_t::iterator it = std::find_if( - m_frame_queue.begin(), m_frame_queue.end(), - boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel)); + std::chrono::microseconds timeout) { + frame_queue_t::iterator it = + std::find_if(m_frame_queue.begin(), m_frame_queue.end(), + boost::bind(&ChannelImpl::is_on_channel, _1, channel)); if (m_frame_queue.end() != it) { frame = *it; diff --git a/src/SimpleAmqpClient/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index f6d41ae8..11b03de6 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -71,20 +71,19 @@ class Channel::ChannelImpl { bool IsChannelOpen(amqp_channel_t channel); bool GetNextFrameFromBroker(amqp_frame_t &frame, - boost::chrono::microseconds timeout); + std::chrono::microseconds timeout); bool CheckForQueuedMessageOnChannel(amqp_channel_t message_on_channel) const; void AddToFrameQueue(const amqp_frame_t &frame); template - bool GetNextFrameFromBrokerOnChannel(const ChannelListType channels, - amqp_frame_t &frame_out, - boost::chrono::microseconds timeout = - boost::chrono::microseconds::max()) { - boost::chrono::steady_clock::time_point end_point; - boost::chrono::microseconds timeout_left = timeout; - if (timeout != boost::chrono::microseconds::max()) { - end_point = boost::chrono::steady_clock::now() + timeout; + bool GetNextFrameFromBrokerOnChannel( + const ChannelListType channels, amqp_frame_t &frame_out, + std::chrono::microseconds timeout = std::chrono::microseconds::max()) { + std::chrono::steady_clock::time_point end_point; + std::chrono::microseconds timeout_left = timeout; + if (timeout != std::chrono::microseconds::max()) { + end_point = std::chrono::steady_clock::now() + timeout; } amqp_frame_t frame; @@ -108,15 +107,14 @@ class Channel::ChannelImpl { AddToFrameQueue(frame); } - if (timeout != boost::chrono::microseconds::max()) { - boost::chrono::steady_clock::time_point now = - boost::chrono::steady_clock::now(); + if (timeout != std::chrono::microseconds::max()) { + std::chrono::steady_clock::time_point now = + std::chrono::steady_clock::now(); if (now >= end_point) { return false; } - timeout_left = - boost::chrono::duration_cast( - end_point - now); + timeout_left = std::chrono::duration_cast( + end_point - now); } } return false; @@ -124,7 +122,7 @@ class Channel::ChannelImpl { bool GetNextFrameOnChannel( amqp_channel_t channel, amqp_frame_t &frame, - boost::chrono::microseconds timeout = boost::chrono::microseconds::max()); + std::chrono::microseconds timeout = std::chrono::microseconds::max()); static bool is_on_channel(const amqp_frame_t frame, amqp_channel_t channel) { return channel == frame.channel; @@ -156,10 +154,10 @@ class Channel::ChannelImpl { } template - bool GetMethodOnChannel(const ChannelListType channels, amqp_frame_t &frame, - const ResponseListType &expected_responses, - boost::chrono::microseconds timeout = - boost::chrono::microseconds::max()) { + bool GetMethodOnChannel( + const ChannelListType channels, amqp_frame_t &frame, + const ResponseListType &expected_responses, + std::chrono::microseconds timeout = std::chrono::microseconds::max()) { frame_queue_t::iterator desired_frame = std::find_if( m_frame_queue.begin(), m_frame_queue.end(), boost::bind( @@ -173,10 +171,10 @@ class Channel::ChannelImpl { return true; } - boost::chrono::steady_clock::time_point end_point; - boost::chrono::microseconds timeout_left = timeout; - if (timeout != boost::chrono::microseconds::max()) { - end_point = boost::chrono::steady_clock::now() + timeout; + std::chrono::steady_clock::time_point end_point; + std::chrono::microseconds timeout_left = timeout; + if (timeout != std::chrono::microseconds::max()) { + end_point = std::chrono::steady_clock::now() + timeout; } amqp_frame_t incoming_frame; @@ -200,15 +198,14 @@ class Channel::ChannelImpl { } m_frame_queue.push_back(incoming_frame); - if (timeout != boost::chrono::microseconds::max()) { - boost::chrono::steady_clock::time_point now = - boost::chrono::steady_clock::now(); + if (timeout != std::chrono::microseconds::max()) { + std::chrono::steady_clock::time_point now = + std::chrono::steady_clock::now(); if (now >= end_point) { return false; } - timeout_left = - boost::chrono::duration_cast( - end_point - now); + timeout_left = std::chrono::duration_cast( + end_point - now); } } return false; @@ -267,9 +264,9 @@ class Channel::ChannelImpl { const std::array DELIVER_OR_CANCEL = { AMQP_BASIC_DELIVER_METHOD, AMQP_BASIC_CANCEL_METHOD}; - boost::chrono::microseconds real_timeout = - (timeout >= 0 ? boost::chrono::milliseconds(timeout) - : boost::chrono::microseconds::max()); + std::chrono::microseconds real_timeout = + (timeout >= 0 ? std::chrono::milliseconds(timeout) + : std::chrono::microseconds::max()); amqp_frame_t deliver; if (!GetMethodOnChannel(channels, deliver, DELIVER_OR_CANCEL, From 2bc812a7bed92e087c279dd6cfecf3296ca7a726 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 23 Jul 2020 08:06:34 +0000 Subject: [PATCH 34/39] lib: replace boost::bind with lambdas Unboostify! --- src/ChannelImpl.cpp | 38 +++++++++++++++--------------- src/SimpleAmqpClient/ChannelImpl.h | 21 +++++++++-------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index 7c046c35..c70bad12 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -47,11 +47,8 @@ #include "SimpleAmqpClient/ConnectionClosedException.h" #include "SimpleAmqpClient/ConsumerTagNotFoundException.h" #include "SimpleAmqpClient/TableImpl.h" -#define BOOST_BIND_GLOBAL_PLACEHOLDERS #include - #include -#include #include #include @@ -396,18 +393,19 @@ std::vector Channel::ChannelImpl::GetAllConsumerChannels() bool Channel::ChannelImpl::CheckForQueuedMessageOnChannel( amqp_channel_t channel) const { - frame_queue_t::const_iterator it = - std::find_if(m_frame_queue.begin(), m_frame_queue.end(), - boost::bind(&Channel::ChannelImpl::is_method_on_channel, _1, - AMQP_BASIC_DELIVER_METHOD, channel)); + frame_queue_t::const_iterator it = std::find_if( + m_frame_queue.begin(), m_frame_queue.end(), [channel](auto &frame) { + return ChannelImpl::is_method_on_channel( + frame, AMQP_BASIC_DELIVER_METHOD, channel); + }); if (it == m_frame_queue.end()) { return false; } - it = std::find_if( - it + 1, m_frame_queue.end(), - boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel)); + it = std::find_if(it + 1, m_frame_queue.end(), [channel](auto &frame) { + return Channel::ChannelImpl::is_on_channel(frame, channel); + }); if (it == m_frame_queue.end()) { return false; @@ -420,9 +418,9 @@ bool Channel::ChannelImpl::CheckForQueuedMessageOnChannel( uint64_t body_received = 0; while (body_received < body_length) { - it = std::find_if( - it + 1, m_frame_queue.end(), - boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel)); + it = std::find_if(it + 1, m_frame_queue.end(), [channel](auto &frame) { + return Channel::ChannelImpl::is_on_channel(frame, channel); + }); if (it == m_frame_queue.end()) { return false; @@ -486,9 +484,10 @@ bool Channel::ChannelImpl::GetNextFrameFromBroker( bool Channel::ChannelImpl::GetNextFrameOnChannel( amqp_channel_t channel, amqp_frame_t &frame, std::chrono::microseconds timeout) { - frame_queue_t::iterator it = - std::find_if(m_frame_queue.begin(), m_frame_queue.end(), - boost::bind(&ChannelImpl::is_on_channel, _1, channel)); + frame_queue_t::iterator it = std::find_if( + m_frame_queue.begin(), m_frame_queue.end(), [channel](auto &frame) { + return ChannelImpl::is_on_channel(frame, channel); + }); if (m_frame_queue.end() != it) { frame = *it; @@ -510,9 +509,10 @@ bool Channel::ChannelImpl::GetNextFrameOnChannel( void Channel::ChannelImpl::MaybeReleaseBuffersOnChannel( amqp_channel_t channel) { if (m_frame_queue.end() == - std::find_if( - m_frame_queue.begin(), m_frame_queue.end(), - boost::bind(&Channel::ChannelImpl::is_on_channel, _1, channel))) { + std::find_if(m_frame_queue.begin(), m_frame_queue.end(), + [channel](auto &frame) { + return Channel::ChannelImpl::is_on_channel(frame, channel); + })) { amqp_maybe_release_buffers_on_channel(m_connection, channel); } } diff --git a/src/SimpleAmqpClient/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index 11b03de6..712aa3b6 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -38,10 +38,8 @@ #include "SimpleAmqpClient/ConsumerCancelledException.h" #include "SimpleAmqpClient/Envelope.h" #include "SimpleAmqpClient/MessageReturnedException.h" -#define BOOST_BIND_GLOBAL_PLACEHOLDERS #include #include -#include #include #include #include @@ -160,10 +158,11 @@ class Channel::ChannelImpl { std::chrono::microseconds timeout = std::chrono::microseconds::max()) { frame_queue_t::iterator desired_frame = std::find_if( m_frame_queue.begin(), m_frame_queue.end(), - boost::bind( - &ChannelImpl::is_expected_method_on_channel, - _1, channels, expected_responses)); + [channels, expected_responses](auto &frame) { + return ChannelImpl::is_expected_method_on_channel( + frame, channels, expected_responses); + }); if (m_frame_queue.end() != desired_frame) { frame = *desired_frame; @@ -244,10 +243,12 @@ class Channel::ChannelImpl { template bool ConsumeMessageOnChannel(const ChannelListType channels, Envelope::ptr_t &message, int timeout) { - envelope_list_t::iterator it = std::find_if( - m_delivered_messages.begin(), m_delivered_messages.end(), - boost::bind(ChannelImpl::envelope_on_channel, _1, - channels)); + envelope_list_t::iterator it = + std::find_if(m_delivered_messages.begin(), m_delivered_messages.end(), + [channels](auto &message) { + return ChannelImpl::envelope_on_channel( + message, channels); + }); if (it != m_delivered_messages.end()) { message = *it; From d37979e71f1bbbc62fa25511a11b2672d3ad3ed0 Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 23 Jul 2020 08:17:25 +0000 Subject: [PATCH 35/39] lib: remove use of boost::split Unboostify. Sadly no really good std library replacement here. --- src/ChannelImpl.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index c70bad12..c87065fa 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -37,8 +37,12 @@ #include #endif -#include -#include +#include + +#include +#include +#include +#include #include "SimpleAmqpClient/AmqpException.h" #include "SimpleAmqpClient/AmqpLibraryException.h" @@ -46,11 +50,6 @@ #include "SimpleAmqpClient/ChannelImpl.h" #include "SimpleAmqpClient/ConnectionClosedException.h" #include "SimpleAmqpClient/ConsumerTagNotFoundException.h" -#include "SimpleAmqpClient/TableImpl.h" -#include -#include -#include -#include #define BROKER_HEARTBEAT 0 @@ -532,6 +531,21 @@ bool bytesEqual(amqp_bytes_t r, amqp_bytes_t l) { } return false; } + +std::vector splitVersion(const std::string &version) { + static char delim = '.'; + std::vector out; + std::size_t prev = 0; + std::size_t cur = version.find(delim); + while (cur != std::string::npos) { + out.push_back(version.substr(prev, cur - prev)); + prev = cur + 1; + cur = version.find(delim, prev); + } + out.push_back(version.substr(prev, cur - prev)); + return out; +} + } // namespace std::uint32_t Channel::ChannelImpl::ComputeBrokerVersion( @@ -553,8 +567,7 @@ std::uint32_t Channel::ChannelImpl::ComputeBrokerVersion( std::string version_string( static_cast(version_entry->value.value.bytes.bytes), version_entry->value.value.bytes.len); - std::vector version_components; - boost::split(version_components, version_string, boost::is_any_of(".")); + std::vector version_components = splitVersion(version_string); if (version_components.size() != 3) { return 0; } From ebbb60387454c78e5ffe8f394dba2cc19fc7dcdf Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Sat, 25 Jul 2020 06:38:47 +0000 Subject: [PATCH 36/39] lib: replace boost::optional with std::optional Un-boostify! --- src/BasicMessage.cpp | 58 +++++++++++++++++----------------- src/Channel.cpp | 10 +++--- src/ChannelImpl.cpp | 1 + src/SimpleAmqpClient/Channel.h | 4 +-- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/BasicMessage.cpp b/src/BasicMessage.cpp index 2ea3088f..9351987a 100644 --- a/src/BasicMessage.cpp +++ b/src/BasicMessage.cpp @@ -32,9 +32,9 @@ #include #include -#include #include #include +#include #include #include "SimpleAmqpClient/TableImpl.h" @@ -43,20 +43,20 @@ namespace AmqpClient { struct BasicMessage::Impl { std::string body; - boost::optional content_type; - boost::optional content_encoding; - boost::optional delivery_mode; - boost::optional priority; - boost::optional correlation_id; - boost::optional reply_to; - boost::optional expiration; - boost::optional message_id; - boost::optional timestamp; - boost::optional type; - boost::optional user_id; - boost::optional app_id; - boost::optional cluster_id; - boost::optional
header_table; + std::optional content_type; + std::optional content_encoding; + std::optional delivery_mode; + std::optional priority; + std::optional correlation_id; + std::optional reply_to; + std::optional expiration; + std::optional message_id; + std::optional timestamp; + std::optional type; + std::optional user_id; + std::optional app_id; + std::optional cluster_id; + std::optional
header_table; }; BasicMessage::BasicMessage() : m_impl(new Impl) {} @@ -86,7 +86,7 @@ void BasicMessage::ContentType(const std::string& content_type) { } bool BasicMessage::ContentTypeIsSet() const { - return m_impl->content_type.is_initialized(); + return m_impl->content_type.has_value(); } void BasicMessage::ContentTypeClear() { m_impl->content_type.reset(); } @@ -104,7 +104,7 @@ void BasicMessage::ContentEncoding(const std::string& content_encoding) { } bool BasicMessage::ContentEncodingIsSet() const { - return m_impl->content_encoding.is_initialized(); + return m_impl->content_encoding.has_value(); } void BasicMessage::ContentEncodingClear() { m_impl->content_encoding.reset(); } @@ -118,7 +118,7 @@ void BasicMessage::DeliveryMode(delivery_mode_t delivery_mode) { } bool BasicMessage::DeliveryModeIsSet() const { - return m_impl->delivery_mode.is_initialized(); + return m_impl->delivery_mode.has_value(); } void BasicMessage::DeliveryModeClear() { m_impl->delivery_mode.reset(); } @@ -132,7 +132,7 @@ void BasicMessage::Priority(std::uint8_t priority) { } bool BasicMessage::PriorityIsSet() const { - return m_impl->priority.is_initialized(); + return m_impl->priority.has_value(); } void BasicMessage::PriorityClear() { m_impl->priority.reset(); } @@ -150,7 +150,7 @@ void BasicMessage::CorrelationId(const std::string& correlation_id) { } bool BasicMessage::CorrelationIdIsSet() const { - return m_impl->correlation_id.is_initialized(); + return m_impl->correlation_id.has_value(); } void BasicMessage::CorrelationIdClear() { m_impl->correlation_id.reset(); } @@ -168,7 +168,7 @@ void BasicMessage::ReplyTo(const std::string& reply_to) { } bool BasicMessage::ReplyToIsSet() const { - return m_impl->reply_to.is_initialized(); + return m_impl->reply_to.has_value(); } void BasicMessage::ReplyToClear() { m_impl->reply_to.reset(); } @@ -186,7 +186,7 @@ void BasicMessage::Expiration(const std::string& expiration) { } bool BasicMessage::ExpirationIsSet() const { - return m_impl->expiration.is_initialized(); + return m_impl->expiration.has_value(); } void BasicMessage::ExpirationClear() { m_impl->expiration.reset(); } @@ -204,7 +204,7 @@ void BasicMessage::MessageId(const std::string& message_id) { } bool BasicMessage::MessageIdIsSet() const { - return m_impl->message_id.is_initialized(); + return m_impl->message_id.has_value(); } void BasicMessage::MessageIdClear() { m_impl->message_id.reset(); } @@ -218,7 +218,7 @@ void BasicMessage::Timestamp(std::uint64_t timestamp) { } bool BasicMessage::TimestampIsSet() const { - return m_impl->timestamp.is_initialized(); + return m_impl->timestamp.has_value(); } void BasicMessage::TimestampClear() { m_impl->timestamp.reset(); } @@ -233,7 +233,7 @@ const std::string& BasicMessage::Type() const { void BasicMessage::Type(const std::string& type) { m_impl->type = type; } -bool BasicMessage::TypeIsSet() const { return m_impl->type.is_initialized(); } +bool BasicMessage::TypeIsSet() const { return m_impl->type.has_value(); } void BasicMessage::TypeClear() { m_impl->type.reset(); } @@ -250,7 +250,7 @@ void BasicMessage::UserId(const std::string& user_id) { } bool BasicMessage::UserIdIsSet() const { - return m_impl->user_id.is_initialized(); + return m_impl->user_id.has_value(); } void BasicMessage::UserIdClear() { m_impl->user_id.reset(); } @@ -266,7 +266,7 @@ const std::string& BasicMessage::AppId() const { void BasicMessage::AppId(const std::string& app_id) { m_impl->app_id = app_id; } bool BasicMessage::AppIdIsSet() const { - return m_impl->app_id.is_initialized(); + return m_impl->app_id.has_value(); } void BasicMessage::AppIdClear() { m_impl->app_id.reset(); } @@ -284,7 +284,7 @@ void BasicMessage::ClusterId(const std::string& cluster_id) { } bool BasicMessage::ClusterIdIsSet() const { - return m_impl->cluster_id.is_initialized(); + return m_impl->cluster_id.has_value(); } void BasicMessage::ClusterIdClear() { m_impl->cluster_id.reset(); } @@ -309,7 +309,7 @@ void BasicMessage::HeaderTable(const Table& header_table) { } bool BasicMessage::HeaderTableIsSet() const { - return m_impl->header_table.is_initialized(); + return m_impl->header_table.has_value(); } void BasicMessage::HeaderTableClear() { m_impl->header_table.reset(); } diff --git a/src/Channel.cpp b/src/Channel.cpp index 0cada225..ca322cc5 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -195,7 +195,7 @@ Channel::ptr_t Channel::Open(const OpenOpts &opts) { if (opts.auth.index()==0) { throw std::runtime_error("opts.auth is not specified, it is required"); } - if (!opts.tls_params.is_initialized()) { + if (!opts.tls_params.has_value()) { switch (opts.auth.index()) { case 1: { const OpenOpts::BasicAuth &auth = @@ -221,14 +221,14 @@ Channel::ptr_t Channel::Open(const OpenOpts &opts) { std::get(opts.auth); return std::make_shared(OpenSecureChannel( opts.host, opts.port, auth.username, auth.password, opts.vhost, - opts.frame_max, opts.tls_params.get(), false)); + opts.frame_max, opts.tls_params.value(), false)); } case 2: { const OpenOpts::ExternalSaslAuth &auth = std::get(opts.auth); return std::make_shared( OpenSecureChannel(opts.host, opts.port, auth.identity, "", opts.vhost, - opts.frame_max, opts.tls_params.get(), true)); + opts.frame_max, opts.tls_params.value(), true)); } default: throw std::logic_error("Unhandled auth type"); @@ -339,7 +339,7 @@ Channel::ptr_t Channel::CreateSecureSaslExternal( Channel::ptr_t Channel::CreateFromUri(const std::string &uri, int frame_max) { OpenOpts opts = OpenOpts::FromUri(uri); - if (opts.tls_params.is_initialized()) { + if (opts.tls_params.has_value()) { throw std::runtime_error( "CreateFromUri only supports non-SSL-enabled URIs"); } @@ -353,7 +353,7 @@ Channel::ptr_t Channel::CreateSecureFromUri( const std::string &path_to_client_cert, bool verify_hostname_and_peer, int frame_max) { OpenOpts opts = OpenOpts::FromUri(uri); - if (!opts.tls_params.is_initialized()) { + if (!opts.tls_params.has_value()) { throw std::runtime_error( "CreateSecureFromUri only supports SSL-enabled URIs"); } diff --git a/src/ChannelImpl.cpp b/src/ChannelImpl.cpp index c87065fa..21ef48e3 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -50,6 +50,7 @@ #include "SimpleAmqpClient/ChannelImpl.h" #include "SimpleAmqpClient/ConnectionClosedException.h" #include "SimpleAmqpClient/ConsumerTagNotFoundException.h" +#include "SimpleAmqpClient/TableImpl.h" #define BROKER_HEARTBEAT 0 diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index df5d9033..b8bfc6bd 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -28,13 +28,13 @@ * ***** END LICENSE BLOCK ***** */ -#include #include #include #include #include #include #include +#include #include "SimpleAmqpClient/BasicMessage.h" #include "SimpleAmqpClient/Envelope.h" @@ -108,7 +108,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { /// One of BasicAuth or ExternalSaslAuth is required. std::variant auth; /// Connect using TLS/SSL when set, otherwise use an unencrypted channel. - boost::optional tls_params; + std::optional tls_params; /** * Create an OpenOpts struct from a URI. From 5ab9e6f9a45906f5b5d71d048ca5f05717bbd86a Mon Sep 17 00:00:00 2001 From: Alan Antonuk Date: Thu, 23 Jul 2020 08:20:15 +0000 Subject: [PATCH 37/39] lib: remove boost library from build boost library is no longer needed as a dependency. Unboostify! --- CMakeLists.txt | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f4f9e34..e53da754 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,17 +41,6 @@ string(REGEX MATCH "[0-9]+" _API_VERSION_PATCH ${_API_VERSION_PATCH}) set(SAC_APIVERSION ${_API_VERSION_MAJOR}.${_API_VERSION_MINOR}.${_API_VERSION_PATCH}) -option(Boost_Dynamic_Linking_ENABLED "Enable boost dynamic linking" OFF) - -if(Boost_Dynamic_Linking_ENABLED) - set(Boost_USE_STATIC_LIBS OFF) - set(Boost_USE_STATIC_RUNTIME OFF) -endif() - -find_package(Boost 1.47.0 REQUIRED) -include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) find_package(Rabbitmqc REQUIRED) INCLUDE_DIRECTORIES(SYSTEM ${Rabbitmqc_INCLUDE_DIRS}) @@ -126,7 +115,7 @@ set(SAC_LIB_SRCS add_library(SimpleAmqpClient ${SAC_LIB_SRCS}) -target_link_libraries(SimpleAmqpClient ${Rabbitmqc_LIBRARY} ${SOCKET_LIBRARY} ${Boost_LIBRARIES} $<$:Boost::dynamic_linking>) +target_link_libraries(SimpleAmqpClient ${Rabbitmqc_LIBRARY} ${SOCKET_LIBRARY}) if (WIN32) set_target_properties(SimpleAmqpClient PROPERTIES VERSION ${SAC_VERSION} OUTPUT_NAME SimpleAmqpClient.${SAC_SOVERSION}) @@ -216,19 +205,6 @@ set(exec_prefix "\${prefix}") set(libdir ${CMAKE_INSTALL_LIBDIR}) set(includedir "\${prefix}/include") -foreach(_lib ${Boost_LIBRARIES}) - get_filename_component(_LIBPATH ${_lib} PATH) - if (NOT _LIBPATH STREQUAL _LASTLIBPATH) - set(libs_private "${libs_private} -L${_LIBPATH}") - set(_LASTLIBPATH ${_LIBPATH}) - endif() - - get_filename_component(_LIBNAME ${_lib} NAME_WE) - string(REGEX REPLACE "^lib" "" _LIBNAME ${_LIBNAME}) - set(_LIBNAME "-l${_LIBNAME}") - set(libs_private "${libs_private} ${_LIBNAME}") -endforeach() - configure_file(libSimpleAmqpClient.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libSimpleAmqpClient.pc @ONLY) install(FILES From 319e32ff8924e293722cb4b0572096a6338ee9c1 Mon Sep 17 00:00:00 2001 From: Prateek Chokse Date: Wed, 13 Jul 2022 12:47:19 +0530 Subject: [PATCH 38/39] lib: replace boost::stringref with std::string_view Un-boostify! --- src/Channel.cpp | 4 ++-- src/SimpleAmqpClient/Bytes.h | 4 ++-- src/SimpleAmqpClient/Channel.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Channel.cpp b/src/Channel.cpp index ca322cc5..7fb0fe5f 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -476,7 +476,7 @@ int Channel::GetSocketFD() const { return amqp_get_sockfd(m_impl->m_connection); } -bool Channel::CheckExchangeExists(boost::string_ref exchange_name) { +bool Channel::CheckExchangeExists(std::string_view exchange_name) { const std::array DECLARE_OK = { AMQP_EXCHANGE_DECLARE_OK_METHOD}; @@ -599,7 +599,7 @@ void Channel::UnbindExchange(const std::string &destination, m_impl->MaybeReleaseBuffersOnChannel(frame.channel); } -bool Channel::CheckQueueExists(boost::string_ref queue_name) { +bool Channel::CheckQueueExists(std::string_view queue_name) { const std::array DECLARE_OK = { AMQP_QUEUE_DECLARE_OK_METHOD}; diff --git a/src/SimpleAmqpClient/Bytes.h b/src/SimpleAmqpClient/Bytes.h index 8f351773..a9fc09cc 100644 --- a/src/SimpleAmqpClient/Bytes.h +++ b/src/SimpleAmqpClient/Bytes.h @@ -2,9 +2,9 @@ #define SIMPLEAMQPCLIENT_BYTES_H #include -#include #include +#include namespace AmqpClient { @@ -15,7 +15,7 @@ amqp_bytes_t StringToBytes(const std::string& str) { return ret; } -amqp_bytes_t StringRefToBytes(boost::string_ref str) { +amqp_bytes_t StringRefToBytes(std::string_view str) { amqp_bytes_t ret; ret.bytes = reinterpret_cast(const_cast(str.data())); ret.len = str.length(); diff --git a/src/SimpleAmqpClient/Channel.h b/src/SimpleAmqpClient/Channel.h index b8bfc6bd..bf43339d 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -28,10 +28,10 @@ * ***** END LICENSE BLOCK ***** */ -#include #include #include #include +#include #include #include #include @@ -352,7 +352,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { * @param exchange_name the name of the exchange to check for. * @returns true if the exchange exists on the broker, false otherwise. */ - bool CheckExchangeExists(boost::string_ref exchange_name); + bool CheckExchangeExists(std::string_view exchange_name); /** * Declares an exchange @@ -455,7 +455,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel { * @param queue_name the name of the exchange to check for. * @returns true if the exchange exists on the broker, false otherwise. */ - bool CheckQueueExists(boost::string_ref queue_name); + bool CheckQueueExists(std::string_view queue_name); /** * Declare a queue From d46e49a37ad14e579262465ec1671bd403b68cd2 Mon Sep 17 00:00:00 2001 From: Prateek Chokse Date: Wed, 13 Jul 2022 13:32:25 +0530 Subject: [PATCH 39/39] 1. updated README, ci and devcontainer with with removed boost lib --- .devcontainer/Dockerfile | 2 +- .travis.yml | 3 --- README.md | 11 ++--------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 989db84a..840c2296 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -8,4 +8,4 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends lsb-release wget software-properties-common \ && bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" \ && apt-get -y install --no-install-recommends clang-format-11 clang-tidy-11 ninja-build rabbitmq-server \ - libssl-dev librabbitmq-dev libboost-dev libboost-chrono-dev libboost-system-dev + libssl-dev librabbitmq-dev diff --git a/.travis.yml b/.travis.yml index 750b33f3..784e083f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,6 @@ addons: - gcc-7 - g++-7 - clang-8 - - libboost-dev - - libboost-chrono-dev - - libboost-system-dev - rabbitmq-server - ninja-build diff --git a/README.md b/README.md index 665b706e..d4f940bd 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ Known to work in the following environments: - Mac OS X (10.7, 10.6, gcc-4.2, 32 and 64-bit). Likely to work on older version, but has not been tested ### Pre-requisites -+ [boost-1.47.0](http://www.boost.org/) or newer (uses chrono, system internally in addition to other header based libraries such as sharedptr and noncopyable) + [rabbitmq-c](http://github.com/alanxz/rabbitmq-c) you'll need version 0.8.0 or better. + [cmake 3.5+](http://www.cmake.org/) what is needed for the build system + [Doxygen](http://www.stack.nl/~dimitri/doxygen/) OPTIONAL only necessary to generate API documentation @@ -44,18 +43,12 @@ Notes: ### Build procedure for Windows -Boost libraries are needed, so you can install them using nuget: -``` -nuget install boost_chrono-vc142 -Version 1.77.0 -nuget install boost_system-vc142 -Version 1.77.0 -nuget install boost -Version 1.77.0 -``` To build and install succesfully, [rabbitmq-c](https://github.com/alanxz/rabbitmq-c) should be built **as shared library**. -Let *boost_chrono* and *boost_system* be in same directory ```C:\boost```, [rabbitmq-c](https://github.com/alanxz/rabbitmq-c) be on ```C:\rabbitmq-c```, +Let [rabbitmq-c](https://github.com/alanxz/rabbitmq-c) be on ```C:\rabbitmq-c```, SSL be OFF, and VS2019 is used, than CMake CLI is: ``` -cd cmake -G "Visual Studio 16" -A x64 -DBoost_INCLUDE_DIR="C:/boost.XX.XX.X.X/lib/native/include" -DBOOST_ROOT="C:/boost.X.XX.X.X" -DBOOST_LIBRARYDIR="C:/boost" -DRabbitmqc_INCLUDE_DIR="C:/rabbitmq-c/include" -DRabbitmqc_LIBRARY="C:/rabbitmq-c/lib/rabbitmq.4.lib" -DBoost_USE_STATIC_LIBS=ON -DBUILD_STATIC_LIBS=ON -DENABLE_SSL_SUPPORT=OFF .. +cd cmake -G "Visual Studio 16" -A x64 -DRabbitmqc_INCLUDE_DIR="C:/rabbitmq-c/include" -DRabbitmqc_LIBRARY="C:/rabbitmq-c/lib/rabbitmq.4.lib" -DBUILD_STATIC_LIBS=ON -DENABLE_SSL_SUPPORT=OFF .. ``` Using the library