Open
Description
Decoding and reading the data section is almost completely irrelevant since the decoder was reworked, we need to update it.
Class Data
has decode
method now. One can call it and pass a reference to container in which the tuples are to be placed. For example, your tuples has format [int, int]
. That's how decoding of such tuples looks like:
using MyTuple = std::tuple<int, int>;
std::vector<MyTuple> tuples;
data.decode(tuples);
Generally, here are supported objects:
std::nullptr_t
will be always decoded asMP_NIL
.- fundamental types (
int
,float
,bool
, ...) char[N]
,std::string
forMP_STR
.- Any putable, contiguous (if underlying type is not char) or tuple-like object is considered as
MP_ARR
. - Any putable, contiguous (if underlying type is not char) or tuple-like object, containing pairs (including
std::map
), is considered asMP_MAP
. - Any optional-like object can be decoded as
MP_NIL
or as its underlying value. - Any variant-like object can be decoded as any of its alternatives.
Also, one can populate its own class with encoding rule using static constexpr mpp_dec
or mpp
member, containing pointers to the class member. Used members must be public. And, one can use mpp::as_*
tag to specify what type to encode into. Semantics is the same as the one in #3967 (these features are described in the end of the issue).