Go to the documentation of this file. 10 #ifndef MSGPACK_DEFINE_DECL_HPP 11 #define MSGPACK_DEFINE_DECL_HPP 17 #if !defined(MSGPACK_PP_VARIADICS) 18 #define MSGPACK_PP_VARIADICS 28 #define MSGPACK_DEFINE_ARRAY(...) \ 29 template <typename Packer> \ 30 void msgpack_pack(Packer& pk) const \ 32 msgpack::type::make_define_array(__VA_ARGS__).msgpack_pack(pk); \ 34 void msgpack_unpack(msgpack::object const& o) \ 36 msgpack::type::make_define_array(__VA_ARGS__).msgpack_unpack(o); \ 38 template <typename MSGPACK_OBJECT> \ 39 void msgpack_object(MSGPACK_OBJECT* o, msgpack::zone& z) const \ 41 msgpack::type::make_define_array(__VA_ARGS__).msgpack_object(o, z); \ 44 #define MSGPACK_BASE_ARRAY(base) (*const_cast<base *>(static_cast<base const*>(this))) 46 #define MSGPACK_DEFINE_MAP_EACH_PROC(r, data, elem) \ 48 MSGPACK_PP_IS_BEGIN_PARENS(elem), \ 50 (MSGPACK_PP_STRINGIZE(elem))(elem) \ 53 #define MSGPACK_DEFINE_MAP_IMPL(...) \ 54 MSGPACK_PP_SEQ_TO_TUPLE( \ 55 MSGPACK_PP_SEQ_FOR_EACH( \ 56 MSGPACK_DEFINE_MAP_EACH_PROC, \ 58 MSGPACK_PP_VARIADIC_TO_SEQ(__VA_ARGS__) \ 62 #define MSGPACK_DEFINE_MAP(...) \ 63 template <typename Packer> \ 64 void msgpack_pack(Packer& pk) const \ 66 msgpack::type::make_define_map \ 67 MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ 70 void msgpack_unpack(msgpack::object const& o) \ 72 msgpack::type::make_define_map \ 73 MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ 76 template <typename MSGPACK_OBJECT> \ 77 void msgpack_object(MSGPACK_OBJECT* o, msgpack::zone& z) const \ 79 msgpack::type::make_define_map \ 80 MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ 81 .msgpack_object(o, z); \ 84 #define MSGPACK_BASE_MAP(base) \ 85 (MSGPACK_PP_STRINGIZE(base))(*const_cast<base *>(static_cast<base const*>(this))) 88 #define MSGPACK_ADD_ENUM(enum_name) \ 91 MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) { \ 95 struct convert<enum_name> { \ 96 msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const { \ 97 msgpack::underlying_type<enum_name>::type tmp; \ 98 msgpack::operator>>(o, tmp); \ 99 v = static_cast<enum_name>(tmp); \ 104 struct object<enum_name> { \ 105 void operator()(msgpack::object& o, const enum_name& v) const { \ 106 msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(v); \ 107 msgpack::operator<<(o, tmp); \ 111 struct object_with_zone<enum_name> { \ 112 void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \ 113 msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(v); \ 114 msgpack::operator<<(o, tmp); \ 118 struct pack<enum_name> { \ 119 template <typename Stream> \ 120 msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \ 121 return msgpack::operator<<(o, static_cast<msgpack::underlying_type<enum_name>::type>(v)); \ 130 #if defined(MSGPACK_USE_DEFINE_MAP) 131 #define MSGPACK_DEFINE MSGPACK_DEFINE_MAP 132 #define MSGPACK_BASE MSGPACK_BASE_MAP 133 #else // defined(MSGPACK_USE_DEFINE_MAP) 134 #define MSGPACK_DEFINE MSGPACK_DEFINE_ARRAY 135 #define MSGPACK_BASE MSGPACK_BASE_ARRAY 136 #endif // defined(MSGPACK_USE_DEFINE_MAP) 142 #endif // MSGPACK_DEFINE_DECL_HPP