Read
APIs for unpacking MessagePack data into object and reading their values. More...
Functions | |
zos_result_t | msgpack_deserialize_with_buffer (msgpack_object_t **root_ptr, const void *buffer, uint32_t length) |
Convert a 'packed' MessagePack binary string to a linked list of msgpack_object_t. More... | |
void | msgpack_free_objects (msgpack_object_t *root) |
Release all msgpack_object_t the supplied object references. More... | |
msgpack_object_t * | msgpack_get_dict_object (const msgpack_object_dict_t *dict, const char *key) |
Return the value of the corresponding key in dictionary. More... | |
msgpack_object_t * | msgpack_get_array_object (const msgpack_object_array_t *array, uint32_t index) |
Return value of corresponding index in array. More... | |
int32_t | msgpack_get_int (const msgpack_object_t *object) |
Return a MessagePack integer object as a signed 32bit value. More... | |
uint32_t | msgpack_get_uint (const msgpack_object_t *object) |
Return a MessagePack integer object as an unsigned 32bit value. More... | |
int64_t * | msgpack_get_long (const msgpack_object_t *object, int64_t *buffer) |
Return a MessagePack integer object as a signed 64bit value. More... | |
uint64_t * | msgpack_get_ulong (const msgpack_object_t *object, uint64_t *buffer) |
Return a MessagePack integer object as an unsigned 64bit value. More... | |
char * | msgpack_get_str (const msgpack_object_t *object, char *buffer, uint16_t max_length) |
Copy a MessagePack string object into the given buffer. More... | |
Detailed Description
APIs for unpacking MessagePack data into object and reading their values.
Function Documentation
zos_result_t msgpack_deserialize_with_buffer | ( | msgpack_object_t ** | root_ptr, |
const void * | buffer, |
||
uint32_t | length |
||
) |
Convert a 'packed' MessagePack binary string to a linked list of msgpack_object_t.
This will parse the binary MessagePack data into a linked list of msgpack_object_t. Each msgpack_object_t is dynamically allocated.
Use msgpack_free_objects() to release the allocated memory.
This function does NOT allocate additional memory for binary strings and strings. Thus the given buffer
MUST persist for as long as the return objects are referenced. If the given buffer
is released, the memory a MSGPACK_TYPE_STR or MSGPACK_TYPE_BIN object references will be invalid.
- Note
- The returned root object will be a msgpack_object_array_t OR msgpack_object_dict_t
- Parameters
-
root_ptr
Pointer to hold allocated linked list of MessagePack object buffer
Buffer containing 'packed' MessagePack data, this buffer MUST persist for as long as the return object are referenced IF binary strings or strings are used length
Length of buffer to parse
- Returns
- result of API, see zos_result_t
void msgpack_free_objects | ( | msgpack_object_t * | root | ) |
Release all msgpack_object_t the supplied object references.
This should be used to release the memory that's allocated with msgpack_deserialize_with_buffer()
- Parameters
-
root
Object to release
msgpack_object_t* msgpack_get_array_object | ( | const msgpack_object_array_t * | array, |
uint32_t | index |
||
) |
Return value of corresponding index in array.
This returns the value at the given index
in the supplied array
If the index
is out-of-range or the array
is invalid, NULL is returned.
- Parameters
-
array
msgpack_object_array_t An array object index
Index to return value
- Returns
- Array value IF found, NULL else
msgpack_object_t* msgpack_get_dict_object | ( | const msgpack_object_dict_t * | dict, |
const char * | key |
||
) |
Return the value of the corresponding key in dictionary.
This returns the value which has the given key
in the supplied dict
If the key
is not found or the dict
is invalid, NULL is returned.
- Parameters
-
dict
msgpack_object_dict_t A dictionary object key
The dictionary key of the desired value to return
- Returns
- The dictionary value IF found, NULL else
int32_t msgpack_get_int | ( | const msgpack_object_t * | object | ) |
Return a MessagePack integer object as a signed 32bit value.
This converts the following msgpack_type_t to a signed 32bit value
- MSGPACK_TYPE_BOOL
- MSGPACK_TYPE_INT8
- MSGPACK_TYPE_UINT8
- MSGPACK_TYPE_INT16
- MSGPACK_TYPE_UINT16
- MSGPACK_TYPE_INT32
- MSGPACK_TYPE_UINT32
This is useful is the actual bit-length is unknown
- Parameters
-
object
Integer object type to return as signed 32bit value
- Returns
- signed 32bit value of supplied object
int64_t* msgpack_get_long | ( | const msgpack_object_t * | object, |
int64_t * | buffer |
||
) |
Return a MessagePack integer object as a signed 64bit value.
This has exact same functionality as msgpack_get_int() except it also supports the following msgpack_type_t :
This is useful is the actual bit-length is unknown
- Parameters
-
object
Integer object to return a signed 64bit value buffer
Buffer to hold 64bit value (must be at least 8 bytes)
- Returns
- Pointer to 64bit value (same pointer as supplied
buffer
)
char* msgpack_get_str | ( | const msgpack_object_t * | object, |
char * | buffer, |
||
uint16_t | max_length |
||
) |
Copy a MessagePack string object into the given buffer.
A MessagePack string object is NOT null-terminated. This function copies a string object's string into the given buffer AND null-terminates the string.
- Parameters
-
object
MessagPacket MSGPACK_TYPE_STR object buffer
Buffer to hold string data, this buffer should contain an additional byte to hold the null-terminator max_length
The maximum length of the supplied buffer
- Returns
- Pointer to populated
buffer
, this is the same pointer as the suppliedbuffer
uint32_t msgpack_get_uint | ( | const msgpack_object_t * | object | ) |
Return a MessagePack integer object as an unsigned 32bit value.
This converts the following msgpack_type_t to an unsigned 32bit value
- MSGPACK_TYPE_BOOL
- MSGPACK_TYPE_INT8
- MSGPACK_TYPE_UINT8
- MSGPACK_TYPE_INT16
- MSGPACK_TYPE_UINT16
- MSGPACK_TYPE_INT32
- MSGPACK_TYPE_UINT32
This is useful is the actual bit-length is unknown
- Parameters
-
object
Integer object type to return as unsigned 32bit value
- Returns
- unsigned 32bit value of supplied object
uint64_t* msgpack_get_ulong | ( | const msgpack_object_t * | object, |
uint64_t * | buffer |
||
) |
Return a MessagePack integer object as an unsigned 64bit value.
This has exact same functionality as msgpack_get_uint() except it also supports the following msgpack_type_t :
This is useful is the actual bit-length is unknown
- Parameters
-
object
Integer object to return an unsigned 64bit value buffer
Buffer to hold 64bit value (must be at least 8 bytes)
- Returns
- Pointer to 64bit value (same pointer as supplied
buffer
)