-
Notifications
You must be signed in to change notification settings - Fork 881
v2_0_cpp_variant
Takatoshi Kondo edited this page Jan 10, 2017
·
5 revisions
msgpack-c doesn't have boost::variant
adaptor. But msgpack::type::variant
can contain any msgpack types. It is implemented using boost::variant
. There are two variant types. One is value based msgpack::type::variant
, the other is reference based msgpack::type::variant_ref
.
msgpack::type | variant type |
---|---|
NIL | msgpack::type::nil_t |
BOOLEAN | bool |
POSITIVE_INTEGER | uint64_t |
NEGATIVE_INTEGER | int64_t |
FLOAT | double |
msgpack::type | variant type |
---|---|
STR | std::string |
BIN | std::vector |
EXT | msgpack::type::ext |
ARRAY | std::vector<msgpack::type::variant> |
MAP | std::multimap<msgpack::type::variant, msgpack::type::variant> |
msgpack::type | variant type |
---|---|
STR | boost::string_ref |
BIN | msgpack::type::raw_ref |
EXT | msgpack::type::ext_ref |
ARRAY | std::vector<msgpack::type::variant_ref> |
MAP | std::multimap<msgpack::type::variant_ref, msgpack::type::variant_ref> |
msgpack-c has a variant type msgpack::object
. However, it is difficult to modify. For example, you can't insert/delete ARRAY, MAP items. You can't change STR, BIN, EXT fields. You can do that using msgpack::type::variant
. So, you can use it when you want to treat unpredictable msgpack data structures and need to modify them.
-
Home
- Q&A
- v2.0.x or later
- v1.1.x - v1.4.x
- v1.0.x