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_tmsgpack_get_dict_object (const msgpack_object_dict_t *dict, const char *key)
 Return the value of the corresponding key in dictionary. More...
 
msgpack_object_tmsgpack_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_ptrPointer to hold allocated linked list of MessagePack object
bufferBuffer containing 'packed' MessagePack data, this buffer MUST persist for as long as the return object are referenced IF binary strings or strings are used
lengthLength 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
rootObject 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
arraymsgpack_object_array_t An array object
indexIndex 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
dictmsgpack_object_dict_t A dictionary object
keyThe 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

This is useful is the actual bit-length is unknown

Parameters
objectInteger 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
objectInteger object to return a signed 64bit value
bufferBuffer 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
objectMessagPacket MSGPACK_TYPE_STR object
bufferBuffer to hold string data, this buffer should contain an additional byte to hold the null-terminator
max_lengthThe maximum length of the supplied buffer
Returns
Pointer to populated buffer, this is the same pointer as the supplied buffer
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

This is useful is the actual bit-length is unknown

Parameters
objectInteger 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
objectInteger object to return an unsigned 64bit value
bufferBuffer to hold 64bit value (must be at least 8 bytes)
Returns
Pointer to 64bit value (same pointer as supplied buffer)