Buffered Writer

APIs for writing (i.e. packing) data into a dynamic buffer. More...

Functions

gos_result_t gos_msgpack_buffered_writer_init ( gos_msgpack_context_t **context_ptr, uint32_t initial_length)
gos_result_t gos_msgpack_buffered_writer_deinit ( gos_msgpack_context_t *context, bool free_buffer)
gos_result_t gos_msgpack_buffered_writer_get_buffer (const gos_msgpack_context_t *context, gos_buffer_t *buffer)

Detailed Description

APIs for writing (i.e. packing) data into a dynamic buffer.

Function Documentation

gos_msgpack_buffered_writer_deinit()

gos_result_t gos_msgpack_buffered_writer_deinit ( gos_msgpack_context_t * context,
bool free_buffer
)

De-allocate buffered msgpack writer context

This de-allocates the memory allocated by gos_msgpack_buffered_writer_init()

This will also optionally de-allocated the internal buffer. If the internal buffer is NOT de-allocated (e.g. free_buffer = false), then gos_msgpack_buffered_writer_get_buffer() should FIRST be used to retrieve a reference to the internal buffer.

Then at a later point, gos_free() should be used to de-allocate the returned buffer.data .

Parameters
[in] context Buffered msgpack writer context to de-allocated
[in] free_buffer If true also de-allocate internal buffer, if false internal buffer is NOT de-allocated.

gos_msgpack_buffered_writer_get_buffer()

gos_result_t gos_msgpack_buffered_writer_get_buffer ( const gos_msgpack_context_t * context,
gos_buffer_t * buffer
)

Retrieve internal buffer of buffered msgpack writer context

This retrieves the internal buffer used by a buffered msgpack writer. The buffer.data points to the allocated buffer. The buffer.size is the total amount of data written to the buffer.

Parameters
[in] context Buffered msgpack writer context
[out] buffer gos_buffer_t to populate with internal buffer

gos_msgpack_buffered_writer_init()

gos_result_t gos_msgpack_buffered_writer_init ( gos_msgpack_context_t ** context_ptr,
uint32_t initial_length
)

Initialize buffered msgpack writer context

This initializes a buffered msgpack writer context. Once initialized, the Write APIs may be used to populate msgpack data into the returned gos_msgpack_context_t While writing data, the internal buffer will automatically be increased as necessary.

Once all the data is populated, use gos_msgpack_buffered_writer_get_buffer() to retrieve the populated buffer.

Use gos_msgpack_buffered_writer_deinit() to cleanup the allocated gos_msgpack_context_t .

Parameters
[out] context_ptr Pointer to hold allocated gos_msgpack_context_t
[in] initial_length Initial length of internal buffer, this will increase as needed
Returns
gos_result_t , result of API