Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_msgpack_io.h File Reference
#include "vl_buffer.h"
#include "vl_msgpack.h"
#include "vl_stack.h"
+ Include dependency graph for vl_msgpack_io.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vl_msgpack_encoder
 MessagePack Format Encoder State. More...
 
struct  vl_msgpack_io_token
 A MessagePack Token. More...
 
struct  vl_msgpack_decoder
 A MessagePack decoder. More...
 

Functions

VL_API void vlMsgPackIOEncoderInit (vl_msgpack_encoder *enc)
 Initializes the specified MessagePack encoder.
 
VL_API void vlMsgPackIOEncoderFree (vl_msgpack_encoder *enc)
 Frees the specified MessagePack encoder.
 
VL_API vl_msgpack_encodervlMsgPackIOEncoderNew (void)
 Allocates and initializes a MessagePack encoder.
 
VL_API void vlMsgPackIOEncoderDelete (vl_msgpack_encoder *enc)
 Deletes the specified MessagePack encoder.
 
VL_API void vlMsgPackIOEncoderClear (vl_msgpack_encoder *enc)
 Clears the state of the MessagePack encoder.
 
VL_API void vlMsgPackIOEncodeMapBegin (vl_msgpack_encoder *enc)
 Begins encoding a map in the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeMapEnd (vl_msgpack_encoder *enc)
 Ends encoding a map in the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeArrayBegin (vl_msgpack_encoder *enc)
 Begins encoding an array in the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeArrayEnd (vl_msgpack_encoder *enc)
 Ends encoding an array in the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeBool (vl_msgpack_encoder *enc, vl_bool_t value)
 Encodes a boolean value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeStringLen (vl_msgpack_encoder *enc, const char *value, vl_uint32_t len)
 Encodes a string's length into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeFloat32 (vl_msgpack_encoder *enc, vl_float32_t value)
 Encodes a 32-bit floating point value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeFloat64 (vl_msgpack_encoder *enc, vl_float64_t value)
 Encodes a 64-bit floating point value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeBinary (vl_msgpack_encoder *enc, const void *value, vl_uint32_t len)
 Encodes a binary value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeExt (vl_msgpack_encoder *enc, vl_int8_t type, const void *value, vl_uint32_t len)
 Encodes an extension type value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeInt (vl_msgpack_encoder *enc, vl_ilarge_t value)
 Encodes a signed integer value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeUInt (vl_msgpack_encoder *enc, vl_ularge_t value)
 Encodes an unsigned integer value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeNil (vl_msgpack_encoder *enc)
 Encodes a nil value into the MessagePack stream.
 
VL_API void vlMsgPackIOEncodeFromDOM (vl_msgpack_encoder *encoder, vl_msgpack *src, vl_msgpack_iter curIter)
 Encodes from a MessagePack DOM.
 
VL_API void vlMsgPackIODecoderStart (vl_msgpack_decoder *dec, const void *srcMem, vl_memsize_t srcLen)
 Starts the MessagePack decoding process.
 
VL_API vl_bool_t vlMsgPackIODecoderNext (vl_msgpack_decoder *decoder, vl_msgpack_io_token *tkPtr)
 Extracts the next token from the MessagePack stream.
 
VL_API vl_msgpack_iter vlMsgPackIODecodeToDOM (vl_msgpack_decoder *decoder, vl_msgpack *dest, vl_msgpack_iter parent, const void *key, vl_memsize_t keyLen)
 Decodes MessagePack data into a DOM.
 

Data Structure Documentation

◆ vl_msgpack_encoder

struct vl_msgpack_encoder

MessagePack Format Encoder State.

This structure holds state for the encoding of information in the MessagePack format. The encoder is completely compliant with the MessagePack spec.

All functions used to encode have signatures among vlMsgPackIOEncode*. The encoding API is loosely modeled on OpenGL 1.x immediate mode.

This encoder attempts to generates the smallest possible (smallest size) result in all cases.

+ Collaboration diagram for vl_msgpack_encoder:
Data Fields
vl_buffer buffer
vl_msgpack_io_error error
vl_dsidx_t errorDepth
vl_msgpack_type errorType
vl_stack stateStack

◆ vl_msgpack_decoder

struct vl_msgpack_decoder

A MessagePack decoder.

The only job of the decoder is to produce a stream of decoded tokens from an arbitrary input buffer.

+ Collaboration diagram for vl_msgpack_decoder:
Data Fields
vl_msgpack_io_error error
vl_dsoffs_t errorOffset
vl_msgpack_type errorType
vl_memsize_t srcLen
const vl_uint8_t * srcMem
vl_dsoffs_t srcOffset

Function Documentation

◆ vlMsgPackIODecoderNext()

VL_API vl_bool_t vlMsgPackIODecoderNext ( vl_msgpack_decoder decoder,
vl_msgpack_io_token tkPtr 
)

Extracts the next token from the MessagePack stream.

This function decodes the next token from the MessagePack data. It returns true if a token was successfully extracted, or false if there are no more tokens or the decoding process encounters an error.

Parameters
decoderPointer to the MessagePack decoder.
tkPtrPointer to the token structure where the extracted token will be stored.
Returns
true if a token was successfully decoded, false otherwise.
+ Here is the caller graph for this function:

◆ vlMsgPackIODecoderStart()

VL_API void vlMsgPackIODecoderStart ( vl_msgpack_decoder dec,
const void *  srcMem,
vl_memsize_t  srcLen 
)

Starts the MessagePack decoding process.

This function initializes the MessagePack decoder with the given source memory and length. It prepares the decoder for further operations, such as token extraction or decoding to a DOM.

Parameters
decPointer to the MessagePack decoder to initialize.
srcMemPointer to the source memory containing the MessagePack data to decode.
srcLenLength of the source memory to decode.

◆ vlMsgPackIODecodeToDOM()

VL_API vl_msgpack_iter vlMsgPackIODecodeToDOM ( vl_msgpack_decoder decoder,
vl_msgpack dest,
vl_msgpack_iter  parent,
const void *  key,
vl_memsize_t  keyLen 
)

Decodes MessagePack data into a DOM.

This function decodes MessagePack data and inserts it into the specified DOM at the given parent node. The decoded data is inserted using the provided key.

Parameters
decoderPointer to the MessagePack decoder.
destPointer to the MessagePack DOM to populate.
parentThe parent node in the DOM where the decoded data will be inserted.
keyPointer to the UTF-8 string key, or pointer to integer index.
keyLenLength of the key.
Returns
The iterator to the newly inserted element in the DOM.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeArrayBegin()

VL_API void vlMsgPackIOEncodeArrayBegin ( vl_msgpack_encoder enc)

Begins encoding an array in the MessagePack stream.

This function serializes the beginning of an array (list of values) into the MessagePack format. It should be followed by calls to encode individual values before the array is closed with vlMsgPackIOEncodeArrayEnd.

Parameters
encPointer to the encoder context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeArrayEnd()

VL_API void vlMsgPackIOEncodeArrayEnd ( vl_msgpack_encoder enc)

Ends encoding an array in the MessagePack stream.

This function serializes the end of an array (list of values) into the MessagePack format. It follows vlMsgPackIOEncodeArrayBegin and should be called once all elements of the array have been encoded.

This resolves the smallest possible encoding for the array.

Parameters
encPointer to the encoder context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeBinary()

VL_API void vlMsgPackIOEncodeBinary ( vl_msgpack_encoder enc,
const void *  value,
vl_uint32_t  len 
)

Encodes a binary value into the MessagePack stream.

This function serializes a binary data value into the MessagePack format and appends it to the encoder's buffer. The length of the binary data must be provided.

Parameters
encPointer to the encoder context.
valuePointer to the binary data to encode.
lenThe length of the binary data to encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeBool()

VL_API void vlMsgPackIOEncodeBool ( vl_msgpack_encoder enc,
vl_bool_t  value 
)

Encodes a boolean value into the MessagePack stream.

This function serializes a boolean value (true or false) into the MessagePack format and appends it to the encoder's buffer.

Parameters
encPointer to the encoder context.
valueThe boolean value to encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeExt()

VL_API void vlMsgPackIOEncodeExt ( vl_msgpack_encoder enc,
vl_int8_t  type,
const void *  value,
vl_uint32_t  len 
)

Encodes an extension type value into the MessagePack stream.

This function serializes an extension type (custom format) into the MessagePack format and appends it to the encoder's buffer. The extension type identifier and the associated value are serialized.

Parameters
encPointer to the encoder context.
typeThe extension type identifier.
valuePointer to the extension data to encode.
lenThe length of the extension data.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeFloat32()

VL_API void vlMsgPackIOEncodeFloat32 ( vl_msgpack_encoder enc,
vl_float32_t  value 
)

Encodes a 32-bit floating point value into the MessagePack stream.

This function serializes a 32-bit floating point value into the MessagePack format and appends it to the encoder's buffer.

Parameters
encPointer to the encoder context.
valueThe 32-bit floating point value to encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeFloat64()

VL_API void vlMsgPackIOEncodeFloat64 ( vl_msgpack_encoder enc,
vl_float64_t  value 
)

Encodes a 64-bit floating point value into the MessagePack stream.

This function serializes a 64-bit floating point value into the MessagePack format and appends it to the encoder's buffer.

Parameters
encPointer to the encoder context.
valueThe 64-bit floating point value to encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeFromDOM()

VL_API void vlMsgPackIOEncodeFromDOM ( vl_msgpack_encoder encoder,
vl_msgpack src,
vl_msgpack_iter  curIter 
)

Encodes from a MessagePack DOM.

Parameters
encPointer to the encoder context.
srcPointer to the source MessagePack DOM.
curIteriterator to fully encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeInt()

VL_API void vlMsgPackIOEncodeInt ( vl_msgpack_encoder enc,
vl_ilarge_t  value 
)

Encodes a signed integer value into the MessagePack stream.

This function serializes a signed integer value into the MessagePack format and appends it to the encoder's buffer.

Parameters
encPointer to the encoder context.
valueThe signed integer value to encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeMapBegin()

VL_API void vlMsgPackIOEncodeMapBegin ( vl_msgpack_encoder enc)

Begins encoding a map in the MessagePack stream.

This function serializes the beginning of a map (key-value pair container) into the MessagePack format. It should be followed by calls to encode individual keys and values before the map is closed with vlMsgPackIOEncodeMapEnd.

Parameters
encPointer to the encoder context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeMapEnd()

VL_API void vlMsgPackIOEncodeMapEnd ( vl_msgpack_encoder enc)

Ends encoding a map in the MessagePack stream.

This function serializes the end of a map (key-value pair container) into the MessagePack format. It follows vlMsgPackIOEncodeMapBegin and should be called once all key-value pairs for the map have been encoded.

This resolves the smallest possible encoding for the map.

Parameters
encPointer to the encoder context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeNil()

VL_API void vlMsgPackIOEncodeNil ( vl_msgpack_encoder enc)

Encodes a nil value into the MessagePack stream.

This function serializes a nil value (similar to null) into the MessagePack format and appends it to the encoder's buffer.

Parameters
encPointer to the encoder context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncoderClear()

VL_API void vlMsgPackIOEncoderClear ( vl_msgpack_encoder enc)

Clears the state of the MessagePack encoder.

This function resets the encoder to its initial state.

Parameters
encPointer to the encoder context.
+ Here is the call graph for this function:

◆ vlMsgPackIOEncoderDelete()

VL_API void vlMsgPackIOEncoderDelete ( vl_msgpack_encoder enc)

Deletes the specified MessagePack encoder.

This function deletes the given MessagePack encoder, freeing all associated resources. It must be called after the encoder has been created with vlMsgPackIOEncoderNew. The function deallocates the entire encoder structure.

See also
vlMsgPackIOEncoderNew
Parameters
encPointer to the MessagePack encoder to delete.
+ Here is the call graph for this function:

◆ vlMsgPackIOEncoderFree()

VL_API void vlMsgPackIOEncoderFree ( vl_msgpack_encoder enc)

Frees the specified MessagePack encoder.

This function frees the resources allocated for the given MessagePack encoder. It must be called after the encoder has been initialized with vlMsgPackIOEncoderInit. This function does not deallocate the encoder structure.

Parameters
encPointer to the MessagePack encoder to free.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncoderInit()

VL_API void vlMsgPackIOEncoderInit ( vl_msgpack_encoder enc)

Initializes the specified MessagePack encoder.

This function initializes the given MessagePack encoder, preparing it for further encoding operations. It must be called before encoding data into MessagePack format.

Parameters
encPointer to the MessagePack encoder to initialize.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncoderNew()

VL_API vl_msgpack_encoder * vlMsgPackIOEncoderNew ( void  )

Allocates and initializes a MessagePack encoder.

This function allocates memory for a new MessagePack encoder and initializes it. The returned pointer must be freed using vlMsgPackIOEncoderDelete.

See also
vlMsgPackIOEncoderDelete
Returns
Pointer to the allocated and initialized MessagePack encoder.
+ Here is the call graph for this function:

◆ vlMsgPackIOEncodeStringLen()

VL_API void vlMsgPackIOEncodeStringLen ( vl_msgpack_encoder enc,
const char *  value,
vl_uint32_t  len 
)

Encodes a string's length into the MessagePack stream.

This function serializes the length of a string value into the MessagePack format. It is often used in combination with the string value itself for encoding large strings efficiently.

Parameters
encPointer to the encoder context.
valuePointer to the string to encode.
lenThe length of the string to encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlMsgPackIOEncodeUInt()

VL_API void vlMsgPackIOEncodeUInt ( vl_msgpack_encoder enc,
vl_ularge_t  value 
)

Encodes an unsigned integer value into the MessagePack stream.

This function serializes an unsigned integer value into the MessagePack format and appends it to the encoder's buffer.

Parameters
encPointer to the encoder context.
valueThe unsigned integer value to encode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function: