The MessagePack specification defines a structure to hold new data-types and this structure implements that feature. To add a new data-type, set the Ext::type to a positive value and then fill the Ext::data with the information to be stored.
- Note
- Negative Ext::type value are reserved for use by the MessagePack specification.
As an example, to add a GIF data-type, define the type value then fill the Ext::data with the GIF.
- Example
#define TYPE_GIF 2
#define INDEX_NAME 0
#define INDEX_FILE 1
#define INDEX_IMAGE 2
array.
append({std::string_view(
"Super-Sonic Scooter")});
array.
append({std::string_view(
"super_sonic_scooter.gif")});
gif.
data = loadGif(
"super_sonic_scooter.gif");
Image image;
if(raw_data.
type == TYPE_GIF)
{
image = parseGif(raw_data.
data);
}
Object deserialize(const std::vector< uint8_t > &) noexcept
Deserialize MessagePack data.
Definition: Zakero_MessagePack.h:4678
std::vector< uint8_t > serialize(const messagepack::Array &) noexcept
Serialize Array data.
Definition: Zakero_MessagePack.h:5943
An array of Objects.
Definition: Zakero_MessagePack.h:272
Object & object(const size_t index) noexcept
Access a data object.
Definition: Zakero_MessagePack.h:291
size_t append(const bool) noexcept
Append a boolean value.
Definition: Zakero_MessagePack.h:1425
Extension Data.
Definition: Zakero_MessagePack.h:304
std::vector< uint8_t > data
Extension binary data.
Definition: Zakero_MessagePack.h:305
int8_t type
A unique identifier for the extension.
Definition: Zakero_MessagePack.h:306
A Data Object.
Definition: Zakero_MessagePack.h:337
const std::string & asString() const noexcept
Convert to a std::string.
Definition: Zakero_MessagePack.h:364
messagepack::Ext & asExt() noexcept
Convert to an Ext.
Definition: Zakero_MessagePack.h:358