From bd78cfbf45a830bf9df22df6237e4b47440362a9 Mon Sep 17 00:00:00 2001 From: sztomi Date: Thu, 20 Apr 2017 23:48:22 +0200 Subject: [PATCH 001/111] doc: added github repo link --- doc/mkdocs.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/mkdocs.yml b/doc/mkdocs.yml index 64cbf2cb..9c58a5dc 100644 --- a/doc/mkdocs.yml +++ b/doc/mkdocs.yml @@ -31,4 +31,7 @@ markdown_extensions: copyright: "Copyright © 2016 Tamás Szelei" extra_css: - - 'extra.css' \ No newline at end of file + - 'extra.css' + +repo_name: 'rpclib/rpclib' +repo_url: 'https://github.com/rpclib/rpclib' From 37d6f9184d3fd8fa4663b44bf3914c14aaa443dd Mon Sep 17 00:00:00 2001 From: sztomi Date: Sun, 28 May 2017 15:11:08 +0200 Subject: [PATCH 002/111] server_session: fix connection leak (#125) Apparently, closing the session was factored out somewhere along the way. Additionally, this also fixes a memory leak. --- include/rpc/config.h | 2 ++ include/rpc/detail/async_writer.h | 6 ++++++ include/rpc/server.h | 6 +++++- lib/rpc/detail/server_session.cc | 25 +++++++++++++++++-------- lib/rpc/server.cc | 7 +++++++ 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/include/rpc/config.h b/include/rpc/config.h index 738ab395..d55f6147 100644 --- a/include/rpc/config.h +++ b/include/rpc/config.h @@ -29,6 +29,8 @@ struct constants RPCLIB_FINAL { #define RPCLIB_MSGPACK clmdep_msgpack #endif /* ifndef RPCLIB_MSGPACK */ +#ifndef RPCLIB_CXX_STANDARD #define RPCLIB_CXX_STANDARD 11 +#endif #endif /* end of include guard: CONFIG_H_L7IVDSPZ */ diff --git a/include/rpc/detail/async_writer.h b/include/rpc/detail/async_writer.h index c3ecb028..9977cdce 100644 --- a/include/rpc/detail/async_writer.h +++ b/include/rpc/detail/async_writer.h @@ -67,6 +67,12 @@ class async_writer : public std::enable_shared_from_this { friend class rpc::client; +protected: + template + std::shared_ptr shared_from_base() { + return std::static_pointer_cast(shared_from_this()); + } + protected: RPCLIB_ASIO::ip::tcp::socket socket_; RPCLIB_ASIO::strand write_strand_; diff --git a/include/rpc/server.h b/include/rpc/server.h index 7da22a91..40a41eef 100644 --- a/include/rpc/server.h +++ b/include/rpc/server.h @@ -95,7 +95,11 @@ class server { friend class detail::server_session; private: - RPCLIB_DECLARE_PIMPL() + //! \brief Closes a specific session. + void close_session(std::shared_ptr const& s); + +private: + RPCLIB_DECLARE_PIMPL() std::shared_ptr disp_; }; diff --git a/lib/rpc/detail/server_session.cc b/lib/rpc/detail/server_session.cc index 15239da7..bd5e0d73 100644 --- a/lib/rpc/detail/server_session.cc +++ b/lib/rpc/detail/server_session.cc @@ -1,17 +1,18 @@ #include "rpc/detail/server_session.h" +#include "rpc/config.h" #include "rpc/server.h" #include "rpc/this_handler.h" #include "rpc/this_server.h" #include "rpc/this_session.h" -#include "rpc/config.h" #include "rpc/detail/log.h" namespace rpc { namespace detail { -static constexpr std::size_t default_buffer_size = rpc::constants::DEFAULT_BUFFER_SIZE; +static constexpr std::size_t default_buffer_size = + rpc::constants::DEFAULT_BUFFER_SIZE; server_session::server_session(server *srv, RPCLIB_ASIO::io_service *io, RPCLIB_ASIO::ip::tcp::socket socket, @@ -33,11 +34,14 @@ void server_session::start() { do_read(); } void server_session::close() { LOG_INFO("Closing session."); exit_ = true; - write_strand_.post([this]() { socket_.close(); }); + write_strand_.post([this]() { + socket_.close(); + parent_->close_session(shared_from_base()); + }); } void server_session::do_read() { - auto self(shared_from_this()); + auto self(shared_from_base()); constexpr std::size_t max_read_bytes = default_buffer_size; socket_.async_read_some( RPCLIB_ASIO::buffer(pac_.buffer(), default_buffer_size), @@ -53,10 +57,9 @@ void server_session::do_read() { output_buf_.clear(); // any worker thread can take this call - auto z = std::shared_ptr(result.zone().release()); - io_->post([ - this, msg, z - ]() { + auto z = std::shared_ptr( + result.zone().release()); + io_->post([this, msg, z]() { this_handler().clear(); this_session().clear(); this_server().cancel_stop(); @@ -124,6 +127,12 @@ void server_session::do_read() { } do_read(); } + } else if (ec == RPCLIB_ASIO::error::eof || + ec == RPCLIB_ASIO::error::connection_reset) { + LOG_INFO("Client disconnected"); + self->close(); + } else { + LOG_ERROR("Unhandled error code: {} | '{}'", ec, ec.message()); } })); if (exit_) { diff --git a/lib/rpc/server.cc b/lib/rpc/server.cc index f0b9b057..759230a7 100644 --- a/lib/rpc/server.cc +++ b/lib/rpc/server.cc @@ -114,4 +114,11 @@ void server::stop() { pimpl->stop(); } void server::close_sessions() { pimpl->close_sessions(); } +void server::close_session(std::shared_ptr const &s) { + auto it = std::find(begin(pimpl->sessions_), end(pimpl->sessions_), s); + if (it != end(pimpl->sessions_)) { + pimpl->sessions_.erase(it); + } +} + } /* rpc */ From 96f4abc31ba290526cb5ec2839aa692400553795 Mon Sep 17 00:00:00 2001 From: sztomi Date: Sun, 28 May 2017 15:27:14 +0200 Subject: [PATCH 003/111] server_session: added test for leak repro (#125) --- tests/rpc/server_session_test.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/rpc/server_session_test.cc b/tests/rpc/server_session_test.cc index 3ab8dfd5..e2cca3bb 100644 --- a/tests/rpc/server_session_test.cc +++ b/tests/rpc/server_session_test.cc @@ -12,6 +12,7 @@ class server_session_test : public testing::Test { s("127.0.0.1", test_port), c("127.0.0.1", test_port) { s.bind("consume_big_param", [](std::string const& str){ (void)str; }); + s.bind("func", [](){ return 0; }); s.async_run(); } @@ -29,3 +30,11 @@ TEST_F(server_session_test, consume_big_param) { } // no crash is enough } + +TEST_F(server_session_test, connection_closed_properly) { + for (unsigned counter = 0; counter < 2000; ++counter) { + rpc::client client("localhost", rpc::constants::DEFAULT_PORT); + auto response = client.call("func"); + } + // no crash is enough +} From bfa701c429a9e9e7d8dae75b5b3cf2dac0afe6cc Mon Sep 17 00:00:00 2001 From: sztomi Date: Sun, 28 May 2017 22:13:21 +0200 Subject: [PATCH 004/111] client: fix timeout-related issues (#114, #115, #116) --- include/rpc/client.h | 8 +- include/rpc/client.inl | 9 +- include/rpc/nonstd/optional.hpp | 1083 +++++++++++++++++++++++++++++++ lib/rpc/client.cc | 23 +- 4 files changed, 1110 insertions(+), 13 deletions(-) create mode 100644 include/rpc/nonstd/optional.hpp diff --git a/include/rpc/client.h b/include/rpc/client.h index 18ebc25e..d2ee42e3 100644 --- a/include/rpc/client.h +++ b/include/rpc/client.h @@ -3,6 +3,8 @@ #include #include +#include "nonstd/optional.hpp" + #include "rpc/config.h" #include "rpc/detail/log.h" #include "rpc/detail/pimpl.h" @@ -96,18 +98,18 @@ class client { //! \brief Returns the timeout setting of this client in milliseconds. //! //! The timeout is applied to synchronous calls. If the timeout expires - //! without receiving a response from the server, rpc::timeout exceptio + //! without receiving a response from the server, rpc::timeout exception //! will be thrown. //! //! \note The timeout has no effect on async calls. For those, //! the preferred timeout mechanism remains using std::future. //! //! The default value for timeout is 5000ms (5 seconds). - uint64_t get_timeout() const; + nonstd::optional get_timeout() const; //! \brief Sets the timeout for synchronous calls. For more information, //! see client::get_timeout(). - void set_timeout(uint64_t value); + void set_timeout(int64_t value); //! \brief Enum representing the connection states of the client. enum class connection_state { initial, connected, disconnected, reset }; diff --git a/include/rpc/client.inl b/include/rpc/client.inl index 4ff33294..04dc825b 100644 --- a/include/rpc/client.inl +++ b/include/rpc/client.inl @@ -5,10 +5,11 @@ RPCLIB_MSGPACK::object_handle client::call(std::string const &func_name, Args... args) { RPCLIB_CREATE_LOG_CHANNEL(client) auto future = async_call(func_name, std::forward(args)...); - auto wait_result = future.wait_for(std::chrono::milliseconds(get_timeout())); - - if (wait_result == std::future_status::timeout) { - throw_timeout(func_name); + if (auto timeout = get_timeout()) { + auto wait_result = future.wait_for(std::chrono::milliseconds(*timeout)); + if (wait_result == std::future_status::timeout) { + throw_timeout(func_name); + } } return future.get(); diff --git a/include/rpc/nonstd/optional.hpp b/include/rpc/nonstd/optional.hpp new file mode 100644 index 00000000..052dd8a3 --- /dev/null +++ b/include/rpc/nonstd/optional.hpp @@ -0,0 +1,1083 @@ +// +// Copyright (c) 2016 Martin Moene +// +// https://github.com/martinmoene/optional-lite +// +// This code is licensed under the MIT License (MIT). +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#pragma once + +#ifndef NONSTD_OPTIONAL_LITE_HPP +#define NONSTD_OPTIONAL_LITE_HPP + +#include +#include +#include + +#define optional_lite_VERSION "2.0.0" + +// variant-lite alignment configuration: + +#ifndef optional_CONFIG_MAX_ALIGN_HACK +# define optional_CONFIG_MAX_ALIGN_HACK 0 +#endif + +#ifndef optional_CONFIG_ALIGN_AS +// no default, used in #if defined() +#endif + +#ifndef optional_CONFIG_ALIGN_AS_FALLBACK +# define optional_CONFIG_ALIGN_AS_FALLBACK double +#endif + +// Compiler detection (C++17 is speculative): + +#define optional_CPP11_OR_GREATER ( __cplusplus >= 201103L ) +#define optional_CPP14_OR_GREATER ( __cplusplus >= 201402L ) +#define optional_CPP17_OR_GREATER ( __cplusplus >= 201700L ) + +// half-open range [lo..hi): +#define optional_BETWEEN( v, lo, hi ) ( lo <= v && v < hi ) + +#if defined(_MSC_VER) && !defined(__clang__) +# define optional_COMPILER_MSVC_VERSION (_MSC_VER / 100 - 5 - (_MSC_VER < 1900)) +#else +# define optional_COMPILER_MSVC_VERSION 0 +#endif + +#if defined __GNUC__ +# define optional_COMPILER_GNUC_VERSION __GNUC__ +#else +# define optional_COMPILER_GNUC_VERSION 0 +#endif + +#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 7, 14 ) +# pragma warning( push ) +# pragma warning( disable: 4345 ) // initialization behavior changed +#endif + +#if optional_BETWEEN(optional_COMPILER_MSVC_VERSION, 7, 15 ) +# pragma warning( push ) +# pragma warning( disable: 4814 ) // in C++14 'constexpr' will not imply 'const' +#endif + +// Presence of C++11 language features: + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 10 +# define optional_HAVE_AUTO 1 +# define optional_HAVE_NULLPTR 1 +# define optional_HAVE_STATIC_ASSERT 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 12 +# define optional_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG 1 +# define optional_HAVE_INITIALIZER_LIST 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 14 +# define optional_HAVE_ALIAS_TEMPLATE 1 +# define optional_HAVE_CONSTEXPR_11 1 +# define optional_HAVE_ENUM_CLASS 1 +# define optional_HAVE_EXPLICIT_CONVERSION 1 +# define optional_HAVE_IS_DEFAULT 1 +# define optional_HAVE_IS_DELETE 1 +# define optional_HAVE_NOEXCEPT 1 +# define optional_HAVE_REF_QUALIFIER 1 +#endif + +// Presence of C++14 language features: + +#if optional_CPP14_OR_GREATER +# define optional_HAVE_CONSTEXPR_14 1 +#endif + +// Presence of C++17 language features: + +#if optional_CPP17_OR_GREATER +# define optional_HAVE_ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE 1 +#endif + +// Presence of C++ library features: + +#if optional_COMPILER_GNUC_VERSION +# define optional_HAVE_TR1_TYPE_TRAITS 1 +# define optional_HAVE_TR1_ADD_POINTER 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 9 +# define optional_HAVE_TYPE_TRAITS 1 +# define optional_HAVE_STD_ADD_POINTER 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 11 +# define optional_HAVE_ARRAY 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 12 +# define optional_HAVE_CONDITIONAL 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 14 || (optional_COMPILER_MSVC_VERSION >= 9 && _HAS_CPP0X) +# define optional_HAVE_CONTAINER_DATA_METHOD 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 12 +# define optional_HAVE_REMOVE_CV 1 +#endif + +#if optional_CPP11_OR_GREATER || optional_COMPILER_MSVC_VERSION >= 14 +# define optional_HAVE_SIZED_TYPES 1 +#endif + +// For the rest, consider VC14 as C++11 for variant-lite: + +#if optional_COMPILER_MSVC_VERSION >= 14 +# undef optional_CPP11_OR_GREATER +# define optional_CPP11_OR_GREATER 1 +#endif + +// C++ feature usage: + +#if optional_HAVE_CONSTEXPR_11 +# define optional_constexpr constexpr +#else +# define optional_constexpr /*constexpr*/ +#endif + +#if optional_HAVE_CONSTEXPR_14 +# define optional_constexpr14 constexpr +#else +# define optional_constexpr14 /*constexpr*/ +#endif + +#if optional_HAVE_NOEXCEPT +# define optional_noexcept noexcept +#else +# define optional_noexcept /*noexcept*/ +#endif + +#if optional_HAVE_NULLPTR +# define optional_nullptr nullptr +#else +# define optional_nullptr NULL +#endif + +#if optional_HAVE_REF_QUALIFIER +# define optional_ref_qual & +# define optional_refref_qual && +#else +# define optional_ref_qual /*&*/ +# define optional_refref_qual /*&&*/ +#endif + +// additional includes: + +#if optional_HAVE_INITIALIZER_LIST +# include +#endif + +#if optional_HAVE_TYPE_TRAITS +# include +#elif optional_HAVE_TR1_TYPE_TRAITS +# include +#endif + +// +// in_place: code duplicated in any-lite, optional-lite, variant-lite: +// + +#if ! nonstd_lite_HAVE_IN_PLACE_TYPES + +namespace nonstd { + +namespace detail { + +template< class T > +struct in_place_type_tag {}; + +template< std::size_t I > +struct in_place_index_tag {}; + +} // namespace detail + +struct in_place_t {}; + +template< class T > +inline in_place_t in_place( detail::in_place_type_tag = detail::in_place_type_tag() ) +{ + return in_place_t(); +} + +template< std::size_t I > +inline in_place_t in_place( detail::in_place_index_tag = detail::in_place_index_tag() ) +{ + return in_place_t(); +} + +// mimic templated typedef: + +#define nonstd_lite_in_place_type_t( T) nonstd::in_place_t(&)( nonstd::detail::in_place_type_tag ) +#define nonstd_lite_in_place_index_t(T) nonstd::in_place_t(&)( nonstd::detail::in_place_index_tag ) + +#define nonstd_lite_HAVE_IN_PLACE_TYPES 1 + +} // namespace nonstd + +#endif // nonstd_lite_HAVE_IN_PLACE_TYPES + +// +// optional: +// + +namespace nonstd { namespace optional_lite { + +/// class optional + +template< typename T > +class optional; + +namespace detail { + +// C++11 emulation: + +#if variant_HAVE_CONDITIONAL + +using std::conditional; + +#else + +template< bool Cond, class Then, class Else > +struct conditional; + +template< class Then, class Else > +struct conditional< true , Then, Else > { typedef Then type; }; + +template< class Then, class Else > +struct conditional< false, Then, Else > { typedef Else type; }; + +#endif // variant_HAVE_CONDITIONAL + +struct nulltype{}; + +template< typename Head, typename Tail > +struct typelist +{ + typedef Head head; + typedef Tail tail; +}; + +#if optional_CONFIG_MAX_ALIGN_HACK + +// Max align, use most restricted type for alignment: + +#define optional_UNIQUE( name ) optional_UNIQUE2( name, __LINE__ ) +#define optional_UNIQUE2( name, line ) optional_UNIQUE3( name, line ) +#define optional_UNIQUE3( name, line ) name ## line + +#define optional_ALIGN_TYPE( type ) \ + type optional_UNIQUE( _t ); struct_t< type > optional_UNIQUE( _st ) + +template< typename T > +struct struct_t { T _; }; + +union max_align_t +{ + optional_ALIGN_TYPE( char ); + optional_ALIGN_TYPE( short int ); + optional_ALIGN_TYPE( int ); + optional_ALIGN_TYPE( long int ); + optional_ALIGN_TYPE( float ); + optional_ALIGN_TYPE( double ); + optional_ALIGN_TYPE( long double ); + optional_ALIGN_TYPE( char * ); + optional_ALIGN_TYPE( short int * ); + optional_ALIGN_TYPE( int * ); + optional_ALIGN_TYPE( long int * ); + optional_ALIGN_TYPE( float * ); + optional_ALIGN_TYPE( double * ); + optional_ALIGN_TYPE( long double * ); + optional_ALIGN_TYPE( void * ); + +#ifdef HAVE_LONG_LONG + optional_ALIGN_TYPE( long long ); +#endif + + struct Unknown; + + Unknown ( * optional_UNIQUE(_) )( Unknown ); + Unknown * Unknown::* optional_UNIQUE(_); + Unknown ( Unknown::* optional_UNIQUE(_) )( Unknown ); + + struct_t< Unknown ( * )( Unknown) > optional_UNIQUE(_); + struct_t< Unknown * Unknown::* > optional_UNIQUE(_); + struct_t< Unknown ( Unknown::* )(Unknown) > optional_UNIQUE(_); +}; + +#undef optional_UNIQUE +#undef optional_UNIQUE2 +#undef optional_UNIQUE3 + +#undef optional_ALIGN_TYPE + +#elif defined( optional_CONFIG_ALIGN_AS ) // optional_CONFIG_MAX_ALIGN_HACK + +// Use user-specified type for alignment: + +#define optional_ALIGN_AS( unused ) \ + optional_CONFIG_ALIGN_AS + +#else // optional_CONFIG_MAX_ALIGN_HACK + +// Determine POD type to use for alignment: + +#define optional_ALIGN_AS( to_align ) \ + typename type_of_size< alignment_types, alignment_of< to_align >::value >::type + +template +struct alignment_of; + +template +struct alignment_of_hack +{ + char c; + T t; + alignment_of_hack(); +}; + +template +struct alignment_logic +{ + enum { value = A < S ? A : S }; +}; + +template< typename T > +struct alignment_of +{ + enum { value = alignment_logic< + sizeof( alignment_of_hack ) - sizeof(T), sizeof(T) >::value, }; +}; + +template< typename List, size_t N > +struct type_of_size +{ + typedef typename conditional< + N == sizeof( typename List::head ), + typename List::head, + typename type_of_size::type >::type type; +}; + +template< size_t N > +struct type_of_size< nulltype, N > +{ + typedef optional_CONFIG_ALIGN_AS_FALLBACK type; +}; + +template< typename T> +struct struct_t { T _; }; + +#define optional_ALIGN_TYPE( type ) \ + typelist< type , typelist< struct_t< type > + +struct Unknown; + +typedef + optional_ALIGN_TYPE( char ), + optional_ALIGN_TYPE( short ), + optional_ALIGN_TYPE( int ), + optional_ALIGN_TYPE( long ), + optional_ALIGN_TYPE( float ), + optional_ALIGN_TYPE( double ), + optional_ALIGN_TYPE( long double ), + + optional_ALIGN_TYPE( char *), + optional_ALIGN_TYPE( short * ), + optional_ALIGN_TYPE( int * ), + optional_ALIGN_TYPE( long * ), + optional_ALIGN_TYPE( float * ), + optional_ALIGN_TYPE( double * ), + optional_ALIGN_TYPE( long double * ), + + optional_ALIGN_TYPE( Unknown ( * )( Unknown ) ), + optional_ALIGN_TYPE( Unknown * Unknown::* ), + optional_ALIGN_TYPE( Unknown ( Unknown::* )( Unknown ) ), + + nulltype + > > > > > > > > > > > > > > + > > > > > > > > > > > > > > + > > > > > > + alignment_types; + +#undef optional_ALIGN_TYPE + +#endif // optional_CONFIG_MAX_ALIGN_HACK + +/// C++03 constructed union to hold value. + +template< typename T > +union storage_t +{ +private: + friend class optional; + + typedef T value_type; + + storage_t() {} + + storage_t( value_type const & v ) + { + construct_value( v ); + } + + void construct_value( value_type const & v ) + { + ::new( value_ptr() ) value_type( v ); + } + +#if optional_CPP11_OR_GREATER + + storage_t( value_type && v ) + { + construct_value( std::move( v ) ); + } + + void construct_value( value_type && v ) + { + ::new( value_ptr() ) value_type( std::move( v ) ); + } + +#endif + + void destruct_value() + { + value_ptr()->~T(); + } + + value_type const * value_ptr() const + { + return as(); + } + + value_type * value_ptr() + { + return as(); + } + + value_type const & value() const optional_ref_qual + { + return * value_ptr(); + } + + value_type & value() optional_ref_qual + { + return * value_ptr(); + } + +#if optional_CPP11_OR_GREATER + + value_type const && value() const optional_refref_qual + { + return * value_ptr(); + } + + value_type && value() optional_refref_qual + { + return * value_ptr(); + } + +#endif + +#if optional_CPP11_OR_GREATER + + using aligned_storage_t = typename std::aligned_storage< sizeof(value_type), alignof(value_type) >::type; + aligned_storage_t data; + +#elif optional_CONFIG_MAX_ALIGN_HACK + + typedef struct { unsigned char data[ sizeof(value_type) ]; } aligned_storage_t; + + max_align_t hack; + aligned_storage_t data; + +#else + typedef optional_ALIGN_AS(value_type) align_as_type; + + typedef struct { align_as_type data[ 1 + ( sizeof(value_type) - 1 ) / sizeof(align_as_type) ]; } aligned_storage_t; + aligned_storage_t data; + +# undef optional_ALIGN_AS + +#endif // optional_CONFIG_MAX_ALIGN_HACK + + void * ptr() optional_noexcept + { + return &data; + } + + void const * ptr() const optional_noexcept + { + return &data; + } + + template + U * as() + { + return reinterpret_cast( ptr() ); + } + + template + U const * as() const + { + return reinterpret_cast( ptr() ); + } +}; + +} // namespace detail + +/// disengaged state tag + +struct nullopt_t +{ + struct init{}; + optional_constexpr nullopt_t( init ) {} +}; + +#if optional_HAVE_CONSTEXPR_11 +constexpr nullopt_t nullopt{ nullopt_t::init{} }; +#else +// extra parenthesis to prevent the most vexing parse: +const nullopt_t nullopt(( nullopt_t::init() )); +#endif + +/// optional access error + +class bad_optional_access : public std::logic_error +{ +public: + explicit bad_optional_access() + : logic_error( "bad optional access" ) {} +}; + +/// optional + +template< typename T> +class optional +{ +private: + typedef void (optional::*safe_bool)() const; + +public: + typedef T value_type; + + optional_constexpr optional() optional_noexcept + : has_value_( false ) + , contained() + {} + + optional_constexpr optional( nullopt_t ) optional_noexcept + : has_value_( false ) + , contained() + {} + + optional( optional const & rhs ) + : has_value_( rhs.has_value() ) + { + if ( rhs.has_value() ) + contained.construct_value( rhs.contained.value() ); + } + +#if optional_CPP11_OR_GREATER + optional_constexpr14 optional( optional && rhs ) noexcept( std::is_nothrow_move_constructible::value ) + : has_value_( rhs.has_value() ) + { + if ( rhs.has_value() ) + contained.construct_value( std::move( rhs.contained.value() ) ); + } +#endif + + optional_constexpr optional( value_type const & value ) + : has_value_( true ) + , contained( value ) + {} + +#if optional_CPP11_OR_GREATER + + optional_constexpr optional( value_type && value ) + : has_value_( true ) + , contained( std::move( value ) ) + {} + + template< class... Args > + optional_constexpr explicit optional( nonstd_lite_in_place_type_t(T), Args&&... args ) + : has_value_( true ) + , contained( T( std::forward(args)...) ) + {} + + template< class U, class... Args > + optional_constexpr explicit optional( nonstd_lite_in_place_type_t(T), std::initializer_list il, Args&&... args ) + : has_value_( true ) + , contained( T( il, std::forward(args)...) ) + {} + +#endif // optional_CPP11_OR_GREATER + + ~optional() + { + if ( has_value() ) + contained.destruct_value(); + } + + // assignment + + optional & operator=( nullopt_t ) optional_noexcept + { + reset(); + return *this; + } + + optional & operator=( optional const & rhs ) +#if optional_CPP11_OR_GREATER + noexcept( std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value ) +#endif + { + if ( has_value() == true && rhs.has_value() == false ) reset(); + else if ( has_value() == false && rhs.has_value() == true ) initialize( *rhs ); + else if ( has_value() == true && rhs.has_value() == true ) contained.value() = *rhs; + return *this; + } + +#if optional_CPP11_OR_GREATER + + optional & operator=( optional && rhs ) noexcept + { + if ( has_value() == true && rhs.has_value() == false ) reset(); + else if ( has_value() == false && rhs.has_value() == true ) initialize( std::move( *rhs ) ); + else if ( has_value() == true && rhs.has_value() == true ) contained.value() = std::move( *rhs ); + return *this; + } + + template< class U, + typename = typename std::enable_if< std::is_same< typename std::decay::type, T>::value >::type > + optional & operator=( U && v ) + { + if ( has_value() ) contained.value() = std::forward( v ); + else initialize( T( std::forward( v ) ) ); + return *this; + } + + template< class... Args > + void emplace( Args&&... args ) + { + *this = nullopt; + initialize( T( std::forward(args)...) ); + } + + template< class U, class... Args > + void emplace( std::initializer_list il, Args&&... args ) + { + *this = nullopt; + initialize( T( il, std::forward(args)...) ); + } + +#endif // optional_CPP11_OR_GREATER + + // swap + + void swap( optional & rhs ) +#if optional_CPP11_OR_GREATER + noexcept( std::is_nothrow_move_constructible::value && noexcept( std::swap( std::declval(), std::declval() ) ) ) +#endif + { + using std::swap; + if ( has_value() == true && rhs.has_value() == true ) { swap( **this, *rhs ); } + else if ( has_value() == false && rhs.has_value() == true ) { initialize( *rhs ); rhs.reset(); } + else if ( has_value() == true && rhs.has_value() == false ) { rhs.initialize( **this ); reset(); } + } + + // observers + + optional_constexpr value_type const * operator ->() const + { + return assert( has_value() ), + contained.value_ptr(); + } + + optional_constexpr14 value_type * operator ->() + { + return assert( has_value() ), + contained.value_ptr(); + } + + optional_constexpr value_type const & operator *() const optional_ref_qual + { + return assert( has_value() ), + contained.value(); + } + + optional_constexpr14 value_type & operator *() optional_ref_qual + { + return assert( has_value() ), + contained.value(); + } + +#if optional_CPP11_OR_GREATER + + optional_constexpr value_type const && operator *() const optional_refref_qual + { + assert( has_value() ); + return std::move( contained.value() ); + } + + optional_constexpr14 value_type && operator *() optional_refref_qual + { + assert( has_value() ); + return std::move( contained.value() ); + } + +#endif + +#if optional_CPP11_OR_GREATER + optional_constexpr explicit operator bool() const optional_noexcept + { + return has_value(); + } +#else + optional_constexpr operator safe_bool() const optional_noexcept + { + return has_value() ? &optional::this_type_does_not_support_comparisons : 0; + } +#endif + + optional_constexpr bool has_value() const optional_noexcept + { + return has_value_; + } + + optional_constexpr14 value_type const & value() const optional_ref_qual + { + if ( ! has_value() ) + throw bad_optional_access(); + + return contained.value(); + } + + optional_constexpr14 value_type & value() optional_ref_qual + { + if ( ! has_value() ) + throw bad_optional_access(); + + return contained.value(); + } + +#if optional_HAVE_REF_QUALIFIER + + optional_constexpr14 value_type const && value() const optional_refref_qual + { + if ( ! has_value() ) + throw bad_optional_access(); + + return std::move( contained.value() ); + } + + optional_constexpr14 value_type && value() optional_refref_qual + { + if ( ! has_value() ) + throw bad_optional_access(); + + return std::move( contained.value() ); + } + +#endif + +#if optional_CPP11_OR_GREATER + + template< class U > + optional_constexpr value_type value_or( U && v ) const optional_ref_qual + { + return has_value() ? contained.value() : static_cast(std::forward( v ) ); + } + + template< class U > + optional_constexpr value_type value_or( U && v ) const optional_refref_qual + { + return has_value() ? std::move( contained.value() ) : static_cast(std::forward( v ) ); + } + +#else + + template< class U > + optional_constexpr value_type value_or( U const & v ) const + { + return has_value() ? contained.value() : static_cast( v ); + } + +#endif // optional_CPP11_OR_GREATER + + // modifiers + + void reset() optional_noexcept + { + if ( has_value() ) + contained.destruct_value(); + + has_value_ = false; + } + +private: + void this_type_does_not_support_comparisons() const {} + + template< typename V > + void initialize( V const & value ) + { + assert( ! has_value() ); + contained.construct_value( value ); + has_value_ = true; + } + +#if optional_CPP11_OR_GREATER + template< typename V > + void initialize( V && value ) + { + assert( ! has_value() ); + contained.construct_value( std::move( value ) ); + has_value_ = true; + } +#endif + +private: + bool has_value_; + detail::storage_t< value_type > contained; + +}; + +// Relational operators + +template< typename T > bool operator==( optional const & x, optional const & y ) +{ + return bool(x) != bool(y) ? false : bool(x) == false ? true : *x == *y; +} + +template< typename T > bool operator!=( optional const & x, optional const & y ) +{ + return !(x == y); +} + +template< typename T > bool operator<( optional const & x, optional const & y ) +{ + return (!y) ? false : (!x) ? true : *x < *y; +} + +template< typename T > bool operator>( optional const & x, optional const & y ) +{ + return (y < x); +} + +template< typename T > bool operator<=( optional const & x, optional const & y ) +{ + return !(y < x); +} + +template< typename T > bool operator>=( optional const & x, optional const & y ) +{ + return !(x < y); +} + +// Comparison with nullopt + +template< typename T > bool operator==( optional const & x, nullopt_t ) optional_noexcept +{ + return (!x); +} + +template< typename T > bool operator==( nullopt_t, optional const & x ) optional_noexcept +{ + return (!x); +} + +template< typename T > bool operator!=( optional const & x, nullopt_t ) optional_noexcept +{ + return bool(x); +} + +template< typename T > bool operator!=( nullopt_t, optional const & x ) optional_noexcept +{ + return bool(x); +} + +template< typename T > bool operator<( optional const &, nullopt_t ) optional_noexcept +{ + return false; +} + +template< typename T > bool operator<( nullopt_t, optional const & x ) optional_noexcept +{ + return bool(x); +} + +template< typename T > bool operator<=( optional const & x, nullopt_t ) optional_noexcept +{ + return (!x); +} + +template< typename T > bool operator<=( nullopt_t, optional const & ) optional_noexcept +{ + return true; +} + +template< typename T > bool operator>( optional const & x, nullopt_t ) optional_noexcept +{ + return bool(x); +} + +template< typename T > bool operator>( nullopt_t, optional const & ) optional_noexcept +{ + return false; +} + +template< typename T > bool operator>=( optional const &, nullopt_t ) +{ + return true; +} + +template< typename T > bool operator>=( nullopt_t, optional const & x ) +{ + return (!x); +} + +// Comparison with T + +template< typename T > bool operator==( optional const & x, const T& v ) +{ + return bool(x) ? *x == v : false; +} + +template< typename T > bool operator==( T const & v, optional const & x ) +{ + return bool(x) ? v == *x : false; +} + +template< typename T > bool operator!=( optional const & x, const T& v ) +{ + return bool(x) ? *x != v : true; +} + +template< typename T > bool operator!=( T const & v, optional const & x ) +{ + return bool(x) ? v != *x : true; +} + +template< typename T > bool operator<( optional const & x, const T& v ) +{ + return bool(x) ? *x < v : true; +} + +template< typename T > bool operator<( T const & v, optional const & x ) +{ + return bool(x) ? v < *x : false; +} + +template< typename T > bool operator<=( optional const & x, const T& v ) +{ + return bool(x) ? *x <= v : true; +} + +template< typename T > bool operator<=( T const & v, optional const & x ) +{ + return bool(x) ? v <= *x : false; +} + +template< typename T > bool operator>( optional const & x, const T& v ) +{ + return bool(x) ? *x > v : false; +} + +template< typename T > bool operator>( T const & v, optional const & x ) +{ + return bool(x) ? v > *x : true; +} + +template< typename T > bool operator>=( optional const & x, const T& v ) +{ + return bool(x) ? *x >= v : false; +} + +template< typename T > bool operator>=( T const & v, optional const & x ) +{ + return bool(x) ? v >= *x : true; +} + +// Specialized algorithms + +template< typename T > +void swap( optional & x, optional & y ) +#if optional_CPP11_OR_GREATER + noexcept( noexcept( x.swap(y) ) ) +#endif +{ + x.swap( y ); +} + +#if optional_CPP11_OR_GREATER + +template< class T > +optional_constexpr optional< typename std::decay::type > make_optional( T && v ) +{ + return optional< typename std::decay::type >( std::forward( v ) ); +} + +template< class T, class...Args > +optional_constexpr optional make_optional( Args&&... args ) +{ + return optional( in_place, std::forward(args)...); +} + +template< class T, class U, class... Args > +optional_constexpr optional make_optional( std::initializer_list il, Args&&... args ) +{ + return optional( in_place, il, std::forward(args)...); +} + +#else + +template< typename T > +optional make_optional( T const & v ) +{ + return optional( v ); +} + +#endif // optional_CPP11_OR_GREATER + +} // namespace optional + +using namespace optional_lite; + +} // namespace nonstd + +#if optional_CPP11_OR_GREATER + +// specialize the std::hash algorithm: + +namespace std { + +template< class T > +class hash< nonstd::optional > +{ +public: + std::size_t operator()( nonstd::optional const & v ) const optional_noexcept + { + return bool( v ) ? hash()( *v ) : 0; + } +}; + +} //namespace std + +#endif // optional_CPP11_OR_GREATER + +#endif // NONSTD_OPTIONAL_LITE_HPP diff --git a/lib/rpc/client.cc b/lib/rpc/client.cc index 5ab9780d..5bdeb550 100644 --- a/lib/rpc/client.cc +++ b/lib/rpc/client.cc @@ -37,7 +37,7 @@ struct client::impl { state_(client::connection_state::initial), writer_(std::make_shared( &io_, RPCLIB_ASIO::ip::tcp::socket(io_))), - timeout_(5000) { + timeout_(nonstd::nullopt) { pac_.reserve_buffer(default_buffer_size); } @@ -145,7 +145,7 @@ struct client::impl { std::thread io_thread_; std::atomic state_; std::shared_ptr writer_; - uint64_t timeout_; + nonstd::optional timeout_; RPCLIB_CREATE_LOG_CHANNEL(client) }; @@ -166,7 +166,17 @@ client::client(std::string const &addr, uint16_t port) void client::wait_conn() { std::unique_lock lock(pimpl->mut_connection_finished_); if (!pimpl->is_connected_) { - pimpl->conn_finished_.wait(lock); + if (auto timeout = pimpl->timeout_) { + auto result = pimpl->conn_finished_.wait_for( + lock, std::chrono::milliseconds(*timeout)); + if (result == std::cv_status::timeout) { + throw rpc::timeout(RPCLIB_FMT::format( + "Timeout of {}ms while connecting to {}:{}", *get_timeout(), + pimpl->addr_, pimpl->port_)); + } + } else { + pimpl->conn_finished_.wait(lock); + } } } @@ -196,11 +206,11 @@ client::connection_state client::get_connection_state() const { return pimpl->get_connection_state(); } -uint64_t client::get_timeout() const { +nonstd::optional client::get_timeout() const { return pimpl->timeout_; } -void client::set_timeout(uint64_t value) { +void client::set_timeout(int64_t value) { pimpl->timeout_ = value; } @@ -213,11 +223,12 @@ void client::wait_all_responses() { RPCLIB_NORETURN void client::throw_timeout(std::string const& func_name) { throw rpc::timeout( RPCLIB_FMT::format("Timeout of {}ms while calling RPC function '{}'", - get_timeout(), func_name)); + *get_timeout(), func_name)); } client::~client() { pimpl->io_.stop(); pimpl->io_thread_.join(); } + } From dcf8f1abb8163320d891d196346f203e1bbcea74 Mon Sep 17 00:00:00 2001 From: sztomi Date: Sun, 28 May 2017 22:27:18 +0200 Subject: [PATCH 005/111] tests: build fix on CI --- tests/rpc/client_test.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/rpc/client_test.cc b/tests/rpc/client_test.cc index c4cae1c0..536bc532 100644 --- a/tests/rpc/client_test.cc +++ b/tests/rpc/client_test.cc @@ -67,17 +67,16 @@ TEST_F(client_test, large_return) { TEST_F(client_test, timeout_setting_works) { rpc::client client("127.0.0.1", test_port); - const uint64_t default_timeout = 5000; - EXPECT_EQ(client.get_timeout(), default_timeout); + EXPECT_FALSE(client.get_timeout()); const uint64_t short_timeout = 50; client.set_timeout(short_timeout); - EXPECT_EQ(client.get_timeout(), short_timeout); + EXPECT_EQ(*client.get_timeout(), short_timeout); EXPECT_THROW(client.call("sleep", short_timeout + 1), rpc::timeout); client.set_timeout(short_timeout * 2); - EXPECT_EQ(client.get_timeout(), short_timeout * 2); + EXPECT_EQ(*client.get_timeout(), short_timeout * 2); EXPECT_NO_THROW(client.call("sleep", short_timeout + 1)); } @@ -91,7 +90,14 @@ TEST_F(client_test, timeout_right_msg) { } catch (rpc::timeout &t) { auto expected_msg = RPCLIB_FMT::format( "rpc::timeout: Timeout of {}ms while calling RPC function '{}'", - client.get_timeout(), "sleep"); + *client.get_timeout(), "sleep"); EXPECT_TRUE(str_match(t.what(), expected_msg)); } } + +TEST(client_test2, timeout_while_connection) { + rpc::client client("localhost", rpc::constants::DEFAULT_PORT); + client.set_timeout(50); + // this client never connects, so this tests the timout in wait_conn() + EXPECT_THROW(client.call("whatev"), rpc::timeout); +} \ No newline at end of file From 4354b5c5ee513f6dabbd8fa3aa02f21fd066679a Mon Sep 17 00:00:00 2001 From: sztomi Date: Thu, 6 Jul 2017 20:30:35 +0200 Subject: [PATCH 006/111] build: Fix warnings when building with clang (#132) I also sneaked in some unrelated cmake improvements. --- CMakeLists.txt | 41 +++++++++++++++------------------ doc/pages/versions.md | 2 +- include/rpc/config.h | 2 +- include/rpc/config.h.in | 3 +++ include/rpc/nonstd/optional.hpp | 3 +-- include/rpc/version.h | 8 +++---- lib/rpc/nonstd/optional.cc | 6 +++++ tests/rpc/client_test.cc | 2 +- 8 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 lib/rpc/nonstd/optional.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index abe6a90f..5c8d6c3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,9 +40,9 @@ endif() include(TargetArch) -set(RPCLIB_VERSION_MAJOR 2) +set(RPCLIB_VERSION_MAJOR 3) set(RPCLIB_VERSION_MINOR 0) -set(RPCLIB_VERSION_PATCH 1) +set(RPCLIB_VERSION_PATCH 0) target_architecture(TARGET_ARCH) @@ -89,7 +89,7 @@ function(set_rpclib_flags TARGET) set(RPCLIB_BUILD_FLAGS "-Wall -pedantic -Weverything -Wno-c++98-compat\ -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-prototypes\ - -pthread") + -Wno-undef -pthread") if(RPCLIB_CXX_STANDARD EQUAL 14) set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -std=c++14") elseif(RPCLIB_CXX_STANDARD EQUAL 11) @@ -102,12 +102,6 @@ function(set_rpclib_flags TARGET) set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m64") endif() - set(RPCLIB_DEP_LIBRARIES "pthread") - - if (RPCLIB_ENABLE_LOGGING) - set(RPCLIB_DEP_LIBRARIES "${RPCLIB_DEP_LIBRARIES}") - endif() - elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") set(RPCLIB_BUILD_FLAGS "-Wall -pedantic -pthread") @@ -127,12 +121,6 @@ function(set_rpclib_flags TARGET) set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m64") endif() - set(RPCLIB_DEP_LIBRARIES "pthread") - - if (RPCLIB_ENABLE_LOGGING) - set(RPCLIB_DEP_LIBRARIES "${RPCLIB_DEP_LIBRARIES}") - endif() - elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") set(RPCLIB_COMPILE_DEFINITIONS @@ -189,7 +177,18 @@ function(set_rpclib_flags TARGET) LINK_FLAGS "-lgcov --coverage") endif() + set(RPCLIB_DEP_LIBRARIES "pthread") + target_link_libraries(${TARGET} ${RPCLIB_DEP_LIBRARIES}) + target_include_directories( + ${TARGET} + PUBLIC include + PRIVATE include/rpc + ) + target_include_directories( + ${TARGET} SYSTEM + PRIVATE dependencies/include + ) endfunction() @@ -199,20 +198,16 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin) configure_file( "${PROJECT_SOURCE_DIR}/include/rpc/version.h.in" - "${PROJECT_BINARY_DIR}/version.h") + "${PROJECT_SOURCE_DIR}/include/rpc/version.h") configure_file( "${PROJECT_SOURCE_DIR}/include/rpc/config.h.in" - "${PROJECT_BINARY_DIR}/config.h") + "${PROJECT_SOURCE_DIR}/include/rpc/config.h") configure_file( "${PROJECT_SOURCE_DIR}/doc/pages/versions.md.in" "${PROJECT_SOURCE_DIR}/doc/pages/versions.md") -include_directories(include) -include_directories(include/rpc) -include_directories(SYSTEM dependencies/include) - file(GLOB_RECURSE RPCLIB_HEADERS include/rpc/*.h include/msgpack/*.hpp) @@ -241,10 +236,12 @@ add_library(${OUTPUT_LIBRARY_NAME} lib/rpc/detail/server_session.cc lib/rpc/detail/response.cc lib/rpc/detail/client_error.cc + lib/rpc/nonstd/optional.cc ${DEP_SOURCES} ${DEP_HEADERS} ${RPCLIB_HEADERS}) + set_rpclib_flags(${OUTPUT_LIBRARY_NAME}) target_link_libraries(${OUTPUT_LIBRARY_NAME}) @@ -322,10 +319,10 @@ if(RPCLIB_BUILD_TESTS) tests/rpc/server_session_test.cc tests/rpc/this_server_test.cc) - include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/tests") add_executable(${TEST_PROJECT_NAME} ${TEST_SOURCES}) set_rpclib_flags(${TEST_PROJECT_NAME}) + target_include_directories(${TEST_PROJECT_NAME} SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/tests") target_link_libraries( ${TEST_PROJECT_NAME} ${OUTPUT_LIBRARY_NAME} diff --git a/doc/pages/versions.md b/doc/pages/versions.md index 29424c01..13a8b0f6 100644 --- a/doc/pages/versions.md +++ b/doc/pages/versions.md @@ -1,4 +1,4 @@ -You are reading the documentation of 2.0.1. +You are reading the documentation of 3.0.0. If, for some reason you need the documentation of older versions, you can download them from this page. * [1.0.0](/archive/rpclib_docs_1.0.0.zip) diff --git a/include/rpc/config.h b/include/rpc/config.h index d55f6147..66620ef3 100644 --- a/include/rpc/config.h +++ b/include/rpc/config.h @@ -11,7 +11,7 @@ namespace rpc { -//! \brief +//! \brief Constants used in the library struct constants RPCLIB_FINAL { static RPCLIB_CONSTEXPR std::size_t DEFAULT_BUFFER_SIZE = 1024 << 10; static RPCLIB_CONSTEXPR std::uint16_t DEFAULT_PORT = 8080; diff --git a/include/rpc/config.h.in b/include/rpc/config.h.in index 01f0c90c..f344fede 100644 --- a/include/rpc/config.h.in +++ b/include/rpc/config.h.in @@ -4,6 +4,7 @@ #define CONFIG_H_L7IVDSPZ #include +#include #include "rpc/compatibility.h" @@ -28,6 +29,8 @@ struct constants RPCLIB_FINAL { #define RPCLIB_MSGPACK clmdep_msgpack #endif /* ifndef RPCLIB_MSGPACK */ +#ifndef RPCLIB_CXX_STANDARD #define RPCLIB_CXX_STANDARD @RPCLIB_CXX_STANDARD@ +#endif #endif /* end of include guard: CONFIG_H_L7IVDSPZ */ diff --git a/include/rpc/nonstd/optional.hpp b/include/rpc/nonstd/optional.hpp index 052dd8a3..e88a4318 100644 --- a/include/rpc/nonstd/optional.hpp +++ b/include/rpc/nonstd/optional.hpp @@ -563,6 +563,7 @@ class bad_optional_access : public std::logic_error public: explicit bad_optional_access() : logic_error( "bad optional access" ) {} + ~bad_optional_access(); }; /// optional @@ -731,13 +732,11 @@ class optional optional_constexpr value_type const && operator *() const optional_refref_qual { - assert( has_value() ); return std::move( contained.value() ); } optional_constexpr14 value_type && operator *() optional_refref_qual { - assert( has_value() ); return std::move( contained.value() ); } diff --git a/include/rpc/version.h b/include/rpc/version.h index 30e3afe7..f5c0a1df 100644 --- a/include/rpc/version.h +++ b/include/rpc/version.h @@ -1,14 +1,14 @@ #pragma once -#ifndef VERSION_H_UMZFBKB4 -#define VERSION_H_UMZFBKB4 +#ifndef VERSION_H_IN_LZK5UJ7E +#define VERSION_H_IN_LZK5UJ7E namespace rpc { -static constexpr unsigned VERSION_MAJOR = 1; +static constexpr unsigned VERSION_MAJOR = 3; static constexpr unsigned VERSION_MINOR = 0; static constexpr unsigned VERSION_PATCH = 0; } /* rpc */ -#endif /* end of include guard: VERSION_H_UMZFBKB4 */ +#endif /* end of include guard: VERSION_H_IN_LZK5UJ7E */ diff --git a/lib/rpc/nonstd/optional.cc b/lib/rpc/nonstd/optional.cc new file mode 100644 index 00000000..f80c9319 --- /dev/null +++ b/lib/rpc/nonstd/optional.cc @@ -0,0 +1,6 @@ +#include "rpc/nonstd/optional.hpp" + +// This is no-op; the reason it exists is to avoid +// the weak vtables problem. For more info, see +// https://stackoverflow.com/a/23749273/140367 +nonstd::bad_optional_access::~bad_optional_access() {} diff --git a/tests/rpc/client_test.cc b/tests/rpc/client_test.cc index 536bc532..36363a1b 100644 --- a/tests/rpc/client_test.cc +++ b/tests/rpc/client_test.cc @@ -100,4 +100,4 @@ TEST(client_test2, timeout_while_connection) { client.set_timeout(50); // this client never connects, so this tests the timout in wait_conn() EXPECT_THROW(client.call("whatev"), rpc::timeout); -} \ No newline at end of file +} From 0063a88141d6242e7033ab6451110d551fb4056a Mon Sep 17 00:00:00 2001 From: sztomi Date: Thu, 6 Jul 2017 22:02:32 +0200 Subject: [PATCH 007/111] dispatcher: fail when binding non-unique names (#119) --- include/rpc/dispatcher.h | 2 ++ include/rpc/dispatcher.inl | 5 +++++ lib/rpc/dispatcher.cc | 9 +++++++++ tests/rpc/dispatcher_test.cc | 15 +++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/include/rpc/dispatcher.h b/include/rpc/dispatcher.h index 513fae68..8044d4cb 100644 --- a/include/rpc/dispatcher.h +++ b/include/rpc/dispatcher.h @@ -98,6 +98,8 @@ class dispatcher { static void enforce_arg_count(std::string const &func, std::size_t found, std::size_t expected); + void enforce_unique_name(std::string const &func); + //! \brief Dispatches a call (which will have a response). detail::response dispatch_call(RPCLIB_MSGPACK::object const &msg, bool suppress_exceptions = false); diff --git a/include/rpc/dispatcher.inl b/include/rpc/dispatcher.inl index dc10edcf..1380bc59 100644 --- a/include/rpc/dispatcher.inl +++ b/include/rpc/dispatcher.inl @@ -3,6 +3,7 @@ namespace rpc { namespace detail { template void dispatcher::bind(std::string const &name, F func) { + enforce_unique_name(name); bind(name, func, typename detail::func_kind_info::result_kind(), typename detail::func_kind_info::args_kind()); } @@ -11,6 +12,7 @@ template void dispatcher::bind(std::string const &name, F func, detail::tags::void_result const &, detail::tags::zero_arg const &) { + enforce_unique_name(name); funcs_.insert( std::make_pair(name, [func, name](RPCLIB_MSGPACK::object const &args) { enforce_arg_count(name, 0, args.via.array.size); @@ -26,6 +28,7 @@ void dispatcher::bind(std::string const &name, F func, using detail::func_traits; using args_type = typename func_traits::args_type; + enforce_unique_name(name); funcs_.insert( std::make_pair(name, [func, name](RPCLIB_MSGPACK::object const &args) { constexpr int args_count = std::tuple_size::value; @@ -43,6 +46,7 @@ void dispatcher::bind(std::string const &name, F func, detail::tags::zero_arg const &) { using detail::func_traits; + enforce_unique_name(name); funcs_.insert(std::make_pair(name, [func, name](RPCLIB_MSGPACK::object const &args) { enforce_arg_count(name, 0, args.via.array.size); @@ -59,6 +63,7 @@ void dispatcher::bind(std::string const &name, F func, using detail::func_traits; using args_type = typename func_traits::args_type; + enforce_unique_name(name); funcs_.insert(std::make_pair(name, [func, name](RPCLIB_MSGPACK::object const &args) { constexpr int args_count = std::tuple_size::value; diff --git a/lib/rpc/dispatcher.cc b/lib/rpc/dispatcher.cc index e8954b88..378a194f 100644 --- a/lib/rpc/dispatcher.cc +++ b/lib/rpc/dispatcher.cc @@ -131,5 +131,14 @@ void dispatcher::enforce_arg_count(std::string const &func, std::size_t found, } } +void dispatcher::enforce_unique_name(std::string const &func) { + auto pos = funcs_.find(func); + if (pos != end(funcs_)) { + throw std::logic_error( + RPCLIB_FMT::format("Function name already bound: '{}'. " + "Please use unique function names", func)); + } +} + } } /* rpc */ diff --git a/tests/rpc/dispatcher_test.cc b/tests/rpc/dispatcher_test.cc index 05c65c54..83a51e7e 100644 --- a/tests/rpc/dispatcher_test.cc +++ b/tests/rpc/dispatcher_test.cc @@ -174,3 +174,18 @@ TEST_F(dispatch_test, bad_format_msgpack_returns_empty) { EXPECT_TRUE(response.is_empty()); } +TEST_F(dispatch_test, unique_names_zeroarg) { + dispatcher.bind("foo", &dummy_void_zeroarg); + EXPECT_THROW(dispatcher.bind("foo", &dummy_void_zeroarg), std::logic_error); +} + +TEST_F(dispatch_test, unique_names_singlearg) { + dispatcher.bind("foo", &dummy_void_singlearg); + EXPECT_THROW(dispatcher.bind("foo", &dummy_void_singlearg), std::logic_error); +} + +TEST_F(dispatch_test, unique_names_multiarg) { + dispatcher.bind("foo", &dummy_void_multiarg); + EXPECT_THROW(dispatcher.bind("foo", &dummy_void_multiarg), std::logic_error); +} + From 8f3e1a9769695aaa6991273fad988889d0f86cb6 Mon Sep 17 00:00:00 2001 From: sztomi Date: Thu, 6 Jul 2017 22:04:22 +0200 Subject: [PATCH 008/111] server: added move constructors (#128) --- include/rpc/server.h | 15 ++++++++++++++- lib/rpc/server.cc | 16 +++++++++++++++- tests/rpc/server_test.cc | 8 ++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/rpc/server.h b/include/rpc/server.h index 40a41eef..4c5f582e 100644 --- a/include/rpc/server.h +++ b/include/rpc/server.h @@ -24,6 +24,7 @@ class server_session; //! The server does not start listening right after construction in order //! to allow binding functions before that. Use the `run` or `async_run` //! functions to start listening on the port. +//! This class is not copyable, but moveable. class server { public: //! \brief Constructs a server that listens on the localhost on the @@ -32,6 +33,12 @@ class server { //! \param port The port number to listen on. explicit server(uint16_t port); + //! \brief Move constructor. This is implemented by calling the + //! move assignment operator. + //! + //! \param other The other instance to move from. + server(server&& other) noexcept; + //! \brief Constructs a server that listens on the specified address on //! the specified port. //! @@ -43,6 +50,12 @@ class server { //! When the server is destroyed, all ongoin sessions are closed gracefully. ~server(); + //! \brief Move assignment operator. + //! + //! \param other The other instance to move from. + //! \return The result of the assignment. + server& operator=(server&& other); + //! \brief Starts the server loop. This is a blocking call. //! //! First and foremost, running the event loop causes the server to start @@ -50,7 +63,7 @@ class server { //! and calls are made by clients, the server executes the calls as part //! of this call. This means that the handlers are executed on the thread //! that calls `run`. Reads and writes are initiated by this function - //% internally as well. + //! internally as well. void run(); //! \brief Starts the server loop on one or more threads. This is a diff --git a/lib/rpc/server.cc b/lib/rpc/server.cc index 759230a7..1012c6d9 100644 --- a/lib/rpc/server.cc +++ b/lib/rpc/server.cc @@ -84,6 +84,10 @@ server::server(uint16_t port) pimpl->start_accept(); } +server::server(server&& other) noexcept { + *this = std::move(other); +} + server::server(std::string const &address, uint16_t port) : pimpl(new server::impl(this, address, port)), disp_(std::make_shared()) { @@ -92,7 +96,17 @@ server::server(std::string const &address, uint16_t port) } server::~server() { - pimpl->stop(); + if (pimpl) { + pimpl->stop(); + } +} + +server& server::operator=(server &&other) { + pimpl = std::move(other.pimpl); + other.pimpl = nullptr; + disp_ = std::move(other.disp_); + other.disp_ = nullptr; + return *this; } void server::suppress_exceptions(bool suppress) { diff --git a/tests/rpc/server_test.cc b/tests/rpc/server_test.cc index aeda715f..ac51c644 100644 --- a/tests/rpc/server_test.cc +++ b/tests/rpc/server_test.cc @@ -169,3 +169,11 @@ TEST(server_misc, single_param_ctor) { s.async_run(); rpc::client c("127.0.0.1", test_port); } + +TEST(server_misc, server_is_moveable) { + rpc::server s(test_port); + s.bind("foo", [](){}); + std::vector vec; + vec.push_back(std::move(s)); + EXPECT_THROW(vec[0].bind("foo", [](){}), std::logic_error); +} From 479f7416b28cab17f90ca0e42994d0f3a0252bdc Mon Sep 17 00:00:00 2001 From: sztomi Date: Sat, 15 Jul 2017 11:44:43 +0200 Subject: [PATCH 009/111] Changed version to 2.1.0 --- CMakeLists.txt | 4 ++-- include/rpc/config.h | 2 +- include/rpc/version.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c8d6c3c..8cd34c22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,8 @@ endif() include(TargetArch) -set(RPCLIB_VERSION_MAJOR 3) -set(RPCLIB_VERSION_MINOR 0) +set(RPCLIB_VERSION_MAJOR 2) +set(RPCLIB_VERSION_MINOR 1) set(RPCLIB_VERSION_PATCH 0) target_architecture(TARGET_ARCH) diff --git a/include/rpc/config.h b/include/rpc/config.h index 66620ef3..06890879 100644 --- a/include/rpc/config.h +++ b/include/rpc/config.h @@ -30,7 +30,7 @@ struct constants RPCLIB_FINAL { #endif /* ifndef RPCLIB_MSGPACK */ #ifndef RPCLIB_CXX_STANDARD -#define RPCLIB_CXX_STANDARD 11 +#define RPCLIB_CXX_STANDARD 14 #endif #endif /* end of include guard: CONFIG_H_L7IVDSPZ */ diff --git a/include/rpc/version.h b/include/rpc/version.h index f5c0a1df..54e2899e 100644 --- a/include/rpc/version.h +++ b/include/rpc/version.h @@ -5,8 +5,8 @@ namespace rpc { -static constexpr unsigned VERSION_MAJOR = 3; -static constexpr unsigned VERSION_MINOR = 0; +static constexpr unsigned VERSION_MAJOR = 2; +static constexpr unsigned VERSION_MINOR = 1; static constexpr unsigned VERSION_PATCH = 0; } /* rpc */ From fcde48323475210b4a6777e2f5828a248125adb8 Mon Sep 17 00:00:00 2001 From: sztomi Date: Sat, 15 Jul 2017 11:58:14 +0200 Subject: [PATCH 010/111] Updated docs --- doc/pages/gettingstarted.md | 9 +++++++-- doc/pages/versions.md | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/pages/gettingstarted.md b/doc/pages/gettingstarted.md index 8fed64d1..70c2de65 100644 --- a/doc/pages/gettingstarted.md +++ b/doc/pages/gettingstarted.md @@ -5,14 +5,19 @@ This chapter details the steps of getting everything in place to be able to use ### Compiler `rpclib` is compatible with C++11, but it's also able to take advantage of C++14 if the compiler -supports it. At the moment, the oldest versions of the major compilers are the following: +supports it. At the moment, the oldest versions of the major compilers that are known to work +are the following: - * g++ 4.9 + * g++ 4.8 * clang++ 3.7 * MSVC 2015 Update 3 Newer versions of these compilers are expected to work, of course. +Since C++11 support was introduced, it might be possible to compile rpclib with even older compilers. +If it builds and the unit tests run without an error then it should be fine to use (please report older compilers +that do compile but produce failing unit tests to the issue tracker!) + ### Tools In addition to a capable compiler, you will need: diff --git a/doc/pages/versions.md b/doc/pages/versions.md index 13a8b0f6..971a2108 100644 --- a/doc/pages/versions.md +++ b/doc/pages/versions.md @@ -1,4 +1,4 @@ -You are reading the documentation of 3.0.0. +You are reading the documentation of 2.1.0. If, for some reason you need the documentation of older versions, you can download them from this page. * [1.0.0](/archive/rpclib_docs_1.0.0.zip) From c1fcb5ad995f3cdc2c38478a71e2c306ae6bd345 Mon Sep 17 00:00:00 2001 From: sztomi Date: Sat, 15 Jul 2017 12:00:39 +0200 Subject: [PATCH 011/111] Updated changelog --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52687274..e79bb251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +### 2.1.0 + +This is mainly a bugfix release. + +Released on 2017-07-15. + +Changes since 2.0.1: + + * Fixed an issue where the server did not properly release closed connections (#125) + * Fixed issues related to timeouts (#114, #115, #116) + * There is no longer a default timeout + * Fixed warnings when compiling with clang + * Fixed the dispatcher silently accepting multiple functions with the same name (#128) + * Changed minimum support g++ version to 4.8 from 4.9 (thanks to reddit user *attomsk* for letting me know) + ### 2.0.1 This is minor release that does not affect the library itself, just the version From d85c44bf1a3e04d8682d6698c67a3270fd3d64d5 Mon Sep 17 00:00:00 2001 From: sztomi Date: Sat, 15 Jul 2017 12:09:59 +0200 Subject: [PATCH 012/111] Fixed MSVC build --- CMakeLists.txt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cd34c22..950ed44f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,8 @@ function(set_rpclib_flags TARGET) set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m64") endif() + set(RPCLIB_DEP_LIBRARIES "pthread") + elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") set(RPCLIB_BUILD_FLAGS "-Wall -pedantic -pthread") @@ -121,6 +123,8 @@ function(set_rpclib_flags TARGET) set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m64") endif() + set(RPCLIB_DEP_LIBRARIES "pthread") + elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") set(RPCLIB_COMPILE_DEFINITIONS @@ -171,14 +175,6 @@ function(set_rpclib_flags TARGET) COMPILE_DEFINITIONS "${RPCLIB_COMPILE_DEFINITIONS}") endif() - if(RPCLIB_ENABLE_COVERAGE) - set_target_properties(${TARGET} - PROPERTIES - LINK_FLAGS "-lgcov --coverage") - endif() - - set(RPCLIB_DEP_LIBRARIES "pthread") - target_link_libraries(${TARGET} ${RPCLIB_DEP_LIBRARIES}) target_include_directories( ${TARGET} From afc922fa28802e5f3eb76ed6f0a33504ac476c5b Mon Sep 17 00:00:00 2001 From: sztomi Date: Sat, 15 Jul 2017 19:08:09 +0200 Subject: [PATCH 013/111] Fixed clang build --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 950ed44f..5a3f5592 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,10 @@ function(set_rpclib_flags TARGET) set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -std=c++11") endif() + if(RPCLIB_ENABLE_COVERAGE) + set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -g --coverage -O0") + endif() + if(RPCLIB_FORCE_M32) set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m32") elseif(RPCLIB_FORCE_M64) From 9885c01db61c6defd412b0c08602d9af5ddf2633 Mon Sep 17 00:00:00 2001 From: sztomi Date: Sat, 15 Jul 2017 19:09:47 +0200 Subject: [PATCH 014/111] Updated changelog --- CHANGELOG.md | 11 +++++++++++ CMakeLists.txt | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e79bb251..31857e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +### 2.1.1 + +This release fixes an embarrassing build breakage. + +Released on 2017-07-15. + +Changes since 2.1.1: + + * Fixes building with coverage using clang + + ### 2.1.0 This is mainly a bugfix release. diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a3f5592..bd605eb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,7 +97,9 @@ function(set_rpclib_flags TARGET) endif() if(RPCLIB_ENABLE_COVERAGE) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -g --coverage -O0") + set_target_properties(${TARGET} + PROPERTIES + LINK_FLAGS "-lgcov --coverage") endif() if(RPCLIB_FORCE_M32) @@ -118,7 +120,9 @@ function(set_rpclib_flags TARGET) endif() if(RPCLIB_ENABLE_COVERAGE) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -g --coverage -O0") + set_target_properties(${TARGET} + PROPERTIES + LINK_FLAGS "-lgcov --coverage") endif() if(RPCLIB_FORCE_M32) From f21c2f478612416c237206efad66c41d6516d978 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Tue, 25 Jul 2017 16:28:02 +0200 Subject: [PATCH 015/111] fix version.h location --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd605eb4..39bb2ee1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,7 +293,7 @@ install(DIRECTORY include/ PATTERN "*.hpp" PATTERN "*.inl" PATTERN "*.in" EXCLUDE) -install(FILES ${PROJECT_BINARY_DIR}/version.h DESTINATION include/rpc) +install(FILES ${PROJECT_SOURCE_DIR}/include/rpc/version.h DESTINATION include/rpc) if(RPCLIB_GENERATE_COMPDB) set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") # for YCM From 9c8ba8406533ddb93cae329122e7e9f21fb4be5e Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Tue, 25 Jul 2017 16:28:09 +0200 Subject: [PATCH 016/111] fix header --- examples/mandelbrot/mandelbrot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mandelbrot/mandelbrot.h b/examples/mandelbrot/mandelbrot.h index 0a6f9260..e0f52315 100644 --- a/examples/mandelbrot/mandelbrot.h +++ b/examples/mandelbrot/mandelbrot.h @@ -3,7 +3,7 @@ #ifndef MANDELBROT_H_I0UEF3KR #define MANDELBROT_H_I0UEF3KR -#include "msgpack.hpp" +#include "rpc/msgpack.hpp" #include struct pixel { From cb35f4ada549dc7bc39805f568c136da7dce1e0b Mon Sep 17 00:00:00 2001 From: tszelei Date: Wed, 26 Jul 2017 14:35:26 +0200 Subject: [PATCH 017/111] build: fixed build on macOS and removed warning reported in #142 --- include/rpc/nonstd/optional.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rpc/nonstd/optional.hpp b/include/rpc/nonstd/optional.hpp index e88a4318..d9888cf4 100644 --- a/include/rpc/nonstd/optional.hpp +++ b/include/rpc/nonstd/optional.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #define optional_lite_VERSION "2.0.0" @@ -1066,7 +1067,7 @@ using namespace optional_lite; namespace std { template< class T > -class hash< nonstd::optional > +struct hash< nonstd::optional > { public: std::size_t operator()( nonstd::optional const & v ) const optional_noexcept From 9183d77682572819446f3dd0fb8cae03166aaba3 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sun, 30 Jul 2017 18:08:49 +0200 Subject: [PATCH 018/111] add macOS build to travis Note : only linux builds the coveralls --- .travis.yml | 66 +++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c83802f..ac72c79a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,53 +1,43 @@ -dist: trusty -language: cpp -compiler: - #- clang - - g++ - -branches: - only: - - master - - dev - - osx_support +language: c++ +os: + - linux + - osx env: - global: - - CI_HOME=`pwd` + matrix: + - RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Debug + - RPCLIB_CXX_STANDARD=11 BUILD_TYPE=Debug + - RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Release + - RPCLIB_CXX_STANDARD=11 BUILD_TYPE=Release + +compiler: + - gcc + - clang addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.7 - - george-edison55-precise-backports packages: - - gcc-5 + - libsfml-dev - g++-5 - - cmake - - cmake-data + - gcc-5 + - clang-3.8 install: - - pip install --user cpp-coveralls - - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi + - if [ "$CXX" == "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi + - if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.8" CC="clang-3.8"; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install sfml llvm@3.8 gcc@5 ; fi + - if [ "$TRAVIS_OS_NAME" == "linux" ]; then pip install --user cpp-coveralls ; fi script: - - g++-5 --version - - gcc-5 --version - - cd $CI_HOME - - git submodule init - - git submodule update --init --recursive - - mkdir build14 && cd build14 - - cmake -DRPCLIB_ENABLE_COVERAGE=ON -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=14 .. - - make -j2 - - cd .. - - mkdir build11 && cd build11 - - cmake -DRPCLIB_ENABLE_COVERAGE=ON -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=11 .. - - make -j2 - - cd .. + - mkdir build ; cd build + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export COV=OFF ;else export COV=ON ; fi + - cmake -DRPCLIB_ENABLE_COVERAGE=$COV -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=$RPCLIB_CXX_STANDARD -DCMAKE_INSTALL_PREFIX=../install .. + - cmake --build . --config $BUILD_TYPE + - cmake --build . --target install after_success: - - ./build14/output/bin/rpc_test - - ./build11/output/bin/rpc_test - - coveralls --exclude dependencies --exclude test --exclude include/rpc/msgpack --exclude include/rcp/msgpack.hpp --gcov /usr/bin/gcov-5 - - + - ./output/bin/rpc_test + - if [ "$TRAVIS_OS_NAME" == "linux" ]; then coveralls --exclude dependencies --exclude test --exclude include/rpc/msgpack --exclude include/rcp/msgpack.hpp --gcov /usr/bin/gcov-5 ; fi From 71f701c9b65b48e233da75f9bf717c3c26138657 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sun, 30 Jul 2017 19:24:01 +0200 Subject: [PATCH 019/111] manually add trusty as default linux OS Trusty is planned to be default at the end of august 2017 : https://blog.travis-ci.com/2017-07-11-trusty-as-default-linux-is-coming --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index ac72c79a..c63e2ae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,13 @@ language: c++ os: - linux - osx + +matrix: + include: + - os: linux + dist: trusty + sudo: false + env: matrix: - RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Debug From 7d2c2f2c2ffb26e3601838c2f44704676d48b4a4 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sun, 30 Jul 2017 19:35:15 +0200 Subject: [PATCH 020/111] add llvm-toolchain-precise editing the include matrix does not seem to work --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index c63e2ae8..b5fb754c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,6 @@ os: - linux - osx -matrix: - include: - - os: linux - dist: trusty - sudo: false - env: matrix: - RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Debug @@ -24,6 +18,7 @@ compiler: addons: apt: sources: + - llvm-toolchain-precise - ubuntu-toolchain-r-test packages: - libsfml-dev From 4484c381b1363fd54fb726a1d5972ba75702867a Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sun, 30 Jul 2017 19:40:47 +0200 Subject: [PATCH 021/111] add cmake 3 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b5fb754c..e992954c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ addons: - g++-5 - gcc-5 - clang-3.8 + - cmake install: - if [ "$CXX" == "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi From 955138e88aaf19959fca9d5693b8ccf3213776af Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sun, 30 Jul 2017 19:50:39 +0200 Subject: [PATCH 022/111] add missing cmake 3 repo --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e992954c..9536bafe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,14 @@ addons: sources: - llvm-toolchain-precise - ubuntu-toolchain-r-test + - george-edison55-precise-backports packages: - libsfml-dev - g++-5 - gcc-5 - clang-3.8 - cmake + - cmake-data install: - if [ "$CXX" == "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi From 25eacaf56100ba778fe1425605f6812fe6387b3b Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sun, 30 Jul 2017 21:19:47 +0200 Subject: [PATCH 023/111] trying new llvm repo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9536bafe..de4fa969 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ compiler: addons: apt: sources: - - llvm-toolchain-precise + - llvm-toolchain-precise-3.8 - ubuntu-toolchain-r-test - george-edison55-precise-backports packages: From 98437b921466b9ebbd028ba4fa432358cc70e858 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Wed, 26 Jul 2017 20:40:17 +0200 Subject: [PATCH 024/111] add cmake config files and export targets Adds also the rpclib:: namespace --- CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++---- cmake/rpclibConfig.cmake.in | 10 ++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 cmake/rpclibConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 39bb2ee1..685a9480 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,9 +185,9 @@ function(set_rpclib_flags TARGET) target_link_libraries(${TARGET} ${RPCLIB_DEP_LIBRARIES}) target_include_directories( - ${TARGET} - PUBLIC include - PRIVATE include/rpc + ${TARGET} INTERFACE + $ + $ ) target_include_directories( ${TARGET} SYSTEM @@ -285,7 +285,7 @@ if (RPCLIB_MSVC_STATIC_RUNTIME) endif() -install(TARGETS ${OUTPUT_LIBRARY_NAME} DESTINATION lib) +install(TARGETS ${OUTPUT_LIBRARY_NAME} DESTINATION lib EXPORT rpclibTargets) install(DIRECTORY include/ DESTINATION include FILES_MATCHING @@ -293,7 +293,6 @@ install(DIRECTORY include/ PATTERN "*.hpp" PATTERN "*.inl" PATTERN "*.in" EXCLUDE) -install(FILES ${PROJECT_SOURCE_DIR}/include/rpc/version.h DESTINATION include/rpc) if(RPCLIB_GENERATE_COMPDB) set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") # for YCM @@ -364,6 +363,43 @@ if(RPCLIB_BUILD_EXAMPLES) endif() +################################################################################ +# +# Cmake Package +# +################################################################################ + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfigVersion.cmake" + VERSION ${RPCLIB_VERSION_MAJOR}.${RPCLIB_VERSION_MINOR}.${RPCLIB_VERSION_PATCH} + COMPATIBILITY AnyNewerVersion +) + +set(CONFIG_PACKAGE_LOCATION lib/cmake/rpclib) +set(INCLUDE_INSTALL_DIR include/ ) + +configure_package_config_file(cmake/rpclibConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfig.cmake + INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION} + PATH_VARS INCLUDE_INSTALL_DIR +) + +export(EXPORT rpclibTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibTargets.cmake" + NAMESPACE rpclib:: +) + +install(EXPORT rpclibTargets + FILE rpclibTargets.cmake + NAMESPACE rpclib:: + DESTINATION ${CONFIG_PACKAGE_LOCATION} +) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfigVersion.cmake + DESTINATION ${CONFIG_PACKAGE_LOCATION} +) ################################################################################ # # CPack diff --git a/cmake/rpclibConfig.cmake.in b/cmake/rpclibConfig.cmake.in new file mode 100644 index 00000000..1f7c385f --- /dev/null +++ b/cmake/rpclibConfig.cmake.in @@ -0,0 +1,10 @@ +# Example usage: +# find_package(rpclib REQUIRED) +# add_executable(foo main.cpp) +# target_link_libraries(foo rpclib::rpc) + +@PACKAGE_INIT@ + +set(RPCLIB_VERSION @RPCLIB_VERSION_MAJOR@.@RPCLIB_VERSION_MINOR@.@RPCLIB_VERSION_PATCH@) + +include("${CMAKE_CURRENT_LIST_DIR}/rpclibTargets.cmake") From 279d563eba0993974e7568765c2c3f4d18578284 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Fri, 28 Jul 2017 16:16:55 +0200 Subject: [PATCH 025/111] Use PUBLIC instead of INTERFACE Thanks to https://stackoverflow.com/questions/26243169/cmake-target-include-directories-meaning-of-scope --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 685a9480..703f373d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,8 +185,8 @@ function(set_rpclib_flags TARGET) target_link_libraries(${TARGET} ${RPCLIB_DEP_LIBRARIES}) target_include_directories( - ${TARGET} INTERFACE - $ + ${TARGET} PUBLIC + $ $ ) target_include_directories( From deee8cf297a2533973050e8e29fc7deb08540889 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Fri, 28 Jul 2017 16:17:03 +0200 Subject: [PATCH 026/111] fix test header --- tests/testutils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testutils.h b/tests/testutils.h index 6a92b006..bc8e7ccf 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -4,7 +4,7 @@ #define TESTUTILS_H_LHCAMVUX #include "gmock/gmock.h" -#include "msgpack.hpp" +#include "rpc/msgpack.hpp" #include #include #include From 7404a9fd1112a7a81ed6b213f3dfd605f052831c Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Fri, 28 Jul 2017 16:40:56 +0200 Subject: [PATCH 027/111] export c++ version flags in PUBLIC interface Removes deprecated COMPILE_FLAGS option --- CMakeLists.txt | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 703f373d..7ffab7b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,14 +86,15 @@ function(set_rpclib_flags TARGET) # but feel free to add similar flags to GCC if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - set(RPCLIB_BUILD_FLAGS - "-Wall -pedantic -Weverything -Wno-c++98-compat\ - -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-prototypes\ - -Wno-undef -pthread") + list(APPEND RPCLIB_BUILD_FLAGS + -Wall -pedantic -Weverything -Wno-c++98-compat + -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-prototypes + -Wno-undef -pthread) + if(RPCLIB_CXX_STANDARD EQUAL 14) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -std=c++14") + target_compile_options(${TARGET} PUBLIC -std=c++14) elseif(RPCLIB_CXX_STANDARD EQUAL 11) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -std=c++11") + target_compile_options(${TARGET} PUBLIC -std=c++11) endif() if(RPCLIB_ENABLE_COVERAGE) @@ -103,20 +104,20 @@ function(set_rpclib_flags TARGET) endif() if(RPCLIB_FORCE_M32) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m32") + list(APPEND RPCLIB_BUILD_FLAGS -m32) elseif(RPCLIB_FORCE_M64) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m64") + list(APPEND RPCLIB_BUILD_FLAGS -m64) endif() set(RPCLIB_DEP_LIBRARIES "pthread") elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - set(RPCLIB_BUILD_FLAGS "-Wall -pedantic -pthread") + list(APPEND RPCLIB_BUILD_FLAGS -Wall -pedantic -pthread) if(RPCLIB_CXX_STANDARD EQUAL 14) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -std=c++14") + target_compile_options(${TARGET} PUBLIC -std=c++14) elseif(RPCLIB_CXX_STANDARD EQUAL 11) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -std=c++11") + target_compile_options(${TARGET} PUBLIC -std=c++11) endif() if(RPCLIB_ENABLE_COVERAGE) @@ -126,9 +127,9 @@ function(set_rpclib_flags TARGET) endif() if(RPCLIB_FORCE_M32) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m32") + list(APPEND RPCLIB_BUILD_FLAGS -m32) elseif(RPCLIB_FORCE_M64) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} -m64") + list(APPEND RPCLIB_BUILD_FLAGS -m64) endif() set(RPCLIB_DEP_LIBRARIES "pthread") @@ -153,7 +154,7 @@ function(set_rpclib_flags TARGET) endif() if (RPCLIB_EXTRA_BUILD_FLAGS) - set(RPCLIB_BUILD_FLAGS "${RPCLIB_BUILD_FLAGS} ${RPCLIB_EXTRA_BUILD_FLAGS}") + list(APPEND RPCLIB_BUILD_FLAGS ${RPCLIB_EXTRA_BUILD_FLAGS}) endif() set(RPCLIB_COMPILE_DEFINITIONS @@ -172,9 +173,7 @@ function(set_rpclib_flags TARGET) endif() if(RPCLIB_BUILD_FLAGS) - set_target_properties(${TARGET} - PROPERTIES - COMPILE_FLAGS "${RPCLIB_BUILD_FLAGS}") + target_compile_options(${TARGET} PRIVATE ${RPCLIB_BUILD_FLAGS}) endif() if(RPCLIB_COMPILE_DEFINITIONS) From ad1387c72dfbe9ad8fa39e07d19fefbcb6349e39 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Fri, 28 Jul 2017 17:19:51 +0200 Subject: [PATCH 028/111] fix cmake policy CMP0054 --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ffab7b9..1a41a221 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,7 @@ function(set_rpclib_flags TARGET) # clang is the compiler used for developing mainly, so # this is where I set the highest warning level # but feel free to add similar flags to GCC - if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") list(APPEND RPCLIB_BUILD_FLAGS -Wall -pedantic -Weverything -Wno-c++98-compat @@ -111,7 +111,7 @@ function(set_rpclib_flags TARGET) set(RPCLIB_DEP_LIBRARIES "pthread") - elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") list(APPEND RPCLIB_BUILD_FLAGS -Wall -pedantic -pthread) if(RPCLIB_CXX_STANDARD EQUAL 14) @@ -134,7 +134,7 @@ function(set_rpclib_flags TARGET) set(RPCLIB_DEP_LIBRARIES "pthread") - elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(RPCLIB_COMPILE_DEFINITIONS "${RPCLIB_COMPILE_DEFINITIONS}" From 01d6e60fe321f19bef4f2b29beb7b78358e6f996 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Fri, 28 Jul 2017 17:20:03 +0200 Subject: [PATCH 029/111] fix test flags --- CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a41a221..0daac960 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,12 +333,11 @@ if(RPCLIB_BUILD_TESTS) # Set less strict warning for tests, since google test is not quite # warning-clean if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - get_target_property(ORIGINAL_FLAGS ${TEST_PROJECT_NAME} COMPILE_FLAGS) - set_target_properties(${TEST_PROJECT_NAME} PROPERTIES COMPILE_FLAGS - "${ORIGINAL_FLAGS} -Wno-sign-conversion -Wno-weak-vtables -Wno-unused-member-function \ - -Wno-global-constructors -Wno-used-but-marked-unused -Wno-covered-switch-default \ - -Wno-missing-variable-declarations -Wno-deprecated -Wno-unused-macros -Wno-undef \ - -Wno-exit-time-destructors -Wno-switch-enum -Wno-format-nonliteral -Wno-unused-parameter -Wno-disabled-macro-expansion") + get_target_property(ORIGINAL_FLAGS ${TEST_PROJECT_NAME} COMPILE_OPTION) + target_compile_options(${TEST_PROJECT_NAME} PRIVATE -Wno-sign-conversion -Wno-weak-vtables -Wno-unused-member-function + -Wno-global-constructors -Wno-used-but-marked-unused -Wno-covered-switch-default + -Wno-missing-variable-declarations -Wno-deprecated -Wno-unused-macros -Wno-undef + -Wno-exit-time-destructors -Wno-switch-enum -Wno-format-nonliteral -Wno-unused-parameter -Wno-disabled-macro-expansion) endif() endif() From a9a76c705147cb10662b478f3a83d5c9b8facfaa Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sat, 29 Jul 2017 15:45:05 +0200 Subject: [PATCH 030/111] reset flags in function --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0daac960..79a1b96f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,8 @@ function(set_rpclib_flags TARGET) # clang is the compiler used for developing mainly, so # this is where I set the highest warning level # but feel free to add similar flags to GCC + set(RPCLIB_BUILD_FLAGS "") # reset flags + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") list(APPEND RPCLIB_BUILD_FLAGS From 1630a8d03f864dc418d7987ecbe55e0d02f233b0 Mon Sep 17 00:00:00 2001 From: Antoine Hoarau Date: Sat, 29 Jul 2017 15:45:20 +0200 Subject: [PATCH 031/111] add pkg-config support --- CMakeLists.txt | 20 ++++++++++++++++++++ rpclib.pc.in | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100644 rpclib.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 79a1b96f..3b48fe16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -400,6 +400,26 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfigVersion.cmake DESTINATION ${CONFIG_PACKAGE_LOCATION} ) + +################################################################################ +# +# Pkg-config +# +################################################################################ +if(NOT MSVC) # Don't install pkg-config files when building with MSVC + # Variables for pkg-config files + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "") + set(libdir "${CMAKE_INSTALL_PREFIX}/lib") + set(includedir "${CMAKE_INSTALL_PREFIX}/include") + set(rpclib_version ${RPCLIB_VERSION_MAJOR}.${RPCLIB_VERSION_MINOR}.${RPCLIB_VERSION_PATCH}) + get_target_property(rpclib_cflags ${OUTPUT_LIBRARY_NAME} COMPILE_OPTIONS) + string(REPLACE ";" " " rpclib_cflags "${rpclib_cflags}") # Convert list to string + + configure_file(rpclib.pc.in "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" DESTINATION "${libdir}/pkgconfig") +endif() + ################################################################################ # # CPack diff --git a/rpclib.pc.in b/rpclib.pc.in new file mode 100644 index 00000000..10e5c16d --- /dev/null +++ b/rpclib.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: rpclib +Description: rpclib is a msgpack-rpc library written using modern C++ +Version: @rpclib_version@ +Libs: -L${libdir} -l@OUTPUT_LIBRARY_NAME@ +Cflags: -I${includedir} @rpclib_cflags@ \ No newline at end of file From 64188c5c9103f8d83d75fedd92fe09b101f2e4f3 Mon Sep 17 00:00:00 2001 From: sztomi Date: Sun, 17 Sep 2017 20:46:34 +0200 Subject: [PATCH 032/111] cmake: removed TargetArch and some useless stuff (#94) --- .travis.yml | 4 + CMakeLists.txt | 516 ++++++++++++--------------------------- cmake/TargetArch.cmake | 134 ---------- cmake/msvc_support.cmake | 55 +++++ cmake/policies.cmake | 2 + conanfile.txt | 5 + doc/pages/versions.md | 2 +- include/rpc/config.h | 2 +- include/rpc/version.h | 4 +- include/rpc/version.h.in | 6 +- tests/CMakeLists.txt | 35 +++ tests/rpc/client_test.cc | 12 +- 12 files changed, 269 insertions(+), 508 deletions(-) delete mode 100644 cmake/TargetArch.cmake create mode 100644 cmake/msvc_support.cmake create mode 100644 cmake/policies.cmake create mode 100644 conanfile.txt create mode 100644 tests/CMakeLists.txt diff --git a/.travis.yml b/.travis.yml index de4fa969..8a12bfe4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,9 +35,13 @@ install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install sfml llvm@3.8 gcc@5 ; fi - if [ "$TRAVIS_OS_NAME" == "linux" ]; then pip install --user cpp-coveralls ; fi + - pip install --user conan + - conan remote add conan-community https://api.bintray.com/conan/conan-community/conan script: - mkdir build ; cd build + - conan install .. -r conan-community + - . ./activate.sh - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export COV=OFF ;else export COV=ON ; fi - cmake -DRPCLIB_ENABLE_COVERAGE=$COV -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=$RPCLIB_CXX_STANDARD -DCMAKE_INSTALL_PREFIX=../install .. - cmake --build . --config $BUILD_TYPE diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b48fe16..7f120e4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,380 +1,211 @@ -cmake_minimum_required(VERSION 3.0.0) -project(rpc) +cmake_minimum_required(VERSION 3.9.0) +project(rpc VERSION 3.0.0) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") -################################################################################ +include(policies) +include(msvc_support) + # # Options # -################################################################################ - -option(RPCLIB_BUILD_TESTS "Build unit RPCLIB_BUILD_TESTS." OFF) -option(RPCLIB_GENERATE_COMPDB "Generate compilation database. Useful for YCM." OFF) -option(RPCLIB_BUILD_EXAMPLES "Build examples." OFF) -option(RPCLIB_ENABLE_LOGGING "ALlow logging in the library for debug purposes. Also usable in a release build." OFF) -option(RPCLIB_ENABLE_COVERAGE "Generate coverage information" OFF) -option(RPCLIB_FORCE_M64 "Force -m64 in CXXFLAGS" OFF) -option(RPCLIB_FORCE_M32 "Force -m32 in CXXFLAGS" OFF) -option(RPCLIB_MSVC_STATIC_RUNTIME "MSVC only: build with /MT instead of /MD" OFF) - -################################################################################ +option(RPCLIB_BUILD_TESTS + "Build unit RPCLIB_BUILD_TESTS." + OFF) +option(RPCLIB_GENERATE_COMPDB + "Generate compilation database. Useful for YCM." + OFF) +option(RPCLIB_BUILD_EXAMPLES + "Build examples." + OFF) +option(RPCLIB_ENABLE_LOGGING + "ALlow logging in the library for debug purposes." + OFF) +option(RPCLIB_ENABLE_COVERAGE + "Generate coverage information" + OFF) +option(RPCLIB_MSVC_STATIC_RUNTIME + "MSVC only: build with /MT instead of /MD" + OFF) + +# Perform steps and checks required for MSVC support +rpclib_msvc_support() + # # Other configuration values # -################################################################################ +set(RPCLIB_DEFAULT_PORT 8080 + CACHE STRING "Default port used for running tests and examples") +set(RPCLIB_DEFAULT_BUFFER_SIZE "1024 << 10" + CACHE STRING "Default buffer size") +set(RPCLIB_CXX_STANDARD 11 CACHE STRING + "C++ version used to build rpclib (Currently: Only 11 and 14 supported)") -set(RPCLIB_DEFAULT_PORT 8080 CACHE STRING "Default port used for running tests and examples") -set(RPCLIB_DEFAULT_BUFFER_SIZE "1024 << 10" CACHE STRING "Default buffer size") -set(RPCLIB_CXX_STANDARD 11 CACHE STRING "C++ version used to build rpclib (Currently: Only 11 and 14 supported)") +if(RPCLIB_GENERATE_COMPDB) + set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") # for YCM + add_custom_command(PROJECT_NAME ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_BINARY_DIR}/../compile_commands.json) +endif() -if(NOT ${RPCLIB_CXX_STANDARD} EQUAL 14 AND NOT ${RPCLIB_CXX_STANDARD} EQUAL 11) - message(fatal_error "Unsupported C++ standard: ${RPCLIB_CXX_STANDARD}") +if(NOT ${RPCLIB_CXX_STANDARD} EQUAL 14 AND + NOT ${RPCLIB_CXX_STANDARD} EQUAL 11) + message(fatal_error "Unsupported C++ standard: ${RPCLIB_CXX_STANDARD}") endif() -################################################################################ # # Compile & install the library # -################################################################################ - -include(TargetArch) - -set(RPCLIB_VERSION_MAJOR 2) -set(RPCLIB_VERSION_MINOR 1) -set(RPCLIB_VERSION_PATCH 0) - -target_architecture(TARGET_ARCH) - -if(RPCLIB_FORCE_M32) - message(STATUS "Compiling for 32-bit") - set(RPCLIB_ARCH_DEF "RPCLIB_ARCH_X86") - set(RPCLIB_TARGET_ARCH "x86") - set(RPCLIB_DEB_ARCH "i386") -elseif(RPCLIB_FORCE_M64) - message(STATUS "Compiling for 64-bit") - set(RPCLIB_ARCH_DEF "RPCLIB_ARCH_X64") - set(RPCLIB_TARGET_ARCH "x64") - set(RPCLIB_DEB_ARCH "amd64") -elseif (${TARGET_ARCH} STREQUAL "i386") - message(STATUS "Compiling for 32-bit") - set(RPCLIB_ARCH_DEF "RPCLIB_ARCH_X86") - set(RPCLIB_TARGET_ARCH "x86") - set(RPCLIB_DEB_ARCH "i386") -elseif(${TARGET_ARCH} STREQUAL "x86_64") - message(STATUS "Compiling for 64-bit") - set(RPCLIB_ARCH_DEF "RPCLIB_ARCH_X64") - set(RPCLIB_TARGET_ARCH "x64") - set(RPCLIB_DEB_ARCH "amd64") -endif() - if (WIN32) - set(RPCLIB_OS_DEF "RPCLIB_WIN32") + set(RPCLIB_OS_DEF "RPCLIB_WIN32") elseif (LINUX) - set(RPCLIB_OS_DEF "RPCLIB_LINUX") + set(RPCLIB_OS_DEF "RPCLIB_LINUX") elseif (APPLE) - set(RPCLIB_OS_DEF "RPCLIB_MAC") + set(RPCLIB_OS_DEF "RPCLIB_MAC") endif() -# This function sets the rpclib-specific flags that are used for -# development. You do not need this in your project. Instead, -# Findrpclib.cmake supplies a (possibly empty) RPCLIB_EXTRA_FLAGS variable -# that you should append to your build flags. -function(set_rpclib_flags TARGET) - # clang is the compiler used for developing mainly, so - # this is where I set the highest warning level - # but feel free to add similar flags to GCC - set(RPCLIB_BUILD_FLAGS "") # reset flags - - if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - - list(APPEND RPCLIB_BUILD_FLAGS - -Wall -pedantic -Weverything -Wno-c++98-compat - -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-prototypes - -Wno-undef -pthread) - - if(RPCLIB_CXX_STANDARD EQUAL 14) - target_compile_options(${TARGET} PUBLIC -std=c++14) - elseif(RPCLIB_CXX_STANDARD EQUAL 11) - target_compile_options(${TARGET} PUBLIC -std=c++11) - endif() - - if(RPCLIB_ENABLE_COVERAGE) - set_target_properties(${TARGET} - PROPERTIES - LINK_FLAGS "-lgcov --coverage") - endif() - - if(RPCLIB_FORCE_M32) - list(APPEND RPCLIB_BUILD_FLAGS -m32) - elseif(RPCLIB_FORCE_M64) - list(APPEND RPCLIB_BUILD_FLAGS -m64) - endif() - - set(RPCLIB_DEP_LIBRARIES "pthread") - - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - - list(APPEND RPCLIB_BUILD_FLAGS -Wall -pedantic -pthread) - if(RPCLIB_CXX_STANDARD EQUAL 14) - target_compile_options(${TARGET} PUBLIC -std=c++14) - elseif(RPCLIB_CXX_STANDARD EQUAL 11) - target_compile_options(${TARGET} PUBLIC -std=c++11) - endif() - - if(RPCLIB_ENABLE_COVERAGE) - set_target_properties(${TARGET} - PROPERTIES - LINK_FLAGS "-lgcov --coverage") - endif() - - if(RPCLIB_FORCE_M32) - list(APPEND RPCLIB_BUILD_FLAGS -m32) - elseif(RPCLIB_FORCE_M64) - list(APPEND RPCLIB_BUILD_FLAGS -m64) - endif() - - set(RPCLIB_DEP_LIBRARIES "pthread") - - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - - set(RPCLIB_COMPILE_DEFINITIONS - "${RPCLIB_COMPILE_DEFINITIONS}" - "WIN32_LEAN_AND_MEAN" - "NOMINMAX" - "VC_EXTRALEAN" - "_CRT_SECURE_NO_WARNINGS" - "_CRT_NONSTDC_NO_DEPRECATE" - "_WIN32_WINNT=0x0501" - "_GNU_SOURCE" - "ASIO_HAS_STD_ADDRESSOF" - "ASIO_HAS_STD_ARRAY" - "ASIO_HAS_CSTDINT" - "ASIO_HAS_STD_SHARED_PTR" - "ASIO_HAS_STD_TYPE_TRAITS") - - endif() - - if (RPCLIB_EXTRA_BUILD_FLAGS) - list(APPEND RPCLIB_BUILD_FLAGS ${RPCLIB_EXTRA_BUILD_FLAGS}) - endif() - - set(RPCLIB_COMPILE_DEFINITIONS - "${RPCLIB_COMPILE_DEFINITIONS}" - "${RPCLIB_ARCH_DEF}" - "${RPCLIB_OS_DEF}" - "ASIO_STANDALONE" - "RPCLIB_ASIO=clmdep_asio" - "RPCLIB_FMT=clmdep_fmt" - "RPCLIB_MSGPACK=clmdep_msgpack" - ) - - if(RPCLIB_ENABLE_LOGGING) - set(RPCLIB_COMPILE_DEFINITIONS - "${RPCLIB_COMPILE_DEFINITIONS};RPCLIB_ENABLE_LOGGING") - endif() - - if(RPCLIB_BUILD_FLAGS) - target_compile_options(${TARGET} PRIVATE ${RPCLIB_BUILD_FLAGS}) - endif() - - if(RPCLIB_COMPILE_DEFINITIONS) - set_target_properties(${TARGET} - PROPERTIES - COMPILE_DEFINITIONS "${RPCLIB_COMPILE_DEFINITIONS}") - endif() - - target_link_libraries(${TARGET} ${RPCLIB_DEP_LIBRARIES}) - target_include_directories( - ${TARGET} PUBLIC - $ - $ - ) - target_include_directories( - ${TARGET} SYSTEM - PRIVATE dependencies/include - ) - -endfunction() - -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin) +set(RPCLIB_DEPENDENCIES "${CMAKE_CURRENT_LIST_DIR}/dependencies") configure_file( - "${PROJECT_SOURCE_DIR}/include/rpc/version.h.in" - "${PROJECT_SOURCE_DIR}/include/rpc/version.h") + "${PROJECT_SOURCE_DIR}/include/rpc/version.h.in" + "${PROJECT_SOURCE_DIR}/include/rpc/version.h") configure_file( - "${PROJECT_SOURCE_DIR}/include/rpc/config.h.in" - "${PROJECT_SOURCE_DIR}/include/rpc/config.h") + "${PROJECT_SOURCE_DIR}/include/rpc/config.h.in" + "${PROJECT_SOURCE_DIR}/include/rpc/config.h") configure_file( - "${PROJECT_SOURCE_DIR}/doc/pages/versions.md.in" - "${PROJECT_SOURCE_DIR}/doc/pages/versions.md") + "${PROJECT_SOURCE_DIR}/doc/pages/versions.md.in" + "${PROJECT_SOURCE_DIR}/doc/pages/versions.md") file(GLOB_RECURSE RPCLIB_HEADERS - include/rpc/*.h - include/msgpack/*.hpp) + include/rpc/*.h + include/msgpack/*.hpp) file(GLOB_RECURSE DEP_HEADERS - dependencies/include/*.h - dependencies/include/*.hpp) + ${RPCLIB_DEPENDENCIES}/include/*.h + ${RPCLIB_DEP_LIBRARIDEPENDENCIES}/include/*.hpp) -if(RPCLIB_NAME_SUFFIX) - set(OUTPUT_LIBRARY_NAME ${CMAKE_PROJECT_NAME}-${RPCLIB_NAME_SUFFIX}) -else() - set(OUTPUT_LIBRARY_NAME ${CMAKE_PROJECT_NAME}) +set(DEP_SOURCES + ${RPCLIB_DEPENDENCIES}/src/format.cc + ${RPCLIB_DEPENDENCIES}/src/posix.cc) + +add_library(${PROJECT_NAME} + lib/rpc/dispatcher.cc + lib/rpc/server.cc + lib/rpc/client.cc + lib/rpc/this_handler.cc + lib/rpc/this_session.cc + lib/rpc/this_server.cc + lib/rpc/rpc_error.cc + lib/rpc/detail/server_session.cc + lib/rpc/detail/response.cc + lib/rpc/detail/client_error.cc + lib/rpc/nonstd/optional.cc + ${DEP_SOURCES} + ${DEP_HEADERS} + ${RPCLIB_HEADERS}) + +set(RPCLIB_BUILD_FLAGS "") # reset flags + +if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + target_compile_options(${PROJECT_NAME} PUBLIC + -std=c++${RPCLIB_CXX_STANDARD}) endif() -set(DEP_SOURCES - dependencies/src/format.cc - dependencies/src/posix.cc) - -add_library(${OUTPUT_LIBRARY_NAME} - lib/rpc/dispatcher.cc - lib/rpc/server.cc - lib/rpc/client.cc - lib/rpc/this_handler.cc - lib/rpc/this_session.cc - lib/rpc/this_server.cc - lib/rpc/rpc_error.cc - lib/rpc/detail/server_session.cc - lib/rpc/detail/response.cc - lib/rpc/detail/client_error.cc - lib/rpc/nonstd/optional.cc - ${DEP_SOURCES} - ${DEP_HEADERS} - ${RPCLIB_HEADERS}) - - -set_rpclib_flags(${OUTPUT_LIBRARY_NAME}) - -target_link_libraries(${OUTPUT_LIBRARY_NAME}) - -# When building via conan, respect the compilation settings. -if ("${CONAN_LINK_RUNTIME}" STREQUAL "/MT") - set(RPCLIB_MSVC_STATIC_RUNTIME ON) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + # clang is the compiler used for developing mainly, so + # this is where I set the highest warning level + list(APPEND RPCLIB_BUILD_FLAGS + -Wall -pedantic -Weverything -Wno-c++98-compat + -Wno-c++98-compat-pedantic -Wno-padded -Wno-missing-prototypes + -Wno-undef -pthread) endif() -# MSVC static runtime support -# -# While this pollutes global flags (when using add_library), you would not want to -# build with a disparity anyway. (also, CMake still has no support for this, so you -# would end up doing something like this yourself). -if (RPCLIB_MSVC_STATIC_RUNTIME) - # Set compiler options. - set(variables - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_DEBUG - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_RELWITHDEBINFO - ) - - message(STATUS - "MSVC -> forcing use of statically-linked runtime." - ) - - foreach(variable ${variables}) - if(${variable} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") - endif() - endforeach() +if(RPCLIB_ENABLE_COVERAGE) + target_compile_options(${PROJECT_NAME} PUBLIC "--coverage") + # yes, this is ugly as "--coverage" is not a library, but a flag. + # however, this does not work with the LINK_FLAGS target property + list(APPEND RPCLIB_DEP_LIBRARIES "--coverage") +endif() +if (RPCLIB_EXTRA_BUILD_FLAGS) + list(APPEND RPCLIB_BUILD_FLAGS ${RPCLIB_EXTRA_BUILD_FLAGS}) endif() -install(TARGETS ${OUTPUT_LIBRARY_NAME} DESTINATION lib EXPORT rpclibTargets) -install(DIRECTORY include/ - DESTINATION include - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.inl" - PATTERN "*.in" EXCLUDE) +target_compile_definitions(${PROJECT_NAME} PRIVATE + "${RPCLIB_COMPILE_DEFINITIONS}" + "${RPCLIB_ARCH_DEF}" + "${RPCLIB_OS_DEF}" + "ASIO_STANDALONE" + "RPCLIB_ASIO=clmdep_asio" + "RPCLIB_FMT=clmdep_fmt") -if(RPCLIB_GENERATE_COMPDB) - set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") # for YCM - add_custom_command(TARGET ${OUTPUT_LIBRARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_BINARY_DIR}/../compile_commands.json) +target_compile_definitions(${PROJECT_NAME} PUBLIC + "RPCLIB_MSGPACK=clmdep_msgpack") + +if(RPCLIB_ENABLE_LOGGING) + target_compile_definitions(${PROJECT_NAME} PRIVATE "RPCLIB_ENABLE_LOGGING") +endif() + +if(RPCLIB_BUILD_FLAGS) + target_compile_options(${PROJECT_NAME} PRIVATE ${RPCLIB_BUILD_FLAGS}) endif() -################################################################################ +if(RPCLIB_COMPILE_DEFINITIONS) + set_target_properties(${PROJECT_NAME} + PROPERTIES + COMPILE_DEFINITIONS "${RPCLIB_COMPILE_DEFINITIONS}") +endif() + +target_link_libraries(${PROJECT_NAME} ${RPCLIB_DEP_LIBRARIES}) +target_include_directories( + ${PROJECT_NAME} PUBLIC + $ + $ + ) +target_include_directories( + ${PROJECT_NAME} SYSTEM + PRIVATE ${RPCLIB_DEPENDENCIES}/include + ) + +install(TARGETS ${PROJECT_NAME} DESTINATION lib EXPORT rpclibTargets) +install(DIRECTORY include/ + DESTINATION include + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.inl" + PATTERN "*.in" EXCLUDE) + # # Unit tests # -################################################################################ - if(RPCLIB_BUILD_TESTS) - set(TEST_PROJECT_NAME ${CMAKE_PROJECT_NAME}_test) - set(TEST_SOURCES - dependencies/src/gmock-gtest-all.cc - tests/testmain.cc - tests/testutils.h - tests/rpc/dispatcher_test.cc - tests/rpc/client_test.cc - tests/rpc/response_test.cc - tests/rpc/server_test.cc - tests/rpc/this_handler_test.cc - tests/rpc/this_session_test.cc - tests/rpc/server_session_test.cc - tests/rpc/this_server_test.cc) - - - add_executable(${TEST_PROJECT_NAME} ${TEST_SOURCES}) - set_rpclib_flags(${TEST_PROJECT_NAME}) - target_include_directories(${TEST_PROJECT_NAME} SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/tests") - target_link_libraries( - ${TEST_PROJECT_NAME} - ${OUTPUT_LIBRARY_NAME} - ${RPCLIB_DEP_LIBRARIES}) - - # Set less strict warning for tests, since google test is not quite - # warning-clean - if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - get_target_property(ORIGINAL_FLAGS ${TEST_PROJECT_NAME} COMPILE_OPTION) - target_compile_options(${TEST_PROJECT_NAME} PRIVATE -Wno-sign-conversion -Wno-weak-vtables -Wno-unused-member-function - -Wno-global-constructors -Wno-used-but-marked-unused -Wno-covered-switch-default - -Wno-missing-variable-declarations -Wno-deprecated -Wno-unused-macros -Wno-undef - -Wno-exit-time-destructors -Wno-switch-enum -Wno-format-nonliteral -Wno-unused-parameter -Wno-disabled-macro-expansion) - endif() - + add_subdirectory(tests) endif() -################################################################################ # # Example programs # -################################################################################ - if(RPCLIB_BUILD_EXAMPLES) - set(RPCLIB_ROOT_DIR "${PROJECT_SOURCE_DIR}") - set(RPCLIB_PROJECT_NAME "${CMAKE_PROJECT_NAME}") - set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/localbuild") - set(ENV{RPCLIB_DEFAULT_PORT} "${RPCLIB_DEFAULT_PORT}") - #add_subdirectory(examples/server) - #add_subdirectory(examples/client) - add_subdirectory(examples/echo) - add_subdirectory(examples/mandelbrot) - add_subdirectory(examples/calculator) + set(RPCLIB_ROOT_DIR "${PROJECT_SOURCE_DIR}") + set(RPCLIB_PROJECT_NAME "${CMAKE_PROJECT_NAME}") + set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/localbuild") + set(ENV{RPCLIB_DEFAULT_PORT} "${RPCLIB_DEFAULT_PORT}") + add_subdirectory(examples/echo) + add_subdirectory(examples/mandelbrot) + add_subdirectory(examples/calculator) endif() - -################################################################################ # # Cmake Package # -################################################################################ - include(CMakePackageConfigHelpers) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfigVersion.cmake" - VERSION ${RPCLIB_VERSION_MAJOR}.${RPCLIB_VERSION_MINOR}.${RPCLIB_VERSION_PATCH} + VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion -) + ) set(CONFIG_PACKAGE_LOCATION lib/cmake/rpclib) set(INCLUDE_INSTALL_DIR include/ ) @@ -383,77 +214,38 @@ configure_package_config_file(cmake/rpclibConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfig.cmake INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION} PATH_VARS INCLUDE_INSTALL_DIR -) + ) export(EXPORT rpclibTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibTargets.cmake" NAMESPACE rpclib:: -) + ) install(EXPORT rpclibTargets FILE rpclibTargets.cmake NAMESPACE rpclib:: DESTINATION ${CONFIG_PACKAGE_LOCATION} -) + ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/rpclibConfigVersion.cmake DESTINATION ${CONFIG_PACKAGE_LOCATION} -) + ) -################################################################################ # # Pkg-config # -################################################################################ if(NOT MSVC) # Don't install pkg-config files when building with MSVC # Variables for pkg-config files set(prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "") set(libdir "${CMAKE_INSTALL_PREFIX}/lib") set(includedir "${CMAKE_INSTALL_PREFIX}/include") - set(rpclib_version ${RPCLIB_VERSION_MAJOR}.${RPCLIB_VERSION_MINOR}.${RPCLIB_VERSION_PATCH}) - get_target_property(rpclib_cflags ${OUTPUT_LIBRARY_NAME} COMPILE_OPTIONS) + set(rpclib_version ${PROJECT_VERSION}) + get_target_property(rpclib_cflags ${PROJECT_NAME} COMPILE_OPTIONS) string(REPLACE ";" " " rpclib_cflags "${rpclib_cflags}") # Convert list to string configure_file(rpclib.pc.in "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rpclib.pc" DESTINATION "${libdir}/pkgconfig") endif() -################################################################################ -# -# CPack -# -################################################################################ - -include(InstallRequiredSystemLibraries) - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Modern msgpack-rpc library for C++") -set(CPACK_PACKAGE_DESCRIPTION "rpclib is a modern msgpack-rpc library for C++. It allows connecting applications through a network channel where they can talk to each other using the msgpack-rpc protocol. It provides both a client and server, which can be used independently.") -set(CPACK_PACKAGE_VENDOR "Tamás Szelei") -set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md") -set(CPACK_PACKAGE_VERSION_MAJOR "${RPCLIB_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${RPCLIB_VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${RPCLIB_VERSION_PATCH}") -set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/output/pkg") -set(CPACK_PACKAGE_EXECUTABLES "librpc" "rpc") -set(CPACK_PACKAGE_NAME "lib${CMAKE_PROJECT_NAME}_${RPCLIB_DEB_ARCH}") -set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${RPCLIB_DEB_ARCH}) -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Tamás Szelei") -set(CPACK_DEBIAN_PACKAGE_CONTACT "Tamás Szelei") -if(WIN32) - set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") -endif() - -if(WIN32) - #set(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp") - #set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe") - set(CPACK_PACKAGE_INSTALL_DIRECTORY "librpc ${RPCLIB_VERSION_MAJOR}.${RPCLIB_VERSION_MINOR}.${RPCLIB_VERSION_PATCH}") - set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} rpclib") - #set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org") - set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\github.com/sztomi/rpc") - #set(CPACK_NSIS_CONTACT "me@my-personal-home-page.com") - set(CPACK_NSIS_MODIFY_PATH ON) -endif() -include(CPack) diff --git a/cmake/TargetArch.cmake b/cmake/TargetArch.cmake deleted file mode 100644 index 3761e4df..00000000 --- a/cmake/TargetArch.cmake +++ /dev/null @@ -1,134 +0,0 @@ -# Based on the Qt 5 processor detection code, so should be very accurate -# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h -# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) - -# Regarding POWER/PowerPC, just as is noted in the Qt source, -# "There are many more known variants/revisions that we do not handle/detect." - -set(archdetect_c_code " -#if defined(__arm__) || defined(__TARGET_ARCH_ARM) - #if defined(__ARM_ARCH_7__) \\ - || defined(__ARM_ARCH_7A__) \\ - || defined(__ARM_ARCH_7R__) \\ - || defined(__ARM_ARCH_7M__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) - #error cmake_ARCH armv7 - #elif defined(__ARM_ARCH_6__) \\ - || defined(__ARM_ARCH_6J__) \\ - || defined(__ARM_ARCH_6T2__) \\ - || defined(__ARM_ARCH_6Z__) \\ - || defined(__ARM_ARCH_6K__) \\ - || defined(__ARM_ARCH_6ZK__) \\ - || defined(__ARM_ARCH_6M__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) - #error cmake_ARCH armv6 - #elif defined(__ARM_ARCH_5TEJ__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) - #error cmake_ARCH armv5 - #else - #error cmake_ARCH arm - #endif -#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) - #error cmake_ARCH i386 -#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) - #error cmake_ARCH x86_64 -#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) - #error cmake_ARCH ia64 -#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ - || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ - || defined(_M_MPPC) || defined(_M_PPC) - #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) - #error cmake_ARCH ppc64 - #else - #error cmake_ARCH ppc - #endif -#endif - -#error cmake_ARCH unknown -") - -# Set ppc_support to TRUE before including this file or ppc and ppc64 -# will be treated as invalid architectures since they are no longer supported by Apple - -function(target_architecture output_var) - if(APPLE AND CMAKE_OSX_ARCHITECTURES) - # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set - # First let's normalize the order of the values - - # Note that it's not possible to compile PowerPC applications if you are using - # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we - # disable it by default - # See this page for more information: - # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 - - # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. - # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. - - foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) - if("${osx_arch}" STREQUAL "ppc" AND ppc_support) - set(osx_arch_ppc TRUE) - elseif("${osx_arch}" STREQUAL "i386") - set(osx_arch_i386 TRUE) - elseif("${osx_arch}" STREQUAL "x86_64") - set(osx_arch_x86_64 TRUE) - elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) - set(osx_arch_ppc64 TRUE) - else() - message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") - endif() - endforeach() - - # Now add all the architectures in our normalized order - if(osx_arch_ppc) - list(APPEND ARCH ppc) - endif() - - if(osx_arch_i386) - list(APPEND ARCH i386) - endif() - - if(osx_arch_x86_64) - list(APPEND ARCH x86_64) - endif() - - if(osx_arch_ppc64) - list(APPEND ARCH ppc64) - endif() - else() - file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") - - enable_language(C) - - # Detect the architecture in a rather creative way... - # This compiles a small C program which is a series of ifdefs that selects a - # particular #error preprocessor directive whose message string contains the - # target architecture. The program will always fail to compile (both because - # file is not a valid C program, and obviously because of the presence of the - # #error preprocessor directives... but by exploiting the preprocessor in this - # way, we can detect the correct target architecture even when cross-compiling, - # since the program itself never needs to be run (only the compiler/preprocessor) - try_run( - run_result_unused - compile_result_unused - "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}/arch.c" - COMPILE_OUTPUT_VARIABLE ARCH - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - ) - - # Parse the architecture name from the compiler output - string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") - - # Get rid of the value marker leaving just the architecture name - string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") - - # If we are compiling with an unknown architecture this variable should - # already be set to "unknown" but in the case that it's empty (i.e. due - # to a typo in the code), then set it to unknown - if (NOT ARCH) - set(ARCH unknown) - endif() - endif() - - set(${output_var} "${ARCH}" PARENT_SCOPE) -endfunction() diff --git a/cmake/msvc_support.cmake b/cmake/msvc_support.cmake new file mode 100644 index 00000000..a063bf8c --- /dev/null +++ b/cmake/msvc_support.cmake @@ -0,0 +1,55 @@ + +function(rpclib_msvc_support) + if(MSVC) + # When building via conan, respect the compilation settings. + if ("${CONAN_LINK_RUNTIME}" STREQUAL "/MT") + set(RPCLIB_MSVC_STATIC_RUNTIME ON) + endif() + + if(RPCLIB_ENABLE_COVERAGE) + message(FATAL_ERROR "Coverage is only supported with non-MS compilers") + endif() + + target_compile_definitions(${PROJECT_NAME} PRIVATE + "WIN32_LEAN_AND_MEAN" + "NOMINMAX" + "VC_EXTRALEAN" + "_CRT_SECURE_NO_WARNINGS" + "_CRT_NONSTDC_NO_DEPRECATE" + "_WIN32_WINNT=0x0501" + "_GNU_SOURCE" + "ASIO_HAS_STD_ADDRESSOF" + "ASIO_HAS_STD_ARRAY" + "ASIO_HAS_CSTDINT" + "ASIO_HAS_STD_SHARED_PTR" + "ASIO_HAS_STD_TYPE_TRAITS") + + # MSVC static runtime support + # + # While this pollutes global flags (when using add_library), you would not want to + # build with a disparity anyway. (also, CMake still has no support for this, so you + # would end up doing something like this yourself). + if (RPCLIB_MSVC_STATIC_RUNTIME) + set(variables + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELWITHDEBINFO + ) + message(STATUS + "MSVC -> forcing use of statically-linked runtime." + ) + + foreach(variable ${variables}) + if(${variable} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}") + endif() + endforeach() + + endif() + endif() +endfunction() diff --git a/cmake/policies.cmake b/cmake/policies.cmake new file mode 100644 index 00000000..914d69a6 --- /dev/null +++ b/cmake/policies.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0054 NEW) + diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 00000000..0911f43d --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,5 @@ +[requires] +cmake_installer/1.0@conan/stable + +[generators] +virtualenv diff --git a/doc/pages/versions.md b/doc/pages/versions.md index 971a2108..7fcf6355 100644 --- a/doc/pages/versions.md +++ b/doc/pages/versions.md @@ -1,4 +1,4 @@ -You are reading the documentation of 2.1.0. +You are reading the documentation of ... If, for some reason you need the documentation of older versions, you can download them from this page. * [1.0.0](/archive/rpclib_docs_1.0.0.zip) diff --git a/include/rpc/config.h b/include/rpc/config.h index 06890879..66620ef3 100644 --- a/include/rpc/config.h +++ b/include/rpc/config.h @@ -30,7 +30,7 @@ struct constants RPCLIB_FINAL { #endif /* ifndef RPCLIB_MSGPACK */ #ifndef RPCLIB_CXX_STANDARD -#define RPCLIB_CXX_STANDARD 14 +#define RPCLIB_CXX_STANDARD 11 #endif #endif /* end of include guard: CONFIG_H_L7IVDSPZ */ diff --git a/include/rpc/version.h b/include/rpc/version.h index 54e2899e..f5c0a1df 100644 --- a/include/rpc/version.h +++ b/include/rpc/version.h @@ -5,8 +5,8 @@ namespace rpc { -static constexpr unsigned VERSION_MAJOR = 2; -static constexpr unsigned VERSION_MINOR = 1; +static constexpr unsigned VERSION_MAJOR = 3; +static constexpr unsigned VERSION_MINOR = 0; static constexpr unsigned VERSION_PATCH = 0; } /* rpc */ diff --git a/include/rpc/version.h.in b/include/rpc/version.h.in index f278fa79..d6edfd8f 100644 --- a/include/rpc/version.h.in +++ b/include/rpc/version.h.in @@ -5,9 +5,9 @@ namespace rpc { -static constexpr unsigned VERSION_MAJOR = @RPCLIB_VERSION_MAJOR@; -static constexpr unsigned VERSION_MINOR = @RPCLIB_VERSION_MINOR@; -static constexpr unsigned VERSION_PATCH = @RPCLIB_VERSION_PATCH@; +static constexpr unsigned VERSION_MAJOR = @rpc_VERSION_MAJOR@; +static constexpr unsigned VERSION_MINOR = @rpc_VERSION_MINOR@; +static constexpr unsigned VERSION_PATCH = @rpc_VERSION_PATCH@; } /* rpc */ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..73e522a4 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,35 @@ +set(TEST_PROJECT_NAME ${CMAKE_PROJECT_NAME}_test) +set(TEST_SOURCES + ${RPCLIB_DEPENDENCIES}/src/gmock-gtest-all.cc + testmain.cc + testutils.h + rpc/dispatcher_test.cc + rpc/client_test.cc + rpc/response_test.cc + rpc/server_test.cc + rpc/this_handler_test.cc + rpc/this_session_test.cc + rpc/server_session_test.cc + rpc/this_server_test.cc) + +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) + +add_executable(${TEST_PROJECT_NAME} ${TEST_SOURCES}) + +target_include_directories(${TEST_PROJECT_NAME} + SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/tests" + PRIVATE "${RPCLIB_DEPENDENCIES}/include") + +target_link_libraries(${TEST_PROJECT_NAME} ${PROJECT_NAME} Threads::Threads) + +# Set less strict warning for tests, since google test is not quite +# warning-clean +if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + get_target_property(ORIGINAL_FLAGS ${TEST_PROJECT_NAME} COMPILE_OPTION) + target_compile_options(${TEST_PROJECT_NAME} PRIVATE -Wno-sign-conversion -Wno-weak-vtables -Wno-unused-member-function + -Wno-global-constructors -Wno-used-but-marked-unused -Wno-covered-switch-default + -Wno-missing-variable-declarations -Wno-deprecated -Wno-unused-macros -Wno-undef + -Wno-exit-time-destructors -Wno-switch-enum -Wno-format-nonliteral -Wno-unused-parameter -Wno-disabled-macro-expansion) +endif() + diff --git a/tests/rpc/client_test.cc b/tests/rpc/client_test.cc index 36363a1b..bf44e107 100644 --- a/tests/rpc/client_test.cc +++ b/tests/rpc/client_test.cc @@ -4,8 +4,8 @@ #include "rpc/server.h" #include "rpc/rpc_error.h" #include "testutils.h" -#include "format.h" +#include #include #include @@ -88,10 +88,12 @@ TEST_F(client_test, timeout_right_msg) { client.call("sleep", short_timeout + 10); FAIL() << "There was no exception thrown."; } catch (rpc::timeout &t) { - auto expected_msg = RPCLIB_FMT::format( - "rpc::timeout: Timeout of {}ms while calling RPC function '{}'", - *client.get_timeout(), "sleep"); - EXPECT_TRUE(str_match(t.what(), expected_msg)); + std::stringstream ss; + ss + << "rpc::timeout: Timeout of " + << *client.get_timeout() + << "ms while calling RPC function 'sleep'"; + EXPECT_TRUE(str_match(t.what(), ss.str())); } } From a0289864cb81e4b5aa4b5210d06a48e8144c71fd Mon Sep 17 00:00:00 2001 From: sztomi Date: Mon, 18 Sep 2017 16:49:45 +0200 Subject: [PATCH 033/111] ci: removed osx and debug configs TravisCI OSX builds take forever to start so I'm removing them in hopes of better build times. Debug builds are removed for a similar reason. --- .travis.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a12bfe4..45e75ae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,9 @@ language: c++ os: - linux - - osx env: matrix: - - RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Debug - - RPCLIB_CXX_STANDARD=11 BUILD_TYPE=Debug - RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Release - RPCLIB_CXX_STANDARD=11 BUILD_TYPE=Release @@ -32,9 +29,7 @@ addons: install: - if [ "$CXX" == "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi - if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.8" CC="clang-3.8"; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install sfml llvm@3.8 gcc@5 ; fi - - if [ "$TRAVIS_OS_NAME" == "linux" ]; then pip install --user cpp-coveralls ; fi + - pip install --user cpp-coveralls - pip install --user conan - conan remote add conan-community https://api.bintray.com/conan/conan-community/conan @@ -42,11 +37,10 @@ script: - mkdir build ; cd build - conan install .. -r conan-community - . ./activate.sh - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export COV=OFF ;else export COV=ON ; fi - cmake -DRPCLIB_ENABLE_COVERAGE=$COV -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=$RPCLIB_CXX_STANDARD -DCMAKE_INSTALL_PREFIX=../install .. - cmake --build . --config $BUILD_TYPE - cmake --build . --target install after_success: - ./output/bin/rpc_test - - if [ "$TRAVIS_OS_NAME" == "linux" ]; then coveralls --exclude dependencies --exclude test --exclude include/rpc/msgpack --exclude include/rcp/msgpack.hpp --gcov /usr/bin/gcov-5 ; fi + - coveralls --exclude dependencies --exclude test --exclude include/rpc/msgpack --exclude include/rcp/msgpack.hpp --gcov /usr/bin/gcov-5 From e4081aa5521dbb33525ae6754c7aa903c8b5429a Mon Sep 17 00:00:00 2001 From: sztomi Date: Mon, 18 Sep 2017 19:20:36 +0200 Subject: [PATCH 034/111] server_session: stop reading when exit_ is set --- lib/rpc/detail/server_session.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rpc/detail/server_session.cc b/lib/rpc/detail/server_session.cc index bd5e0d73..56b16e5a 100644 --- a/lib/rpc/detail/server_session.cc +++ b/lib/rpc/detail/server_session.cc @@ -49,6 +49,7 @@ void server_session::do_read() { // (since it's constexpr), but MSVC insists. read_strand_.wrap([this, self, max_read_bytes](std::error_code ec, std::size_t length) { + if (exit_) { return; } if (!ec) { pac_.buffer_consumed(length); RPCLIB_MSGPACK::unpacked result; From b275f8e6a2048a9554f830ce2241aa684f6a24cf Mon Sep 17 00:00:00 2001 From: sztomi Date: Mon, 18 Sep 2017 19:21:13 +0200 Subject: [PATCH 035/111] server_session: test only 1000 connections to save time --- tests/rpc/server_session_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rpc/server_session_test.cc b/tests/rpc/server_session_test.cc index e2cca3bb..2e21161c 100644 --- a/tests/rpc/server_session_test.cc +++ b/tests/rpc/server_session_test.cc @@ -32,7 +32,7 @@ TEST_F(server_session_test, consume_big_param) { } TEST_F(server_session_test, connection_closed_properly) { - for (unsigned counter = 0; counter < 2000; ++counter) { + for (unsigned counter = 0; counter < 1000; ++counter) { rpc::client client("localhost", rpc::constants::DEFAULT_PORT); auto response = client.call("func"); } From b1b8d90892d35e4e5e06c582f2de09b1c9ee13b4 Mon Sep 17 00:00:00 2001 From: sztomi Date: Mon, 18 Sep 2017 19:23:15 +0200 Subject: [PATCH 036/111] ci: downgrade requests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 45e75ae8..edfb8028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,7 @@ install: - if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.8" CC="clang-3.8"; fi - pip install --user cpp-coveralls - pip install --user conan + - pip install --user requests==2.5.3 - conan remote add conan-community https://api.bintray.com/conan/conan-community/conan script: From 7fa5ce7ae21ce86bbd812d59def78a6e2ba8038f Mon Sep 17 00:00:00 2001 From: sztomi Date: Mon, 18 Sep 2017 22:19:38 +0200 Subject: [PATCH 037/111] cmake: add missing flags for coverage --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f120e4d..cfb1b753 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,7 +122,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") endif() if(RPCLIB_ENABLE_COVERAGE) - target_compile_options(${PROJECT_NAME} PUBLIC "--coverage") + target_compile_options(${PROJECT_NAME} PUBLIC "-g --coverage -O0") # yes, this is ugly as "--coverage" is not a library, but a flag. # however, this does not work with the LINK_FLAGS target property list(APPEND RPCLIB_DEP_LIBRARIES "--coverage") From 5faa8a25db23ff4b0bb02f9fa3fba21fad5f19d8 Mon Sep 17 00:00:00 2001 From: sztomi Date: Mon, 18 Sep 2017 22:29:55 +0200 Subject: [PATCH 038/111] ci: enable coverage --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index edfb8028..9139db69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ script: - mkdir build ; cd build - conan install .. -r conan-community - . ./activate.sh - - cmake -DRPCLIB_ENABLE_COVERAGE=$COV -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=$RPCLIB_CXX_STANDARD -DCMAKE_INSTALL_PREFIX=../install .. + - cmake -DRPCLIB_ENABLE_COVERAGE=ON -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=$RPCLIB_CXX_STANDARD -DCMAKE_INSTALL_PREFIX=../install .. - cmake --build . --config $BUILD_TYPE - cmake --build . --target install From bcf31bc3bd9b805fc5b3aebe866ecf390cda84da Mon Sep 17 00:00:00 2001 From: sztomi Date: Tue, 19 Sep 2017 10:00:06 +0200 Subject: [PATCH 039/111] cmake: moved -g flag to the end --- CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfb1b753..c5420da0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,12 @@ set(RPCLIB_BUILD_FLAGS "") # reset flags if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") target_compile_options(${PROJECT_NAME} PUBLIC -std=c++${RPCLIB_CXX_STANDARD}) + if(RPCLIB_ENABLE_COVERAGE) + target_compile_options(${PROJECT_NAME} PRIVATE "--coverage -O0 -g") + # yes, this is ugly as "--coverage" is not a library, but a flag. + # however, this does not work with the LINK_FLAGS target property + list(APPEND RPCLIB_DEP_LIBRARIES "--coverage") + endif() endif() if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") @@ -121,13 +127,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") -Wno-undef -pthread) endif() -if(RPCLIB_ENABLE_COVERAGE) - target_compile_options(${PROJECT_NAME} PUBLIC "-g --coverage -O0") - # yes, this is ugly as "--coverage" is not a library, but a flag. - # however, this does not work with the LINK_FLAGS target property - list(APPEND RPCLIB_DEP_LIBRARIES "--coverage") -endif() - if (RPCLIB_EXTRA_BUILD_FLAGS) list(APPEND RPCLIB_BUILD_FLAGS ${RPCLIB_EXTRA_BUILD_FLAGS}) endif() From 97a71cbf2dfbe9dcdeb59194984066441f5f4e77 Mon Sep 17 00:00:00 2001 From: sztomi Date: Tue, 19 Sep 2017 10:05:45 +0200 Subject: [PATCH 040/111] cmake: use list vs. string --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5420da0..df7cd9b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,7 +111,7 @@ if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") target_compile_options(${PROJECT_NAME} PUBLIC -std=c++${RPCLIB_CXX_STANDARD}) if(RPCLIB_ENABLE_COVERAGE) - target_compile_options(${PROJECT_NAME} PRIVATE "--coverage -O0 -g") + target_compile_options(${PROJECT_NAME} PRIVATE --coverage -O0 -g) # yes, this is ugly as "--coverage" is not a library, but a flag. # however, this does not work with the LINK_FLAGS target property list(APPEND RPCLIB_DEP_LIBRARIES "--coverage") From 4e4efcdc337a4fffb4e43383626d453976f61506 Mon Sep 17 00:00:00 2001 From: sztomi Date: Tue, 19 Sep 2017 10:08:40 +0200 Subject: [PATCH 041/111] ci: switch to trusty image --- .gitignore | 13 ++++++----- .travis.yml | 52 +++++++++++++++++++------------------------- CMakeLists.txt | 41 ++++++++++++++++------------------ README.md | 2 +- appveyor.yml | 9 ++++---- cmake/coverage.cmake | 16 ++++++++++++++ codecov.yml | 7 ++++++ tests/CMakeLists.txt | 5 +++++ 8 files changed, 82 insertions(+), 63 deletions(-) create mode 100644 cmake/coverage.cmake create mode 100644 codecov.yml diff --git a/.gitignore b/.gitignore index 1b855612..169dfff2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,16 @@ -build -.idea +.DS_Store +build/ +.idea/ +.vscode/ + +doc/site/ +doc/doxygen/ + *.pyc compile_commands.json CMakeLists.txt.user cppcheck* report utils/release -.vscode -doc/site -doc/doxygen doc/all.xml reference.md diff --git a/.travis.yml b/.travis.yml index 9139db69..93087951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,26 @@ language: c++ +os: linux +dist: trusty +sudo: required -os: - - linux +matrix: + include: + - compiler: gcc + env: RPCLIB_CXX_STANDARD=11 BUILD_TYPE=Release COVERAGE="ON" + - compiler: gcc + env: RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Release COVERAGE="OFF" + - compiler: clang + env: RPCLIB_CXX_STANDARD=11 BUILD_TYPE=Release COVERAGE="OFF" + - compiler: clang + env: RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Release COVERAGE="OFF" -env: - matrix: - - RPCLIB_CXX_STANDARD=14 BUILD_TYPE=Release - - RPCLIB_CXX_STANDARD=11 BUILD_TYPE=Release - -compiler: - - gcc - - clang - -addons: - apt: - sources: - - llvm-toolchain-precise-3.8 - - ubuntu-toolchain-r-test - - george-edison55-precise-backports - packages: - - libsfml-dev - - g++-5 - - gcc-5 - - clang-3.8 - - cmake - - cmake-data +before_install: + - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + - sudo apt-get update -qq install: - - if [ "$CXX" == "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi - - if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.8" CC="clang-3.8"; fi - - pip install --user cpp-coveralls + - sudo apt-get install -qq g++-5 + - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 90 - pip install --user conan - pip install --user requests==2.5.3 - conan remote add conan-community https://api.bintray.com/conan/conan-community/conan @@ -38,10 +29,11 @@ script: - mkdir build ; cd build - conan install .. -r conan-community - . ./activate.sh - - cmake -DRPCLIB_ENABLE_COVERAGE=ON -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=$RPCLIB_CXX_STANDARD -DCMAKE_INSTALL_PREFIX=../install .. + - cmake -DRPCLIB_ENABLE_COVERAGE=$COVERAGE -DRPCLIB_BUILD_TESTS=ON -DRPCLIB_CXX_STANDARD=$RPCLIB_CXX_STANDARD -DCMAKE_INSTALL_PREFIX=../install .. - cmake --build . --config $BUILD_TYPE - cmake --build . --target install after_success: - - ./output/bin/rpc_test - - coveralls --exclude dependencies --exclude test --exclude include/rpc/msgpack --exclude include/rcp/msgpack.hpp --gcov /usr/bin/gcov-5 + - ./tests/rpc_test + - lcov --capture --directory . --output-file coverage.info + - bash <(curl -s https://codecov.io/bash) diff --git a/CMakeLists.txt b/CMakeLists.txt index df7cd9b6..0ef017d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") include(policies) include(msvc_support) +include(coverage) # # Options @@ -28,9 +29,6 @@ option(RPCLIB_MSVC_STATIC_RUNTIME "MSVC only: build with /MT instead of /MD" OFF) -# Perform steps and checks required for MSVC support -rpclib_msvc_support() - # # Other configuration values # @@ -53,6 +51,8 @@ if(NOT ${RPCLIB_CXX_STANDARD} EQUAL 14 AND message(fatal_error "Unsupported C++ standard: ${RPCLIB_CXX_STANDARD}") endif() +set(CMAKE_CXX_STANDARD ${RPCLIB_CXX_STANDARD}) + # # Compile & install the library # @@ -105,17 +105,13 @@ add_library(${PROJECT_NAME} ${DEP_HEADERS} ${RPCLIB_HEADERS}) +# Perform steps and checks required for MSVC support +rpclib_msvc_support() + set(RPCLIB_BUILD_FLAGS "") # reset flags -if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_compile_options(${PROJECT_NAME} PUBLIC - -std=c++${RPCLIB_CXX_STANDARD}) - if(RPCLIB_ENABLE_COVERAGE) - target_compile_options(${PROJECT_NAME} PRIVATE --coverage -O0 -g) - # yes, this is ugly as "--coverage" is not a library, but a flag. - # however, this does not work with the LINK_FLAGS target property - list(APPEND RPCLIB_DEP_LIBRARIES "--coverage") - endif() +if(RPCLIB_ENABLE_COVERAGE) + enable_coverage(${PROJECT_NAME}) endif() if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") @@ -131,16 +127,17 @@ if (RPCLIB_EXTRA_BUILD_FLAGS) list(APPEND RPCLIB_BUILD_FLAGS ${RPCLIB_EXTRA_BUILD_FLAGS}) endif() -target_compile_definitions(${PROJECT_NAME} PRIVATE - "${RPCLIB_COMPILE_DEFINITIONS}" - "${RPCLIB_ARCH_DEF}" - "${RPCLIB_OS_DEF}" - "ASIO_STANDALONE" - "RPCLIB_ASIO=clmdep_asio" - "RPCLIB_FMT=clmdep_fmt") - -target_compile_definitions(${PROJECT_NAME} PUBLIC - "RPCLIB_MSGPACK=clmdep_msgpack") +target_compile_definitions(${PROJECT_NAME} + PRIVATE + "${RPCLIB_COMPILE_DEFINITIONS}" + "${RPCLIB_ARCH_DEF}" + "ASIO_STANDALONE" + "RPCLIB_ASIO=clmdep_asio" + "RPCLIB_FMT=clmdep_fmt" + PUBLIC + "${RPCLIB_OS_DEF}" + "RPCLIB_MSGPACK=clmdep_msgpack" + ) if(RPCLIB_ENABLE_LOGGING) target_compile_definitions(${PROJECT_NAME} PRIVATE "RPCLIB_ENABLE_LOGGING") diff --git a/README.md b/README.md index 2404a18f..504286bc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# rpclib ![MIT](https://img.shields.io/badge/license-MIT-blue.svg) [![Build Status](https://travis-ci.org/rpclib/rpclib.svg?branch=master)](https://travis-ci.org/rpclib/rpclib) [![Build status](https://ci.appveyor.com/api/projects/status/9lft2tlamcox8epq?svg=true)](https://ci.appveyor.com/project/sztomi/callme) [![Coverage Status](https://coveralls.io/repos/github/rpclib/rpclib/badge.svg)](https://coveralls.io/github/rpclib/rpclib?branch=dev) ![Coverity](https://scan.coverity.com/projects/7259/badge.svg?flat=1) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg?maxAge=2592000)](https://gitter.im/rpclib/Lobby) +# rpclib ![MIT](https://img.shields.io/badge/license-MIT-blue.svg) [![Build Status](https://travis-ci.org/rpclib/rpclib.svg?branch=master)](https://travis-ci.org/rpclib/rpclib) [![Build status](https://ci.appveyor.com/api/projects/status/9lft2tlamcox8epq?svg=true)](https://ci.appveyor.com/project/sztomi/callme) [![Coverage Status](https://img.shields.io/codecov/c/github/rpclib/rpclib/dev.svg)](https://img.shields.io/codecov/c/github/rpclib/rpclib/dev.svg) ![Coverity](https://scan.coverity.com/projects/7259/badge.svg?flat=1) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg?maxAge=2592000)](https://gitter.im/rpclib/Lobby) `rpclib` is a RPC library for C++, providing both a client and server implementation. It is built using modern C++14, and as such, requires a recent compiler. Main highlights: diff --git a/appveyor.yml b/appveyor.yml index 4eee674b..4d9969a6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,6 +14,7 @@ configuration: environment: matrix: - CMAKE_PLATFORM: "Visual Studio 14 2015" + - CMAKE_PLATFORM: "Visual Studio 15 2017" install: true @@ -23,8 +24,6 @@ build_script: - git submodule update --init --recursive - md build - cd build - - cmake -DRPCLIB_ENABLE_COVERAGE=ON -DRPCLIB_BUILD_TESTS=ON -G "%CMAKE_PLATFORM%" .. - - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - set MSBuildOptions=/v:m /p:Configuration=%Configuration% /logger:%MSBuildLogger% - - msbuild %MSBuildOptions% rpc.sln - - .\output\bin\Release\rpc_test.exe + - cmake -DRPCLIB_BUILD_TESTS=ON -G "%CMAKE_PLATFORM%" .. + - cmake --build . --config %CONFIGURATION% + - .\tests\Release\rpc_test.exe diff --git a/cmake/coverage.cmake b/cmake/coverage.cmake new file mode 100644 index 00000000..78f1d140 --- /dev/null +++ b/cmake/coverage.cmake @@ -0,0 +1,16 @@ +function(enable_coverage TARGET) + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + + if(APPLE) + set(COVERAGE_LIB "") + else() + set(COVERAGE_LIB -lgcov) + endif() + + set_target_properties(${TARGET} + PROPERTIES + COMPILE_FLAGS --coverage + LINK_FLAGS "${COVERAGE_LIB} --coverage" + ) + endif() +endfunction() diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..f5ca393c --- /dev/null +++ b/codecov.yml @@ -0,0 +1,7 @@ + +ignore: + - "include/rpc/msgpack" + - "dependencies" + +coverage: + precision: 2 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 73e522a4..1f0419eb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,5 @@ +include(coverage) + set(TEST_PROJECT_NAME ${CMAKE_PROJECT_NAME}_test) set(TEST_SOURCES ${RPCLIB_DEPENDENCIES}/src/gmock-gtest-all.cc @@ -33,3 +35,6 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") -Wno-exit-time-destructors -Wno-switch-enum -Wno-format-nonliteral -Wno-unused-parameter -Wno-disabled-macro-expansion) endif() +if(RPCLIB_ENABLE_COVERAGE) + enable_coverage(${TEST_PROJECT_NAME}) +endif() From e8bfa06d524db549b8753c1322e68698f30ec7ec Mon Sep 17 00:00:00 2001 From: sztomi Date: Thu, 28 Sep 2017 00:47:17 +0200 Subject: [PATCH 042/111] msgpack: updated to msgpack to version 2.1.5 --- include/rpc/dispatcher.inl | 4 +- include/rpc/msgpack.hpp | 1 + include/rpc/msgpack/adaptor/adaptor_base.hpp | 88 +- .../rpc/msgpack/adaptor/adaptor_base_decl.hpp | 16 + include/rpc/msgpack/adaptor/array_ref.hpp | 179 +- .../rpc/msgpack/adaptor/array_ref_decl.hpp | 16 + include/rpc/msgpack/adaptor/bool.hpp | 69 +- include/rpc/msgpack/adaptor/boost/fusion.hpp | 161 +- .../msgpack/adaptor/boost/msgpack_variant.hpp | 434 +--- .../adaptor/boost/msgpack_variant_decl.hpp | 16 + .../rpc/msgpack/adaptor/boost/optional.hpp | 99 +- .../rpc/msgpack/adaptor/boost/string_ref.hpp | 90 +- .../rpc/msgpack/adaptor/boost/string_view.hpp | 15 + include/rpc/msgpack/adaptor/carray.hpp | 15 + include/rpc/msgpack/adaptor/char_ptr.hpp | 160 +- .../msgpack/adaptor/check_container_size.hpp | 70 +- .../adaptor/check_container_size_decl.hpp | 16 + include/rpc/msgpack/adaptor/cpp11/array.hpp | 146 +- .../rpc/msgpack/adaptor/cpp11/array_char.hpp | 97 +- .../adaptor/cpp11/array_unsigned_char.hpp | 97 +- .../msgpack/adaptor/cpp11/forward_list.hpp | 102 +- .../adaptor/cpp11/reference_wrapper.hpp | 16 + .../rpc/msgpack/adaptor/cpp11/shared_ptr.hpp | 90 +- include/rpc/msgpack/adaptor/cpp11/tuple.hpp | 184 +- .../rpc/msgpack/adaptor/cpp11/unique_ptr.hpp | 90 +- .../msgpack/adaptor/cpp11/unordered_map.hpp | 190 +- .../msgpack/adaptor/cpp11/unordered_set.hpp | 180 +- .../rpc/msgpack/adaptor/cpp17/optional.hpp | 16 + .../rpc/msgpack/adaptor/cpp17/string_view.hpp | 16 + include/rpc/msgpack/adaptor/define.hpp | 34 +- include/rpc/msgpack/adaptor/define_decl.hpp | 143 ++ include/rpc/msgpack/adaptor/deque.hpp | 113 +- include/rpc/msgpack/adaptor/ext.hpp | 240 +-- include/rpc/msgpack/adaptor/ext_decl.hpp | 16 + include/rpc/msgpack/adaptor/fixint.hpp | 303 +-- include/rpc/msgpack/adaptor/fixint_decl.hpp | 16 + include/rpc/msgpack/adaptor/float.hpp | 126 +- include/rpc/msgpack/adaptor/int.hpp | 433 +--- include/rpc/msgpack/adaptor/int_decl.hpp | 16 + include/rpc/msgpack/adaptor/list.hpp | 109 +- include/rpc/msgpack/adaptor/map.hpp | 308 +-- include/rpc/msgpack/adaptor/map_decl.hpp | 16 + include/rpc/msgpack/adaptor/msgpack_tuple.hpp | 22 +- .../msgpack/adaptor/msgpack_tuple_decl.hpp | 16 + include/rpc/msgpack/adaptor/nil.hpp | 87 +- include/rpc/msgpack/adaptor/nil_decl.hpp | 16 + include/rpc/msgpack/adaptor/pair.hpp | 86 +- include/rpc/msgpack/adaptor/raw.hpp | 109 +- include/rpc/msgpack/adaptor/raw_decl.hpp | 16 + include/rpc/msgpack/adaptor/set.hpp | 191 +- .../rpc/msgpack/adaptor/size_equal_only.hpp | 17 + .../msgpack/adaptor/size_equal_only_decl.hpp | 16 + include/rpc/msgpack/adaptor/string.hpp | 89 +- .../rpc/msgpack/adaptor/tr1/unordered_map.hpp | 22 +- .../rpc/msgpack/adaptor/tr1/unordered_set.hpp | 22 +- include/rpc/msgpack/adaptor/v4raw.hpp | 109 +- include/rpc/msgpack/adaptor/v4raw_decl.hpp | 16 + include/rpc/msgpack/adaptor/vector.hpp | 124 +- include/rpc/msgpack/adaptor/vector_bool.hpp | 91 +- include/rpc/msgpack/adaptor/vector_char.hpp | 92 +- .../msgpack/adaptor/vector_unsigned_char.hpp | 92 +- include/rpc/msgpack/cpp_config.hpp | 132 +- include/rpc/msgpack/cpp_config_decl.hpp | 16 + include/rpc/msgpack/fbuffer.h | 18 +- include/rpc/msgpack/fbuffer.hpp | 67 +- include/rpc/msgpack/fbuffer_decl.hpp | 16 + include/rpc/msgpack/gcc_atomic.h | 14 +- include/rpc/msgpack/gcc_atomic.hpp | 31 + include/rpc/msgpack/iterator.hpp | 40 +- include/rpc/msgpack/iterator_decl.hpp | 17 + include/rpc/msgpack/meta.hpp | 53 +- include/rpc/msgpack/meta_decl.hpp | 17 + include/rpc/msgpack/object.h | 19 +- include/rpc/msgpack/object.hpp | 835 +------- include/rpc/msgpack/object_decl.hpp | 17 + include/rpc/msgpack/object_fwd.hpp | 198 +- include/rpc/msgpack/object_fwd_decl.hpp | 17 + include/rpc/msgpack/pack.h | 14 +- include/rpc/msgpack/pack.hpp | 1095 +---------- include/rpc/msgpack/pack_decl.hpp | 16 + include/rpc/msgpack/pack_define.h | 14 +- include/rpc/msgpack/pack_template.h | 14 +- include/rpc/msgpack/parse_return.hpp | 16 + include/rpc/msgpack/predef.h | 7 +- include/rpc/msgpack/predef/architecture.h | 4 +- .../rpc/msgpack/predef/architecture/alpha.h | 7 +- include/rpc/msgpack/predef/architecture/arm.h | 7 +- .../msgpack/predef/architecture/blackfin.h | 7 +- .../rpc/msgpack/predef/architecture/convex.h | 8 +- .../rpc/msgpack/predef/architecture/ia64.h | 6 +- .../rpc/msgpack/predef/architecture/m68k.h | 7 +- .../rpc/msgpack/predef/architecture/mips.h | 7 +- .../rpc/msgpack/predef/architecture/parisc.h | 7 +- include/rpc/msgpack/predef/architecture/ppc.h | 7 +- .../rpc/msgpack/predef/architecture/pyramid.h | 7 +- .../rpc/msgpack/predef/architecture/rs6k.h | 8 +- .../rpc/msgpack/predef/architecture/sparc.h | 7 +- .../rpc/msgpack/predef/architecture/superh.h | 7 +- .../rpc/msgpack/predef/architecture/sys370.h | 7 +- .../rpc/msgpack/predef/architecture/sys390.h | 7 +- include/rpc/msgpack/predef/architecture/x86.h | 12 +- .../rpc/msgpack/predef/architecture/x86/32.h | 8 +- .../rpc/msgpack/predef/architecture/x86/64.h | 8 +- include/rpc/msgpack/predef/architecture/z.h | 7 +- include/rpc/msgpack/predef/compiler.h | 4 +- include/rpc/msgpack/predef/compiler/borland.h | 7 +- include/rpc/msgpack/predef/compiler/clang.h | 7 +- include/rpc/msgpack/predef/compiler/comeau.h | 9 +- include/rpc/msgpack/predef/compiler/compaq.h | 7 +- include/rpc/msgpack/predef/compiler/diab.h | 7 +- .../rpc/msgpack/predef/compiler/digitalmars.h | 7 +- include/rpc/msgpack/predef/compiler/dignus.h | 7 +- include/rpc/msgpack/predef/compiler/edg.h | 7 +- include/rpc/msgpack/predef/compiler/ekopath.h | 7 +- include/rpc/msgpack/predef/compiler/gcc.h | 7 +- include/rpc/msgpack/predef/compiler/gcc_xml.h | 6 +- .../rpc/msgpack/predef/compiler/greenhills.h | 7 +- include/rpc/msgpack/predef/compiler/hp_acc.h | 7 +- include/rpc/msgpack/predef/compiler/iar.h | 7 +- include/rpc/msgpack/predef/compiler/ibm.h | 7 +- include/rpc/msgpack/predef/compiler/intel.h | 7 +- include/rpc/msgpack/predef/compiler/kai.h | 7 +- include/rpc/msgpack/predef/compiler/llvm.h | 7 +- .../rpc/msgpack/predef/compiler/metaware.h | 7 +- .../rpc/msgpack/predef/compiler/metrowerks.h | 7 +- .../rpc/msgpack/predef/compiler/microtec.h | 7 +- include/rpc/msgpack/predef/compiler/mpw.h | 7 +- include/rpc/msgpack/predef/compiler/palm.h | 7 +- include/rpc/msgpack/predef/compiler/pgi.h | 7 +- .../rpc/msgpack/predef/compiler/sgi_mipspro.h | 7 +- include/rpc/msgpack/predef/compiler/sunpro.h | 25 +- include/rpc/msgpack/predef/compiler/tendra.h | 7 +- include/rpc/msgpack/predef/compiler/visualc.h | 7 +- include/rpc/msgpack/predef/compiler/watcom.h | 7 +- include/rpc/msgpack/predef/detail/_cassert.h | 2 +- .../rpc/msgpack/predef/detail/_exception.h | 2 +- include/rpc/msgpack/predef/detail/test_def.h | 71 + include/rpc/msgpack/predef/hardware.h | 16 + include/rpc/msgpack/predef/hardware/simd.h | 119 ++ .../rpc/msgpack/predef/hardware/simd/arm.h | 57 + .../predef/hardware/simd/arm/versions.h | 32 + .../rpc/msgpack/predef/hardware/simd/ppc.h | 69 + .../predef/hardware/simd/ppc/versions.h | 51 + .../rpc/msgpack/predef/hardware/simd/x86.h | 123 ++ .../predef/hardware/simd/x86/versions.h | 129 ++ .../msgpack/predef/hardware/simd/x86_amd.h | 87 + .../predef/hardware/simd/x86_amd/versions.h | 51 + include/rpc/msgpack/predef/language.h | 4 +- include/rpc/msgpack/predef/language/objc.h | 7 +- include/rpc/msgpack/predef/language/stdc.h | 7 +- include/rpc/msgpack/predef/language/stdcpp.h | 19 +- include/rpc/msgpack/predef/library.h | 4 +- include/rpc/msgpack/predef/library/c.h | 4 +- include/rpc/msgpack/predef/library/c/gnu.h | 7 +- include/rpc/msgpack/predef/library/c/uc.h | 7 +- include/rpc/msgpack/predef/library/c/vms.h | 7 +- include/rpc/msgpack/predef/library/c/zos.h | 7 +- include/rpc/msgpack/predef/library/std.h | 4 +- include/rpc/msgpack/predef/library/std/cxx.h | 7 +- .../msgpack/predef/library/std/dinkumware.h | 7 +- .../rpc/msgpack/predef/library/std/libcomo.h | 7 +- .../rpc/msgpack/predef/library/std/modena.h | 7 +- include/rpc/msgpack/predef/library/std/msl.h | 7 +- .../msgpack/predef/library/std/roguewave.h | 7 +- include/rpc/msgpack/predef/library/std/sgi.h | 7 +- .../rpc/msgpack/predef/library/std/stdcpp3.h | 7 +- .../rpc/msgpack/predef/library/std/stlport.h | 7 +- .../rpc/msgpack/predef/library/std/vacpp.h | 7 +- include/rpc/msgpack/predef/make.h | 4 +- include/rpc/msgpack/predef/os.h | 4 +- include/rpc/msgpack/predef/os/aix.h | 7 +- include/rpc/msgpack/predef/os/amigaos.h | 7 +- include/rpc/msgpack/predef/os/android.h | 7 +- include/rpc/msgpack/predef/os/beos.h | 7 +- include/rpc/msgpack/predef/os/bsd.h | 14 +- include/rpc/msgpack/predef/os/bsd/bsdi.h | 6 +- include/rpc/msgpack/predef/os/bsd/dragonfly.h | 6 +- include/rpc/msgpack/predef/os/bsd/free.h | 6 +- include/rpc/msgpack/predef/os/bsd/net.h | 6 +- include/rpc/msgpack/predef/os/bsd/open.h | 6 +- include/rpc/msgpack/predef/os/cygwin.h | 9 +- include/rpc/msgpack/predef/os/haiku.h | 7 +- include/rpc/msgpack/predef/os/hpux.h | 7 +- include/rpc/msgpack/predef/os/ios.h | 6 +- include/rpc/msgpack/predef/os/irix.h | 7 +- include/rpc/msgpack/predef/os/linux.h | 7 +- include/rpc/msgpack/predef/os/macos.h | 7 +- include/rpc/msgpack/predef/os/os400.h | 7 +- include/rpc/msgpack/predef/os/qnxnto.h | 7 +- include/rpc/msgpack/predef/os/solaris.h | 7 +- include/rpc/msgpack/predef/os/unix.h | 6 +- include/rpc/msgpack/predef/os/vms.h | 7 +- include/rpc/msgpack/predef/os/windows.h | 6 +- include/rpc/msgpack/predef/other.h | 4 +- include/rpc/msgpack/predef/other/endian.h | 9 +- include/rpc/msgpack/predef/platform.h | 4 +- include/rpc/msgpack/predef/platform/mingw.h | 7 +- .../msgpack/predef/platform/windows_desktop.h | 7 +- .../msgpack/predef/platform/windows_phone.h | 7 +- .../msgpack/predef/platform/windows_runtime.h | 7 +- .../msgpack/predef/platform/windows_store.h | 7 +- include/rpc/msgpack/predef/version.h | 4 +- include/rpc/msgpack/predef/version_number.h | 3 +- .../msgpack/preprocessor/arithmetic/dec.hpp | 1 + .../msgpack/preprocessor/config/config.hpp | 7 +- .../preprocessor/facilities/identity.hpp | 4 + include/rpc/msgpack/preprocessor/library.hpp | 1 + .../msgpack/preprocessor/repetition/for.hpp | 20 +- .../preprocessor/seq/detail/is_empty.hpp | 49 + .../rpc/msgpack/preprocessor/seq/for_each.hpp | 67 +- .../msgpack/preprocessor/seq/for_each_i.hpp | 68 +- .../rpc/msgpack/preprocessor/seq/replace.hpp | 20 +- .../rpc/msgpack/preprocessor/seq/rest_n.hpp | 20 +- include/rpc/msgpack/preprocessor/seq/size.hpp | 1 + .../rpc/msgpack/preprocessor/tuple/eat.hpp | 11 +- include/rpc/msgpack/sbuffer.h | 14 +- include/rpc/msgpack/sbuffer.hpp | 157 +- include/rpc/msgpack/sbuffer_decl.hpp | 17 + include/rpc/msgpack/sysdep.h | 90 +- include/rpc/msgpack/type.hpp | 11 + include/rpc/msgpack/unpack.h | 27 +- include/rpc/msgpack/unpack.hpp | 1718 +--------------- include/rpc/msgpack/unpack_decl.hpp | 16 + include/rpc/msgpack/unpack_define.h | 14 +- include/rpc/msgpack/unpack_exception.hpp | 15 + include/rpc/msgpack/unpack_template.h | 66 +- include/rpc/msgpack/util.h | 14 +- .../rpc/msgpack/v1/adaptor/adaptor_base.hpp | 116 ++ .../msgpack/v1/adaptor/adaptor_base_decl.hpp | 87 + include/rpc/msgpack/v1/adaptor/array_ref.hpp | 305 +++ .../rpc/msgpack/v1/adaptor/array_ref_decl.hpp | 55 + include/rpc/msgpack/v1/adaptor/bool.hpp | 66 + .../rpc/msgpack/v1/adaptor/boost/fusion.hpp | 203 ++ .../v1/adaptor/boost/msgpack_variant.hpp | 443 +++++ .../v1/adaptor/boost/msgpack_variant_decl.hpp | 62 + .../rpc/msgpack/v1/adaptor/boost/optional.hpp | 96 + .../msgpack/v1/adaptor/boost/string_ref.hpp | 87 + .../msgpack/v1/adaptor/boost/string_view.hpp | 87 + include/rpc/msgpack/v1/adaptor/carray.hpp | 253 +++ include/rpc/msgpack/v1/adaptor/char_ptr.hpp | 92 + .../v1/adaptor/check_container_size.hpp | 67 + .../v1/adaptor/check_container_size_decl.hpp | 44 + .../rpc/msgpack/v1/adaptor/cpp11/array.hpp | 138 ++ .../msgpack/v1/adaptor/cpp11/array_char.hpp | 97 + .../v1/adaptor/cpp11/array_unsigned_char.hpp | 97 + .../msgpack/v1/adaptor/cpp11/forward_list.hpp | 94 + .../v1/adaptor/cpp11/reference_wrapper.hpp | 68 + .../msgpack/v1/adaptor/cpp11/shared_ptr.hpp | 82 + .../rpc/msgpack/v1/adaptor/cpp11/tuple.hpp | 175 ++ .../msgpack/v1/adaptor/cpp11/unique_ptr.hpp | 82 + .../v1/adaptor/cpp11/unordered_map.hpp | 182 ++ .../v1/adaptor/cpp11/unordered_set.hpp | 172 ++ .../rpc/msgpack/v1/adaptor/cpp17/optional.hpp | 90 + .../msgpack/v1/adaptor/cpp17/string_view.hpp | 86 + include/rpc/msgpack/v1/adaptor/define.hpp | 21 + .../rpc/msgpack/v1/adaptor/define_decl.hpp | 23 + include/rpc/msgpack/v1/adaptor/deque.hpp | 108 + .../adaptor/detail/cpp03_define_array.hpp | 1211 ++++++++++-- .../detail/cpp03_define_array_decl.hpp | 135 ++ .../adaptor/detail/cpp03_define_map.hpp | 114 +- .../adaptor/detail/cpp03_define_map_decl.hpp | 135 ++ .../adaptor/detail/cpp03_msgpack_tuple.hpp | 1752 +++++++++++------ .../detail/cpp03_msgpack_tuple_decl.hpp | 317 +++ .../adaptor/detail/cpp11_define_array.hpp | 92 +- .../detail/cpp11_define_array_decl.hpp | 39 + .../adaptor/detail/cpp11_define_map.hpp | 85 +- .../adaptor/detail/cpp11_define_map_decl.hpp | 37 + .../adaptor/detail/cpp11_msgpack_tuple.hpp | 133 +- .../detail/cpp11_msgpack_tuple_decl.hpp | 120 ++ include/rpc/msgpack/v1/adaptor/ext.hpp | 236 +++ include/rpc/msgpack/v1/adaptor/ext_decl.hpp | 38 + include/rpc/msgpack/v1/adaptor/fixint.hpp | 283 +++ .../rpc/msgpack/v1/adaptor/fixint_decl.hpp | 46 + include/rpc/msgpack/v1/adaptor/float.hpp | 123 ++ include/rpc/msgpack/v1/adaptor/int.hpp | 426 ++++ include/rpc/msgpack/v1/adaptor/int_decl.hpp | 49 + include/rpc/msgpack/v1/adaptor/list.hpp | 106 + include/rpc/msgpack/v1/adaptor/map.hpp | 314 +++ include/rpc/msgpack/v1/adaptor/map_decl.hpp | 36 + .../rpc/msgpack/v1/adaptor/msgpack_tuple.hpp | 21 + .../msgpack/v1/adaptor/msgpack_tuple_decl.hpp | 21 + include/rpc/msgpack/v1/adaptor/nil.hpp | 76 + include/rpc/msgpack/v1/adaptor/nil_decl.hpp | 44 + include/rpc/msgpack/v1/adaptor/pair.hpp | 83 + include/rpc/msgpack/v1/adaptor/raw.hpp | 106 + include/rpc/msgpack/v1/adaptor/raw_decl.hpp | 36 + include/rpc/msgpack/v1/adaptor/set.hpp | 188 ++ .../msgpack/v1/adaptor/size_equal_only.hpp | 118 ++ .../v1/adaptor/size_equal_only_decl.hpp | 52 + include/rpc/msgpack/v1/adaptor/string.hpp | 87 + .../msgpack/v1/adaptor/tr1/unordered_map.hpp | 171 ++ .../msgpack/v1/adaptor/tr1/unordered_set.hpp | 165 ++ include/rpc/msgpack/v1/adaptor/v4raw.hpp | 105 + include/rpc/msgpack/v1/adaptor/v4raw_decl.hpp | 34 + include/rpc/msgpack/v1/adaptor/vector.hpp | 121 ++ .../rpc/msgpack/v1/adaptor/vector_bool.hpp | 90 + .../rpc/msgpack/v1/adaptor/vector_char.hpp | 114 ++ .../v1/adaptor/vector_unsigned_char.hpp | 114 ++ include/rpc/msgpack/v1/cpp_config.hpp | 135 ++ include/rpc/msgpack/v1/cpp_config_decl.hpp | 131 ++ .../msgpack/{ => v1}/detail/cpp03_zone.hpp | 120 +- .../rpc/msgpack/v1/detail/cpp03_zone_decl.hpp | 54 + .../msgpack/{ => v1}/detail/cpp11_zone.hpp | 86 +- .../rpc/msgpack/v1/detail/cpp11_zone_decl.hpp | 55 + include/rpc/msgpack/v1/fbuffer.hpp | 60 + include/rpc/msgpack/v1/fbuffer_decl.hpp | 32 + include/rpc/msgpack/v1/iterator.hpp | 40 + include/rpc/msgpack/v1/iterator_decl.hpp | 40 + include/rpc/msgpack/v1/meta.hpp | 53 + include/rpc/msgpack/v1/meta_decl.hpp | 57 + include/rpc/msgpack/v1/object.hpp | 885 +++++++++ include/rpc/msgpack/v1/object_decl.hpp | 115 ++ include/rpc/msgpack/v1/object_fwd.hpp | 255 +++ include/rpc/msgpack/v1/object_fwd_decl.hpp | 78 + include/rpc/msgpack/v1/pack.hpp | 1602 +++++++++++++++ include/rpc/msgpack/v1/pack_decl.hpp | 91 + include/rpc/msgpack/v1/parse_return.hpp | 36 + include/rpc/msgpack/v1/preprocessor.hpp | 19 + include/rpc/msgpack/v1/sbuffer.hpp | 149 ++ include/rpc/msgpack/v1/sbuffer_decl.hpp | 33 + include/rpc/msgpack/v1/unpack.hpp | 1592 +++++++++++++++ include/rpc/msgpack/v1/unpack_decl.hpp | 454 +++++ include/rpc/msgpack/v1/unpack_exception.hpp | 122 ++ include/rpc/msgpack/v1/version.hpp | 36 + include/rpc/msgpack/v1/versioning.hpp | 69 + include/rpc/msgpack/v1/vrefbuffer.hpp | 292 +++ include/rpc/msgpack/v1/vrefbuffer_decl.hpp | 39 + include/rpc/msgpack/v1/zbuffer.hpp | 159 ++ include/rpc/msgpack/v1/zbuffer_decl.hpp | 37 + include/rpc/msgpack/v1/zone.hpp | 21 + include/rpc/msgpack/v1/zone_decl.hpp | 21 + .../rpc/msgpack/v2/adaptor/adaptor_base.hpp | 58 + .../msgpack/v2/adaptor/adaptor_base_decl.hpp | 52 + .../rpc/msgpack/v2/adaptor/array_ref_decl.hpp | 36 + .../v2/adaptor/boost/msgpack_variant_decl.hpp | 42 + .../v2/adaptor/check_container_size_decl.hpp | 39 + .../rpc/msgpack/v2/adaptor/define_decl.hpp | 23 + .../detail/cpp03_define_array_decl.hpp | 31 + .../adaptor/detail/cpp03_define_map_decl.hpp | 31 + .../detail/cpp03_msgpack_tuple_decl.hpp | 43 + .../detail/cpp11_define_array_decl.hpp | 32 + .../adaptor/detail/cpp11_define_map_decl.hpp | 31 + .../detail/cpp11_msgpack_tuple_decl.hpp | 59 + include/rpc/msgpack/v2/adaptor/ext_decl.hpp | 34 + .../rpc/msgpack/v2/adaptor/fixint_decl.hpp | 43 + include/rpc/msgpack/v2/adaptor/int_decl.hpp | 54 + include/rpc/msgpack/v2/adaptor/map_decl.hpp | 33 + .../msgpack/v2/adaptor/msgpack_tuple_decl.hpp | 21 + include/rpc/msgpack/v2/adaptor/nil_decl.hpp | 42 + include/rpc/msgpack/v2/adaptor/raw_decl.hpp | 33 + .../v2/adaptor/size_equal_only_decl.hpp | 35 + include/rpc/msgpack/v2/adaptor/v4raw_decl.hpp | 34 + include/rpc/msgpack/v2/cpp_config_decl.hpp | 84 + .../rpc/msgpack/v2/create_object_visitor.hpp | 249 +++ .../rpc/msgpack/v2/detail/cpp03_zone_decl.hpp | 31 + .../rpc/msgpack/v2/detail/cpp11_zone_decl.hpp | 31 + include/rpc/msgpack/v2/fbuffer_decl.hpp | 32 + include/rpc/msgpack/v2/iterator_decl.hpp | 33 + include/rpc/msgpack/v2/meta_decl.hpp | 50 + include/rpc/msgpack/v2/null_visitor.hpp | 97 + include/rpc/msgpack/v2/object.hpp | 33 + include/rpc/msgpack/v2/object_decl.hpp | 49 + include/rpc/msgpack/v2/object_fwd.hpp | 109 + include/rpc/msgpack/v2/object_fwd_decl.hpp | 75 + include/rpc/msgpack/v2/pack_decl.hpp | 55 + include/rpc/msgpack/v2/parse.hpp | 1061 ++++++++++ include/rpc/msgpack/v2/parse_return.hpp | 37 + include/rpc/msgpack/v2/sbuffer_decl.hpp | 33 + include/rpc/msgpack/v2/unpack.hpp | 345 ++++ include/rpc/msgpack/v2/unpack_decl.hpp | 340 ++++ include/rpc/msgpack/v2/vrefbuffer_decl.hpp | 29 + include/rpc/msgpack/v2/x3_parse.hpp | 874 ++++++++ include/rpc/msgpack/v2/x3_unpack.hpp | 119 ++ include/rpc/msgpack/v2/zbuffer_decl.hpp | 29 + include/rpc/msgpack/v2/zone_decl.hpp | 21 + include/rpc/msgpack/version.h | 14 +- include/rpc/msgpack/version.hpp | 14 +- include/rpc/msgpack/version_master.h | 6 +- include/rpc/msgpack/versioning.hpp | 24 +- include/rpc/msgpack/vrefbuffer.h | 16 +- include/rpc/msgpack/vrefbuffer.hpp | 297 +-- include/rpc/msgpack/vrefbuffer_decl.hpp | 16 + include/rpc/msgpack/zbuffer.h | 14 +- include/rpc/msgpack/zbuffer.hpp | 170 +- include/rpc/msgpack/zbuffer_decl.hpp | 16 + include/rpc/msgpack/zone.h | 14 +- include/rpc/msgpack/zone.hpp | 24 +- include/rpc/msgpack/zone_decl.hpp | 16 + include/rpc/server.h | 2 +- lib/rpc/client.cc | 2 +- lib/rpc/detail/response.cc | 14 +- lib/rpc/detail/server_session.cc | 2 +- lib/rpc/dispatcher.cc | 7 +- tests/rpc/dispatcher_test.cc | 2 +- tests/rpc/response_test.cc | 34 +- tests/testutils.h | 4 +- 396 files changed, 24182 insertions(+), 11713 deletions(-) create mode 100644 include/rpc/msgpack/adaptor/adaptor_base_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/array_ref_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/boost/msgpack_variant_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/boost/string_view.hpp create mode 100644 include/rpc/msgpack/adaptor/carray.hpp create mode 100644 include/rpc/msgpack/adaptor/check_container_size_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/cpp11/reference_wrapper.hpp create mode 100644 include/rpc/msgpack/adaptor/cpp17/optional.hpp create mode 100644 include/rpc/msgpack/adaptor/cpp17/string_view.hpp create mode 100644 include/rpc/msgpack/adaptor/define_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/ext_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/fixint_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/int_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/map_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/msgpack_tuple_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/nil_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/raw_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/size_equal_only.hpp create mode 100644 include/rpc/msgpack/adaptor/size_equal_only_decl.hpp create mode 100644 include/rpc/msgpack/adaptor/v4raw_decl.hpp create mode 100644 include/rpc/msgpack/cpp_config_decl.hpp create mode 100644 include/rpc/msgpack/fbuffer_decl.hpp create mode 100644 include/rpc/msgpack/gcc_atomic.hpp create mode 100644 include/rpc/msgpack/iterator_decl.hpp create mode 100644 include/rpc/msgpack/meta_decl.hpp create mode 100644 include/rpc/msgpack/object_decl.hpp create mode 100644 include/rpc/msgpack/object_fwd_decl.hpp create mode 100644 include/rpc/msgpack/pack_decl.hpp create mode 100644 include/rpc/msgpack/parse_return.hpp create mode 100644 include/rpc/msgpack/predef/detail/test_def.h create mode 100644 include/rpc/msgpack/predef/hardware.h create mode 100644 include/rpc/msgpack/predef/hardware/simd.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/arm.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/arm/versions.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/ppc.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/ppc/versions.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/x86.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/x86/versions.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/x86_amd.h create mode 100644 include/rpc/msgpack/predef/hardware/simd/x86_amd/versions.h create mode 100644 include/rpc/msgpack/preprocessor/seq/detail/is_empty.hpp create mode 100644 include/rpc/msgpack/sbuffer_decl.hpp create mode 100644 include/rpc/msgpack/unpack_decl.hpp create mode 100644 include/rpc/msgpack/unpack_exception.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/adaptor_base.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/adaptor_base_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/array_ref.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/array_ref_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/bool.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/boost/fusion.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/boost/msgpack_variant.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/boost/optional.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/boost/string_ref.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/boost/string_view.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/carray.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/char_ptr.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/check_container_size.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/check_container_size_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/array.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/array_char.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/array_unsigned_char.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/forward_list.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/reference_wrapper.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/shared_ptr.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/tuple.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/unique_ptr.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/unordered_map.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp11/unordered_set.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp17/optional.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/cpp17/string_view.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/define.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/define_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/deque.hpp rename include/rpc/msgpack/{ => v1}/adaptor/detail/cpp03_define_array.hpp (88%) create mode 100644 include/rpc/msgpack/v1/adaptor/detail/cpp03_define_array_decl.hpp rename include/rpc/msgpack/{ => v1}/adaptor/detail/cpp03_define_map.hpp (96%) create mode 100644 include/rpc/msgpack/v1/adaptor/detail/cpp03_define_map_decl.hpp rename include/rpc/msgpack/{ => v1}/adaptor/detail/cpp03_msgpack_tuple.hpp (92%) create mode 100644 include/rpc/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp rename include/rpc/msgpack/{ => v1}/adaptor/detail/cpp11_define_array.hpp (52%) create mode 100644 include/rpc/msgpack/v1/adaptor/detail/cpp11_define_array_decl.hpp rename include/rpc/msgpack/{ => v1}/adaptor/detail/cpp11_define_map.hpp (53%) create mode 100644 include/rpc/msgpack/v1/adaptor/detail/cpp11_define_map_decl.hpp rename include/rpc/msgpack/{ => v1}/adaptor/detail/cpp11_msgpack_tuple.hpp (58%) create mode 100644 include/rpc/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/ext.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/ext_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/fixint.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/fixint_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/float.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/int.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/int_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/list.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/map.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/map_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/msgpack_tuple.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/msgpack_tuple_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/nil.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/nil_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/pair.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/raw.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/raw_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/set.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/size_equal_only.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/size_equal_only_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/string.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/tr1/unordered_map.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/tr1/unordered_set.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/v4raw.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/v4raw_decl.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/vector.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/vector_bool.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/vector_char.hpp create mode 100644 include/rpc/msgpack/v1/adaptor/vector_unsigned_char.hpp create mode 100644 include/rpc/msgpack/v1/cpp_config.hpp create mode 100644 include/rpc/msgpack/v1/cpp_config_decl.hpp rename include/rpc/msgpack/{ => v1}/detail/cpp03_zone.hpp (88%) create mode 100644 include/rpc/msgpack/v1/detail/cpp03_zone_decl.hpp rename include/rpc/msgpack/{ => v1}/detail/cpp11_zone.hpp (82%) create mode 100644 include/rpc/msgpack/v1/detail/cpp11_zone_decl.hpp create mode 100644 include/rpc/msgpack/v1/fbuffer.hpp create mode 100644 include/rpc/msgpack/v1/fbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v1/iterator.hpp create mode 100644 include/rpc/msgpack/v1/iterator_decl.hpp create mode 100644 include/rpc/msgpack/v1/meta.hpp create mode 100644 include/rpc/msgpack/v1/meta_decl.hpp create mode 100644 include/rpc/msgpack/v1/object.hpp create mode 100644 include/rpc/msgpack/v1/object_decl.hpp create mode 100644 include/rpc/msgpack/v1/object_fwd.hpp create mode 100644 include/rpc/msgpack/v1/object_fwd_decl.hpp create mode 100644 include/rpc/msgpack/v1/pack.hpp create mode 100644 include/rpc/msgpack/v1/pack_decl.hpp create mode 100644 include/rpc/msgpack/v1/parse_return.hpp create mode 100644 include/rpc/msgpack/v1/preprocessor.hpp create mode 100644 include/rpc/msgpack/v1/sbuffer.hpp create mode 100644 include/rpc/msgpack/v1/sbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v1/unpack.hpp create mode 100644 include/rpc/msgpack/v1/unpack_decl.hpp create mode 100644 include/rpc/msgpack/v1/unpack_exception.hpp create mode 100644 include/rpc/msgpack/v1/version.hpp create mode 100644 include/rpc/msgpack/v1/versioning.hpp create mode 100644 include/rpc/msgpack/v1/vrefbuffer.hpp create mode 100644 include/rpc/msgpack/v1/vrefbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v1/zbuffer.hpp create mode 100644 include/rpc/msgpack/v1/zbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v1/zone.hpp create mode 100644 include/rpc/msgpack/v1/zone_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/adaptor_base.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/adaptor_base_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/array_ref_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/boost/msgpack_variant_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/check_container_size_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/define_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/detail/cpp03_define_array_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/detail/cpp03_define_map_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/detail/cpp03_msgpack_tuple_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/detail/cpp11_define_array_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/detail/cpp11_define_map_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/detail/cpp11_msgpack_tuple_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/ext_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/fixint_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/int_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/map_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/msgpack_tuple_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/nil_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/raw_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/size_equal_only_decl.hpp create mode 100644 include/rpc/msgpack/v2/adaptor/v4raw_decl.hpp create mode 100644 include/rpc/msgpack/v2/cpp_config_decl.hpp create mode 100644 include/rpc/msgpack/v2/create_object_visitor.hpp create mode 100644 include/rpc/msgpack/v2/detail/cpp03_zone_decl.hpp create mode 100644 include/rpc/msgpack/v2/detail/cpp11_zone_decl.hpp create mode 100644 include/rpc/msgpack/v2/fbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v2/iterator_decl.hpp create mode 100644 include/rpc/msgpack/v2/meta_decl.hpp create mode 100644 include/rpc/msgpack/v2/null_visitor.hpp create mode 100644 include/rpc/msgpack/v2/object.hpp create mode 100644 include/rpc/msgpack/v2/object_decl.hpp create mode 100644 include/rpc/msgpack/v2/object_fwd.hpp create mode 100644 include/rpc/msgpack/v2/object_fwd_decl.hpp create mode 100644 include/rpc/msgpack/v2/pack_decl.hpp create mode 100644 include/rpc/msgpack/v2/parse.hpp create mode 100644 include/rpc/msgpack/v2/parse_return.hpp create mode 100644 include/rpc/msgpack/v2/sbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v2/unpack.hpp create mode 100644 include/rpc/msgpack/v2/unpack_decl.hpp create mode 100644 include/rpc/msgpack/v2/vrefbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v2/x3_parse.hpp create mode 100644 include/rpc/msgpack/v2/x3_unpack.hpp create mode 100644 include/rpc/msgpack/v2/zbuffer_decl.hpp create mode 100644 include/rpc/msgpack/v2/zone_decl.hpp create mode 100644 include/rpc/msgpack/vrefbuffer_decl.hpp create mode 100644 include/rpc/msgpack/zbuffer_decl.hpp create mode 100644 include/rpc/msgpack/zone_decl.hpp diff --git a/include/rpc/dispatcher.inl b/include/rpc/dispatcher.inl index 1380bc59..0d5e413c 100644 --- a/include/rpc/dispatcher.inl +++ b/include/rpc/dispatcher.inl @@ -34,7 +34,7 @@ void dispatcher::bind(std::string const &name, F func, constexpr int args_count = std::tuple_size::value; enforce_arg_count(name, args_count, args.via.array.size); args_type args_real; - args.convert(&args_real); + args.convert(args_real); detail::call(func, args_real); return rpc::detail::make_unique(); })); @@ -69,7 +69,7 @@ void dispatcher::bind(std::string const &name, F func, constexpr int args_count = std::tuple_size::value; enforce_arg_count(name, args_count, args.via.array.size); args_type args_real; - args.convert(&args_real); + args.convert(args_real); auto z = rpc::detail::make_unique(); auto result = RPCLIB_MSGPACK::object(detail::call(func, args_real), *z); return rpc::detail::make_unique(result, std::move(z)); diff --git a/include/rpc/msgpack.hpp b/include/rpc/msgpack.hpp index fbb58ca7..a99073b5 100644 --- a/include/rpc/msgpack.hpp +++ b/include/rpc/msgpack.hpp @@ -29,3 +29,4 @@ #include "rpc/msgpack/vrefbuffer.hpp" #include "rpc/msgpack/version.hpp" #include "rpc/msgpack/type.hpp" + diff --git a/include/rpc/msgpack/adaptor/adaptor_base.hpp b/include/rpc/msgpack/adaptor/adaptor_base.hpp index 70f19b0c..0f221f2f 100644 --- a/include/rpc/msgpack/adaptor/adaptor_base.hpp +++ b/include/rpc/msgpack/adaptor/adaptor_base.hpp @@ -1,92 +1,18 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2015-2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_ADAPTOR_BASE_HPP #define MSGPACK_ADAPTOR_BASE_HPP -#include "rpc/msgpack/object_fwd.hpp" - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -template -class packer; - -namespace adaptor { - -// Adaptor functors - -template -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, T& v) const; -}; - -template -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, T const& v) const; -}; - -template -struct object { - void operator()(clmdep_msgpack::object& o, T const& v) const; -}; - -template -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, T const& v) const; -}; - -} // namespace adaptor - -// operators - -template -inline -clmdep_msgpack::object const& operator>> (clmdep_msgpack::object const& o, T& v) { - return adaptor::convert()(o, v); -} - -template -inline -clmdep_msgpack::packer& operator<< (clmdep_msgpack::packer& o, T const& v) { - return adaptor::pack()(o, v); -} - -template -inline -void operator<< (clmdep_msgpack::object& o, T const& v) { - adaptor::object()(o, v); -} - -template -inline -void operator<< (clmdep_msgpack::object::with_zone& o, T const& v) { - adaptor::object_with_zone()(o, v); -} - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/adaptor/adaptor_base_decl.hpp" +#include "rpc/msgpack/v1/adaptor/adaptor_base.hpp" +#include "rpc/msgpack/v2/adaptor/adaptor_base.hpp" #endif // MSGPACK_ADAPTOR_BASE_HPP diff --git a/include/rpc/msgpack/adaptor/adaptor_base_decl.hpp b/include/rpc/msgpack/adaptor/adaptor_base_decl.hpp new file mode 100644 index 00000000..2915933d --- /dev/null +++ b/include/rpc/msgpack/adaptor/adaptor_base_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_ADAPTOR_BASE_DECL_HPP +#define MSGPACK_ADAPTOR_BASE_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/adaptor_base_decl.hpp" +#include "rpc/msgpack/v2/adaptor/adaptor_base_decl.hpp" + +#endif // MSGPACK_ADAPTOR_BASE_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/array_ref.hpp b/include/rpc/msgpack/adaptor/array_ref.hpp index 393fc906..ddf8dfa9 100644 --- a/include/rpc/msgpack/adaptor/array_ref.hpp +++ b/include/rpc/msgpack/adaptor/array_ref.hpp @@ -1,182 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_ARRAY_REF_HPP #define MSGPACK_TYPE_ARRAY_REF_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { - -template -struct array_ref { - array_ref() : data(nullptr) {} - array_ref(T& t) : data(&t) {} - - T* data; - - template - bool operator==(array_ref const& t) const { - return *data == *t.data; - } - template - bool operator!=(array_ref const& t) const { - return !(*data == *t.data); - } - template - bool operator< (array_ref const& t) const - { - return *data < *t.data; - } - template - bool operator> (array_ref const& t) const - { - return *t.data < *data; - } - template - bool operator<= (array_ref const& t) const - { - return !(*t.data < *data); - } - template - bool operator>= (array_ref const& t) const - { - return !(*data < *t.data); - } -}; - -template -inline array_ref make_array_ref(T const& t) { - return array_ref(t); -} - -template -inline array_ref make_array_ref(T& t) { - return array_ref(t); -} - - -} // namespace type - -namespace adaptor { - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, clmdep_msgpack::type::array_ref& v) const { - if (!v.data) { throw clmdep_msgpack::type_error(); } - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if (v.data->size() < o.via.bin.size) { throw clmdep_msgpack::type_error(); } - if (o.via.array.size > 0) { - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - typename T::iterator it = v.data->begin(); - do { - p->convert(*it); - ++p; - ++it; - } while(p < pend); - } - return o; - } -}; - -template -struct convert > > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, clmdep_msgpack::type::array_ref >& v) const { - if (!v.data) { throw clmdep_msgpack::type_error(); } - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - v.data->resize(o.via.bin.size); - if (o.via.array.size > 0) { - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - typename std::vector::iterator it = v.data->begin(); - do { - p->convert(*it); - ++p; - ++it; - } while(p < pend); - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const clmdep_msgpack::type::array_ref& v) const { - if (!v.data) { throw clmdep_msgpack::type_error(); } - uint32_t size = checked_get_container_size(v.data->size()); - o.pack_array(size); - for (typename T::const_iterator it(v.data->begin()), it_end(v.data->end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const clmdep_msgpack::type::array_ref& v) const { - if (!v.data) { throw clmdep_msgpack::type_error(); } - o.type = clmdep_msgpack::type::ARRAY; - if (v.data->empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } - else { - uint32_t size = checked_get_container_size(v.data->size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename T::const_iterator it(v.data->begin()); - do { -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) - *p = clmdep_msgpack::object(*it, o.zone); -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/array_ref_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/array_ref.hpp" -#endif // MSGPACK_TYPE_ARRAY_REF_HPP +#endif // MSGPACK_TYPE_ARRAY_REFL_HPP diff --git a/include/rpc/msgpack/adaptor/array_ref_decl.hpp b/include/rpc/msgpack/adaptor/array_ref_decl.hpp new file mode 100644 index 00000000..550e24e7 --- /dev/null +++ b/include/rpc/msgpack/adaptor/array_ref_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_ARRAY_REF_DECL_HPP +#define MSGPACK_TYPE_ARRAY_REF_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/array_ref_decl.hpp" +#include "rpc/msgpack/v2/adaptor/array_ref_decl.hpp" + +#endif // MSGPACK_TYPE_ARRAY_REF_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/bool.hpp b/include/rpc/msgpack/adaptor/bool.hpp index f5867ca3..02b4c3f2 100644 --- a/include/rpc/msgpack/adaptor/bool.hpp +++ b/include/rpc/msgpack/adaptor/bool.hpp @@ -1,74 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_BOOL_HPP #define MSGPACK_TYPE_BOOL_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, bool& v) const { - if(o.type != clmdep_msgpack::type::BOOLEAN) { throw clmdep_msgpack::type_error(); } - v = o.via.boolean; - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const bool& v) const { - if(v) { o.pack_true(); } - else { o.pack_false(); } - return o; - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, bool v) const { - o.type = clmdep_msgpack::type::BOOLEAN; - o.via.boolean = v; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, bool v) const { - static_cast(o) << v; - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/bool.hpp" #endif // MSGPACK_TYPE_BOOL_HPP diff --git a/include/rpc/msgpack/adaptor/boost/fusion.hpp b/include/rpc/msgpack/adaptor/boost/fusion.hpp index 98085f2b..d44f517d 100644 --- a/include/rpc/msgpack/adaptor/boost/fusion.hpp +++ b/include/rpc/msgpack/adaptor/boost/fusion.hpp @@ -3,166 +3,13 @@ // // Copyright (C) 2015 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_BOOST_FUSION_HPP #define MSGPACK_TYPE_BOOST_FUSION_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" -#include "rpc/msgpack/meta.hpp" - -#if !defined (MSGPACK_USE_CPP03) -#include "rpc/msgpack/adaptor/cpp11/tuple.hpp" -#endif // #if !defined (MSGPACK_USE_CPP03) - -#include -#include -#include -#include -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -#if !defined (MSGPACK_USE_CPP03) - -template -struct as< - T, - typename clmdep_msgpack::enable_if< - boost::fusion::traits::is_sequence::value && - boost::mpl::fold< - T, - boost::mpl::bool_, - boost::mpl::if_ < - boost::mpl::and_< - boost::mpl::_1, - clmdep_msgpack::has_as - >, - boost::mpl::bool_, - boost::mpl::bool_ - > - >::type::value - >::type -> { - T operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if (o.via.array.size != checked_get_container_size(boost::mpl::size::value)) { - throw clmdep_msgpack::type_error(); - } - using tuple_t = decltype(to_tuple(std::declval(), gen_seq::value>())); - return to_t( - o.as(), - clmdep_msgpack::gen_seq::value>()); - } - template - static std::tuple< - typename std::remove_reference< - typename boost::fusion::result_of::at_c::type - >::type...> - to_tuple(U const& u, seq) { - return std::make_tuple(boost::fusion::at_c(u)...); - } - template - static T to_t(U const& u, seq) { - return T(std::get(u)...); - } -}; - -#endif // !defined (MSGPACK_USE_CPP03) - -template -struct convert::value>::type > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, T& v) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if (o.via.array.size != checked_get_container_size(boost::fusion::size(v))) { - throw clmdep_msgpack::type_error(); - } - uint32_t index = 0; - boost::fusion::for_each(v, convert_imp(o, index)); - return o; - } -private: - struct convert_imp { - convert_imp(clmdep_msgpack::object const& obj, uint32_t& index):obj_(obj), index_(index) {} - template - void operator()(U& v) const { - clmdep_msgpack::adaptor::convert()(obj_.via.array.ptr[index_++], v); - } - private: - clmdep_msgpack::object const& obj_; - uint32_t& index_; - }; -}; - -template -struct pack::value>::type > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const T& v) const { - uint32_t size = checked_get_container_size(boost::fusion::size(v)); - o.pack_array(size); - boost::fusion::for_each(v, pack_imp(o)); - return o; - } -private: - template - struct pack_imp { - pack_imp(clmdep_msgpack::packer& stream):stream_(stream) {} - template - void operator()(U const& v) const { - stream_.pack(v); - } - private: - clmdep_msgpack::packer& stream_; - }; -}; - -template -struct object_with_zone::value>::type > { - void operator()(clmdep_msgpack::object::with_zone& o, const T& v) const { - uint32_t size = checked_get_container_size(boost::fusion::size(v)); - o.type = clmdep_msgpack::type::ARRAY; - o.via.array.ptr = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - o.via.array.size = size; - uint32_t count = 0; - boost::fusion::for_each(v, with_zone_imp(o, count)); - } -private: - struct with_zone_imp { - with_zone_imp(clmdep_msgpack::object::with_zone const& obj, uint32_t& count):obj_(obj), count_(count) {} - template - void operator()(U const& v) const { - obj_.via.array.ptr[count_++] = clmdep_msgpack::object(v, obj_.zone); - } - clmdep_msgpack::object::with_zone const& obj_; - uint32_t& count_; - }; -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/boost/fusion.hpp" #endif // MSGPACK_TYPE_BOOST_FUSION_HPP diff --git a/include/rpc/msgpack/adaptor/boost/msgpack_variant.hpp b/include/rpc/msgpack/adaptor/boost/msgpack_variant.hpp index 7dbd2bec..128c3c0f 100644 --- a/include/rpc/msgpack/adaptor/boost/msgpack_variant.hpp +++ b/include/rpc/msgpack/adaptor/boost/msgpack_variant.hpp @@ -1,438 +1,18 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2015-2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_HPP #define MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_HPP -#if defined(MSGPACK_USE_BOOST) - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" -#include "rpc/msgpack/adaptor/boost/string_ref.hpp" - -#include "rpc/msgpack/adaptor/nil.hpp" -#include "rpc/msgpack/adaptor/bool.hpp" -#include "rpc/msgpack/adaptor/int.hpp" -#include "rpc/msgpack/adaptor/float.hpp" -#include "rpc/msgpack/adaptor/string.hpp" -#include "rpc/msgpack/adaptor/vector_char.hpp" -#include "rpc/msgpack/adaptor/raw.hpp" -#include "rpc/msgpack/adaptor/ext.hpp" -#include "rpc/msgpack/adaptor/vector.hpp" -#include "rpc/msgpack/adaptor/map.hpp" - -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { - - -template -struct basic_variant : - boost::variant< - nil, // NIL - bool, // BOOL - int64_t, // NEGATIVE_INTEGER - uint64_t, // POSITIVE_INTEGER - double, // FLOAT - std::string, // STR -#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - boost::string_ref, // STR -#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - std::vector, // BIN - clmdep_msgpack::type::raw_ref, // BIN - ext, // EXT - ext_ref, // EXT - boost::recursive_wrapper > >, // ARRAY - boost::recursive_wrapper, basic_variant > >, // MAP - boost::recursive_wrapper, basic_variant > >// MAP - >, - private boost::totally_ordered > { - typedef boost::variant< - nil, // NIL - bool, // BOOL - int64_t, // NEGATIVE_INTEGER - uint64_t, // POSITIVE_INTEGER - double, // FLOAT - std::string, // STR -#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - boost::string_ref, // STR -#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - std::vector, // BIN - clmdep_msgpack::type::raw_ref, // BIN - ext, // EXT - ext_ref, // EXT - boost::recursive_wrapper > >, // ARRAY - boost::recursive_wrapper, basic_variant > >, // MAP - boost::recursive_wrapper, basic_variant > >// MAP - > base; - basic_variant() {} - template - basic_variant(T const& t):base(t) {} - basic_variant(char const* p):base(std::string(p)) {} - basic_variant(char v) { - int_init(v); - } - basic_variant(signed char v) { - int_init(v); - } - basic_variant(unsigned char v):base(uint64_t(v)) {} - basic_variant(signed int v) { - int_init(v); - } - basic_variant(unsigned int v):base(uint64_t(v)) {} - basic_variant(signed long v) { - int_init(v); - } - basic_variant(unsigned long v):base(uint64_t(v)) {} - basic_variant(signed long long v) { - int_init(v); - } - basic_variant(unsigned long long v):base(uint64_t(v)) {} - - bool is_nil() const { - return boost::get(this); - } - bool is_bool() const { - return boost::get(this); - } - bool is_int64_t() const { - return boost::get(this); - } - bool is_uint64_t() const { - return boost::get(this); - } - bool is_double() const { - return boost::get(this); - } - bool is_string() const { - return boost::get(this); - } -#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - bool is_boost_string_ref() const { - return boost::get(this); - } -#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - bool is_vector_char() const { - return boost::get >(this); - } - bool is_vector_char() { - return boost::get >(this); - } - bool is_raw_ref() const { - return boost::get(this); - } - bool is_ext() const { - return boost::get(this); - } - bool is_ext_ref() const { - return boost::get(this); - } - bool is_vector() const { - return boost::get > >(this); - } - bool is_map() const { - return boost::get, basic_variant > >(this); - } - bool is_multimap() const { - return boost::get, basic_variant > >(this); - } - - bool as_bool() const { - return boost::get(*this); - } - int64_t as_int64_t() const { - return boost::get(*this); - } - int64_t& as_int64_t() { - return boost::get(*this); - } - uint64_t as_uint64_t() const { - return boost::get(*this); - } - uint64_t& as_uint64_t() { - return boost::get(*this); - } - double as_double() const { - return boost::get(*this); - } - double& as_double() { - return boost::get(*this); - } - std::string const& as_string() const { - return boost::get(*this); - } - std::string& as_string() { - return boost::get(*this); - } -#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - boost::string_ref const& as_boost_string_ref() const { - return boost::get(*this); - } - boost::string_ref& as_boost_string_ref() { - return boost::get(*this); - } -#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - std::vector const& as_vector_char() const { - return boost::get >(*this); - } - std::vector& as_vector_char() { - return boost::get >(*this); - } - raw_ref const& as_raw_ref() const { - return boost::get(*this); - } - ext const& as_ext() const { - return boost::get(*this); - } - ext& as_ext() { - return boost::get(*this); - } - ext_ref const& as_ext_ref() const { - return boost::get(*this); - } - std::vector > const& as_vector() const { - return boost::get > >(*this); - } - std::vector >& as_vector() { - return boost::get > >(*this); - } - std::map, basic_variant > const& as_map() const { - return boost::get, basic_variant > >(*this); - } - std::map, basic_variant >& as_map() { - return boost::get, basic_variant > >(*this); - } - std::multimap, basic_variant > const& as_multimap() const { - return boost::get, basic_variant > >(*this); - } - std::multimap, basic_variant >& as_multimap() { - return boost::get, basic_variant > >(*this); - } -private: - template - void int_init(T v) { - if (v < 0) { - static_cast(*this) = int64_t(v); - } - else { - static_cast(*this) = uint64_t(v); - } - } -}; - -template -inline bool operator<(basic_variant const& lhs, basic_variant const& rhs) { - return - static_cast::base const&>(lhs) < - static_cast::base const&>(rhs); -} - -template -inline bool operator==(basic_variant const& lhs, basic_variant const& rhs) { - return - static_cast::base const&>(lhs) == - static_cast::base const&>(rhs); -} - -typedef basic_variant, ext> variant; -typedef basic_variant< -#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - boost::string_ref, -#else // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - std::string, -#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - raw_ref, ext_ref> variant_ref; - -} // namespace type - -namespace adaptor { - -#if !defined (MSGPACK_USE_CPP03) - -template -struct as > { - clmdep_msgpack::type::basic_variant operator()(clmdep_msgpack::object const& o) const { - switch(o.type) { - case type::NIL: - return o.as(); - case type::BOOLEAN: - return o.as(); - case type::POSITIVE_INTEGER: - return o.as(); - case type::NEGATIVE_INTEGER: - return o.as(); - case type::FLOAT: - return o.as(); - case type::STR: - return o.as(); - case type::BIN: - return o.as(); - case type::EXT: - return o.as(); - case type::ARRAY: - return o.as > >(); - case type::MAP: - return o.as, clmdep_msgpack::type::basic_variant > >(); - default: - break; - } - return clmdep_msgpack::type::basic_variant(); - } -}; - -#endif // !defined (MSGPACK_USE_CPP03) - - -template -struct convert > { - clmdep_msgpack::object const& operator()( - clmdep_msgpack::object const& o, - clmdep_msgpack::type::basic_variant& v) const { - switch(o.type) { - case type::NIL: - v = o.as(); - break; - case type::BOOLEAN: - v = o.as(); - break; - case type::POSITIVE_INTEGER: - v = o.as(); - break; - case type::NEGATIVE_INTEGER: - v = o.as(); - break; - case type::FLOAT: - v = o.as(); - break; - case type::STR: - v = o.as(); - break; - case type::BIN: - v = o.as(); - break; - case type::EXT: - v = o.as(); - break; - case type::ARRAY: - v = o.as > >(); - break; - case type::MAP: - v = o.as, clmdep_msgpack::type::basic_variant > >(); - break; - default: - break; - } - return o; - } -}; - -namespace detail { - -template -struct pack_imp : boost::static_visitor { - template - void operator()(T const& value) const { - pack()(o_, value); - } - pack_imp(packer& o):o_(o) {} - packer& o_; -}; - -} // namespace detail - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const clmdep_msgpack::type::basic_variant& v) const { - boost::apply_visitor(detail::pack_imp(o), v); - return o; - } -}; - -namespace detail { - -struct object_imp : boost::static_visitor { - void operator()(clmdep_msgpack::type::nil const& v) const { - object()(o_, v); - } - void operator()(bool const& v) const { - object()(o_, v); - } - void operator()(uint64_t const& v) const { - object()(o_, v); - } - void operator()(int64_t const& v) const { - object()(o_, v); - } - void operator()(double const& v) const { - object()(o_, v); - } - template - void operator()(T const&) const { - throw clmdep_msgpack::type_error(); - } - object_imp(clmdep_msgpack::object& o):o_(o) {} - clmdep_msgpack::object& o_; -}; - -} // namespace detail - -template -struct object > { - void operator()(clmdep_msgpack::object& o, const clmdep_msgpack::type::basic_variant& v) const { - boost::apply_visitor(detail::object_imp(o), v); - } -}; - -namespace detail { - -struct object_with_zone_imp : boost::static_visitor { - template - void operator()(T const& v) const { - object_with_zone()(o_, v); - } - object_with_zone_imp(clmdep_msgpack::object::with_zone& o):o_(o) {} - clmdep_msgpack::object::with_zone& o_; -}; - -} // namespace detail - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const clmdep_msgpack::type::basic_variant& v) const { - boost::apply_visitor(detail::object_with_zone_imp(o), v); - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/boost/msgpack_variant_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/boost/msgpack_variant.hpp" +//#include "rpc/msgpack/v2/adaptor/boost/msgpack_variant.hpp" -#endif // MSGPACK_USE_BOOST #endif // MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_HPP diff --git a/include/rpc/msgpack/adaptor/boost/msgpack_variant_decl.hpp b/include/rpc/msgpack/adaptor/boost/msgpack_variant_decl.hpp new file mode 100644 index 00000000..258967b3 --- /dev/null +++ b/include/rpc/msgpack/adaptor/boost/msgpack_variant_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_DECL_HPP +#define MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp" +#include "rpc/msgpack/v2/adaptor/boost/msgpack_variant_decl.hpp" + +#endif // MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/boost/optional.hpp b/include/rpc/msgpack/adaptor/boost/optional.hpp index 74f7908e..26d0a8b7 100644 --- a/include/rpc/msgpack/adaptor/boost/optional.hpp +++ b/include/rpc/msgpack/adaptor/boost/optional.hpp @@ -1,104 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_BOOST_OPTIONAL_HPP #define MSGPACK_TYPE_BOOST_OPTIONAL_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -// To supress warning on Boost.1.58.0 -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__) - -#include - -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__) -#pragma GCC diagnostic pop -#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__) - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -#if !defined (MSGPACK_USE_CPP03) - -template -struct as, typename std::enable_if::value>::type> { - boost::optional operator()(clmdep_msgpack::object const& o) const { - if(o.is_nil()) return boost::none; - return o.as(); - } -}; - -#endif // !defined (MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, boost::optional& v) const { - if(o.is_nil()) v = boost::none; - else { - T t; - clmdep_msgpack::adaptor::convert()(o, t); - v = t; - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const boost::optional& v) const { - if (v) o.pack(*v); - else o.pack_nil(); - return o; - } -}; - -template -struct object > { - void operator()(clmdep_msgpack::object& o, const boost::optional& v) const { - if (v) clmdep_msgpack::adaptor::object()(o, *v); - else o.type = clmdep_msgpack::type::NIL; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const boost::optional& v) const { - if (v) clmdep_msgpack::adaptor::object_with_zone()(o, *v); - else o.type = clmdep_msgpack::type::NIL; - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/boost/optional.hpp" #endif // MSGPACK_TYPE_BOOST_OPTIONAL_HPP diff --git a/include/rpc/msgpack/adaptor/boost/string_ref.hpp b/include/rpc/msgpack/adaptor/boost/string_ref.hpp index 6dea3da5..d487b061 100644 --- a/include/rpc/msgpack/adaptor/boost/string_ref.hpp +++ b/include/rpc/msgpack/adaptor/boost/string_ref.hpp @@ -1,95 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_BOOST_STRING_REF_HPP #define MSGPACK_TYPE_BOOST_STRING_REF_HPP -#include -#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, boost::string_ref& v) const { - switch (o.type) { - case clmdep_msgpack::type::BIN: - v = boost::string_ref(o.via.bin.ptr, o.via.bin.size); - break; - case clmdep_msgpack::type::STR: - v = boost::string_ref(o.via.str.ptr, o.via.str.size); - break; - default: - throw clmdep_msgpack::type_error(); - break; - } - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const boost::string_ref& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_str(size); - o.pack_str_body(v.data(), size); - return o; - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, const boost::string_ref& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::STR; - o.via.str.ptr = v.data(); - o.via.str.size = size; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const boost::string_ref& v) const { - static_cast(o) << v; - } -}; - - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack - -#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53 +#include "rpc/msgpack/v1/adaptor/boost/string_ref.hpp" #endif // MSGPACK_TYPE_BOOST_STRING_REF_HPP diff --git a/include/rpc/msgpack/adaptor/boost/string_view.hpp b/include/rpc/msgpack/adaptor/boost/string_view.hpp new file mode 100644 index 00000000..fde49a5b --- /dev/null +++ b/include/rpc/msgpack/adaptor/boost/string_view.hpp @@ -0,0 +1,15 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2017 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_BOOST_STRING_VIEW_HPP +#define MSGPACK_TYPE_BOOST_STRING_VIEW_HPP + +#include "rpc/msgpack/v1/adaptor/boost/string_view.hpp" + +#endif // MSGPACK_TYPE_BOOST_STRING_VIEW_HPP diff --git a/include/rpc/msgpack/adaptor/carray.hpp b/include/rpc/msgpack/adaptor/carray.hpp new file mode 100644 index 00000000..08e0f1eb --- /dev/null +++ b/include/rpc/msgpack/adaptor/carray.hpp @@ -0,0 +1,15 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_CARRAY_HPP +#define MSGPACK_TYPE_CARRAY_HPP + +#include "rpc/msgpack/v1/adaptor/carray.hpp" + +#endif // MSGPACK_TYPE_CARRAY_HPP diff --git a/include/rpc/msgpack/adaptor/char_ptr.hpp b/include/rpc/msgpack/adaptor/char_ptr.hpp index 0743524a..406e3246 100644 --- a/include/rpc/msgpack/adaptor/char_ptr.hpp +++ b/include/rpc/msgpack/adaptor/char_ptr.hpp @@ -1,165 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_CHAR_PTR_HPP #define MSGPACK_TYPE_CHAR_PTR_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/object_fwd.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.pack_str(size); - o.pack_str_body(v, size); - return o; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.type = clmdep_msgpack::type::STR; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.str.ptr = ptr; - o.via.str.size = size; - std::memcpy(ptr, v, size); - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.type = clmdep_msgpack::type::STR; - o.via.str.ptr = v; - o.via.str.size = size; - } -}; - - -template <> -struct pack { - template - packer& operator()(packer& o, char* v) const { - return o << static_cast(v); - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, char* v) const { - o << static_cast(v); - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, char* v) const { - o << static_cast(v); - } -}; - -template -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.pack_str(size); - o.pack_str_body(v, size); - return o; - } -}; - -template -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.type = clmdep_msgpack::type::STR; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.str.ptr = ptr; - o.via.str.size = size; - std::memcpy(ptr, v, size); - } -}; - -template -struct object { - void operator()(clmdep_msgpack::object& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.type = clmdep_msgpack::type::STR; - o.via.str.ptr = v; - o.via.str.size = size; - } -}; - -template -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.pack_str(size); - o.pack_str_body(v, size); - return o; - } -}; - -template -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.type = clmdep_msgpack::type::STR; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.str.ptr = ptr; - o.via.str.size = size; - std::memcpy(ptr, v, size); - } -}; - -template -struct object { - void operator()(clmdep_msgpack::object& o, const char* v) const { - uint32_t size = checked_get_container_size(std::strlen(v)); - o.type = clmdep_msgpack::type::STR; - o.via.str.ptr = v; - o.via.str.size = size; - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/char_ptr.hpp" #endif // MSGPACK_TYPE_CHAR_PTR_HPP diff --git a/include/rpc/msgpack/adaptor/check_container_size.hpp b/include/rpc/msgpack/adaptor/check_container_size.hpp index a5b4531b..f65c5d5d 100644 --- a/include/rpc/msgpack/adaptor/check_container_size.hpp +++ b/include/rpc/msgpack/adaptor/check_container_size.hpp @@ -1,75 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2015-2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_CHECK_CONTAINER_SIZE_HPP #define MSGPACK_CHECK_CONTAINER_SIZE_HPP -#include "rpc/msgpack/versioning.hpp" -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -struct container_size_overflow : public std::runtime_error { - explicit container_size_overflow(const std::string& msg) - :std::runtime_error(msg) {} -#if !defined(MSGPACK_USE_CPP03) - explicit container_size_overflow(const char* msg): - std::runtime_error(msg) {} -#endif // !defined(MSGPACK_USE_CPP03) -}; - -namespace detail { - -template -inline void check_container_size(std::size_t size) { - if (size > 0xffffffff) throw container_size_overflow("container size overflow"); -} - -template <> -inline void check_container_size<4>(std::size_t /*size*/) { -} - -template -inline void check_container_size_for_ext(std::size_t size) { - if (size > 0xffffffff) throw container_size_overflow("container size overflow"); -} - -template <> -inline void check_container_size_for_ext<4>(std::size_t size) { - if (size > 0xfffffffe) throw container_size_overflow("container size overflow"); -} - -} // namespace detail - -template -inline uint32_t checked_get_container_size(T size) { - detail::check_container_size(size); - return static_cast(size); -} - - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/check_container_size_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/check_container_size.hpp" #endif // MSGPACK_CHECK_CONTAINER_SIZE_HPP diff --git a/include/rpc/msgpack/adaptor/check_container_size_decl.hpp b/include/rpc/msgpack/adaptor/check_container_size_decl.hpp new file mode 100644 index 00000000..ee698567 --- /dev/null +++ b/include/rpc/msgpack/adaptor/check_container_size_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_CHECK_CONTAINER_SIZE_DECL_HPP +#define MSGPACK_CHECK_CONTAINER_SIZE_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/check_container_size_decl.hpp" +#include "rpc/msgpack/v2/adaptor/check_container_size_decl.hpp" + +#endif // MSGPACK_CHECK_CONTAINER_SIZE_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/array.hpp b/include/rpc/msgpack/adaptor/cpp11/array.hpp index 0a234a1b..f7d2b038 100644 --- a/include/rpc/msgpack/adaptor/cpp11/array.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/array.hpp @@ -1,146 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef MSGPACK_CPP11_ARRAY_HPP -#define MSGPACK_CPP11_ARRAY_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" -#include "rpc/msgpack/meta.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -namespace detail { - -namespace array { - -template -inline std::array concat( - std::array&& a1, - std::array&& a2, - clmdep_msgpack::seq, - clmdep_msgpack::seq) { - return {{ std::move(a1[I1])..., std::move(a2[I2])... }}; -} - -template -inline std::array concat(std::array&& a1, std::array&& a2) { - return concat(std::move(a1), std::move(a2), clmdep_msgpack::gen_seq(), clmdep_msgpack::gen_seq()); -} - -template -struct as_impl { - static std::array as(clmdep_msgpack::object const& o) { - clmdep_msgpack::object* p = o.via.array.ptr + N - 1; - return concat(as_impl::as(o), std::array{{p->as()}}); - } -}; - -template -struct as_impl { - static std::array as(clmdep_msgpack::object const& o) { - clmdep_msgpack::object* p = o.via.array.ptr; - return std::array{{p->as()}}; - } -}; - -template -struct as_impl { - static std::array as(clmdep_msgpack::object const&) { - return std::array(); - } -}; - -} // namespace array - -} // namespace detail - -template -struct as, typename std::enable_if::value>::type> { - std::array operator()(clmdep_msgpack::object const& o) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if(o.via.array.size != N) { throw clmdep_msgpack::type_error(); } - return detail::array::as_impl::as(o); - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::array& v) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if(o.via.array.size != N) { throw clmdep_msgpack::type_error(); } - if(o.via.array.size > 0) { - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - T* it = &v[0]; - do { - p->convert(*it); - ++p; - ++it; - } while(p < pend); - } - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::array& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for(auto const& e : v) o.pack(e); - return o; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::array& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if(v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - o.via.array.size = size; - o.via.array.ptr = p; - for (auto const& e : v) *p++ = clmdep_msgpack::object(e, o.zone); - } - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_ARRAY_HPP +#define MSGPACK_TYPE_CPP11_ARRAY_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/array.hpp" -#endif // MSGPACK_CPP11_ARRAY_HPP +#endif // MSGPACK_TYPE_CPP11_ARRAY_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/array_char.hpp b/include/rpc/msgpack/adaptor/cpp11/array_char.hpp index e2a5dcf4..922b65f6 100644 --- a/include/rpc/msgpack/adaptor/cpp11/array_char.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/array_char.hpp @@ -1,97 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef MSGPACK_TYPE_ARRAY_CHAR_HPP -#define MSGPACK_TYPE_ARRAY_CHAR_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::array& v) const { - switch (o.type) { - case clmdep_msgpack::type::BIN: - if(o.via.bin.size != N) { throw clmdep_msgpack::type_error(); } - std::memcpy(v.data(), o.via.bin.ptr, o.via.bin.size); - break; - case clmdep_msgpack::type::STR: - if(o.via.str.size != N) { throw clmdep_msgpack::type_error(); } - std::memcpy(v.data(), o.via.str.ptr, N); - break; - default: - throw clmdep_msgpack::type_error(); - break; - } - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::array& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_bin(size); - o.pack_bin_body(v.data(), size); - - return o; - } -}; - -template -struct object> { - void operator()(clmdep_msgpack::object& o, const std::array& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - o.via.bin.ptr = v.data(); - o.via.bin.size = size; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::array& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.bin.ptr = ptr; - o.via.bin.size = size; - std::memcpy(ptr, v.data(), size); - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_ARRAY_CHAR_HPP +#define MSGPACK_TYPE_CPP11_ARRAY_CHAR_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/array_char.hpp" -#endif // MSGPACK_TYPE_ARRAY_CHAR_HPP +#endif // MSGPACK_TYPE_CPP11_ARRAY_CHAR_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/array_unsigned_char.hpp b/include/rpc/msgpack/adaptor/cpp11/array_unsigned_char.hpp index 35b1df63..c31841d4 100644 --- a/include/rpc/msgpack/adaptor/cpp11/array_unsigned_char.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/array_unsigned_char.hpp @@ -1,97 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef MSGPACK_TYPE_ARRAY_UNSIGNED_CHAR_HPP -#define MSGPACK_TYPE_ARRAY_UNSIGNED_CHAR_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::array& v) const { - switch (o.type) { - case clmdep_msgpack::type::BIN: - if(o.via.bin.size != N) { throw clmdep_msgpack::type_error(); } - std::memcpy(v.data(), o.via.bin.ptr, o.via.bin.size); - break; - case clmdep_msgpack::type::STR: - if(o.via.str.size != N) { throw clmdep_msgpack::type_error(); } - std::memcpy(v.data(), o.via.str.ptr, N); - break; - default: - throw clmdep_msgpack::type_error(); - break; - } - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::array& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_bin(size); - o.pack_bin_body(reinterpret_cast(v.data()), size); - - return o; - } -}; - -template -struct object> { - void operator()(clmdep_msgpack::object& o, const std::array& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - o.via.bin.ptr = reinterpret_cast(v.data()); - o.via.bin.size = size; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::array& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.bin.ptr = ptr; - o.via.bin.size = size; - std::memcpy(ptr, v.data(), size); - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_ARRAY_UNSIGNED_CHAR_HPP +#define MSGPACK_TYPE_CPP11_ARRAY_UNSIGNED_CHAR_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/array_unsigned_char.hpp" -#endif // MSGPACK_TYPE_ARRAY_UNSIGNED_CHAR_HPP +#endif // MSGPACK_TYPE_CPP11_ARRAY_UNSIGNED_CHAR_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/forward_list.hpp b/include/rpc/msgpack/adaptor/cpp11/forward_list.hpp index b1200760..44329ce1 100644 --- a/include/rpc/msgpack/adaptor/cpp11/forward_list.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/forward_list.hpp @@ -1,102 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014 KONDO-2015 Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef MSGPACK_CPP11_FORWARD_LIST_HPP -#define MSGPACK_CPP11_FORWARD_LIST_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template - struct as, typename std::enable_if::value>::type> { - std::forward_list operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - std::forward_list v; - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pend = o.via.array.ptr; - while (p != pend) { - --p; - v.push_front(p->as()); - } - return v; - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::forward_list& v) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - v.resize(o.via.array.size); - clmdep_msgpack::object* p = o.via.array.ptr; - for (auto &e : v) { - p->convert(e); - ++p; - } - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::forward_list& v) const { - uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end())); - o.pack_array(size); - for(auto const& e : v) o.pack(e); - return o; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::forward_list& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if(v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } else { - uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end())); - o.via.array.size = size; - clmdep_msgpack::object* p = static_cast( - o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - o.via.array.ptr = p; - for(auto const& e : v) *p++ = clmdep_msgpack::object(e, o.zone); - } - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_FORWARD_LIST_HPP +#define MSGPACK_TYPE_CPP11_FORWARD_LIST_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/forward_list.hpp" -#endif // MSGPACK_CPP11_FORWARD_LIST_HPP +#endif // MSGPACK_TYPE_CPP11_FORWARD_LIST_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/reference_wrapper.hpp b/include/rpc/msgpack/adaptor/cpp11/reference_wrapper.hpp new file mode 100644 index 00000000..3c15d3e2 --- /dev/null +++ b/include/rpc/msgpack/adaptor/cpp11/reference_wrapper.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MSGPACK_TYPE_CPP11_REFERENCE_WRAPPER_HPP +#define MSGPACK_TYPE_CPP11_REFERENCE_WRAPPER_HPP + +#include "rpc/msgpack/v1/adaptor/cpp11/reference_wrapper.hpp" + +#endif // MSGPACK_TYPE_CPP11_REFERENCE_WRAPPER_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/shared_ptr.hpp b/include/rpc/msgpack/adaptor/cpp11/shared_ptr.hpp index 9054c781..0dff7995 100644 --- a/include/rpc/msgpack/adaptor/cpp11/shared_ptr.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/shared_ptr.hpp @@ -1,90 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef MSGPACK_CPP11_SHARED_PTR_HPP -#define MSGPACK_CPP11_SHARED_PTR_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct as, typename std::enable_if::value>::type> { - std::shared_ptr operator()(clmdep_msgpack::object const& o) const { - if(o.is_nil()) return nullptr; - return std::make_shared(o.as()); - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::shared_ptr& v) const { - if(o.is_nil()) v.reset(); - else { - v = std::make_shared(); - clmdep_msgpack::adaptor::convert()(o, *v); - } - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::shared_ptr& v) const { - if (v) o.pack(*v); - else o.pack_nil(); - return o; - } -}; - -template -struct object > { - void operator()(clmdep_msgpack::object& o, const std::shared_ptr& v) const { - if (v) clmdep_msgpack::adaptor::object()(o, *v); - else o.type = clmdep_msgpack::type::NIL; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::shared_ptr& v) const { - if (v) clmdep_msgpack::adaptor::object_with_zone()(o, *v); - else o.type = clmdep_msgpack::type::NIL; - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_SHARED_PTR_HPP +#define MSGPACK_TYPE_CPP11_SHARED_PTR_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/shared_ptr.hpp" -#endif // MSGPACK_CPP11_SHARED_PTR_HPP +#endif // MSGPACK_TYPE_CPP11_SHARED_PTR_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/tuple.hpp b/include/rpc/msgpack/adaptor/cpp11/tuple.hpp index 35be7b12..242a027f 100644 --- a/include/rpc/msgpack/adaptor/cpp11/tuple.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/tuple.hpp @@ -1,184 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef MSGPACK_CPP11_TUPLE_HPP -#define MSGPACK_CPP11_TUPLE_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" -#include "rpc/msgpack/meta.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -// --- Pack from tuple to packer stream --- -template -struct StdTuplePacker { - static void pack( - clmdep_msgpack::packer& o, - const Tuple& v) { - StdTuplePacker::pack(o, v); - o.pack(std::get(v)); - } -}; - -template -struct StdTuplePacker { - static void pack ( - clmdep_msgpack::packer&, - const Tuple&) { - } -}; - -namespace adaptor { - -template -struct pack> { - template - clmdep_msgpack::packer& operator()( - clmdep_msgpack::packer& o, - const std::tuple& v) const { - uint32_t size = checked_get_container_size(sizeof...(Args)); - o.pack_array(size); - StdTuplePacker::pack(o, v); - return o; - } -}; - -} // namespace adaptor - -// --- Convert from tuple to object --- - -template -struct StdTupleAs; - -template -struct StdTupleAsImpl { - static std::tuple as(clmdep_msgpack::object const& o) { - return std::tuple_cat( - std::make_tuple(o.via.array.ptr[o.via.array.size - sizeof...(Args) - 1].as()), - StdTupleAs::as(o)); - } -}; - -template -struct StdTupleAs { - static std::tuple as(clmdep_msgpack::object const& o) { - return StdTupleAsImpl::as(o); - } -}; - -template <> -struct StdTupleAs<> { - static std::tuple<> as (clmdep_msgpack::object const&) { - return std::tuple<>(); - } -}; - -template -struct StdTupleConverter { - static void convert( - clmdep_msgpack::object const& o, - Tuple& v) { - StdTupleConverter::convert(o, v); - o.via.array.ptr[N-1].convert(v))>::type>(std::get(v)); - } -}; - -template -struct StdTupleConverter { - static void convert ( - clmdep_msgpack::object const&, - Tuple&) { - } -}; - -namespace adaptor { - -template -struct as, typename std::enable_if::value>::type> { - std::tuple operator()( - clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if (o.via.array.size < sizeof...(Args)) { throw clmdep_msgpack::type_error(); } - return StdTupleAs::as(o); - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()( - clmdep_msgpack::object const& o, - std::tuple& v) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if(o.via.array.size < sizeof...(Args)) { throw clmdep_msgpack::type_error(); } - StdTupleConverter::convert(o, v); - return o; - } -}; - -} // namespace adaptor - -// --- Convert from tuple to object with zone --- -template -struct StdTupleToObjectWithZone { - static void convert( - clmdep_msgpack::object::with_zone& o, - const Tuple& v) { - StdTupleToObjectWithZone::convert(o, v); - o.via.array.ptr[N-1] = clmdep_msgpack::object(std::get(v), o.zone); - } -}; - -template -struct StdTupleToObjectWithZone { - static void convert ( - clmdep_msgpack::object::with_zone&, - const Tuple&) { - } -}; - -namespace adaptor { - -template -struct object_with_zone> { - void operator()( - clmdep_msgpack::object::with_zone& o, - std::tuple const& v) const { - uint32_t size = checked_get_container_size(sizeof...(Args)); - o.type = clmdep_msgpack::type::ARRAY; - o.via.array.ptr = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - o.via.array.size = size; - StdTupleToObjectWithZone::convert(o, v); - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_TUPLE_HPP +#define MSGPACK_TYPE_CPP11_TUPLE_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/tuple.hpp" -#endif // MSGPACK_CPP11_TUPLE_HPP +#endif // MSGPACK_TYPE_CPP11_TUPLE_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/unique_ptr.hpp b/include/rpc/msgpack/adaptor/cpp11/unique_ptr.hpp index 49792b06..874ad176 100644 --- a/include/rpc/msgpack/adaptor/cpp11/unique_ptr.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/unique_ptr.hpp @@ -1,90 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef MSGPACK_CPP11_UNIQUE_PTR_HPP -#define MSGPACK_CPP11_UNIQUE_PTR_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct as, typename std::enable_if::value>::type> { - std::unique_ptr operator()(clmdep_msgpack::object const& o) const { - if(o.is_nil()) return nullptr; - return std::unique_ptr(new T(o.as())); - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::unique_ptr& v) const { - if(o.is_nil()) v.reset(); - else { - v.reset(new T); - clmdep_msgpack::adaptor::convert()(o, *v); - } - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::unique_ptr& v) const { - if (v) o.pack(*v); - else o.pack_nil(); - return o; - } -}; - -template -struct object > { - void operator()(clmdep_msgpack::object& o, const std::unique_ptr& v) const { - if (v) clmdep_msgpack::adaptor::object()(o, *v); - else o.type = clmdep_msgpack::type::NIL; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::unique_ptr& v) const { - if (v) clmdep_msgpack::adaptor::object_with_zone()(o, *v); - else o.type = clmdep_msgpack::type::NIL; - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_UNIQUE_PTR_HPP +#define MSGPACK_TYPE_CPP11_UNIQUE_PTR_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/unique_ptr.hpp" -#endif // MSGPACK_CPP11_UNIQUE_PTR_HPP +#endif // MSGPACK_TYPE_CPP11_UNIQUE_PTR_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/unordered_map.hpp b/include/rpc/msgpack/adaptor/cpp11/unordered_map.hpp index 428c987d..93d7db60 100644 --- a/include/rpc/msgpack/adaptor/cpp11/unordered_map.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/unordered_map.hpp @@ -1,190 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef MSGPACK_TYPE_UNORDERED_MAP_HPP -#define MSGPACK_TYPE_UNORDERED_MAP_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct as< - std::unordered_map, - typename std::enable_if::value && clmdep_msgpack::has_as::value>::type> { - std::unordered_map operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::unordered_map v; - for (; p != pend; ++p) { - v.emplace(p->key.as(), p->val.as()); - } - return v; - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::unordered_map& v) const { - if(o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::unordered_map tmp; - for(; p != pend; ++p) { - K key; - p->key.convert(key); - p->val.convert(tmp[std::move(key)]); - } - v = std::move(tmp); - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::unordered_map& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_map(size); - for(typename std::unordered_map::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(it->first); - o.pack(it->second); - } - return o; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::unordered_map& v) const { - o.type = clmdep_msgpack::type::MAP; - if(v.empty()) { - o.via.map.ptr = nullptr; - o.via.map.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size)); - clmdep_msgpack::object_kv* const pend = p + size; - o.via.map.ptr = p; - o.via.map.size = size; - typename std::unordered_map::const_iterator it(v.begin()); - do { - p->key = clmdep_msgpack::object(it->first, o.zone); - p->val = clmdep_msgpack::object(it->second, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - - -template -struct as< - std::unordered_multimap, - typename std::enable_if::value && clmdep_msgpack::has_as::value>::type> { - std::unordered_multimap operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::unordered_multimap v; - for (; p != pend; ++p) { - v.emplace(p->key.as(), p->val.as()); - } - return v; - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::unordered_multimap& v) const { - if(o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::unordered_multimap tmp; - for(; p != pend; ++p) { - std::pair value; - p->key.convert(value.first); - p->val.convert(value.second); - tmp.insert(std::move(value)); - } - v = std::move(tmp); - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::unordered_multimap& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_map(size); - for(typename std::unordered_multimap::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(it->first); - o.pack(it->second); - } - return o; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::unordered_multimap& v) const { - o.type = clmdep_msgpack::type::MAP; - if(v.empty()) { - o.via.map.ptr = nullptr; - o.via.map.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size)); - clmdep_msgpack::object_kv* const pend = p + size; - o.via.map.ptr = p; - o.via.map.size = size; - typename std::unordered_multimap::const_iterator it(v.begin()); - do { - p->key = clmdep_msgpack::object(it->first, o.zone); - p->val = clmdep_msgpack::object(it->second, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond -} // namespace clmdep_msgpack +#ifndef MSGPACK_TYPE_CPP11_UNORDERED_MAP_HPP +#define MSGPACK_TYPE_CPP11_UNORDERED_MAP_HPP +#include "rpc/msgpack/v1/adaptor/cpp11/unordered_map.hpp" -#endif // MSGPACK_TYPE_UNORDERED_MAP_HPP +#endif // MSGPACK_TYPE_CPP11_UNORDERED_MAP_HPP diff --git a/include/rpc/msgpack/adaptor/cpp11/unordered_set.hpp b/include/rpc/msgpack/adaptor/cpp11/unordered_set.hpp index 2e5eeef1..46b8c131 100644 --- a/include/rpc/msgpack/adaptor/cpp11/unordered_set.hpp +++ b/include/rpc/msgpack/adaptor/cpp11/unordered_set.hpp @@ -1,180 +1,16 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef MSGPACK_TYPE_UNORDERED_SET_HPP -#define MSGPACK_TYPE_UNORDERED_SET_HPP - -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct as, typename std::enable_if::value>::type> { - std::unordered_set operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::unordered_set v; - while (p > pbegin) { - --p; - v.insert(p->as()); - } - return v; - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::unordered_set& v) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::unordered_set tmp; - while(p > pbegin) { - --p; - tmp.insert(p->as()); - } - v = std::move(tmp); - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::unordered_set& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for(typename std::unordered_set::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::unordered_set& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if(v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::unordered_set::const_iterator it(v.begin()); - do { - *p = clmdep_msgpack::object(*it, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - - -template -struct as, typename std::enable_if::value>::type> { - std::unordered_multiset operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::unordered_multiset v; - while (p > pbegin) { - --p; - v.insert(p->as()); - } - return v; - } -}; - -template -struct convert> { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::unordered_multiset& v) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::unordered_multiset tmp; - while(p > pbegin) { - --p; - tmp.insert(p->as()); - } - v = std::move(tmp); - return o; - } -}; - -template -struct pack> { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::unordered_multiset& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for(typename std::unordered_multiset::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone> { - void operator()(clmdep_msgpack::object::with_zone& o, const std::unordered_multiset& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if(v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::unordered_multiset::const_iterator it(v.begin()); - do { - *p = clmdep_msgpack::object(*it, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#ifndef MSGPACK_TYPE_CPP11_UNORDERED_SET_HPP +#define MSGPACK_TYPE_CPP11_UNORDERED_SET_HPP -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/cpp11/unordered_set.hpp" -#endif // MSGPACK_TYPE_UNORDERED_SET_HPP +#endif // MSGPACK_TYPE_CPP11_UNORDERED_SET_HPP diff --git a/include/rpc/msgpack/adaptor/cpp17/optional.hpp b/include/rpc/msgpack/adaptor/cpp17/optional.hpp new file mode 100644 index 00000000..8e7a2566 --- /dev/null +++ b/include/rpc/msgpack/adaptor/cpp17/optional.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2017 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MSGPACK_TYPE_CPP17_OPTIONAL_HPP +#define MSGPACK_TYPE_CPP17_OPTIONAL_HPP + +#include "rpc/msgpack/v1/adaptor/cpp17/optional.hpp" + +#endif // MSGPACK_TYPE_CPP17_OPTIONAL_HPP diff --git a/include/rpc/msgpack/adaptor/cpp17/string_view.hpp b/include/rpc/msgpack/adaptor/cpp17/string_view.hpp new file mode 100644 index 00000000..bdc48fed --- /dev/null +++ b/include/rpc/msgpack/adaptor/cpp17/string_view.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2017 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MSGPACK_TYPE_CPP17_STRING_VIEW_HPP +#define MSGPACK_TYPE_CPP17_STRING_VIEW_HPP + +#include "rpc/msgpack/v1/adaptor/cpp17/string_view.hpp" + +#endif // MSGPACK_TYPE_CPP17_STRING_VIEW_HPP diff --git a/include/rpc/msgpack/adaptor/define.hpp b/include/rpc/msgpack/adaptor/define.hpp index dce5f53c..46d7caf0 100644 --- a/include/rpc/msgpack/adaptor/define.hpp +++ b/include/rpc/msgpack/adaptor/define.hpp @@ -1,39 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_DEFINE_HPP #define MSGPACK_DEFINE_HPP -#include "rpc/msgpack/cpp_config.hpp" - -#if defined(MSGPACK_USE_CPP03) -#include "detail/cpp03_define_array.hpp" -#include "detail/cpp03_define_map.hpp" -#else // MSGPACK_USE_CPP03 -#include "detail/cpp11_define_array.hpp" -#include "detail/cpp11_define_map.hpp" -#endif // MSGPACK_USE_CPP03 +#include "rpc/msgpack/adaptor/define_decl.hpp" -#if defined(MSGPACK_USE_DEFINE_MAP) -#define MSGPACK_DEFINE MSGPACK_DEFINE_MAP -#define MSGPACK_BASE MSGPACK_BASE_MAP -#else // defined(MSGPACK_USE_DEFINE_MAP) -#define MSGPACK_DEFINE MSGPACK_DEFINE_ARRAY -#define MSGPACK_BASE MSGPACK_BASE_ARRAY -#endif // defined(MSGPACK_USE_DEFINE_MAP) +#include "rpc/msgpack/v1/adaptor/define.hpp" #endif // MSGPACK_DEFINE_HPP diff --git a/include/rpc/msgpack/adaptor/define_decl.hpp b/include/rpc/msgpack/adaptor/define_decl.hpp new file mode 100644 index 00000000..7b80cef7 --- /dev/null +++ b/include/rpc/msgpack/adaptor/define_decl.hpp @@ -0,0 +1,143 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_DEFINE_DECL_HPP +#define MSGPACK_DEFINE_DECL_HPP + +// BOOST_PP_VARIADICS is defined in boost/preprocessor/config/config.hpp +// http://www.boost.org/libs/preprocessor/doc/ref/variadics.html +// However, supporting compiler detection is not complete. msgpack-c requires +// variadic macro arguments support. So BOOST_PP_VARIADICS is defined here explicitly. +#if !defined(MSGPACK_PP_VARIADICS) +#define MSGPACK_PP_VARIADICS +#endif + +#include + +#include "rpc/msgpack/versioning.hpp" + +// for MSGPACK_ADD_ENUM +#include "rpc/msgpack/adaptor/int.hpp" + +#define MSGPACK_DEFINE_ARRAY(...) \ + template \ + void msgpack_pack(Packer& pk) const \ + { \ + clmdep_msgpack::type::make_define_array(__VA_ARGS__).msgpack_pack(pk); \ + } \ + void msgpack_unpack(clmdep_msgpack::object const& o) \ + { \ + clmdep_msgpack::type::make_define_array(__VA_ARGS__).msgpack_unpack(o); \ + }\ + template \ + void msgpack_object(MSGPACK_OBJECT* o, clmdep_msgpack::zone& z) const \ + { \ + clmdep_msgpack::type::make_define_array(__VA_ARGS__).msgpack_object(o, z); \ + } + +#define MSGPACK_BASE_ARRAY(base) (*const_cast(static_cast(this))) +#define MSGPACK_NVP(name, value) (name) (value) + +#define MSGPACK_DEFINE_MAP_EACH_PROC(r, data, elem) \ + MSGPACK_PP_IF( \ + MSGPACK_PP_IS_BEGIN_PARENS(elem), \ + elem, \ + (MSGPACK_PP_STRINGIZE(elem))(elem) \ + ) + +#define MSGPACK_DEFINE_MAP_IMPL(...) \ + MSGPACK_PP_SEQ_TO_TUPLE( \ + MSGPACK_PP_SEQ_FOR_EACH( \ + MSGPACK_DEFINE_MAP_EACH_PROC, \ + 0, \ + MSGPACK_PP_VARIADIC_TO_SEQ(__VA_ARGS__) \ + ) \ + ) + +#define MSGPACK_DEFINE_MAP(...) \ + template \ + void msgpack_pack(Packer& pk) const \ + { \ + clmdep_msgpack::type::make_define_map \ + MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ + .msgpack_pack(pk); \ + } \ + void msgpack_unpack(clmdep_msgpack::object const& o) \ + { \ + clmdep_msgpack::type::make_define_map \ + MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ + .msgpack_unpack(o); \ + }\ + template \ + void msgpack_object(MSGPACK_OBJECT* o, clmdep_msgpack::zone& z) const \ + { \ + clmdep_msgpack::type::make_define_map \ + MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ + .msgpack_object(o, z); \ + } + +#define MSGPACK_BASE_MAP(base) \ + (MSGPACK_PP_STRINGIZE(base))(*const_cast(static_cast(this))) + +// MSGPACK_ADD_ENUM must be used in the global namespace. +#define MSGPACK_ADD_ENUM(enum_name) \ + namespace clmdep_msgpack { \ + /** @cond */ \ + MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) { \ + /** @endcond */ \ + namespace adaptor { \ + template<> \ + struct convert { \ + clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, enum_name& v) const { \ + clmdep_msgpack::underlying_type::type tmp; \ + clmdep_msgpack::operator>>(o, tmp); \ + v = static_cast(tmp); \ + return o; \ + } \ + }; \ + template<> \ + struct object { \ + void operator()(clmdep_msgpack::object& o, const enum_name& v) const { \ + clmdep_msgpack::underlying_type::type tmp = static_cast::type>(v); \ + clmdep_msgpack::operator<<(o, tmp); \ + } \ + }; \ + template<> \ + struct object_with_zone { \ + void operator()(clmdep_msgpack::object::with_zone& o, const enum_name& v) const { \ + clmdep_msgpack::underlying_type::type tmp = static_cast::type>(v); \ + clmdep_msgpack::operator<<(o, tmp); \ + } \ + }; \ + template <> \ + struct pack { \ + template \ + clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const enum_name& v) const { \ + return clmdep_msgpack::operator<<(o, static_cast::type>(v)); \ + } \ + }; \ + } \ + /** @cond */ \ + } \ + /** @endcond */ \ + } + +#if defined(MSGPACK_USE_DEFINE_MAP) +#define MSGPACK_DEFINE MSGPACK_DEFINE_MAP +#define MSGPACK_BASE MSGPACK_BASE_MAP +#else // defined(MSGPACK_USE_DEFINE_MAP) +#define MSGPACK_DEFINE MSGPACK_DEFINE_ARRAY +#define MSGPACK_BASE MSGPACK_BASE_ARRAY +#endif // defined(MSGPACK_USE_DEFINE_MAP) + + +#include "rpc/msgpack/v1/adaptor/define_decl.hpp" +#include "rpc/msgpack/v2/adaptor/define_decl.hpp" + +#endif // MSGPACK_DEFINE_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/deque.hpp b/include/rpc/msgpack/adaptor/deque.hpp index e2e5b853..6d4e640c 100644 --- a/include/rpc/msgpack/adaptor/deque.hpp +++ b/include/rpc/msgpack/adaptor/deque.hpp @@ -1,116 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_DEQUE_HPP #define MSGPACK_TYPE_DEQUE_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as, typename std::enable_if::value>::type> { - std::deque operator()(const clmdep_msgpack::object& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - std::deque v; - if (o.via.array.size > 0) { - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - do { - v.push_back(p->as()); - ++p; - } while (p < pend); - } - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::deque& v) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - v.resize(o.via.array.size); - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - typename std::deque::iterator it = v.begin(); - for(; p < pend; ++p, ++it) { - p->convert(*it); - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::deque& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for(typename std::deque::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::deque& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if(v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::deque::const_iterator it(v.begin()); - do { - *p = clmdep_msgpack::object(*it, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/deque.hpp" -#endif /* msgpack/type/deque.hpp */ +#endif // MSGPACK_TYPE_DEQUE_HPP diff --git a/include/rpc/msgpack/adaptor/ext.hpp b/include/rpc/msgpack/adaptor/ext.hpp index 1f1a6040..74dd8e5b 100644 --- a/include/rpc/msgpack/adaptor/ext.hpp +++ b/include/rpc/msgpack/adaptor/ext.hpp @@ -3,243 +3,15 @@ // // Copyright (C) 2015 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_EXT_HPP #define MSGPACK_TYPE_EXT_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { -class ext_ref; - -class ext { -public: - ext() : m_data(1, 0) {} - ext(int8_t t, const char* p, uint32_t s) { - detail::check_container_size_for_ext(s); - m_data.reserve(static_cast(s) + 1); - m_data.push_back(static_cast(t)); - m_data.insert(m_data.end(), p, p + s); - } - ext(int8_t t, uint32_t s) { - detail::check_container_size_for_ext(s); - m_data.resize(static_cast(s) + 1); - m_data[0] = static_cast(t); - } - ext(ext_ref const&); - int8_t type() const { - return static_cast(m_data[0]); - } - const char* data() const { - return &m_data[1]; - } - char* data() { - return &m_data[1]; - } - uint32_t size() const { - return static_cast(m_data.size()) - 1; - } - bool operator== (const ext& x) const { - return m_data == x.m_data; - } - - bool operator!= (const ext& x) const { - return !(*this == x); - } - - bool operator< (const ext& x) const { - return m_data < x.m_data; - } - - bool operator> (const ext& x) const { - return m_data > x.m_data; - } -private: - std::vector m_data; - friend class ext_ref; -}; - -} // namespace type - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, clmdep_msgpack::type::ext& v) const { - if(o.type != clmdep_msgpack::type::EXT) { - throw clmdep_msgpack::type_error(); - } - v = clmdep_msgpack::type::ext(o.via.ext.type(), o.via.ext.data(), o.via.ext.size); - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const clmdep_msgpack::type::ext& v) const { - // size limit has aleady been checked at ext's constructor - uint32_t size = v.size(); - o.pack_ext(size, v.type()); - o.pack_ext_body(v.data(), size); - return o; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const clmdep_msgpack::type::ext& v) const { - // size limit has aleady been checked at ext's constructor - uint32_t size = v.size(); - o.type = clmdep_msgpack::type::EXT; - char* ptr = static_cast(o.zone.allocate_align(size + 1)); - o.via.ext.ptr = ptr; - o.via.ext.size = size; - ptr[0] = static_cast(v.type()); - std::memcpy(ptr + 1, v.data(), size); - } -}; - -} // namespace adaptor - -namespace type { - -class ext_ref { -public: - // ext_ref should be default constructible to support 'convert'. - // A default constructed ext_ref object::m_ptr doesn't have the buffer to point to. - // In order to avoid nullptr checking branches, m_ptr points to m_size. - // So type() returns unspecified but valid value. It might be a zero because m_size - // is initialized as zero, but shoudn't assume that. - ext_ref() : m_ptr(static_cast(static_cast(&m_size))), m_size(0) {} - ext_ref(const char* p, uint32_t s) : - m_ptr(s == 0 ? static_cast(static_cast(&m_size)) : p), - m_size(s == 0 ? 0 : s - 1) { - detail::check_container_size_for_ext(s); - } - - // size limit has aleady been checked at ext's constructor - ext_ref(ext const& x) : m_ptr(&x.m_data[0]), m_size(x.size()) {} - - const char* data() const { - return m_ptr + 1; - } - - uint32_t size() const { - return m_size; - } - - int8_t type() const { - return static_cast(m_ptr[0]); - } - - std::string str() const { - return std::string(m_ptr + 1, m_size); - } - - bool operator== (const ext_ref& x) const { - return m_size == x.m_size && std::memcmp(m_ptr, x.m_ptr, m_size) == 0; - } - - bool operator!= (const ext_ref& x) const { - return !(*this == x); - } - - bool operator< (const ext_ref& x) const { - if (m_size < x.m_size) return true; - if (m_size > x.m_size) return false; - return std::memcmp(m_ptr, x.m_ptr, m_size) < 0; - } - - bool operator> (const ext_ref& x) const { - if (m_size > x.m_size) return true; - if (m_size < x.m_size) return false; - return std::memcmp(m_ptr, x.m_ptr, m_size) > 0; - } -private: - const char* m_ptr; - uint32_t m_size; - friend struct clmdep_msgpack::adaptor::object; -}; - -inline ext::ext(ext_ref const& x) { - // size limit has aleady been checked at ext_ref's constructor - m_data.reserve(x.size() + 1); - - m_data.push_back(x.type()); - m_data.insert(m_data.end(), x.data(), x.data() + x.size()); -} - -} // namespace type - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, clmdep_msgpack::type::ext_ref& v) const { - if(o.type != clmdep_msgpack::type::EXT) { throw clmdep_msgpack::type_error(); } - v = clmdep_msgpack::type::ext_ref(o.via.ext.ptr, o.via.ext.size + 1); - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const clmdep_msgpack::type::ext_ref& v) const { - // size limit has aleady been checked at ext_ref's constructor - uint32_t size = v.size(); - o.pack_ext(size, v.type()); - o.pack_ext_body(v.data(), size); - return o; - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, const clmdep_msgpack::type::ext_ref& v) const { - // size limit has aleady been checked at ext_ref's constructor - uint32_t size = v.size(); - o.type = clmdep_msgpack::type::EXT; - o.via.ext.ptr = v.m_ptr; - o.via.ext.size = size; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const clmdep_msgpack::type::ext_ref& v) const { - static_cast(o) << v; - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/ext_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/ext.hpp" -#endif // MSGPACK_TYPE_EXT_HPP +#endif // MSGPACK_TYPE_EXT_HPP diff --git a/include/rpc/msgpack/adaptor/ext_decl.hpp b/include/rpc/msgpack/adaptor/ext_decl.hpp new file mode 100644 index 00000000..a8cf78a9 --- /dev/null +++ b/include/rpc/msgpack/adaptor/ext_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_EXT_DECL_HPP +#define MSGPACK_TYPE_EXT_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/ext_decl.hpp" +#include "rpc/msgpack/v2/adaptor/ext_decl.hpp" + +#endif // MSGPACK_TYPE_EXT_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/fixint.hpp b/include/rpc/msgpack/adaptor/fixint.hpp index b5f5b095..ef395e69 100644 --- a/include/rpc/msgpack/adaptor/fixint.hpp +++ b/include/rpc/msgpack/adaptor/fixint.hpp @@ -1,306 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2020 FURUHASHI Sadayuki +// Copyright (C) 2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_FIXINT_HPP #define MSGPACK_TYPE_FIXINT_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/int.hpp" - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { - - -template -struct fix_int { - fix_int() : value(0) { } - fix_int(T value) : value(value) { } - - operator T() const { return value; } - - T get() const { return value; } - -private: - T value; -}; - - -typedef fix_int fix_uint8; -typedef fix_int fix_uint16; -typedef fix_int fix_uint32; -typedef fix_int fix_uint64; - -typedef fix_int fix_int8; -typedef fix_int fix_int16; -typedef fix_int fix_int32; -typedef fix_int fix_int64; - - -} // namespace type - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_int8& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_int16& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_int32& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_int64& v) const - { v = type::detail::convert_integer(o); return o; } -}; - - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_uint8& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_uint16& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_uint32& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::fix_uint64& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_int8& v) const - { o.pack_fix_int8(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_int16& v) const - { o.pack_fix_int16(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_int32& v) const - { o.pack_fix_int32(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_int64& v) const - { o.pack_fix_int64(v); return o; } -}; - - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_uint8& v) const - { o.pack_fix_uint8(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_uint16& v) const - { o.pack_fix_uint16(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_uint32& v) const - { o.pack_fix_uint32(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::fix_uint64& v) const - { o.pack_fix_uint64(v); return o; } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_int8 v) const { - if (v.get() < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v.get(); - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v.get(); - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_int16 v) const { - if(v.get() < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v.get(); - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v.get(); - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_int32 v) const { - if (v.get() < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v.get(); - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v.get(); - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_int64 v) const { - if (v.get() < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v.get(); - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v.get(); - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_uint8 v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_uint16 v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_uint32 v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::fix_uint64 v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_int8 v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_int16 v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_int32 v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_int64 v) const - { static_cast(o) << v; } -}; - - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_uint8 v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_uint16 v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_uint32 v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::fix_uint64 v) const - { static_cast(o) << v; } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/fixint_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/fixint.hpp" -#endif /* msgpack/type/fixint.hpp */ +#endif // MSGPACK_TYPE_FIXINT_HPP diff --git a/include/rpc/msgpack/adaptor/fixint_decl.hpp b/include/rpc/msgpack/adaptor/fixint_decl.hpp new file mode 100644 index 00000000..05776d27 --- /dev/null +++ b/include/rpc/msgpack/adaptor/fixint_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 FURUHASHI Sadayuki and KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_FIXINT_DECL_HPP +#define MSGPACK_TYPE_FIXINT_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/fixint_decl.hpp" +#include "rpc/msgpack/v2/adaptor/fixint_decl.hpp" + +#endif // MSGPACK_TYPE_FIXINT_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/float.hpp b/include/rpc/msgpack/adaptor/float.hpp index 8967b64d..e1ed4d90 100644 --- a/include/rpc/msgpack/adaptor/float.hpp +++ b/include/rpc/msgpack/adaptor/float.hpp @@ -1,131 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_FLOAT_HPP #define MSGPACK_TYPE_FLOAT_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/object_fwd.hpp" -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -// FIXME check overflow, underflow - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, float& v) const { - if(o.type == clmdep_msgpack::type::FLOAT) { - v = static_cast(o.via.f64); - } - else if (o.type == clmdep_msgpack::type::POSITIVE_INTEGER) { - v = static_cast(o.via.u64); - } - else if (o.type == clmdep_msgpack::type::NEGATIVE_INTEGER) { - v = static_cast(o.via.i64); - } - else { - throw clmdep_msgpack::type_error(); - } - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const float& v) const { - o.pack_float(v); - return o; - } -}; - - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, double& v) const { - if(o.type == clmdep_msgpack::type::FLOAT) { - v = o.via.f64; - } - else if (o.type == clmdep_msgpack::type::POSITIVE_INTEGER) { - v = static_cast(o.via.u64); - } - else if (o.type == clmdep_msgpack::type::NEGATIVE_INTEGER) { - v = static_cast(o.via.i64); - } - else { - throw clmdep_msgpack::type_error(); - } - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const double& v) const { - o.pack_double(v); - return o; - } -}; - - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, float v) const { - o.type = clmdep_msgpack::type::FLOAT; - o.via.f64 = static_cast(v); - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, double v) const { - o.type = clmdep_msgpack::type::FLOAT; - o.via.f64 = v; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, float v) const { - static_cast(o) << v; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, double v) const { - static_cast(o) << v; - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/float.hpp" #endif // MSGPACK_TYPE_FLOAT_HPP diff --git a/include/rpc/msgpack/adaptor/int.hpp b/include/rpc/msgpack/adaptor/int.hpp index 68856b23..021be266 100644 --- a/include/rpc/msgpack/adaptor/int.hpp +++ b/include/rpc/msgpack/adaptor/int.hpp @@ -1,436 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_INT_HPP #define MSGPACK_TYPE_INT_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1){ -/// @endcond - -namespace type { -namespace detail { - template - struct convert_integer_sign; - - template - struct convert_integer_sign { - static inline T convert(clmdep_msgpack::object const& o) { - if(o.type == clmdep_msgpack::type::POSITIVE_INTEGER) { - if(o.via.u64 > static_cast(std::numeric_limits::max())) - { throw clmdep_msgpack::type_error(); } - return static_cast(o.via.u64); - } else if(o.type == clmdep_msgpack::type::NEGATIVE_INTEGER) { - if(o.via.i64 < static_cast(std::numeric_limits::min())) - { throw clmdep_msgpack::type_error(); } - return static_cast(o.via.i64); - } - throw clmdep_msgpack::type_error(); - } - }; - - template - struct convert_integer_sign { - static inline T convert(clmdep_msgpack::object const& o) { - if(o.type == clmdep_msgpack::type::POSITIVE_INTEGER) { - if(o.via.u64 > static_cast(std::numeric_limits::max())) - { throw clmdep_msgpack::type_error(); } - return static_cast(o.via.u64); - } - throw clmdep_msgpack::type_error(); - } - }; - - template - struct is_signed { - static const bool value = std::numeric_limits::is_signed; - }; - - template - static inline T convert_integer(clmdep_msgpack::object const& o) - { - return detail::convert_integer_sign::value>::convert(o); - } - - template - struct object_char_sign; - - template <> - struct object_char_sign { - static inline void make(clmdep_msgpack::object& o, char v) { - if (v < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v; - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v; - } - } - }; - - template <> - struct object_char_sign { - static inline void make(clmdep_msgpack::object& o, char v) { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; - } - }; - - static inline void object_char(clmdep_msgpack::object& o, char v) { - return object_char_sign::value>::make(o, v); - } - -} // namespace detail -} // namespace type - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, char& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, signed char& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, signed short& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, signed int& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, signed long& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, signed long long& v) const - { v = type::detail::convert_integer(o); return o; } -}; - - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, unsigned char& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, unsigned short& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, unsigned int& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, unsigned long& v) const - { v = type::detail::convert_integer(o); return o; } -}; - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, unsigned long long& v) const - { v = type::detail::convert_integer(o); return o; } -}; - - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, char v) const - { o.pack_char(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, signed char v) const - { o.pack_signed_char(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, signed short v) const - { o.pack_short(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, signed int v) const - { o.pack_int(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, signed long v) const - { o.pack_long(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, signed long long v) const - { o.pack_long_long(v); return o; } -}; - - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, unsigned char v) const - { o.pack_unsigned_char(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, unsigned short v) const - { o.pack_unsigned_short(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, unsigned int v) const - { o.pack_unsigned_int(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, unsigned long v) const - { o.pack_unsigned_long(v); return o; } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, unsigned long long v) const - { o.pack_unsigned_long_long(v); return o; } -}; - - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, char v) const - { type::detail::object_char(o, v); } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, signed char v) const { - if (v < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v; - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v; - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, signed short v) const { - if (v < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v; - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v; - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, signed int v) const { - if (v < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v; - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v; - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, signed long v) const { - if (v < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v; - } - else { - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v; - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, signed long long v) const { - if (v < 0) { - o.type = clmdep_msgpack::type::NEGATIVE_INTEGER; - o.via.i64 = v; - } - else{ - o.type = clmdep_msgpack::type::POSITIVE_INTEGER; - o.via.u64 = v; - } - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, unsigned char v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, unsigned short v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, unsigned int v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, unsigned long v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, unsigned long long v) const - { o.type = clmdep_msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; } -}; - - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, char v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, signed char v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, signed short v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, signed int v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, signed long v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const signed long long& v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, unsigned char v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, unsigned short v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, unsigned int v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, unsigned long v) const - { static_cast(o) << v; } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const unsigned long long& v) const - { static_cast(o) << v; } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/int_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/int.hpp" -#endif /* msgpack/type/int.hpp */ +#endif // MSGPACK_TYPE_INT_HPP diff --git a/include/rpc/msgpack/adaptor/int_decl.hpp b/include/rpc/msgpack/adaptor/int_decl.hpp new file mode 100644 index 00000000..c0bfc798 --- /dev/null +++ b/include/rpc/msgpack/adaptor/int_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_INT_DECL_HPP +#define MSGPACK_TYPE_INT_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/int_decl.hpp" +#include "rpc/msgpack/v2/adaptor/int_decl.hpp" + +#endif // MSGPACK_TYPE_INT_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/list.hpp b/include/rpc/msgpack/adaptor/list.hpp index 38666cb9..f3157d50 100644 --- a/include/rpc/msgpack/adaptor/list.hpp +++ b/include/rpc/msgpack/adaptor/list.hpp @@ -1,114 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_LIST_HPP #define MSGPACK_TYPE_LIST_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as, typename std::enable_if::value>::type> { - std::list operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - std::list v; - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - for (; p < pend; ++p) { - v.push_back(p->as()); - } - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::list& v) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - v.resize(o.via.array.size); - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - typename std::list::iterator it = v.begin(); - for (; p < pend; ++p, ++it) { - p->convert(*it); - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::list& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for (typename std::list::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::list& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if (v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } - else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::list::const_iterator it(v.begin()); - do { - *p = clmdep_msgpack::object(*it, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/list.hpp" #endif // MSGPACK_TYPE_LIST_HPP diff --git a/include/rpc/msgpack/adaptor/map.hpp b/include/rpc/msgpack/adaptor/map.hpp index 7e94223f..f846db44 100644 --- a/include/rpc/msgpack/adaptor/map.hpp +++ b/include/rpc/msgpack/adaptor/map.hpp @@ -1,314 +1,18 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_MAP_HPP #define MSGPACK_TYPE_MAP_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/object_fwd.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { - -template , typename Alloc = std::allocator > > -class assoc_vector : public std::vector< std::pair, Alloc > { -#if !defined(MSGPACK_USE_CPP03) - using std::vector, Alloc>::vector; -#endif // !defined(MSGPACK_USE_CPP03) -}; - -namespace detail { - template - struct pair_first_less { - bool operator() (const std::pair& x, const std::pair& y) const - { return Compare()(x.first, y.first); } - }; -} - -} //namespace type - -namespace adaptor { - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as< - type::assoc_vector, - typename std::enable_if::value && clmdep_msgpack::has_as::value>::type> { - type::assoc_vector operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - type::assoc_vector v; - v.reserve(o.via.map.size); - clmdep_msgpack::object_kv* p = o.via.map.ptr; - clmdep_msgpack::object_kv* const pend = o.via.map.ptr + o.via.map.size; - for (; p < pend; ++p) { - v.emplace_back(p->key.as(), p->val.as()); - } - std::sort(v.begin(), v.end(), type::detail::pair_first_less()); - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::assoc_vector& v) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - v.resize(o.via.map.size); - clmdep_msgpack::object_kv* p = o.via.map.ptr; - clmdep_msgpack::object_kv* const pend = o.via.map.ptr + o.via.map.size; - std::pair* it(&v.front()); - for (; p < pend; ++p, ++it) { - p->key.convert(it->first); - p->val.convert(it->second); - } - std::sort(v.begin(), v.end(), type::detail::pair_first_less()); - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::assoc_vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_map(size); - for (typename type::assoc_vector::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(it->first); - o.pack(it->second); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const type::assoc_vector& v) const { - o.type = clmdep_msgpack::type::MAP; - if (v.empty()) { - o.via.map.ptr = nullptr; - o.via.map.size = 0; - } - else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size)); - clmdep_msgpack::object_kv* const pend = p + size; - o.via.map.ptr = p; - o.via.map.size = size; - typename type::assoc_vector::const_iterator it(v.begin()); - do { - p->key = clmdep_msgpack::object(it->first, o.zone); - p->val = clmdep_msgpack::object(it->second, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as< - std::map, - typename std::enable_if::value && clmdep_msgpack::has_as::value>::type> { - std::map operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::map v; - for (; p != pend; ++p) { - v.emplace(p->key.as(), p->val.as()); - } - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::map& v) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::map tmp; - for (; p != pend; ++p) { - K key; - p->key.convert(key); -#if __cplusplus >= 201103L - p->val.convert(tmp[std::move(key)]); -#else - p->val.convert(tmp[key]); -#endif - } -#if __cplusplus >= 201103L - v = std::move(tmp); -#else - tmp.swap(v); -#endif - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::map& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_map(size); - for (typename std::map::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(it->first); - o.pack(it->second); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::map& v) const { - o.type = clmdep_msgpack::type::MAP; - if (v.empty()) { - o.via.map.ptr = nullptr; - o.via.map.size = 0; - } - else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size)); - clmdep_msgpack::object_kv* const pend = p + size; - o.via.map.ptr = p; - o.via.map.size = size; - typename std::map::const_iterator it(v.begin()); - do { - p->key = clmdep_msgpack::object(it->first, o.zone); - p->val = clmdep_msgpack::object(it->second, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as< - std::multimap, - typename std::enable_if::value && clmdep_msgpack::has_as::value>::type> { - std::multimap operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::multimap v; - for (; p != pend; ++p) { - v.emplace(p->key.as(), p->val.as()); - } - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::multimap& v) const { - if (o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object_kv* p(o.via.map.ptr); - clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size); - std::multimap tmp; - for (; p != pend; ++p) { - std::pair value; - p->key.convert(value.first); - p->val.convert(value.second); -#if __cplusplus >= 201103L - tmp.insert(std::move(value)); -#else - tmp.insert(value); -#endif - } -#if __cplusplus >= 201103L - v = std::move(tmp); -#else - tmp.swap(v); -#endif - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::multimap& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_map(size); - for (typename std::multimap::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(it->first); - o.pack(it->second); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::multimap& v) const { - o.type = clmdep_msgpack::type::MAP; - if (v.empty()) { - o.via.map.ptr = nullptr; - o.via.map.size = 0; - } - else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size)); - clmdep_msgpack::object_kv* const pend = p + size; - o.via.map.ptr = p; - o.via.map.size = size; - typename std::multimap::const_iterator it(v.begin()); - do { - p->key = clmdep_msgpack::object(it->first, o.zone); - p->val = clmdep_msgpack::object(it->second, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor +#include "rpc/msgpack/adaptor/map_decl.hpp" -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/v1/adaptor/map.hpp" -} // namespace clmdep_msgpack #endif // MSGPACK_TYPE_MAP_HPP diff --git a/include/rpc/msgpack/adaptor/map_decl.hpp b/include/rpc/msgpack/adaptor/map_decl.hpp new file mode 100644 index 00000000..42a86987 --- /dev/null +++ b/include/rpc/msgpack/adaptor/map_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_MAP_DECL_HPP +#define MSGPACK_TYPE_MAP_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/map_decl.hpp" +#include "rpc/msgpack/v2/adaptor/map_decl.hpp" + +#endif // MSGPACK_TYPE_MAP_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/msgpack_tuple.hpp b/include/rpc/msgpack/adaptor/msgpack_tuple.hpp index 6ca153df..2c566c01 100644 --- a/include/rpc/msgpack/adaptor/msgpack_tuple.hpp +++ b/include/rpc/msgpack/adaptor/msgpack_tuple.hpp @@ -3,27 +3,15 @@ // // Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_MSGPACK_TUPLE_HPP #define MSGPACK_MSGPACK_TUPLE_HPP -#include "rpc/msgpack/cpp_config.hpp" +#include "rpc/msgpack/adaptor/msgpack_tuple_decl.hpp" -#if defined(MSGPACK_USE_CPP03) -#include "detail/cpp03_msgpack_tuple.hpp" -#else // MSGPACK_USE_CPP03 -#include "detail/cpp11_msgpack_tuple.hpp" -#endif // MSGPACK_USE_CPP03 +#include "rpc/msgpack/v1/adaptor/msgpack_tuple.hpp" #endif // MSGPACK_MSGPACK_TUPLE_HPP diff --git a/include/rpc/msgpack/adaptor/msgpack_tuple_decl.hpp b/include/rpc/msgpack/adaptor/msgpack_tuple_decl.hpp new file mode 100644 index 00000000..e60b6b7c --- /dev/null +++ b/include/rpc/msgpack/adaptor/msgpack_tuple_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_MSGPACK_TUPLE_DECL_HPP +#define MSGPACK_MSGPACK_TUPLE_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/msgpack_tuple_decl.hpp" +#include "rpc/msgpack/v2/adaptor/msgpack_tuple_decl.hpp" + +#endif // MSGPACK_MSGPACK_TUPLE_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/nil.hpp b/include/rpc/msgpack/adaptor/nil.hpp index 4dca2af1..5872b513 100644 --- a/include/rpc/msgpack/adaptor/nil.hpp +++ b/include/rpc/msgpack/adaptor/nil.hpp @@ -1,92 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_NIL_HPP #define MSGPACK_TYPE_NIL_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { - -struct nil { }; - -inline bool operator<(nil const& lhs, nil const& rhs) { - return &lhs < &rhs; -} - -inline bool operator==(nil const& lhs, nil const& rhs) { - return &lhs == &rhs; -} - -} // namespace type - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::nil&) const { - if(o.type != clmdep_msgpack::type::NIL) { throw clmdep_msgpack::type_error(); } - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const type::nil&) const { - o.pack_nil(); - return o; - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, type::nil) const { - o.type = clmdep_msgpack::type::NIL; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, type::nil v) const { - static_cast(o) << v; - } -}; - -} // namespace adaptror - -template <> -inline void clmdep_msgpack::object::as() const -{ - clmdep_msgpack::type::nil v; - convert(v); -} - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/nil_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/nil.hpp" #endif // MSGPACK_TYPE_NIL_HPP diff --git a/include/rpc/msgpack/adaptor/nil_decl.hpp b/include/rpc/msgpack/adaptor/nil_decl.hpp new file mode 100644 index 00000000..d9d8b7a2 --- /dev/null +++ b/include/rpc/msgpack/adaptor/nil_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_NIL_DECL_HPP +#define MSGPACK_TYPE_NIL_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/nil_decl.hpp" +#include "rpc/msgpack/v2/adaptor/nil_decl.hpp" + +#endif // MSGPACK_TYPE_NIL_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/pair.hpp b/include/rpc/msgpack/adaptor/pair.hpp index 2f6f0c18..04a67f2b 100644 --- a/include/rpc/msgpack/adaptor/pair.hpp +++ b/include/rpc/msgpack/adaptor/pair.hpp @@ -1,91 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_PAIR_HPP #define MSGPACK_TYPE_PAIR_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/meta.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as, - typename std::enable_if::value>::type> { - std::pair operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if (o.via.array.size != 2) { throw clmdep_msgpack::type_error(); } - return std::make_pair(o.via.array.ptr[0].as(), o.via.array.ptr[1].as()); - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::pair& v) const { - if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if(o.via.array.size != 2) { throw clmdep_msgpack::type_error(); } - o.via.array.ptr[0].convert(v.first); - o.via.array.ptr[1].convert(v.second); - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::pair& v) const { - o.pack_array(2); - o.pack(v.first); - o.pack(v.second); - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::pair& v) const { - o.type = clmdep_msgpack::type::ARRAY; - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*2)); - o.via.array.ptr = p; - o.via.array.size = 2; - p[0] = clmdep_msgpack::object(v.first, o.zone); - p[1] = clmdep_msgpack::object(v.second, o.zone); - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/pair.hpp" #endif // MSGPACK_TYPE_PAIR_HPP diff --git a/include/rpc/msgpack/adaptor/raw.hpp b/include/rpc/msgpack/adaptor/raw.hpp index a0134008..85ccd683 100644 --- a/include/rpc/msgpack/adaptor/raw.hpp +++ b/include/rpc/msgpack/adaptor/raw.hpp @@ -1,114 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2009 FURUHASHI Sadayuki +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_RAW_HPP #define MSGPACK_TYPE_RAW_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { - -struct raw_ref { - raw_ref() : size(0), ptr(nullptr) {} - raw_ref(const char* p, uint32_t s) : size(s), ptr(p) {} - - uint32_t size; - const char* ptr; - - std::string str() const { return std::string(ptr, size); } - - bool operator== (const raw_ref& x) const - { - return size == x.size && std::memcmp(ptr, x.ptr, size) == 0; - } - - bool operator!= (const raw_ref& x) const - { - return !(*this == x); - } - - bool operator< (const raw_ref& x) const - { - if(size == x.size) { return std::memcmp(ptr, x.ptr, size) < 0; } - else { return size < x.size; } - } - - bool operator> (const raw_ref& x) const - { - if(size == x.size) { return std::memcmp(ptr, x.ptr, size) > 0; } - else { return size > x.size; } - } -}; - -} // namespace type - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, clmdep_msgpack::type::raw_ref& v) const { - if(o.type != clmdep_msgpack::type::BIN) { throw clmdep_msgpack::type_error(); } - v.ptr = o.via.bin.ptr; - v.size = o.via.bin.size; - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const clmdep_msgpack::type::raw_ref& v) const { - o.pack_bin(v.size); - o.pack_bin_body(v.ptr, v.size); - return o; - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, const clmdep_msgpack::type::raw_ref& v) const { - o.type = clmdep_msgpack::type::BIN; - o.via.bin.ptr = v.ptr; - o.via.bin.size = v.size; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const clmdep_msgpack::type::raw_ref& v) const { - static_cast(o) << v; - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/raw_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/raw.hpp" #endif // MSGPACK_TYPE_RAW_HPP diff --git a/include/rpc/msgpack/adaptor/raw_decl.hpp b/include/rpc/msgpack/adaptor/raw_decl.hpp new file mode 100644 index 00000000..88932506 --- /dev/null +++ b/include/rpc/msgpack/adaptor/raw_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_RAW_DECL_HPP +#define MSGPACK_TYPE_RAW_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/raw_decl.hpp" +#include "rpc/msgpack/v2/adaptor/raw_decl.hpp" + +#endif // MSGPACK_TYPE_RAW_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/set.hpp b/include/rpc/msgpack/adaptor/set.hpp index 405a9927..48f267fc 100644 --- a/include/rpc/msgpack/adaptor/set.hpp +++ b/include/rpc/msgpack/adaptor/set.hpp @@ -1,196 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_SET_HPP #define MSGPACK_TYPE_SET_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as, typename std::enable_if::value>::type> { - std::set operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::set v; - while (p > pbegin) { - --p; - v.insert(p->as()); - } - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::set& v) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::set tmp; - while (p > pbegin) { - --p; - tmp.insert(p->as()); - } -#if __cplusplus >= 201103L - v = std::move(tmp); -#else - tmp.swap(v); -#endif - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::set& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for (typename std::set::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::set& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if (v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } - else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::set::const_iterator it(v.begin()); - do { - *p = clmdep_msgpack::object(*it, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as, typename std::enable_if::value>::type> { - std::multiset operator()(clmdep_msgpack::object const& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::multiset v; - while (p > pbegin) { - --p; - v.insert(p->as()); - } - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::multiset& v) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size; - clmdep_msgpack::object* const pbegin = o.via.array.ptr; - std::multiset tmp; - while (p > pbegin) { - --p; - tmp.insert(p->as()); - } -#if __cplusplus >= 201103L - v = std::move(tmp); -#else - tmp.swap(v); -#endif - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::multiset& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for (typename std::multiset::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::multiset& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if (v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::multiset::const_iterator it(v.begin()); - do { - *p = clmdep_msgpack::object(*it, o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/set.hpp" #endif // MSGPACK_TYPE_SET_HPP diff --git a/include/rpc/msgpack/adaptor/size_equal_only.hpp b/include/rpc/msgpack/adaptor/size_equal_only.hpp new file mode 100644 index 00000000..9daef986 --- /dev/null +++ b/include/rpc/msgpack/adaptor/size_equal_only.hpp @@ -0,0 +1,17 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_SIZE_EQUAL_ONLY_HPP +#define MSGPACK_TYPE_SIZE_EQUAL_ONLY_HPP + +#include "rpc/msgpack/adaptor/size_equal_only_decl.hpp" + +#include "rpc/msgpack/v1/adaptor/size_equal_only.hpp" + +#endif // MSGPACK_TYPE_SIZE_EQUAL_ONLYL_HPP diff --git a/include/rpc/msgpack/adaptor/size_equal_only_decl.hpp b/include/rpc/msgpack/adaptor/size_equal_only_decl.hpp new file mode 100644 index 00000000..438609c4 --- /dev/null +++ b/include/rpc/msgpack/adaptor/size_equal_only_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_SIZE_EQUAL_ONLY_DECL_HPP +#define MSGPACK_TYPE_SIZE_EQUAL_ONLY_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/size_equal_only_decl.hpp" +#include "rpc/msgpack/v2/adaptor/size_equal_only_decl.hpp" + +#endif // MSGPACK_TYPE_SIZE_EQUAL_ONLY_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/string.hpp b/include/rpc/msgpack/adaptor/string.hpp index c9c5359f..c4908138 100644 --- a/include/rpc/msgpack/adaptor/string.hpp +++ b/include/rpc/msgpack/adaptor/string.hpp @@ -1,94 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_STRING_HPP #define MSGPACK_TYPE_STRING_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::string& v) const { - switch (o.type) { - case clmdep_msgpack::type::BIN: - v.assign(o.via.bin.ptr, o.via.bin.size); - break; - case clmdep_msgpack::type::STR: - v.assign(o.via.str.ptr, o.via.str.size); - break; - default: - throw clmdep_msgpack::type_error(); - break; - } - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::string& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_str(size); - o.pack_str_body(v.data(), size); - return o; - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, const std::string& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::STR; - o.via.str.ptr = v.data(); - o.via.str.size = size; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const std::string& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::STR; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.str.ptr = ptr; - o.via.str.size = size; - std::memcpy(ptr, v.data(), v.size()); - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/string.hpp" #endif // MSGPACK_TYPE_STRING_HPP diff --git a/include/rpc/msgpack/adaptor/tr1/unordered_map.hpp b/include/rpc/msgpack/adaptor/tr1/unordered_map.hpp index 4fec3ba6..61bdc2f7 100644 --- a/include/rpc/msgpack/adaptor/tr1/unordered_map.hpp +++ b/include/rpc/msgpack/adaptor/tr1/unordered_map.hpp @@ -3,17 +3,9 @@ // // Copyright (C) 2008-2015 FURUHASHI Sadayuki // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP #define MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP @@ -88,11 +80,11 @@ struct object_with_zone void operator()(clmdep_msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map& v) const { o.type = clmdep_msgpack::type::MAP; if(v.empty()) { - o.via.map.ptr = nullptr; + o.via.map.ptr = MSGPACK_NULLPTR; o.via.map.size = 0; } else { uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size)); + clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size, MSGPACK_ZONE_ALIGNOF(clmdep_msgpack::object_kv))); clmdep_msgpack::object_kv* const pend = p + size; o.via.map.ptr = p; o.via.map.size = size; @@ -145,11 +137,11 @@ struct object_with_zone& v) const { o.type = clmdep_msgpack::type::MAP; if(v.empty()) { - o.via.map.ptr = nullptr; + o.via.map.ptr = MSGPACK_NULLPTR; o.via.map.size = 0; } else { uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size)); + clmdep_msgpack::object_kv* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size, MSGPACK_ZONE_ALIGNOF(clmdep_msgpack::object_kv))); clmdep_msgpack::object_kv* const pend = p + size; o.via.map.ptr = p; o.via.map.size = size; diff --git a/include/rpc/msgpack/adaptor/tr1/unordered_set.hpp b/include/rpc/msgpack/adaptor/tr1/unordered_set.hpp index e00b160d..51dfe4bd 100644 --- a/include/rpc/msgpack/adaptor/tr1/unordered_set.hpp +++ b/include/rpc/msgpack/adaptor/tr1/unordered_set.hpp @@ -3,17 +3,9 @@ // // Copyright (C) 2008-2015 FURUHASHI Sadayuki // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_TR1_UNORDERED_SET_HPP #define MSGPACK_TYPE_TR1_UNORDERED_SET_HPP @@ -86,11 +78,11 @@ struct object_with_zone void operator()(clmdep_msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set& v) const { o.type = clmdep_msgpack::type::ARRAY; if(v.empty()) { - o.via.array.ptr = nullptr; + o.via.array.ptr = MSGPACK_NULLPTR; o.via.array.size = 0; } else { uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); + clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(clmdep_msgpack::object))); clmdep_msgpack::object* const pend = p + size; o.via.array.ptr = p; o.via.array.size = size; @@ -140,11 +132,11 @@ struct object_with_zone& v) const { o.type = clmdep_msgpack::type::ARRAY; if(v.empty()) { - o.via.array.ptr = nullptr; + o.via.array.ptr = MSGPACK_NULLPTR; o.via.array.size = 0; } else { uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); + clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(clmdep_msgpack::object))); clmdep_msgpack::object* const pend = p + size; o.via.array.ptr = p; o.via.array.size = size; diff --git a/include/rpc/msgpack/adaptor/v4raw.hpp b/include/rpc/msgpack/adaptor/v4raw.hpp index 8ddf786b..315f02e2 100644 --- a/include/rpc/msgpack/adaptor/v4raw.hpp +++ b/include/rpc/msgpack/adaptor/v4raw.hpp @@ -1,114 +1,17 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi +// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_V4RAW_HPP #define MSGPACK_TYPE_V4RAW_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace type { - -struct v4raw_ref { - v4raw_ref() : size(0), ptr(nullptr) {} - v4raw_ref(const char* p, uint32_t s) : size(s), ptr(p) {} - - uint32_t size; - const char* ptr; - - std::string str() const { return std::string(ptr, size); } - - bool operator== (const v4raw_ref& x) const - { - return size == x.size && std::memcmp(ptr, x.ptr, size) == 0; - } - - bool operator!= (const v4raw_ref& x) const - { - return !(*this == x); - } - - bool operator< (const v4raw_ref& x) const - { - if(size == x.size) { return std::memcmp(ptr, x.ptr, size) < 0; } - else { return size < x.size; } - } - - bool operator> (const v4raw_ref& x) const - { - if(size == x.size) { return std::memcmp(ptr, x.ptr, size) > 0; } - else { return size > x.size; } - } -}; - -} // namespace type - -namespace adaptor { - -template <> -struct convert { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, clmdep_msgpack::type::v4raw_ref& v) const { - if(o.type != clmdep_msgpack::type::STR) { throw clmdep_msgpack::type_error(); } - v.ptr = o.via.str.ptr; - v.size = o.via.str.size; - return o; - } -}; - -template <> -struct pack { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const clmdep_msgpack::type::v4raw_ref& v) const { - o.pack_v4raw(v.size); - o.pack_v4raw_body(v.ptr, v.size); - return o; - } -}; - -template <> -struct object { - void operator()(clmdep_msgpack::object& o, const clmdep_msgpack::type::v4raw_ref& v) const { - o.type = clmdep_msgpack::type::STR; - o.via.str.ptr = v.ptr; - o.via.str.size = v.size; - } -}; - -template <> -struct object_with_zone { - void operator()(clmdep_msgpack::object::with_zone& o, const clmdep_msgpack::type::v4raw_ref& v) const { - static_cast(o) << v; - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/adaptor/v4raw_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/v4raw.hpp" #endif // MSGPACK_TYPE_V4RAW_HPP diff --git a/include/rpc/msgpack/adaptor/v4raw_decl.hpp b/include/rpc/msgpack/adaptor/v4raw_decl.hpp new file mode 100644 index 00000000..890620d2 --- /dev/null +++ b/include/rpc/msgpack/adaptor/v4raw_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_TYPE_V4RAW_DECL_HPP +#define MSGPACK_TYPE_V4RAW_DECL_HPP + +#include "rpc/msgpack/v1/adaptor/v4raw_decl.hpp" +#include "rpc/msgpack/v2/adaptor/v4raw_decl.hpp" + +#endif // MSGPACK_TYPE_V4RAW_DECL_HPP diff --git a/include/rpc/msgpack/adaptor/vector.hpp b/include/rpc/msgpack/adaptor/vector.hpp index d5a2a12e..8e7016d6 100644 --- a/include/rpc/msgpack/adaptor/vector.hpp +++ b/include/rpc/msgpack/adaptor/vector.hpp @@ -1,129 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_VECTOR_HPP #define MSGPACK_TYPE_VECTOR_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -#if !defined(MSGPACK_USE_CPP03) - -template -struct as, typename std::enable_if::value>::type> { - std::vector operator()(const clmdep_msgpack::object& o) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - std::vector v; - v.reserve(o.via.array.size); - if (o.via.array.size > 0) { - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - do { - v.push_back(p->as()); - ++p; - } while (p < pend); - } - return v; - } -}; - -#endif // !defined(MSGPACK_USE_CPP03) - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::vector& v) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - v.resize(o.via.array.size); - if (o.via.array.size > 0) { - clmdep_msgpack::object* p = o.via.array.ptr; - clmdep_msgpack::object* const pend = o.via.array.ptr + o.via.array.size; - typename std::vector::iterator it = v.begin(); - do { - p->convert(*it); - ++p; - ++it; - } while(p < pend); - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for (typename std::vector::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(*it); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::vector& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if (v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } - else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::vector::const_iterator it(v.begin()); - do { -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) - *p = clmdep_msgpack::object(*it, o.zone); -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__) - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/vector.hpp" #endif // MSGPACK_TYPE_VECTOR_HPP diff --git a/include/rpc/msgpack/adaptor/vector_bool.hpp b/include/rpc/msgpack/adaptor/vector_bool.hpp index bfee60e6..5dadb6b8 100644 --- a/include/rpc/msgpack/adaptor/vector_bool.hpp +++ b/include/rpc/msgpack/adaptor/vector_bool.hpp @@ -1,96 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_VECTOR_BOOL_HPP #define MSGPACK_TYPE_VECTOR_BOOL_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/object_fwd.hpp" -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::vector& v) const { - if (o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); } - if (o.via.array.size > 0) { - v.resize(o.via.array.size); - clmdep_msgpack::object* p = o.via.array.ptr; - for (typename std::vector::iterator it = v.begin(), end = v.end(); - it != end; - ++it) { - *it = p->as(); - ++p; - } - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_array(size); - for(typename std::vector::const_iterator it(v.begin()), it_end(v.end()); - it != it_end; ++it) { - o.pack(static_cast(*it)); - } - return o; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::vector& v) const { - o.type = clmdep_msgpack::type::ARRAY; - if(v.empty()) { - o.via.array.ptr = nullptr; - o.via.array.size = 0; - } else { - uint32_t size = checked_get_container_size(v.size()); - clmdep_msgpack::object* p = static_cast(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size)); - clmdep_msgpack::object* const pend = p + size; - o.via.array.ptr = p; - o.via.array.size = size; - typename std::vector::const_iterator it(v.begin()); - do { - *p = clmdep_msgpack::object(static_cast(*it), o.zone); - ++p; - ++it; - } while(p < pend); - } - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/vector_bool.hpp" #endif // MSGPACK_TYPE_VECTOR_BOOL_HPP diff --git a/include/rpc/msgpack/adaptor/vector_char.hpp b/include/rpc/msgpack/adaptor/vector_char.hpp index a5416e8d..ba61de3b 100644 --- a/include/rpc/msgpack/adaptor/vector_char.hpp +++ b/include/rpc/msgpack/adaptor/vector_char.hpp @@ -1,97 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_VECTOR_CHAR_HPP #define MSGPACK_TYPE_VECTOR_CHAR_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::vector& v) const { - switch (o.type) { - case clmdep_msgpack::type::BIN: - v.resize(o.via.bin.size); - std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size); - break; - case clmdep_msgpack::type::STR: - v.resize(o.via.str.size); - std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size); - break; - default: - throw clmdep_msgpack::type_error(); - break; - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_bin(size); - o.pack_bin_body(&v.front(), size); - - return o; - } -}; - -template -struct object > { - void operator()(clmdep_msgpack::object& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - o.via.bin.ptr = &v.front(); - o.via.bin.size = size; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.bin.ptr = ptr; - o.via.bin.size = size; - std::memcpy(ptr, &v.front(), size); - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/vector_char.hpp" #endif // MSGPACK_TYPE_VECTOR_CHAR_HPP diff --git a/include/rpc/msgpack/adaptor/vector_unsigned_char.hpp b/include/rpc/msgpack/adaptor/vector_unsigned_char.hpp index 3321d0d6..d953c7af 100644 --- a/include/rpc/msgpack/adaptor/vector_unsigned_char.hpp +++ b/include/rpc/msgpack/adaptor/vector_unsigned_char.hpp @@ -1,97 +1,15 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2014-2015 KONDO Takatoshi +// Copyright (C) 2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_TYPE_VECTOR_UNSIGNED_CHAR_HPP #define MSGPACK_TYPE_VECTOR_UNSIGNED_CHAR_HPP -#include "rpc/msgpack/versioning.hpp" -#include "rpc/msgpack/adaptor/adaptor_base.hpp" -#include "rpc/msgpack/adaptor/check_container_size.hpp" - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace adaptor { - -template -struct convert > { - clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::vector& v) const { - switch (o.type) { - case clmdep_msgpack::type::BIN: - v.resize(o.via.bin.size); - std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size); - break; - case clmdep_msgpack::type::STR: - v.resize(o.via.str.size); - std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size); - break; - default: - throw clmdep_msgpack::type_error(); - break; - } - return o; - } -}; - -template -struct pack > { - template - clmdep_msgpack::packer& operator()(clmdep_msgpack::packer& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.pack_bin(size); - o.pack_bin_body(reinterpret_cast(&v.front()), size); - - return o; - } -}; - -template -struct object > { - void operator()(clmdep_msgpack::object& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - o.via.bin.ptr = reinterpret_cast(&v.front()); - o.via.bin.size = size; - } -}; - -template -struct object_with_zone > { - void operator()(clmdep_msgpack::object::with_zone& o, const std::vector& v) const { - uint32_t size = checked_get_container_size(v.size()); - o.type = clmdep_msgpack::type::BIN; - char* ptr = static_cast(o.zone.allocate_align(size)); - o.via.bin.ptr = ptr; - o.via.bin.size = size; - std::memcpy(ptr, &v.front(), size); - } -}; - -} // namespace adaptor - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/adaptor/vector_unsigned_char.hpp" #endif // MSGPACK_TYPE_VECTOR_UNSIGNED_CHAR_HPP diff --git a/include/rpc/msgpack/cpp_config.hpp b/include/rpc/msgpack/cpp_config.hpp index 9836ba47..f399e8c8 100644 --- a/include/rpc/msgpack/cpp_config.hpp +++ b/include/rpc/msgpack/cpp_config.hpp @@ -1,135 +1,17 @@ // // MessagePack for C++ C++03/C++11 Adaptation // -// Copyright (C) 2013 KONDO Takatoshi +// Copyright (C) 2013-2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_CPP_CONFIG_HPP #define MSGPACK_CPP_CONFIG_HPP -#include "rpc/msgpack/versioning.hpp" - -#if !defined(MSGPACK_USE_CPP03) -# if defined(_MSC_VER) -# if _MSC_VER < 1900 -# define MSGPACK_USE_CPP03 -# endif -# elif (__cplusplus < 201103L) -# define MSGPACK_USE_CPP03 -# endif -#endif // MSGPACK_USE_CPP03 - - - -#if defined __cplusplus -#if __cplusplus < 201103L - -#if !defined(nullptr) -# if _MSC_VER < 1600 -# define nullptr (0) -# endif -#endif - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -template -struct unique_ptr : std::auto_ptr { - explicit unique_ptr(T* p = 0) throw() : std::auto_ptr(p) {} - unique_ptr(unique_ptr& a) throw() : std::auto_ptr(a) {} - template - unique_ptr (unique_ptr& a) throw() : std::auto_ptr(a) {} -}; - -template -T& move(T& t) -{ - return t; -} - -template -T const& move(T const& t) -{ - return t; -} - -template -struct enable_if { - typedef T type; -}; - -template -struct enable_if { -}; - -template -struct integral_constant { - static T const value = val; - typedef T value_type; - typedef integral_constant type; -}; - -typedef integral_constant true_type; -typedef integral_constant false_type; - -template -struct is_same : false_type {}; - -template -struct is_same : true_type {}; - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond - -} // namespace clmdep_msgpack - - -#else // __cplusplus < 201103L - -#include -#include - -namespace clmdep_msgpack { -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - - // unique_ptr - using std::unique_ptr; - // using std::make_unique; // since C++14 - using std::hash; - - // utility - using std::move; - using std::swap; - using std::enable_if; - using std::is_same; - -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond -} // namespace clmdep_msgpack - - -#endif // __cplusplus < 201103L +#include "rpc/msgpack/cpp_config_decl.hpp" -#endif // __cplusplus +#include "rpc/msgpack/v1/cpp_config.hpp" -#endif /* msgpack/cpp_config.hpp */ +#endif // MSGPACK_CPP_CONFIG_HPP diff --git a/include/rpc/msgpack/cpp_config_decl.hpp b/include/rpc/msgpack/cpp_config_decl.hpp new file mode 100644 index 00000000..44e1e627 --- /dev/null +++ b/include/rpc/msgpack/cpp_config_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ C++03/C++11 Adaptation +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_CPP_CONFIG_DECL_HPP +#define MSGPACK_CPP_CONFIG_DECL_HPP + +#include "rpc/msgpack/v1/cpp_config_decl.hpp" +#include "rpc/msgpack/v2/cpp_config_decl.hpp" + +#endif // MSGPACK_CPP_CONFIG_DECL_HPP diff --git a/include/rpc/msgpack/fbuffer.h b/include/rpc/msgpack/fbuffer.h index d12830e4..d766c839 100644 --- a/include/rpc/msgpack/fbuffer.h +++ b/include/rpc/msgpack/fbuffer.h @@ -3,17 +3,9 @@ * * Copyright (C) 2013 Vladimir Volodko * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) */ #ifndef MSGPACK_FBUFFER_H #define MSGPACK_FBUFFER_H @@ -31,9 +23,9 @@ extern "C" { * @{ */ -static inline int msgpack_fbuffer_write(void* data, const char* buf, unsigned int len) +static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len) { - return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1; + return (len == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1; } /** @} */ diff --git a/include/rpc/msgpack/fbuffer.hpp b/include/rpc/msgpack/fbuffer.hpp index 460fdfcd..8a887bf2 100644 --- a/include/rpc/msgpack/fbuffer.hpp +++ b/include/rpc/msgpack/fbuffer.hpp @@ -3,66 +3,15 @@ // // Copyright (C) 2013 Vladimir Volodko // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef MSGPACK_FBUFFER_HPP__ -#define MSGPACK_FBUFFER_HPP__ - -#include "rpc/msgpack/versioning.hpp" - -#include -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -class fbuffer { -public: - explicit fbuffer(FILE* file) : m_file(file) { } - -public: - void write(const char* buf, unsigned int len) - { - if (1 != fwrite(buf, len, 1, m_file)) { - throw std::runtime_error("fwrite() failed"); - } - } - - FILE* file() const - { - return m_file; - } - -#if defined(MSGPACK_USE_CPP03) -private: - fbuffer(const fbuffer&); - fbuffer& operator=(const fbuffer&); -#else // defined(MSGPACK_USE_CPP03) - fbuffer(const fbuffer&) = delete; - fbuffer& operator=(const fbuffer&) = delete; -#endif // defined(MSGPACK_USE_CPP03) - -private: - FILE* m_file; -}; +#ifndef MSGPACK_FBUFFER_HPP +#define MSGPACK_FBUFFER_HPP -/// @cond -} // MSGPACK_API_VERSION_NAMESPACE(v1) -/// @endcond +#include "rpc/msgpack/fbuffer_decl.hpp" -} // namespace clmdep_msgpack +#include "rpc/msgpack/v1/fbuffer.hpp" -#endif /* msgpack/fbuffer.hpp */ +#endif // MSGPACK_FBUFFER_HPP diff --git a/include/rpc/msgpack/fbuffer_decl.hpp b/include/rpc/msgpack/fbuffer_decl.hpp new file mode 100644 index 00000000..76ae765f --- /dev/null +++ b/include/rpc/msgpack/fbuffer_decl.hpp @@ -0,0 +1,16 @@ +// +// MessagePack for C++ FILE* buffer adaptor +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#ifndef MSGPACK_FBUFFER_DECL_HPP +#define MSGPACK_FBUFFER_DECL_HPP + +#include "rpc/msgpack/v1/fbuffer_decl.hpp" +#include "rpc/msgpack/v2/fbuffer_decl.hpp" + +#endif // MSGPACK_FBUFFER_DECL_HPP diff --git a/include/rpc/msgpack/gcc_atomic.h b/include/rpc/msgpack/gcc_atomic.h index 276acdc9..6b1b1a79 100644 --- a/include/rpc/msgpack/gcc_atomic.h +++ b/include/rpc/msgpack/gcc_atomic.h @@ -1,15 +1,7 @@ /* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) */ #ifndef MSGPACK_GCC_ATOMIC_H diff --git a/include/rpc/msgpack/gcc_atomic.hpp b/include/rpc/msgpack/gcc_atomic.hpp new file mode 100644 index 00000000..3a71a609 --- /dev/null +++ b/include/rpc/msgpack/gcc_atomic.hpp @@ -0,0 +1,31 @@ +// +// MessagePack for C++ old gcc workaround for atomic operation +// +// Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MSGPACK_GCC_ATOMIC_HPP +#define MSGPACK_GCC_ATOMIC_HPP + +#if defined(__GNUC__) && ((__GNUC__*10 + __GNUC_MINOR__) < 41) + +#include "rpc/msgpack/gcc_atomic.h" +#include + +int _msgpack_sync_decr_and_fetch(volatile _msgpack_atomic_counter_t* ptr) +{ + return __gnu_cxx::__exchange_and_add(ptr, -1) - 1; +} + +int _msgpack_sync_incr_and_fetch(volatile _msgpack_atomic_counter_t* ptr) +{ + return __gnu_cxx::__exchange_and_add(ptr, 1) + 1; +} + +#endif // old gcc workaround + +#endif /* gcc_atomic.hpp */ diff --git a/include/rpc/msgpack/iterator.hpp b/include/rpc/msgpack/iterator.hpp index 2e33eeb3..4f29f0d5 100644 --- a/include/rpc/msgpack/iterator.hpp +++ b/include/rpc/msgpack/iterator.hpp @@ -1,46 +1,18 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 MIZUKI Hirata +// Copyright (C) 2015-2016 MIZUKI Hirata // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_ITERATOR_HPP #define MSGPACK_ITERATOR_HPP -#if !defined(MSGPACK_USE_CPP03) - -#include -namespace clmdep_msgpack -{ - /// @cond - MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) - { - /// @endcond - inline object_kv* begin(object_map &map) { return map.ptr; } - inline const object_kv* begin(const object_map &map) { return map.ptr; } - inline object_kv* end(object_map &map) { return map.ptr + map.size; } - inline const object_kv* end(const object_map &map) { return map.ptr + map.size; } +#include - inline object* begin(object_array &array) { return array.ptr; } - inline const object* begin(const object_array &array) { return array.ptr; } - inline object* end(object_array &array) { return array.ptr + array.size; } - inline const object* end(const object_array &array) { return array.ptr + array.size; } - /// @cond - } - /// @endcond -} +#include -#endif // !defined(MSGPACK_USE_CPP03) #endif // MSGPACK_ITERATOR_HPP diff --git a/include/rpc/msgpack/iterator_decl.hpp b/include/rpc/msgpack/iterator_decl.hpp new file mode 100644 index 00000000..a26709df --- /dev/null +++ b/include/rpc/msgpack/iterator_decl.hpp @@ -0,0 +1,17 @@ +// +// MessagePack for C++ static resolution routine +// +// Copyright (C) 2016 KONDO Takatoshi +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MSGPACK_ITERATOR_DECL_HPP +#define MSGPACK_ITERATOR_DECL_HPP + +#include +#include + +#endif // MSGPACK_V1_ITERATOR_DECL_HPP diff --git a/include/rpc/msgpack/meta.hpp b/include/rpc/msgpack/meta.hpp index c6e976d4..68c9eb04 100644 --- a/include/rpc/msgpack/meta.hpp +++ b/include/rpc/msgpack/meta.hpp @@ -1,59 +1,18 @@ // // MessagePack for C++ static resolution routine // -// Copyright (C) 2015 KONDO Takatoshi +// Copyright (C) 2015-2016 KONDO Takatoshi // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // #ifndef MSGPACK_META_HPP #define MSGPACK_META_HPP -#if !defined(MSGPACK_USE_CPP03) - -#include - -namespace clmdep_msgpack { - -/// @cond -MSGPACK_API_VERSION_NAMESPACE(v1) { -/// @endcond - -namespace detail { -template struct bool_pack; - -template struct all_of_imp - : std::is_same, bool_pack>{}; - -} // namespace detail - -template