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 30529ead..bf5b1115 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,26 +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: - - libboost-dev - - libboost-chrono-dev - - libboost-system-dev + - gcc-7 + - g++-7 + - clang-8 - rabbitmq-server - ninja-build @@ -37,7 +35,7 @@ install: - pushd _prereqs - git clone https://github.com/alanxz/rabbitmq-c - cd rabbitmq-c - - git checkout v0.10.0 + - git checkout v0.11.0 - export RABBITMQC_DIR=`pwd`/../../_install - cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${RABBITMQC_DIR} -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_TOOLS=OFF . - cmake --build . --target install @@ -50,6 +48,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 -Drabbitmq-c_ROOT=${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..143ee51b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,11 @@ # version of CMake by first installing Extra Packages for Enterprise Linux # (https://fedoraproject.org/wiki/EPEL#Extra_Packages_for_Enterprise_Linux_.28EPEL.29) # and then issuing `yum install cmake3` on the command line. -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) 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) @@ -41,20 +41,8 @@ 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 COMPONENTS chrono system 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}) option(ENABLE_SSL_SUPPORT "Enable SSL support." ${Rabbitmqc_SSL_ENABLED}) @@ -68,15 +56,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}) @@ -135,7 +114,12 @@ set(SAC_LIB_SRCS add_library(SimpleAmqpClient ${SAC_LIB_SRCS}) -target_link_libraries(SimpleAmqpClient ${Rabbitmqc_LIBRARY} ${SOCKET_LIBRARY} ${Boost_LIBRARIES} $<$:Boost::dynamic_linking>) +target_include_directories( + SimpleAmqpClient + PRIVATE ${Rabbitmqc_INCLUDE_DIR} + PUBLIC "$" + "$") +target_link_libraries(SimpleAmqpClient Rabbitmqc::rabbitmq ${SOCKET_LIBRARY}) if (WIN32) set_target_properties(SimpleAmqpClient PROPERTIES VERSION ${SAC_VERSION} OUTPUT_NAME SimpleAmqpClient.${SAC_SOVERSION}) @@ -195,6 +179,7 @@ endif () include(GNUInstallDirs) install(TARGETS SimpleAmqpClient + EXPORT ${PROJECT_NAME}Targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -225,22 +210,48 @@ 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 ${CMAKE_CURRENT_BINARY_DIR}/libSimpleAmqpClient.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig ) + +include(CMakePackageConfigHelpers) +# create and install target cmake file +install( + EXPORT ${PROJECT_NAME}Targets + NAMESPACE ${PROJECT_NAME}:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) + +# create main config file for find_package +# create project config file +set(PROJECT_CONFIG_CONTENT "@PACKAGE_INIT@\n") +# appending find_dependency for each dependency +if(PROJECT_DEP_PKG) + string(APPEND PROJECT_CONFIG_CONTENT "include(CMakeFindDependencyMacro)\n") + foreach(PKG_NAME ${PROJECT_DEP_PKG}) + string(APPEND PROJECT_CONFIG_CONTENT + "find_dependency(${PKG_NAME} REQUIRED)\n") + endforeach() +endif() +string(APPEND PROJECT_CONFIG_CONTENT + "include(\"\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake\")") +file(WRITE PROJECT_CONFIG_FILE ${PROJECT_CONFIG_CONTENT}) + +configure_package_config_file( + PROJECT_CONFIG_FILE ${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + +file(REMOVE PROJECT_CONFIG_FILE) + +# create version file +write_basic_package_version_file( + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + VERSION ${SAC_VERSION} + COMPATIBILITY SameMajorVersion) + +# install cmake configs +install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") diff --git a/Modules/FindRabbitmqc.cmake b/Modules/FindRabbitmqc.cmake index 523ae934..e5d32ac1 100644 --- a/Modules/FindRabbitmqc.cmake +++ b/Modules/FindRabbitmqc.cmake @@ -1,32 +1,33 @@ -#Find the Rabbitmq C library - -INCLUDE(LibFindMacros) - -# Find the include directories -FIND_PATH(Rabbitmqc_INCLUDE_DIR - NAMES amqp.h - HINTS ${Rabbitmqc_DIR}/include - ) - -FIND_LIBRARY(Rabbitmqc_LIBRARY - NAMES rabbitmq - HINTS ${Rabbitmqc_DIR}/lib - ) - -SET(Rabbitmqc_PROCESS_INCLUDES Rabbitmqc_INCLUDE_DIR) -SET(Rabbitmqc_PROCESS_LIBS Rabbitmqc_LIBRARY) - -LIBFIND_PROCESS(Rabbitmqc) - +find_package(rabbitmq-c CONFIG REQUIRED) +# needed because currently rabbitmq target doesn;t have include path in it +get_filename_component(_Rabbitmqc_PARENT_DIR ${rabbitmq-c_DIR} DIRECTORY) +set(_Rabbitmqc_INCLUDE_DIR "${_Rabbitmqc_PARENT_DIR}/include") +while(NOT EXISTS ${_Rabbitmqc_INCLUDE_DIR}) + get_filename_component(_Rabbitmqc_PARENT_DIR ${_Rabbitmqc_PARENT_DIR} DIRECTORY) + set(_Rabbitmqc_INCLUDE_DIR "${_Rabbitmqc_PARENT_DIR}/include") +endwhile() + +set(Rabbitmqc_INCLUDE_DIR ${_Rabbitmqc_INCLUDE_DIR}) +message(STATUS "asdasd ${Rabbitmqc_INCLUDE_DIR}") find_file(_Rabbitmqc_SSL_HEADER NAMES amqp_ssl_socket.h PATHS ${Rabbitmqc_INCLUDE_DIR} NO_DEFAULT_PATH - ) +) string(COMPARE NOTEQUAL "${_Rabbitmqc_SSL_HEADER}" "_Rabbitmqc_SSL_HEADER-NOTFOUND" _rmqc_ssl_enabled) set(Rabbitmqc_SSL_ENABLED ${_rmqc_ssl_enabled} CACHE BOOL "Rabbitmqc is SSL Enabled" FORCE) -mark_as_advanced(_Rabbitmqc_SSL_HEADER Rabbitmqc_SSL_ENABLED) + +if(TARGET rabbitmq::rabbitmq) + set_target_properties(rabbitmq::rabbitmq PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(Rabbitmqc::rabbitmq ALIAS rabbitmq::rabbitmq) +else() + set_target_properties(rabbitmq::rabbitmq-static PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(Rabbitmqc::rabbitmq ALIAS rabbitmq::rabbitmq-static) +endif() + +mark_as_advanced(_Rabbitmqc_INCLUDE_DIR Rabbitmqc_INCLUDE_DIR) +mark_as_advanced(_Rabbitmqc_SSL_HEADER Rabbitmqc_SSL_ENABLED) \ No newline at end of file diff --git a/Modules/LibFindMacros.cmake b/Modules/LibFindMacros.cmake deleted file mode 100644 index 69975c51..00000000 --- a/Modules/LibFindMacros.cmake +++ /dev/null @@ -1,99 +0,0 @@ -# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments -# used for the current package. For this to work, the first parameter must be the -# prefix of the current package, then the prefix of the new package etc, which are -# passed to find_package. -macro (libfind_package PREFIX) - set (LIBFIND_PACKAGE_ARGS ${ARGN}) - if (${PREFIX}_FIND_QUIETLY) - set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET) - endif (${PREFIX}_FIND_QUIETLY) - if (${PREFIX}_FIND_REQUIRED) - set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED) - endif (${PREFIX}_FIND_REQUIRED) - find_package(${LIBFIND_PACKAGE_ARGS}) -endmacro (libfind_package) - -# CMake developers made the UsePkgConfig system deprecated in the same release (2.6) -# where they added pkg_check_modules. Consequently I need to support both in my scripts -# to avoid those deprecated warnings. Here's a helper that does just that. -# Works identically to pkg_check_modules, except that no checks are needed prior to use. -macro (libfind_pkg_check_modules PREFIX PKGNAME) - if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - include(UsePkgConfig) - pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) - else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(${PREFIX} ${PKGNAME}) - endif (PKG_CONFIG_FOUND) - endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) -endmacro (libfind_pkg_check_modules) - -# Do the final processing once the paths have been detected. -# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain -# all the variables, each of which contain one include directory. -# Ditto for ${PREFIX}_PROCESS_LIBS and library files. -# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. -# Also handles errors in case library detection was required, etc. -macro (libfind_process PREFIX) - # Skip processing if already processed during this run - if (NOT ${PREFIX}_FOUND) - # Start with the assumption that the library was found - set (${PREFIX}_FOUND TRUE) - - # Process all includes and set _FOUND to false if any are missing - foreach (i ${${PREFIX}_PROCESS_INCLUDES}) - if (${i}) - set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) - mark_as_advanced(${i}) - else (${i}) - set (${PREFIX}_FOUND FALSE) - endif (${i}) - endforeach (i) - - # Process all libraries and set _FOUND to false if any are missing - foreach (i ${${PREFIX}_PROCESS_LIBS}) - if (${i}) - set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) - mark_as_advanced(${i}) - else (${i}) - set (${PREFIX}_FOUND FALSE) - endif (${i}) - endforeach (i) - - # Print message and/or exit on fatal error - if (${PREFIX}_FOUND) - if (NOT ${PREFIX}_FIND_QUIETLY) - message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") - endif (NOT ${PREFIX}_FIND_QUIETLY) - else (${PREFIX}_FOUND) - if (${PREFIX}_FIND_REQUIRED) - foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) - message("${i}=${${i}}") - endforeach (i) - message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.") - endif (${PREFIX}_FIND_REQUIRED) - endif (${PREFIX}_FOUND) - endif (NOT ${PREFIX}_FOUND) -endmacro (libfind_process) - -macro(libfind_library PREFIX basename) - set(TMP "") - if(MSVC80) - set(TMP -vc80) - endif(MSVC80) - if(MSVC90) - set(TMP -vc90) - endif(MSVC90) - set(${PREFIX}_LIBNAMES ${basename}${TMP}) - if(${ARGC} GREATER 2) - set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) - string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) - set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) - endif(${ARGC} GREATER 2) - find_library(${PREFIX}_LIBRARY - NAMES ${${PREFIX}_LIBNAMES} - PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS} - ) -endmacro(libfind_library) - diff --git a/README.md b/README.md index 3be3d9fb..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 @@ -72,9 +65,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/AmqpException.cpp b/src/AmqpException.cpp index c1998cfd..387dc0b5 100644 --- a/src/AmqpException.cpp +++ b/src/AmqpException.cpp @@ -32,35 +32,33 @@ #include #include -#include +#include +#include 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); @@ -77,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))); } } @@ -124,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))); } } @@ -186,14 +184,14 @@ 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))); } } 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..9351987a 100644 --- a/src/BasicMessage.cpp +++ b/src/BasicMessage.cpp @@ -32,8 +32,9 @@ #include #include -#include +#include #include +#include #include #include "SimpleAmqpClient/TableImpl.h" @@ -42,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) {} @@ -85,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(); } @@ -103,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(); } @@ -117,21 +118,21 @@ 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(); } -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; } bool BasicMessage::PriorityIsSet() const { - return m_impl->priority.is_initialized(); + return m_impl->priority.has_value(); } void BasicMessage::PriorityClear() { m_impl->priority.reset(); } @@ -149,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(); } @@ -167,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(); } @@ -185,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(); } @@ -203,20 +204,21 @@ 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(); } -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; } bool BasicMessage::TimestampIsSet() const { - return m_impl->timestamp.is_initialized(); + return m_impl->timestamp.has_value(); } void BasicMessage::TimestampClear() { m_impl->timestamp.reset(); } @@ -231,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(); } @@ -248,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(); } @@ -264,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(); } @@ -282,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(); } @@ -307,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 8950786f..7fb0fe5f 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -36,11 +36,10 @@ #include -#include -#include -#include -#include +#include +#include #include +#include #include #include #include @@ -142,8 +141,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(); @@ -193,22 +192,22 @@ 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: { + if (!opts.tls_params.has_value()) { + switch (opts.auth.index()) { + case 1: { const OpenOpts::BasicAuth &auth = - boost::get(opts.auth); - return boost::make_shared( + 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); - return boost::make_shared( + std::get(opts.auth); + return std::make_shared( OpenChannel(opts.host, opts.port, auth.identity, "", opts.vhost, opts.frame_max, true)); } @@ -216,20 +215,20 @@ 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); - return boost::make_shared(OpenSecureChannel( + 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 1: { + case 2: { const OpenOpts::ExternalSaslAuth &auth = - boost::get(opts.auth); - return boost::make_shared( + 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"); @@ -340,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"); } @@ -354,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"); } @@ -477,9 +476,9 @@ int Channel::GetSocketFD() const { return amqp_get_sockfd(m_impl->m_connection); } -bool Channel::CheckExchangeExists(boost::string_ref exchange_name) { - const boost::array DECLARE_OK = { - {AMQP_EXCHANGE_DECLARE_OK_METHOD}}; +bool Channel::CheckExchangeExists(std::string_view exchange_name) { + const std::array DECLARE_OK = { + AMQP_EXCHANGE_DECLARE_OK_METHOD}; amqp_exchange_declare_t declare = {}; declare.exchange = StringRefToBytes(exchange_name); @@ -507,8 +506,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 +529,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 +553,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 +580,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 = {}; @@ -601,9 +599,9 @@ 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}}; +bool Channel::CheckQueueExists(std::string_view queue_name) { + const std::array DECLARE_OK = { + AMQP_QUEUE_DECLARE_OK_METHOD}; amqp_queue_declare_t declare = {}; declare.queue = StringRefToBytes(queue_name); @@ -630,16 +628,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,13 +646,13 @@ 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 = { - {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 +684,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,8 +707,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 = {}; @@ -738,8 +734,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 = {}; @@ -757,8 +752,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 = {}; @@ -845,11 +839,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) { @@ -868,8 +861,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); @@ -882,8 +874,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 = {}; @@ -902,7 +894,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,8 +910,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 = {}; @@ -935,21 +927,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 std::array QOS_OK = {AMQP_BASIC_QOS_OK_METHOD}; amqp_basic_qos_t qos = {}; qos.prefetch_size = 0; @@ -959,8 +951,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); @@ -989,11 +981,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 std::array QOS_OK = {AMQP_BASIC_QOS_OK_METHOD}; amqp_basic_qos_t qos = {}; qos.prefetch_size = 0; @@ -1008,8 +1000,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); @@ -1051,7 +1042,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 eb276ca3..21ef48e3 100644 --- a/src/ChannelImpl.cpp +++ b/src/ChannelImpl.cpp @@ -37,9 +37,12 @@ #include #endif -#include -#include -#include +#include + +#include +#include +#include +#include #include "SimpleAmqpClient/AmqpException.h" #include "SimpleAmqpClient/AmqpLibraryException.h" @@ -48,11 +51,6 @@ #include "SimpleAmqpClient/ConnectionClosedException.h" #include "SimpleAmqpClient/ConsumerTagNotFoundException.h" #include "SimpleAmqpClient/TableImpl.h" -#define BOOST_BIND_GLOBAL_PLACEHOLDERS -#include - -#include -#include #define BROKER_HEARTBEAT 0 @@ -179,16 +177,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; @@ -395,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; @@ -419,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; @@ -439,7 +438,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( @@ -451,25 +450,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 boost::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 +483,11 @@ bool Channel::ChannelImpl::GetNextFrameFromBroker( bool Channel::ChannelImpl::GetNextFrameOnChannel( amqp_channel_t channel, amqp_frame_t &frame, - boost::chrono::microseconds timeout) { + std::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)); + 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; @@ -503,16 +502,17 @@ bool Channel::ChannelImpl::GetNextFrameOnChannel( return true; } - boost::array channels = {{channel}}; + std::array channels = {channel}; return GetNextFrameFromBrokerOnChannel(channels, frame, timeout); } 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); } } @@ -532,9 +532,24 @@ 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 -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"); @@ -553,17 +568,13 @@ boost::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; } - 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 = 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/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..8ea9f83f 100644 --- a/src/MessageReturnedException.cpp +++ b/src/MessageReturnedException.cpp @@ -28,16 +28,16 @@ #include "SimpleAmqpClient/MessageReturnedException.h" -#include +#include 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( 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/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 ffa8789f..c6ed0d67 100644 --- a/src/SimpleAmqpClient/BasicMessage.h +++ b/src/SimpleAmqpClient/BasicMessage.h @@ -28,11 +28,8 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include -#include -#include -#include +#include +#include #include #include "SimpleAmqpClient/Table.h" @@ -51,10 +48,10 @@ 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; + /// 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 { @@ -66,7 +63,7 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { /** * 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 @@ -75,7 +72,7 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { * @returns a new BasicMessage object */ static ptr_t Create(const std::string& body) { - return boost::make_shared(body); + return std::make_shared(body); } /// Construct empty BasicMessage @@ -84,6 +81,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 */ @@ -154,11 +155,11 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { /** * 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 */ @@ -239,11 +240,11 @@ class SIMPLEAMQPCLIENT_EXPORT BasicMessage : boost::noncopyable { /** * 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 */ @@ -342,7 +343,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/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 ee65bef5..bf43339d 100644 --- a/src/SimpleAmqpClient/Channel.h +++ b/src/SimpleAmqpClient/Channel.h @@ -28,16 +28,13 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include +#include #include +#include +#include #include "SimpleAmqpClient/BasicMessage.h" #include "SimpleAmqpClient/Envelope.h" @@ -59,10 +56,10 @@ 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; + /// a `std::shared_ptr` to Channel + typedef std::shared_ptr ptr_t; static const std::string EXCHANGE_TYPE_DIRECT; ///< `"direct"` string constant @@ -109,9 +106,9 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { 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; + std::optional tls_params; /** * Create an OpenOpts struct from a URI. @@ -330,6 +327,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(); /** @@ -351,7 +352,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(boost::string_ref exchange_name); + bool CheckExchangeExists(std::string_view exchange_name); /** * Declares an exchange @@ -454,7 +455,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * @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 @@ -527,8 +528,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * 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); @@ -558,8 +559,8 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * 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); @@ -772,7 +773,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { 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 @@ -800,7 +801,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { 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); /** @@ -816,7 +817,7 @@ class SIMPLEAMQPCLIENT_EXPORT Channel : boost::noncopyable { * 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 @@ -934,7 +935,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/ChannelImpl.h b/src/SimpleAmqpClient/ChannelImpl.h index 62af935c..712aa3b6 100644 --- a/src/SimpleAmqpClient/ChannelImpl.h +++ b/src/SimpleAmqpClient/ChannelImpl.h @@ -32,26 +32,28 @@ #include #include -#include - #include "SimpleAmqpClient/AmqpException.h" #include "SimpleAmqpClient/BasicMessage.h" #include "SimpleAmqpClient/Channel.h" #include "SimpleAmqpClient/ConsumerCancelledException.h" #include "SimpleAmqpClient/Envelope.h" #include "SimpleAmqpClient/MessageReturnedException.h" -#define BOOST_BIND_GLOBAL_PLACEHOLDERS -#include -#include -#include +#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; @@ -67,20 +69,19 @@ class Channel::ChannelImpl : boost::noncopyable { 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; @@ -104,15 +105,14 @@ class Channel::ChannelImpl : boost::noncopyable { 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; @@ -120,7 +120,7 @@ class Channel::ChannelImpl : boost::noncopyable { 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; @@ -152,16 +152,17 @@ class Channel::ChannelImpl : boost::noncopyable { } 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( - &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; @@ -169,10 +170,10 @@ class Channel::ChannelImpl : boost::noncopyable { 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; @@ -196,35 +197,34 @@ class Channel::ChannelImpl : boost::noncopyable { } 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; } 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)); amqp_frame_t response; - boost::array channels = {{channel}}; + std::array channels = {channel}; GetMethodOnChannel(channels, response, expected_responses); return response; } 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 = @@ -243,10 +243,12 @@ class Channel::ChannelImpl : boost::noncopyable { 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; @@ -260,12 +262,12 @@ class Channel::ChannelImpl : boost::noncopyable { 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) - : 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, @@ -298,7 +300,7 @@ class Channel::ChannelImpl : boost::noncopyable { 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); @@ -343,7 +345,7 @@ class Channel::ChannelImpl : boost::noncopyable { 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; @@ -358,7 +360,7 @@ class Channel::ChannelImpl : boost::noncopyable { 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 b112e307..ff5a6c9e 100644 --- a/src/SimpleAmqpClient/Envelope.h +++ b/src/SimpleAmqpClient/Envelope.h @@ -28,10 +28,8 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include -#include -#include +#include +#include #include #include "SimpleAmqpClient/BasicMessage.h" @@ -50,10 +48,10 @@ 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; + /// a `std::shared_ptr` pointer to Envelope + typedef std::shared_ptr ptr_t; /** * Creates an new envelope object @@ -66,17 +64,17 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { * 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, - 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) { - return boost::make_shared(message, consumer_tag, delivery_tag, - exchange, redelivered, routing_key, - delivery_channel); + const std::uint16_t delivery_channel) { + return std::make_shared(message, consumer_tag, delivery_tag, + exchange, redelivered, routing_key, + delivery_channel); } /** @@ -93,12 +91,16 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { */ 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 + Envelope(const Envelope &) = delete; + Envelope &operator=(const Envelope &) = delete; + /** * destructor */ @@ -127,7 +129,7 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { * * @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 @@ -159,7 +161,7 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { /** * 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 @@ -176,9 +178,9 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { 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; }; /** @@ -195,11 +197,11 @@ class SIMPLEAMQPCLIENT_EXPORT Envelope : boost::noncopyable { 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..8ef7bb7c 100644 --- a/src/SimpleAmqpClient/MessageRejectedException.h +++ b/src/SimpleAmqpClient/MessageRejectedException.h @@ -28,9 +28,9 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include +#include #include +#include #include "SimpleAmqpClient/BasicMessage.h" @@ -48,17 +48,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))), + .append(std::to_string(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 ee41af81..807f6870 100644 --- a/src/SimpleAmqpClient/Table.h +++ b/src/SimpleAmqpClient/Table.h @@ -28,10 +28,10 @@ * ***** END LICENSE BLOCK ***** */ -#include -#include +#include #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 @@ -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 diff --git a/src/SimpleAmqpClient/TableImpl.h b/src/SimpleAmqpClient/TableImpl.h index b72bc665..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 #include #include "SimpleAmqpClient/Table.h" @@ -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 {}; @@ -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,22 +80,21 @@ 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() {} 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..a059dca4 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -29,12 +29,12 @@ #include "SimpleAmqpClient/Table.h" #include -#include -#include +#include #include #include #include #include +#include #include "SimpleAmqpClient/TableImpl.h" @@ -45,32 +45,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) @@ -134,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); } -boost::uint8_t TableValue::GetUint8() const { - return boost::get(m_impl->m_value); +std::uint8_t TableValue::GetUint8() const { + return std::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 std::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 std::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 std::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 std::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 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)); } -boost::int64_t TableValue::GetInt64() const { - return boost::get(m_impl->m_value); +std::int64_t TableValue::GetInt64() const { + return std::get(m_impl->m_value); } -boost::int64_t TableValue::GetInteger() const { - switch (m_impl->m_value.which()) { +std::int64_t TableValue::GetInteger() const { + switch (m_impl->m_value.index()) { case VT_uint8: return GetUint8(); case VT_int8: @@ -188,62 +188,58 @@ boost::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(); } 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..ba81c9dd 100644 --- a/src/TableImpl.cpp +++ b/src/TableImpl.cpp @@ -36,10 +36,9 @@ #include #include -#include -#include -#include +#include #include +#include #ifdef _MSC_VER #pragma warning(disable : 4800) @@ -64,7 +63,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 +71,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 +79,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 +87,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 +95,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 +103,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 +111,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 +119,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; @@ -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; } @@ -191,7 +190,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()); @@ -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; @@ -297,7 +296,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()); diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 2cd58151..eb1ad8c7 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -1,6 +1,3 @@ -include_directories(BEFORE SYSTEM ${gtest_SOURCE_DIR}/include) -include_directories(../src) - add_executable(test_api connected_test.h test_connect.cpp @@ -15,5 +12,6 @@ add_executable(test_api test_ack.cpp test_nack.cpp ) +target_include_directories(test_api PRIVATE ${gtest_SOURCE_DIR}/include ${Rabbitmqc_INCLUDE_DIR} "${CMAKE_CURRENT_LIST_DIR}/../src") target_link_libraries(test_api SimpleAmqpClient gtest gtest_main) add_test(test_api test_api) 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); 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..c65690ec 100644 --- a/testing/test_table.cpp +++ b/testing/test_table.cpp @@ -27,9 +27,9 @@ */ #include -#include -#include #include +#include +#include #include "connected_test.h" @@ -39,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) { @@ -85,311 +85,311 @@ 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) { - 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()); 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) { - 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()); 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) { - 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()); 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) { - 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()); 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) { - 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()); 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) { - 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()); 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) { @@ -400,86 +400,86 @@ 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) { - 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()); 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) { @@ -491,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) { @@ -536,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) { @@ -580,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) { @@ -630,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()); @@ -652,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) { @@ -682,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()); @@ -704,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) { 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