I'm using "msgpack" to serialize my messages.
There is a customized type that was defined in a 3rd party lib's header, I can NOT modify the include file, i.e. I should NOT add a MSGPACK_DEFINE
into the declare of this class.
But I know that it is a int32_t indeed, and it also offers a getter method named as<int32_t>();
like the following:
class GlobalCustomizedType_t {
template <typename T>
T as() const { return static_cast<T>( _data ); };
protected:
int32_t _data;
};
Now I need to serialize my message struct that has a member of type GlobalCustomizedType_t with msgpack
. Obviously I can't directly add a macro into my message struct, like this:
struct MyMessage_t {
GlobalCustomizedType_t _glob;
MSGPACK_DEFINE( _glob );
};
I have tried it like this:
struct MyMessage_t {
GlobalCustomizedType_t _glob;
MSGPACK_DEFINE( _glob.as<int32_t> );
};
But it still can't work.
Would anyone please to help me? thx!