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_stack.h"
#include "vl_msgpack.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...
 
union  vl_msgpack_io_token.__unnamed5__
 
struct  vl_msgpack_io_token.__unnamed5__.array
 
struct  vl_msgpack_io_token.__unnamed5__.map
 
struct  vl_msgpack_io_token.__unnamed5__.integer
 
struct  vl_msgpack_io_token.__unnamed5__.uinteger
 
struct  vl_msgpack_io_token.__unnamed5__.float32
 
struct  vl_msgpack_io_token.__unnamed5__.float64
 
struct  vl_msgpack_io_token.__unnamed5__.boolean
 
struct  vl_msgpack_io_token.__unnamed5__.string
 
struct  vl_msgpack_io_token.__unnamed5__.binary
 
struct  vl_msgpack_io_token.__unnamed5__.ext
 

Enumerations

enum  vl_msgpack_io_error {
  VL_MSGPACK_IO_ERR_NONE , VL_MSGPACK_IO_ERR_STACK_UNDERFLOW , VL_MSGPACK_IO_ERR_UNEXPECTED_TOKEN , VL_MSGPACK_IO_ERR_UNBALANCED_MAP ,
  VL_MSGPACK_IO_ERR_UNEXPECTED_EOF
}
 

Functions

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

struct vl_msgpack_io_token

A MessagePack Token.

Represents a single decoded value from a stream of encoded MessagePack values.

+ Collaboration diagram for vl_msgpack_io_token:
Data Fields
union vl_msgpack_io_token.__unnamed5__ __unnamed__
vl_msgpack_type type

◆ 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

◆ vl_msgpack_io_token.__unnamed5__

union vl_msgpack_io_token.__unnamed5__
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__:
Data Fields
struct vl_msgpack_io_token.__unnamed5__.array array
struct vl_msgpack_io_token.__unnamed5__.binary binary
struct vl_msgpack_io_token.__unnamed5__.boolean boolean
struct vl_msgpack_io_token.__unnamed5__.ext ext
struct vl_msgpack_io_token.__unnamed5__.float32 float32
struct vl_msgpack_io_token.__unnamed5__.float64 float64
struct vl_msgpack_io_token.__unnamed5__.integer integer
struct vl_msgpack_io_token.__unnamed5__.map map
struct vl_msgpack_io_token.__unnamed5__.string string
struct vl_msgpack_io_token.__unnamed5__.uinteger uinteger

◆ vl_msgpack_io_token.__unnamed5__.array

struct vl_msgpack_io_token.__unnamed5__.array
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.array:
Data Fields
vl_dsidx_t elements

◆ vl_msgpack_io_token.__unnamed5__.map

struct vl_msgpack_io_token.__unnamed5__.map
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.map:
Data Fields
vl_dsidx_t keyValuePairs

◆ vl_msgpack_io_token.__unnamed5__.integer

struct vl_msgpack_io_token.__unnamed5__.integer
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.integer:
Data Fields
vl_ilarge_t value

◆ vl_msgpack_io_token.__unnamed5__.uinteger

struct vl_msgpack_io_token.__unnamed5__.uinteger
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.uinteger:
Data Fields
vl_ularge_t value

◆ vl_msgpack_io_token.__unnamed5__.float32

struct vl_msgpack_io_token.__unnamed5__.float32
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.float32:
Data Fields
vl_float32_t value

◆ vl_msgpack_io_token.__unnamed5__.float64

struct vl_msgpack_io_token.__unnamed5__.float64
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.float64:
Data Fields
vl_float64_t value

◆ vl_msgpack_io_token.__unnamed5__.boolean

struct vl_msgpack_io_token.__unnamed5__.boolean
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.boolean:
Data Fields
vl_bool_t value

◆ vl_msgpack_io_token.__unnamed5__.string

struct vl_msgpack_io_token.__unnamed5__.string
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.string:
Data Fields
vl_uint32_t length
const char * ptr

◆ vl_msgpack_io_token.__unnamed5__.binary

struct vl_msgpack_io_token.__unnamed5__.binary
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.binary:
Data Fields
vl_uint32_t length
const void * ptr

◆ vl_msgpack_io_token.__unnamed5__.ext

struct vl_msgpack_io_token.__unnamed5__.ext
+ Collaboration diagram for vl_msgpack_io_token.__unnamed5__.ext:
Data Fields
vl_int8_t extType
vl_uint32_t length
const void * ptr

Enumeration Type Documentation

◆ vl_msgpack_io_error

Enumerator
VL_MSGPACK_IO_ERR_NONE 
VL_MSGPACK_IO_ERR_STACK_UNDERFLOW 
VL_MSGPACK_IO_ERR_UNEXPECTED_TOKEN 
VL_MSGPACK_IO_ERR_UNBALANCED_MAP 
VL_MSGPACK_IO_ERR_UNEXPECTED_EOF 

Function Documentation

◆ vlMsgPackIODecoderNext()

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()

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_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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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_msgpack_encoder * vlMsgPackIOEncoderNew ( )

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()

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()

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: