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))) 45 #define MSGPACK_NVP(name, value) (name) (value) 47 #define MSGPACK_DEFINE_MAP_EACH_PROC(r, data, elem) \ 49 MSGPACK_PP_IS_BEGIN_PARENS(elem), \ 51 (MSGPACK_PP_STRINGIZE(elem))(elem) \ 54 #define MSGPACK_DEFINE_MAP_IMPL(...) \ 55 MSGPACK_PP_SEQ_TO_TUPLE( \ 56 MSGPACK_PP_SEQ_FOR_EACH( \ 57 MSGPACK_DEFINE_MAP_EACH_PROC, \ 59 MSGPACK_PP_VARIADIC_TO_SEQ(__VA_ARGS__) \ 63 #define MSGPACK_DEFINE_MAP(...) \ 64 template <typename Packer> \ 65 void msgpack_pack(Packer& pk) const \ 67 msgpack::type::make_define_map \ 68 MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ 71 void msgpack_unpack(msgpack::object const& o) \ 73 msgpack::type::make_define_map \ 74 MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ 77 template <typename MSGPACK_OBJECT> \ 78 void msgpack_object(MSGPACK_OBJECT* o, msgpack::zone& z) const \ 80 msgpack::type::make_define_map \ 81 MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \ 82 .msgpack_object(o, z); \ 85 #define MSGPACK_BASE_MAP(base) \ 86 (MSGPACK_PP_STRINGIZE(base))(*const_cast<base *>(static_cast<base const*>(this))) 89 #define MSGPACK_ADD_ENUM(enum_name) \ 92 MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) { \ 96 struct convert<enum_name> { \ 97 msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const { \ 98 msgpack::underlying_type<enum_name>::type tmp; \ 99 msgpack::operator>>(o, tmp); \ 100 v = static_cast<enum_name>(tmp); \ 105 struct object<enum_name> { \ 106 void operator()(msgpack::object& o, const enum_name& v) const { \ 107 msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(v); \ 108 msgpack::operator<<(o, tmp); \ 112 struct object_with_zone<enum_name> { \ 113 void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \ 114 msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(v); \ 115 msgpack::operator<<(o, tmp); \ 119 struct pack<enum_name> { \ 120 template <typename Stream> \ 121 msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \ 122 return msgpack::operator<<(o, static_cast<msgpack::underlying_type<enum_name>::type>(v)); \ 131 #if defined(MSGPACK_USE_DEFINE_MAP) 132 #define MSGPACK_DEFINE MSGPACK_DEFINE_MAP 133 #define MSGPACK_BASE MSGPACK_BASE_MAP 134 #else // defined(MSGPACK_USE_DEFINE_MAP) 135 #define MSGPACK_DEFINE MSGPACK_DEFINE_ARRAY 136 #define MSGPACK_BASE MSGPACK_BASE_ARRAY 137 #endif // defined(MSGPACK_USE_DEFINE_MAP) 143 #endif // MSGPACK_DEFINE_DECL_HPP