diff --git a/.gitignore b/.gitignore index 4a62ba7..3235c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ *.la *.a *.a.* +/build +/.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c73267..34f19e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,9 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) project(amqpcpp) # ensure c++11 on all compilers -include(set_cxx_norm.cmake) -set_cxx_norm (${CXX_NORM_CXX11}) +set (CMAKE_CXX_STANDARD 11) macro (add_sources) file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") @@ -22,7 +21,9 @@ macro (add_sources) endmacro() add_subdirectory(src) -add_subdirectory(include) +if(AMQPCPP_BUILD_TCP) + add_subdirectory(src/tcpconnection) +endif() option(BUILD_SHARED "build shared library" OFF) diff --git a/amqpcpp.h b/amqpcpp.h index a1ac8d5..960f5f2 100644 --- a/amqpcpp.h +++ b/amqpcpp.h @@ -72,6 +72,3 @@ #include #include #include -#include -#include -#include diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt deleted file mode 100644 index 140f8f2..0000000 --- a/include/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -add_sources( -address.h -addresses.h -array.h -booleanset.h -buffer.h -bytebuffer.h -callbacks.h -channel.h -channelimpl.h -classes.h -connection.h -connectionhandler.h -connectionimpl.h -copiedbuffer.h -decimalfield.h -deferred.h -deferredcancel.h -deferredconsumer.h -deferredconsumerbase.h -deferreddelete.h -deferredget.h -deferredqueue.h -endian.h -entityimpl.h -envelope.h -exception.h -exchangetype.h -field.h -fieldproxy.h -flags.h -frame.h -libboostasio.h -libev.h -libevent.h -libuv.h -login.h -message.h -metadata.h -monitor.h -numericfield.h -outbuffer.h -protocolexception.h -receivedframe.h -stack_ptr.h -stringfield.h -table.h -tcpchannel.h -tcpconnection.h -tcpdefines.h -tcphandler.h -watchable.h - -) diff --git a/include/message.h b/include/message.h index 5ce4e68..21a5767 100644 --- a/include/message.h +++ b/include/message.h @@ -21,6 +21,7 @@ #include "envelope.h" #include #include +#include /** * Set up namespace diff --git a/include/metadata.h b/include/metadata.h index 4b1a04e..8b18d99 100644 --- a/include/metadata.h +++ b/include/metadata.h @@ -302,20 +302,20 @@ public: // the result (2 for the two boolean sets) uint32_t result = 2; - if (hasExpiration()) result += _expiration.size(); - if (hasReplyTo()) result += _replyTo.size(); - if (hasCorrelationID()) result += _correlationID.size(); - if (hasPriority()) result += _priority.size(); - if (hasDeliveryMode()) result += _deliveryMode.size(); - if (hasHeaders()) result += _headers.size(); - if (hasContentEncoding()) result += _contentEncoding.size(); - if (hasContentType()) result += _contentType.size(); - if (hasClusterID()) result += _clusterID.size(); - if (hasAppID()) result += _appID.size(); - if (hasUserID()) result += _userID.size(); - if (hasTypeName()) result += _typeName.size(); - if (hasTimestamp()) result += _timestamp.size(); - if (hasMessageID()) result += _messageID.size(); + if (hasExpiration()) result += (uint32_t)_expiration.size(); + if (hasReplyTo()) result += (uint32_t)_replyTo.size(); + if (hasCorrelationID()) result += (uint32_t)_correlationID.size(); + if (hasPriority()) result += (uint32_t)_priority.size(); + if (hasDeliveryMode()) result += (uint32_t)_deliveryMode.size(); + if (hasHeaders()) result += (uint32_t)_headers.size(); + if (hasContentEncoding()) result += (uint32_t)_contentEncoding.size(); + if (hasContentType()) result += (uint32_t)_contentType.size(); + if (hasClusterID()) result += (uint32_t)_clusterID.size(); + if (hasAppID()) result += (uint32_t)_appID.size(); + if (hasUserID()) result += (uint32_t)_userID.size(); + if (hasTypeName()) result += (uint32_t)_typeName.size(); + if (hasTimestamp()) result += (uint32_t)_timestamp.size(); + if (hasMessageID()) result += (uint32_t)_messageID.size(); // done return result; diff --git a/include/numericfield.h b/include/numericfield.h index 29f2f42..5c1e8a1 100644 --- a/include/numericfield.h +++ b/include/numericfield.h @@ -42,6 +42,8 @@ private: T _value; public: + using Type = T; + /** * Default constructor, assign 0 */ @@ -116,14 +118,14 @@ public: * Get the value * @return mixed */ - operator uint8_t () const override { return _value; } - operator uint16_t() const override { return _value; } - operator uint32_t() const override { return _value; } - operator uint64_t() const override { return _value; } - operator int8_t () const override { return _value; } - operator int16_t () const override { return _value; } - operator int32_t () const override { return _value; } - operator int64_t () const override { return _value; } + operator uint8_t () const override { return (uint8_t)_value; } + operator uint16_t() const override { return (uint16_t)_value; } + operator uint32_t() const override { return (uint32_t)_value; } + operator uint64_t() const override { return (uint64_t)_value; } + operator int8_t () const override { return (int8_t)_value; } + operator int16_t () const override { return (int16_t)_value; } + operator int32_t () const override { return (int32_t)_value; } + operator int64_t () const override { return (int64_t)_value; } /** * Get the value diff --git a/include/stringfield.h b/include/stringfield.h index bab6310..b4836f4 100644 --- a/include/stringfield.h +++ b/include/stringfield.h @@ -119,7 +119,7 @@ public: virtual size_t size() const override { // find out size of the size parameter - T size(_data.size()); + T size((T::Type)_data.size()); // size of the uint8 or uint32 + the actual string size return size.size() + _data.size(); @@ -160,7 +160,7 @@ public: virtual void fill(OutBuffer& buffer) const override { // create size - T size(_data.size()); + T size((T::Type)_data.size()); // first, write down the size of the string size.fill(buffer); diff --git a/include/tcpchannel.h b/include/tcpconnection/tcpchannel.h similarity index 100% rename from include/tcpchannel.h rename to include/tcpconnection/tcpchannel.h diff --git a/include/tcpconnection.h b/include/tcpconnection/tcpconnection.h similarity index 100% rename from include/tcpconnection.h rename to include/tcpconnection/tcpconnection.h diff --git a/include/tcpdefines.h b/include/tcpconnection/tcpdefines.h similarity index 100% rename from include/tcpdefines.h rename to include/tcpconnection/tcpdefines.h diff --git a/include/tcphandler.h b/include/tcpconnection/tcphandler.h similarity index 100% rename from include/tcphandler.h rename to include/tcpconnection/tcphandler.h diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index a438335..0000000 --- a/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.d diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eae0c22..d61b3e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,100 +1,14 @@ add_sources( -addressinfo.h -array.cpp -basicackframe.h -basiccancelframe.h -basiccancelokframe.h -basicconsumeframe.h -basicconsumeokframe.h -basicdeliverframe.h -basicframe.h -basicgetemptyframe.h -basicgetframe.h -basicgetokframe.h -basicheaderframe.h -basicnackframe.h -basicpublishframe.h -basicqosframe.h -basicqosokframe.h -basicrecoverasyncframe.h -basicrecoverframe.h -basicrecoverokframe.h -basicrejectframe.h -basicreturnframe.h -bodyframe.h -channelcloseframe.h -channelcloseokframe.h -channelflowframe.h -channelflowokframe.h -channelframe.h -channelimpl.cpp -channelopenframe.h -channelopenokframe.h -connectioncloseframe.h -connectioncloseokframe.h -connectionframe.h -connectionimpl.cpp -connectionopenframe.h -connectionopenokframe.h -connectionsecureframe.h -connectionsecureokframe.h -connectionstartframe.h -connectionstartokframe.h -connectiontuneframe.h -connectiontuneokframe.h -consumedmessage.h -deferredcancel.cpp -deferredconsumer.cpp -deferredconsumerbase.cpp -deferredget.cpp -exchangebindframe.h -exchangebindokframe.h -exchangedeclareframe.h -exchangedeclareokframe.h -exchangedeleteframe.h -exchangedeleteokframe.h -exchangeframe.h -exchangeunbindframe.h -exchangeunbindokframe.h -extframe.h -field.cpp -flags.cpp -framecheck.h -headerframe.h -heartbeatframe.h -includes.h -methodframe.h -passthroughbuffer.h -pipe.h -protocolheaderframe.h -queuebindframe.h -queuebindokframe.h -queuedeclareframe.h -queuedeclareokframe.h -queuedeleteframe.h -queuedeleteokframe.h -queueframe.h -queuepurgeframe.h -queuepurgeokframe.h -queueunbindframe.h -queueunbindokframe.h -receivedframe.cpp -reducedbuffer.h -returnedmessage.h -table.cpp -tcpclosed.h -tcpconnected.h -tcpconnection.cpp -tcpinbuffer.h -tcpoutbuffer.h -tcpresolver.h -tcpstate.h -transactioncommitframe.h -transactioncommitokframe.h -transactionframe.h -transactionrollbackframe.h -transactionrollbackokframe.h -transactionselectframe.h -transactionselectokframe.h -watchable.cpp + array.cpp + channelimpl.cpp + connectionimpl.cpp + deferredcancel.cpp + deferredconsumer.cpp + deferredconsumerbase.cpp + deferredget.cpp + field.cpp + flags.cpp + receivedframe.cpp + table.cpp + watchable.cpp ) diff --git a/src/array.cpp b/src/array.cpp index d04c865..9017faf 100644 --- a/src/array.cpp +++ b/src/array.cpp @@ -29,7 +29,7 @@ Array::Array(ReceivedFrame &frame) if (!field) continue; // less bytes to read - charsToRead -= field->size(); + charsToRead -= (uint32_t)field->size(); // add the additional field _fields.push_back(std::shared_ptr(field)); @@ -76,7 +76,7 @@ const Field &Array::get(uint8_t index) const */ uint32_t Array::count() const { - return _fields.size(); + return (uint32_t)_fields.size(); } /** diff --git a/src/basiccancelframe.h b/src/basiccancelframe.h index 6dd26dd..cdcf916 100644 --- a/src/basiccancelframe.h +++ b/src/basiccancelframe.h @@ -59,7 +59,7 @@ public: * @param noWait whether to wait for a response. */ BasicCancelFrame(uint16_t channel, const std::string& consumerTag, bool noWait = false) : - BasicFrame(channel, consumerTag.size() + 2), // 1 for extra string size, 1 for bool + BasicFrame(channel, (uint32_t)(consumerTag.size() + 2)), // 1 for extra string size, 1 for bool _consumerTag(consumerTag), _noWait(noWait) {} diff --git a/src/basiccancelokframe.h b/src/basiccancelokframe.h index 192417f..a894c5c 100644 --- a/src/basiccancelokframe.h +++ b/src/basiccancelokframe.h @@ -53,7 +53,7 @@ public: * @param consumerTag holds the consumertag specified by client or server */ BasicCancelOKFrame(uint16_t channel, std::string& consumerTag) : - BasicFrame(channel, consumerTag.length() + 1), // add 1 byte for encoding the size of consumer tag + BasicFrame(channel, (uint32_t)(consumerTag.length() + 1)), // add 1 byte for encoding the size of consumer tag _consumerTag(consumerTag) {} diff --git a/src/basicconsumeframe.h b/src/basicconsumeframe.h index 7e57eee..39a8930 100644 --- a/src/basicconsumeframe.h +++ b/src/basicconsumeframe.h @@ -86,7 +86,7 @@ public: * @param filter additional arguments */ BasicConsumeFrame(uint16_t channel, const std::string& queueName, const std::string& consumerTag, bool noLocal = false, bool noAck = false, bool exclusive = false, bool noWait = false, const Table& filter = {}) : - BasicFrame(channel, (queueName.length() + consumerTag.length() + 5 + filter.size())), // size of vars, +1 for each shortstring size, +1 for bools, +2 for deprecated value + BasicFrame(channel, (uint32_t)(queueName.length() + consumerTag.length() + 5 + filter.size())), // size of vars, +1 for each shortstring size, +1 for bools, +2 for deprecated value _queueName(queueName), _consumerTag(consumerTag), _bools(noLocal, noAck, exclusive, noWait), diff --git a/src/basicconsumeokframe.h b/src/basicconsumeokframe.h index 927fa38..9ec6397 100644 --- a/src/basicconsumeokframe.h +++ b/src/basicconsumeokframe.h @@ -43,7 +43,7 @@ public: * @param consumerTag consumertag specified by client of provided by server */ BasicConsumeOKFrame(uint16_t channel, const std::string& consumerTag) : - BasicFrame(channel, consumerTag.length() + 1), // length of string + 1 for encoding of stringsize + BasicFrame(channel, (uint32_t)(consumerTag.length() + 1)), // length of string + 1 for encoding of stringsize _consumerTag(consumerTag) {} diff --git a/src/basicdeliverframe.h b/src/basicdeliverframe.h index 1252969..7986355 100644 --- a/src/basicdeliverframe.h +++ b/src/basicdeliverframe.h @@ -87,7 +87,7 @@ public: * @param routingKey message routing key */ BasicDeliverFrame(uint16_t channel, const std::string& consumerTag, uint64_t deliveryTag, bool redelivered = false, const std::string& exchange = "", const std::string& routingKey = "") : - BasicFrame(channel, (consumerTag.length() + exchange.length() + routingKey.length() + 12)), + BasicFrame(channel, (uint32_t)(consumerTag.length() + exchange.length() + routingKey.length() + 12)), // length of strings + 1 byte per string for stringsize, 8 bytes for uint64_t and 1 for bools _consumerTag(consumerTag), _deliveryTag(deliveryTag), diff --git a/src/basicgetframe.h b/src/basicgetframe.h index f7244c8..4d112ff 100644 --- a/src/basicgetframe.h +++ b/src/basicgetframe.h @@ -59,7 +59,7 @@ public: * @param noAck whether server expects acknowledgements for messages */ BasicGetFrame(uint16_t channel, const std::string& queue, bool noAck = false) : - BasicFrame(channel, queue.length() + 4), // 1 for bool, 1 for string size, 2 for deprecated field + BasicFrame(channel, (uint32_t)(queue.length() + 4)), // 1 for bool, 1 for string size, 2 for deprecated field _queue(queue), _noAck(noAck) {} diff --git a/src/basicgetokframe.h b/src/basicgetokframe.h index 5cc3a12..0de5ea9 100644 --- a/src/basicgetokframe.h +++ b/src/basicgetokframe.h @@ -76,7 +76,7 @@ public: * @param messageCount number of messages in the queue */ BasicGetOKFrame(uint16_t channel, uint64_t deliveryTag, bool redelivered, const std::string& exchange, const std::string& routingKey, uint32_t messageCount) : - BasicFrame(channel, (exchange.length() + routingKey.length() + 15)), // string length, +1 for each shortsrting length + 8 (uint64_t) + 4 (uint32_t) + 1 (bool) + BasicFrame(channel, (uint32_t)(exchange.length() + routingKey.length() + 15)), // string length, +1 for each shortsrting length + 8 (uint64_t) + 4 (uint32_t) + 1 (bool) _deliveryTag(deliveryTag), _redelivered(redelivered), _exchange(exchange), diff --git a/src/basicpublishframe.h b/src/basicpublishframe.h index 975c2ab..bbaed57 100644 --- a/src/basicpublishframe.h +++ b/src/basicpublishframe.h @@ -70,7 +70,7 @@ public: * @param immediate request immediate delivery @default = false */ BasicPublishFrame(uint16_t channel, const std::string& exchange = "", const std::string& routingKey = "", bool mandatory = false, bool immediate = false) : - BasicFrame(channel, exchange.length() + routingKey.length() + 5), // 1 extra per string (for the size), 1 for bools, 2 for deprecated field + BasicFrame(channel, (uint32_t)(exchange.length() + routingKey.length() + 5)), // 1 extra per string (for the size), 1 for bools, 2 for deprecated field _exchange(exchange), _routingKey(routingKey), _bools(mandatory, immediate) diff --git a/src/basicreturnframe.h b/src/basicreturnframe.h index 2fedce6..e140e9c 100644 --- a/src/basicreturnframe.h +++ b/src/basicreturnframe.h @@ -67,7 +67,7 @@ public: * @param routingKey message routing key */ BasicReturnFrame(uint16_t channel, int16_t replyCode, const std::string& replyText = "", const std::string& exchange = "", const std::string& routingKey = "") : - BasicFrame(channel, replyText.length() + exchange.length() + routingKey.length() + 5), // 3 for each string (extra size byte), 2 for uint16_t + BasicFrame(channel, (uint32_t)(replyText.length() + exchange.length() + routingKey.length() + 5)), // 3 for each string (extra size byte), 2 for uint16_t _replyCode(replyCode), _replyText(replyText), _exchange(exchange), diff --git a/src/channelcloseframe.h b/src/channelcloseframe.h index d47d88d..48476af 100644 --- a/src/channelcloseframe.h +++ b/src/channelcloseframe.h @@ -82,7 +82,7 @@ public: * @param failingMethod failing method id if applicable */ ChannelCloseFrame(uint16_t channel, uint16_t code = 0, const std::string& text = "", uint16_t failingClass = 0, uint16_t failingMethod = 0) : - ChannelFrame(channel, (text.length() + 7)), // sizeof code, failingclass, failingmethod (2byte + 2byte + 2byte) + text length + text length byte + ChannelFrame(channel, (uint32_t)(text.length() + 7)), // sizeof code, failingclass, failingmethod (2byte + 2byte + 2byte) + text length + text length byte _code(code), _text(text), _failingClass(failingClass), diff --git a/src/channelimpl.cpp b/src/channelimpl.cpp index 73471ab..9d32874 100644 --- a/src/channelimpl.cpp +++ b/src/channelimpl.cpp @@ -481,7 +481,7 @@ bool ChannelImpl::publish(const std::string &exchange, const std::string &routin uint64_t chunksize = std::min(static_cast(maxpayload), bytesleft); // send out a body frame - if (!send(BodyFrame(_id, data + bytessent, chunksize))) return false; + if (!send(BodyFrame(_id, data + bytessent, (uint32_t)chunksize))) return false; // channel still valid? if (!monitor.valid()) return false; diff --git a/src/connectioncloseframe.h b/src/connectioncloseframe.h index 17378c0..9828bb5 100644 --- a/src/connectioncloseframe.h +++ b/src/connectioncloseframe.h @@ -82,7 +82,7 @@ public: * @param failingMethod id of the failing method if applicable */ ConnectionCloseFrame(uint16_t code, const std::string &text, uint16_t failingClass = 0, uint16_t failingMethod = 0) : - ConnectionFrame(text.length() + 7), // 1 for extra string byte, 2 for each uint16 + ConnectionFrame((uint32_t)(text.length() + 7)), // 1 for extra string byte, 2 for each uint16 _code(code), _text(text), _failingClass(failingClass), diff --git a/src/connectionimpl.cpp b/src/connectionimpl.cpp index f2bd13c..756e084 100644 --- a/src/connectionimpl.cpp +++ b/src/connectionimpl.cpp @@ -146,7 +146,7 @@ uint64_t ConnectionImpl::parse(const Buffer &buffer) // have the initial bytes of the header, we already know how much // data we need for the next frame, otherwise we need at least 7 // bytes for processing the header of the next frame - _expected = receivedFrame.header() ? receivedFrame.totalSize() : 7; + _expected = receivedFrame.header() ? (uint32_t)receivedFrame.totalSize() : 7; // we're ready for now return processed; diff --git a/src/connectionopenframe.h b/src/connectionopenframe.h index ca78dd6..c063357 100644 --- a/src/connectionopenframe.h +++ b/src/connectionopenframe.h @@ -60,7 +60,7 @@ public: * @param vhost name of virtual host to open */ ConnectionOpenFrame(const std::string &vhost) : - ConnectionFrame(vhost.length() + 3), // length of vhost + byte to encode this length + deprecated shortstring size + deprecated bool + ConnectionFrame((uint32_t)(vhost.length() + 3)), // length of vhost + byte to encode this length + deprecated shortstring size + deprecated bool _vhost(vhost), _deprecatedCapabilities(""), _deprecatedInsist() diff --git a/src/connectionsecureframe.h b/src/connectionsecureframe.h index f8564ec..8c128d1 100644 --- a/src/connectionsecureframe.h +++ b/src/connectionsecureframe.h @@ -43,7 +43,7 @@ public: * @param challenge the challenge */ ConnectionSecureFrame(const std::string& challenge) : - ConnectionFrame(challenge.length() + 4), // 4 for the length of the challenge (uint32_t) + ConnectionFrame((uint32_t)(challenge.length() + 4)), // 4 for the length of the challenge (uint32_t) _challenge(challenge) {} diff --git a/src/connectionsecureokframe.h b/src/connectionsecureokframe.h index d5c907b..7867804 100644 --- a/src/connectionsecureokframe.h +++ b/src/connectionsecureokframe.h @@ -43,7 +43,7 @@ public: * @param response the challenge response */ ConnectionSecureOKFrame(const std::string& response) : - ConnectionFrame(response.length() + 4), //response length + uint32_t for encoding the length + ConnectionFrame((uint32_t)(response.length() + 4)), //response length + uint32_t for encoding the length _response(response) {} diff --git a/src/connectionstartframe.h b/src/connectionstartframe.h index 139d2b9..f11c69b 100644 --- a/src/connectionstartframe.h +++ b/src/connectionstartframe.h @@ -81,7 +81,7 @@ public: * @param locales available locales */ ConnectionStartFrame(uint8_t major, uint8_t minor, const Table& properties, const std::string& mechanisms, const std::string& locales) : - ConnectionFrame((properties.size() + mechanisms.length() + locales.length() + 10)), // 4 for each longstring (size-uint32), 2 major/minor + ConnectionFrame((uint32_t)(properties.size() + mechanisms.length() + locales.length() + 10)), // 4 for each longstring (size-uint32), 2 major/minor _major(major), _minor(minor), _properties(properties), diff --git a/src/connectionstartokframe.h b/src/connectionstartokframe.h index 5ca994e..bc46d5e 100644 --- a/src/connectionstartokframe.h +++ b/src/connectionstartokframe.h @@ -82,7 +82,7 @@ public: * @param locale selected locale. */ ConnectionStartOKFrame(const Table& properties, const std::string& mechanism, const std::string& response, const std::string& locale) : - ConnectionFrame((properties.size() + mechanism.length() + response.length() + locale.length() + 6)), // 1 byte extra per shortstring, 4 per longstring + ConnectionFrame((uint32_t)(properties.size() + mechanism.length() + response.length() + locale.length() + 6)), // 1 byte extra per shortstring, 4 per longstring _properties(properties), _mechanism(mechanism), _response(response), diff --git a/src/exchangebindframe.h b/src/exchangebindframe.h index 1d01161..0b6a092 100644 --- a/src/exchangebindframe.h +++ b/src/exchangebindframe.h @@ -95,7 +95,7 @@ public: * @param arguments */ ExchangeBindFrame(uint16_t channel, const std::string &destination, const std::string &source, const std::string &routingKey, bool noWait, const Table &arguments) : - ExchangeFrame(channel, (destination.length() + source.length() + routingKey.length() + arguments.size() + 6)), // 1 for each string, 1 for booleanset, 2 for deprecated field + ExchangeFrame(channel, (uint32_t)(destination.length() + source.length() + routingKey.length() + arguments.size() + 6)), // 1 for each string, 1 for booleanset, 2 for deprecated field _destination(destination), _source(source), _routingKey(routingKey), diff --git a/src/exchangedeclareframe.h b/src/exchangedeclareframe.h index aa940dd..cb45f01 100644 --- a/src/exchangedeclareframe.h +++ b/src/exchangedeclareframe.h @@ -81,7 +81,7 @@ public: * @param arguments additional arguments */ ExchangeDeclareFrame(uint16_t channel, const std::string& name, const std::string& type, bool passive, bool durable, bool noWait, const Table& arguments) : - ExchangeFrame(channel, (name.length() + type.length() + arguments.size() + 5)), // size of name, type and arguments + 1 (all booleans are stored in 1 byte) + 2 (deprecated short) + 2 (string sizes) + ExchangeFrame(channel, (uint32_t)(name.length() + type.length() + arguments.size() + 5)), // size of name, type and arguments + 1 (all booleans are stored in 1 byte) + 2 (deprecated short) + 2 (string sizes) _name(name), _type(type), _bools(passive, durable, false, false, noWait), diff --git a/src/exchangedeleteframe.h b/src/exchangedeleteframe.h index cdd906f..2fc9e23 100644 --- a/src/exchangedeleteframe.h +++ b/src/exchangedeleteframe.h @@ -73,7 +73,7 @@ public: * @param bool noWait Do not wait for a response */ ExchangeDeleteFrame(uint16_t channel, const std::string& name, bool ifUnused = false, bool noWait = false) : - ExchangeFrame(channel, name.length() + 4), // length of the name, 1 byte for encoding this length, 1 for bools, 2 for deprecated short + ExchangeFrame(channel, (uint32_t)(name.length() + 4)), // length of the name, 1 byte for encoding this length, 1 for bools, 2 for deprecated short _name(name), _bools(ifUnused, noWait) {} diff --git a/src/exchangeunbindframe.h b/src/exchangeunbindframe.h index d92d941..bfd3469 100644 --- a/src/exchangeunbindframe.h +++ b/src/exchangeunbindframe.h @@ -95,7 +95,7 @@ public: * @param arguments */ ExchangeUnbindFrame(uint16_t channel, const std::string &destination, const std::string &source, const std::string &routingKey, bool noWait, const Table &arguments) : - ExchangeFrame(channel, (destination.length() + source.length() + routingKey.length() + arguments.size() + 6)), // 1 for each string, 1 for booleanset, 2 for deprecated field + ExchangeFrame(channel, (uint32_t)(destination.length() + source.length() + routingKey.length() + arguments.size() + 6)), // 1 for each string, 1 for booleanset, 2 for deprecated field _destination(destination), _source(source), _routingKey(routingKey), diff --git a/src/framecheck.h b/src/framecheck.h index ab8c959..675cebe 100644 --- a/src/framecheck.h +++ b/src/framecheck.h @@ -50,7 +50,7 @@ public: virtual ~FrameCheck() { // update the number of bytes to skip - _frame->_skip += _size; + _frame->_skip += (uint32_t)_size; } }; diff --git a/src/includes.h b/src/includes.h index 2a10061..ddabc00 100644 --- a/src/includes.h +++ b/src/includes.h @@ -9,7 +9,7 @@ // c and c++ dependencies #include -#include +#include // TODO cstring #include #include #include @@ -21,14 +21,19 @@ #include #include #include -#include -#include -#include -#include -#include + +#include // TODO is this needed + #include #include +// TODO make this nice +#ifdef _MSC_VER +//not #if defined(_WIN32) || defined(_WIN64) because we have strncasecmp in mingw +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif + // forward declarations #include "../include/classes.h" @@ -41,7 +46,6 @@ #include "../include/copiedbuffer.h" #include "../include/watchable.h" #include "../include/monitor.h" -#include "../include/tcpdefines.h" // amqp types #include "../include/field.h" @@ -75,8 +79,6 @@ #include "../include/connectionhandler.h" #include "../include/connectionimpl.h" #include "../include/connection.h" -#include "../include/tcphandler.h" -#include "../include/tcpconnection.h" // classes that are very commonly used #include "../include/exception.h" @@ -91,6 +93,5 @@ #include "queueframe.h" #include "basicframe.h" #include "transactionframe.h" -#include "addressinfo.h" diff --git a/src/queuebindframe.h b/src/queuebindframe.h index bc4d2e9..8418fe1 100644 --- a/src/queuebindframe.h +++ b/src/queuebindframe.h @@ -87,7 +87,7 @@ public: * @param Table arguments additional arguments */ QueueBindFrame(uint16_t channel, const std::string& name, const std::string& exchange, const std::string& routingKey = "", bool noWait = false, const Table& arguments = {}) : - QueueFrame(channel, (name.length() + exchange.length() + routingKey.length() + arguments.size() + 6) ), // 3 extra per string, 1 for bools, 2 for deprecated field + QueueFrame(channel, (uint32_t)(name.length() + exchange.length() + routingKey.length() + arguments.size() + 6) ), // 3 extra per string, 1 for bools, 2 for deprecated field _name(name), _exchange(exchange), _routingKey(routingKey), diff --git a/src/queuedeclareframe.h b/src/queuedeclareframe.h index 475c8b6..627b17c 100644 --- a/src/queuedeclareframe.h +++ b/src/queuedeclareframe.h @@ -80,7 +80,7 @@ public: * @param Table arguments additional arguments, implementation dependent */ QueueDeclareFrame(uint16_t channel, const std::string& name = "", bool passive = false, bool durable = false, bool exclusive = false, bool autoDelete = false, bool noWait = false, const Table& arguments = {}) : - QueueFrame(channel, (name.length() + arguments.size() + 4 ) ), // 1 extra for string size, 1 for bools, 2 for deprecated value + QueueFrame(channel, (uint32_t)(name.length() + arguments.size() + 4 ) ), // 1 extra for string size, 1 for bools, 2 for deprecated value _name(name), _bools(passive, durable, exclusive, autoDelete, noWait), _arguments(arguments) diff --git a/src/queuedeclareokframe.h b/src/queuedeclareokframe.h index 44821a5..99ad1e8 100644 --- a/src/queuedeclareokframe.h +++ b/src/queuedeclareokframe.h @@ -62,7 +62,7 @@ public: * @param failingMethod failing method id if applicable */ QueueDeclareOKFrame(uint16_t channel, const std::string& name, int32_t messageCount, int32_t consumerCount) : - QueueFrame(channel, name.length() + 9), // 4 per int, 1 for string size + QueueFrame(channel, (uint32_t)(name.length() + 9)), // 4 per int, 1 for string size _name(name), _messageCount(messageCount), _consumerCount(consumerCount) diff --git a/src/queuedeleteframe.h b/src/queuedeleteframe.h index dc9a00a..f76e736 100644 --- a/src/queuedeleteframe.h +++ b/src/queuedeleteframe.h @@ -69,7 +69,7 @@ public: * @param noWait do not wait on response */ QueueDeleteFrame(uint16_t channel, const std::string& name, bool ifUnused = false, bool ifEmpty = false, bool noWait = false) : - QueueFrame(channel, name.length() + 4), // 1 for string length, 1 for bools, 2 for deprecated field + QueueFrame(channel, (uint32_t)(name.length() + 4)), // 1 for string length, 1 for bools, 2 for deprecated field _name(name), _bools(ifUnused, ifEmpty, noWait) {} diff --git a/src/queuepurgeframe.h b/src/queuepurgeframe.h index 08cfad5..016cfd0 100644 --- a/src/queuepurgeframe.h +++ b/src/queuepurgeframe.h @@ -65,7 +65,7 @@ public: * @return newly created Queuepurgeframe */ QueuePurgeFrame(uint16_t channel, const std::string& name, bool noWait = false) : - QueueFrame(channel, name.length() + 4), // 1 extra for string length, 1 for bool, 2 for deprecated field + QueueFrame(channel, (uint32_t)(name.length() + 4)), // 1 extra for string length, 1 for bool, 2 for deprecated field _name(name), _noWait(noWait) {} diff --git a/src/queueunbindframe.h b/src/queueunbindframe.h index 8460663..e40b3b9 100644 --- a/src/queueunbindframe.h +++ b/src/queueunbindframe.h @@ -80,7 +80,7 @@ public: * @param arguments additional arguments, implementation dependant. */ QueueUnbindFrame(uint16_t channel, const std::string& name, const std::string& exchange, const std::string& routingKey = "", const Table& arguments = {} ) : - QueueFrame(channel, (name.length() + exchange.length() + routingKey.length() + arguments.size() + 5) ), // 1 per string, 2 for deprecated field + QueueFrame(channel, (uint32_t)(name.length() + exchange.length() + routingKey.length() + arguments.size() + 5) ), // 1 per string, 2 for deprecated field _name(name), _exchange(exchange), _routingKey(routingKey), diff --git a/src/table.cpp b/src/table.cpp index ac2fd45..d4177f4 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -21,7 +21,7 @@ Table::Table(ReceivedFrame &frame) ShortString name(frame); // subtract number of bytes to read, plus one byte for the decoded type - bytesToRead -= (name.size() + 1); + bytesToRead -= (uint32_t)(name.size() + 1); // get the field Field *field = Field::decode(frame); @@ -31,7 +31,7 @@ Table::Table(ReceivedFrame &frame) _fields[name] = std::shared_ptr(field); // subtract size - bytesToRead -= field->size(); + bytesToRead -= (uint32_t)field->size(); } } diff --git a/src/tcpconnection/CMakeLists.txt b/src/tcpconnection/CMakeLists.txt new file mode 100644 index 0000000..d5cb67f --- /dev/null +++ b/src/tcpconnection/CMakeLists.txt @@ -0,0 +1,3 @@ +add_sources( + tcpconnection.cpp +) diff --git a/src/tcpconnection/includes.h b/src/tcpconnection/includes.h new file mode 100644 index 0000000..2a10061 --- /dev/null +++ b/src/tcpconnection/includes.h @@ -0,0 +1,96 @@ +/** + * Includes.h + * + * The includes that are necessary to compile the AMQP library + * This file also holds includes that may not be necessary for including the library + * + * @documentation private + */ + +// c and c++ dependencies +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// forward declarations +#include "../include/classes.h" + +// utility classes +#include "../include/endian.h" +#include "../include/buffer.h" +#include "../include/bytebuffer.h" +#include "../include/receivedframe.h" +#include "../include/outbuffer.h" +#include "../include/copiedbuffer.h" +#include "../include/watchable.h" +#include "../include/monitor.h" +#include "../include/tcpdefines.h" + +// amqp types +#include "../include/field.h" +#include "../include/numericfield.h" +#include "../include/decimalfield.h" +#include "../include/stringfield.h" +#include "../include/booleanset.h" +#include "../include/fieldproxy.h" +#include "../include/table.h" +#include "../include/array.h" + +// envelope for publishing and consuming +#include "../include/metadata.h" +#include "../include/envelope.h" +#include "../include/message.h" + +// mid level includes +#include "../include/exchangetype.h" +#include "../include/flags.h" +#include "../include/callbacks.h" +#include "../include/deferred.h" +#include "../include/deferredconsumer.h" +#include "../include/deferredqueue.h" +#include "../include/deferreddelete.h" +#include "../include/deferredcancel.h" +#include "../include/deferredget.h" +#include "../include/channelimpl.h" +#include "../include/channel.h" +#include "../include/login.h" +#include "../include/address.h" +#include "../include/connectionhandler.h" +#include "../include/connectionimpl.h" +#include "../include/connection.h" +#include "../include/tcphandler.h" +#include "../include/tcpconnection.h" + +// classes that are very commonly used +#include "../include/exception.h" +#include "../include/protocolexception.h" +#include "../include/frame.h" +#include "extframe.h" +#include "methodframe.h" +#include "headerframe.h" +#include "connectionframe.h" +#include "channelframe.h" +#include "exchangeframe.h" +#include "queueframe.h" +#include "basicframe.h" +#include "transactionframe.h" +#include "addressinfo.h" + + diff --git a/src/tcpclosed.h b/src/tcpconnection/tcpclosed.h similarity index 100% rename from src/tcpclosed.h rename to src/tcpconnection/tcpclosed.h diff --git a/src/tcpconnected.h b/src/tcpconnection/tcpconnected.h similarity index 100% rename from src/tcpconnected.h rename to src/tcpconnection/tcpconnected.h diff --git a/src/tcpconnection.cpp b/src/tcpconnection/tcpconnection.cpp similarity index 100% rename from src/tcpconnection.cpp rename to src/tcpconnection/tcpconnection.cpp diff --git a/src/tcpinbuffer.h b/src/tcpconnection/tcpinbuffer.h similarity index 100% rename from src/tcpinbuffer.h rename to src/tcpconnection/tcpinbuffer.h diff --git a/src/tcpoutbuffer.h b/src/tcpconnection/tcpoutbuffer.h similarity index 100% rename from src/tcpoutbuffer.h rename to src/tcpconnection/tcpoutbuffer.h diff --git a/src/tcpresolver.h b/src/tcpconnection/tcpresolver.h similarity index 100% rename from src/tcpresolver.h rename to src/tcpconnection/tcpresolver.h diff --git a/src/tcpstate.h b/src/tcpconnection/tcpstate.h similarity index 100% rename from src/tcpstate.h rename to src/tcpconnection/tcpstate.h