10 #ifndef MSGPACK_V1_TYPE_BOOST_MSGPACK_VARIANT_HPP
11 #define MSGPACK_V1_TYPE_BOOST_MSGPACK_VARIANT_HPP
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wconversion"
35 #include <boost/variant.hpp>
38 #pragma GCC diagnostic pop
41 #include <boost/operators.hpp>
52 template <
typename STR,
typename BIN,
typename EXT>
61 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
68 boost::recursive_wrapper<std::vector<basic_variant<STR, BIN, EXT> > >,
69 boost::recursive_wrapper<std::map<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >,
70 boost::recursive_wrapper<std::multimap<basic_variant<STR, BIN, EXT>, basic_variant<STR, BIN, EXT> > >
72 private boost::totally_ordered<basic_variant<STR, BIN, EXT> > {
80 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
87 boost::recursive_wrapper<std::vector<basic_variant<STR, BIN, EXT> > >,
95 #if defined(_MSC_VER) && _MSC_VER < 1700
100 *
static_cast<base*
>(
this) =
static_cast<base const&
>(other);
144 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
145 bool is_boost_string_ref()
const {
165 return boost::get<std::vector<basic_variant<STR, BIN, EXT> > >(
this) !=
MSGPACK_NULLPTR;
175 return boost::get<bool>(*
this);
178 return boost::get<int64_t>(*
this);
181 return boost::get<int64_t>(*
this);
184 return boost::get<uint64_t>(*
this);
187 return boost::get<uint64_t>(*
this);
190 return boost::get<double>(*
this);
193 return boost::get<double>(*
this);
196 return boost::get<std::string>(*
this);
199 return boost::get<std::string>(*
this);
201 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
202 boost::string_ref
const& as_boost_string_ref()
const {
203 return boost::get<boost::string_ref>(*
this);
205 boost::string_ref& as_boost_string_ref() {
206 return boost::get<boost::string_ref>(*
this);
210 return boost::get<std::vector<char> >(*this);
213 return boost::get<std::vector<char> >(*this);
216 return boost::get<raw_ref>(*
this);
219 return boost::get<ext>(*
this);
222 return boost::get<ext>(*
this);
225 return boost::get<ext_ref>(*
this);
227 std::vector<basic_variant<STR, BIN, EXT> >
const&
as_vector()
const {
228 return boost::get<std::vector<basic_variant<STR, BIN, EXT> > >(*this);
230 std::vector<basic_variant<STR, BIN, EXT> >&
as_vector() {
231 return boost::get<std::vector<basic_variant<STR, BIN, EXT> > >(*this);
246 template <
typename T>
249 static_cast<base&
>(*this) = int64_t(v);
252 static_cast<base&
>(*this) = uint64_t(v);
257 template <
typename STR,
typename BIN,
typename EXT>
264 template <
typename STR,
typename BIN,
typename EXT>
273 #if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
284 #if !defined (MSGPACK_USE_CPP03)
286 template <
typename STR,
typename BIN,
typename EXT>
287 struct as<type::basic_variant<STR, BIN, EXT> > {
295 return o.
as<uint64_t>();
297 return o.
as<int64_t>();
300 return o.
as<
double>();
308 return o.
as<std::vector<type::basic_variant<STR, BIN, EXT> > >();
321 template <
typename STR,
typename BIN,
typename EXT>
322 struct convert<type::basic_variant<STR, BIN, EXT> > {
334 v = o.
as<uint64_t>();
353 v = o.
as<std::vector<type::basic_variant<STR, BIN, EXT> > >();
367 template <
typename Stream>
369 template <
typename T>
379 template <
typename STR,
typename BIN,
typename EXT>
380 struct pack<type::basic_variant<STR, BIN, EXT> > {
381 template <
typename Stream>
406 template <
typename T>
416 template <
typename STR,
typename BIN,
typename EXT>
417 struct object<type::basic_variant<STR, BIN, EXT> > {
426 template <
typename T>
436 template <
typename STR,
typename BIN,
typename EXT>
The class template that supports continuous packing.
Definition: pack.hpp:33
Definition: object_fwd.hpp:231
basic_variant< std::string, std::vector< char >, ext > variant
Definition: msgpack_variant.hpp:271
bool operator<(basic_variant< STR, BIN, EXT > const &lhs, basic_variant< STR, BIN, EXT > const &rhs)
Definition: msgpack_variant.hpp:258
basic_variant< std::string, raw_ref, ext_ref > variant_ref
Definition: msgpack_variant.hpp:278
@ EXT
Definition: object_fwd_decl.hpp:42
@ FLOAT64
Definition: object_fwd_decl.hpp:33
@ BOOLEAN
Definition: object_fwd_decl.hpp:29
@ MAP
Definition: object_fwd_decl.hpp:41
@ NIL
Definition: object_fwd_decl.hpp:28
@ STR
Definition: object_fwd_decl.hpp:38
@ ARRAY
Definition: object_fwd_decl.hpp:40
@ BIN
Definition: object_fwd_decl.hpp:39
@ POSITIVE_INTEGER
Definition: object_fwd_decl.hpp:30
@ NEGATIVE_INTEGER
Definition: object_fwd_decl.hpp:31
@ FLOAT32
Definition: object_fwd_decl.hpp:32
bool operator==(basic_variant< STR, BIN, EXT > const &lhs, basic_variant< STR, BIN, EXT > const &rhs)
Definition: msgpack_variant.hpp:265
Definition: adaptor_base.hpp:15
type::basic_variant< STR, BIN, EXT > operator()(msgpack::object const &o) const
Definition: msgpack_variant.hpp:288
Definition: object_fwd_decl.hpp:61
msgpack::object const & operator()(msgpack::object const &o, type::basic_variant< STR, BIN, EXT > &v) const
Definition: msgpack_variant.hpp:323
Definition: adaptor_base.hpp:27
Definition: msgpack_variant.hpp:390
void operator()(uint64_t const &v) const
Definition: msgpack_variant.hpp:397
void operator()(bool const &v) const
Definition: msgpack_variant.hpp:394
object_imp(msgpack::object &o)
Definition: msgpack_variant.hpp:410
void operator()(int64_t const &v) const
Definition: msgpack_variant.hpp:400
msgpack::object & o_
Definition: msgpack_variant.hpp:411
void operator()(T const &) const
Definition: msgpack_variant.hpp:407
void operator()(double const &v) const
Definition: msgpack_variant.hpp:403
void operator()(msgpack::type::nil_t const &v) const
Definition: msgpack_variant.hpp:391
Definition: msgpack_variant.hpp:425
msgpack::object::with_zone & o_
Definition: msgpack_variant.hpp:431
object_with_zone_imp(msgpack::object::with_zone &o)
Definition: msgpack_variant.hpp:430
void operator()(T const &v) const
Definition: msgpack_variant.hpp:427
Definition: msgpack_variant.hpp:368
pack_imp(packer< Stream > &o)
Definition: msgpack_variant.hpp:373
packer< Stream > & o_
Definition: msgpack_variant.hpp:374
void operator()(T const &value) const
Definition: msgpack_variant.hpp:370
void operator()(msgpack::object &o, const type::basic_variant< STR, BIN, EXT > &v) const
Definition: msgpack_variant.hpp:418
void operator()(msgpack::object::with_zone &o, const type::basic_variant< STR, BIN, EXT > &v) const
Definition: msgpack_variant.hpp:438
Definition: adaptor_base.hpp:43
Definition: adaptor_base.hpp:38
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::basic_variant< STR, BIN, EXT > &v) const
Definition: msgpack_variant.hpp:382
Definition: adaptor_base.hpp:32
Definition: object.hpp:35
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
std::enable_if< msgpack::has_as< T >::value, T >::type as() const
Get value as T.
Definition: object.hpp:1121
msgpack::type::object_type type
Definition: object_fwd.hpp:92
Definition: msgpack_variant.hpp:72
bool is_map() const
Definition: msgpack_variant.hpp:167
boost::variant< nil_t, bool, int64_t, uint64_t, double, std::string, std::vector< char >, msgpack::type::raw_ref, msgpack::type::ext, msgpack::type::ext_ref, boost::recursive_wrapper< std::vector< basic_variant< STR, BIN, EXT > > >, boost::recursive_wrapper< std::map< basic_variant< STR, BIN, EXT >, basic_variant< STR, BIN, EXT > > >, boost::recursive_wrapper< std::multimap< basic_variant< STR, BIN, EXT >, basic_variant< STR, BIN, EXT > > > > base
Definition: msgpack_variant.hpp:90
std::vector< char > & as_vector_char()
Definition: msgpack_variant.hpp:212
bool is_raw_ref() const
Definition: msgpack_variant.hpp:155
ext const & as_ext() const
Definition: msgpack_variant.hpp:218
std::map< basic_variant< STR, BIN, EXT >, basic_variant< STR, BIN, EXT > > & as_map()
Definition: msgpack_variant.hpp:236
std::string const & as_string() const
Definition: msgpack_variant.hpp:195
std::vector< basic_variant< STR, BIN, EXT > > const & as_vector() const
Definition: msgpack_variant.hpp:227
double as_double() const
Definition: msgpack_variant.hpp:189
std::vector< char > const & as_vector_char() const
Definition: msgpack_variant.hpp:209
std::vector< basic_variant< STR, BIN, EXT > > & as_vector()
Definition: msgpack_variant.hpp:230
bool is_ext_ref() const
Definition: msgpack_variant.hpp:161
bool is_string() const
Definition: msgpack_variant.hpp:141
bool is_int64_t() const
Definition: msgpack_variant.hpp:132
ext_ref const & as_ext_ref() const
Definition: msgpack_variant.hpp:224
uint64_t & as_uint64_t()
Definition: msgpack_variant.hpp:186
bool is_vector_char()
Definition: msgpack_variant.hpp:152
bool is_vector() const
Definition: msgpack_variant.hpp:164
int64_t & as_int64_t()
Definition: msgpack_variant.hpp:180
std::multimap< basic_variant< STR, BIN, EXT >, basic_variant< STR, BIN, EXT > > & as_multimap()
Definition: msgpack_variant.hpp:242
raw_ref const & as_raw_ref() const
Definition: msgpack_variant.hpp:215
ext & as_ext()
Definition: msgpack_variant.hpp:221
bool as_bool() const
Definition: msgpack_variant.hpp:174
bool is_vector_char() const
Definition: msgpack_variant.hpp:149
double & as_double()
Definition: msgpack_variant.hpp:192
basic_variant(unsigned char v)
Definition: msgpack_variant.hpp:112
basic_variant(signed int v)
Definition: msgpack_variant.hpp:113
int64_t as_int64_t() const
Definition: msgpack_variant.hpp:177
basic_variant(unsigned long long v)
Definition: msgpack_variant.hpp:124
uint64_t as_uint64_t() const
Definition: msgpack_variant.hpp:183
bool is_ext() const
Definition: msgpack_variant.hpp:158
basic_variant(signed long long v)
Definition: msgpack_variant.hpp:121
bool is_uint64_t() const
Definition: msgpack_variant.hpp:135
bool is_nil() const
Definition: msgpack_variant.hpp:126
basic_variant(unsigned long v)
Definition: msgpack_variant.hpp:120
bool is_double() const
Definition: msgpack_variant.hpp:138
basic_variant(signed long v)
Definition: msgpack_variant.hpp:117
std::multimap< basic_variant< STR, BIN, EXT >, basic_variant< STR, BIN, EXT > > const & as_multimap() const
Definition: msgpack_variant.hpp:239
bool is_multimap() const
Definition: msgpack_variant.hpp:170
basic_variant(T const &t)
Definition: msgpack_variant.hpp:93
basic_variant(char const *p)
Definition: msgpack_variant.hpp:105
basic_variant(unsigned int v)
Definition: msgpack_variant.hpp:116
bool is_bool() const
Definition: msgpack_variant.hpp:129
std::string & as_string()
Definition: msgpack_variant.hpp:198
basic_variant(char v)
Definition: msgpack_variant.hpp:106
basic_variant(signed char v)
Definition: msgpack_variant.hpp:109
std::map< basic_variant< STR, BIN, EXT >, basic_variant< STR, BIN, EXT > > const & as_map() const
Definition: msgpack_variant.hpp:233
basic_variant()
Definition: msgpack_variant.hpp:91
#define MSGPACK_NULLPTR
Definition: cpp_config_decl.hpp:85
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66