Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_msgpack_io.c File Reference
#include "vl_msgpack_io.h"
#include "vl_libconfig.h"
+ Include dependency graph for vl_msgpack_io.c:

Macros

#define _VL_FLIP_ENDIAN(symbol)   vlMemReverse(&(symbol), sizeof(symbol))
 Equivalent to a generic htnohl/htons/ntohl/ntohs, which convert to/from system to network byte order.
 
#define _VL_DECODE_EOFCHECK(dec, size)
 

Enumerations

enum  vl_msgpack_io_type {
  VL_MSGPACK_IO_POS_FIXINT = 0x00 , VL_MSGPACK_IO_FIXMAP = 0x80 , VL_MSGPACK_IO_FIXARRAY = 0x90 , VL_MSGPACK_IO_FIXSTR = 0xA0 ,
  VL_MSGPACK_IO_NEG_FIXINT = 0xE0 , VL_MSGPACK_IO_NIL = 0xC0 , VL_MSGPACK_IO_FALSE = 0xC2 , VL_MSGPACK_IO_TRUE = 0xC3 ,
  VL_MSGPACK_IO_BIN8 = 0xC4 , VL_MSGPACK_IO_BIN16 = 0xC5 , VL_MSGPACK_IO_BIN32 = 0xC6 , VL_MSGPACK_IO_EXT8 = 0xC7 ,
  VL_MSGPACK_IO_EXT16 = 0xC8 , VL_MSGPACK_IO_EXT32 = 0xC9 , VL_MSGPACK_IO_FLOAT32 = 0xCA , VL_MSGPACK_IO_FLOAT64 = 0xCB ,
  VL_MSGPACK_IO_UINT8 = 0xCC , VL_MSGPACK_IO_UINT16 = 0xCD , VL_MSGPACK_IO_UINT32 = 0xCE , VL_MSGPACK_IO_UINT64 = 0xCF ,
  VL_MSGPACK_IO_INT8 = 0xD0 , VL_MSGPACK_IO_INT16 = 0xD1 , VL_MSGPACK_IO_INT32 = 0xD2 , VL_MSGPACK_IO_INT64 = 0xD3 ,
  VL_MSGPACK_IO_FIXEXT1 = 0xD4 , VL_MSGPACK_IO_FIXEXT2 = 0xD5 , VL_MSGPACK_IO_FIXEXT4 = 0xD6 , VL_MSGPACK_IO_FIXEXT8 = 0xD7 ,
  VL_MSGPACK_IO_FIXEXT16 = 0xD8 , VL_MSGPACK_IO_STR8 = 0xD9 , VL_MSGPACK_IO_STR16 = 0xDA , VL_MSGPACK_IO_STR32 = 0xDB ,
  VL_MSGPACK_IO_ARRAY16 = 0xDC , VL_MSGPACK_IO_ARRAY32 = 0xDD , VL_MSGPACK_IO_MAP16 = 0xDE , VL_MSGPACK_IO_MAP32 = 0xDF
}
 

Functions

vl_uint8_t vl_MsgPackEncodeFrame (vl_msgpack_encframe *frame, vl_dsoffs_t *offset)
 
void vl_MsgPackEncodePush (vl_msgpack_encoder *enc, vl_bool_t isArray)
 
vl_bool_t vl_MsgPackEncodePop (vl_msgpack_encoder *enc)
 
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 *enc, 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 *dec, 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.
 

Macro Definition Documentation

◆ _VL_DECODE_EOFCHECK

#define _VL_DECODE_EOFCHECK ( dec,
size )
Value:
if((dec->srcOffset + (size)) > dec->srcLen){ \
dec->errorOffset = dec->srcOffset; \
dec->errorType = tkPtr->type; \
return VL_FALSE; \
}
@ VL_MSGPACK_IO_ERR_UNEXPECTED_EOF
Definition vl_msgpack_io.h:13
#define VL_FALSE
Definition vl_numtypes.h:126

◆ _VL_FLIP_ENDIAN

#define _VL_FLIP_ENDIAN ( symbol)    vlMemReverse(&(symbol), sizeof(symbol))

Equivalent to a generic htnohl/htons/ntohl/ntohs, which convert to/from system to network byte order.

Flips byte sequences in-place.

Enumeration Type Documentation

◆ vl_msgpack_io_type

Enumerator
VL_MSGPACK_IO_POS_FIXINT 
VL_MSGPACK_IO_FIXMAP 
VL_MSGPACK_IO_FIXARRAY 
VL_MSGPACK_IO_FIXSTR 
VL_MSGPACK_IO_NEG_FIXINT 
VL_MSGPACK_IO_NIL 
VL_MSGPACK_IO_FALSE 
VL_MSGPACK_IO_TRUE 
VL_MSGPACK_IO_BIN8 
VL_MSGPACK_IO_BIN16 
VL_MSGPACK_IO_BIN32 
VL_MSGPACK_IO_EXT8 
VL_MSGPACK_IO_EXT16 
VL_MSGPACK_IO_EXT32 
VL_MSGPACK_IO_FLOAT32 
VL_MSGPACK_IO_FLOAT64 
VL_MSGPACK_IO_UINT8 
VL_MSGPACK_IO_UINT16 
VL_MSGPACK_IO_UINT32 
VL_MSGPACK_IO_UINT64 
VL_MSGPACK_IO_INT8 
VL_MSGPACK_IO_INT16 
VL_MSGPACK_IO_INT32 
VL_MSGPACK_IO_INT64 
VL_MSGPACK_IO_FIXEXT1 
VL_MSGPACK_IO_FIXEXT2 
VL_MSGPACK_IO_FIXEXT4 
VL_MSGPACK_IO_FIXEXT8 
VL_MSGPACK_IO_FIXEXT16 
VL_MSGPACK_IO_STR8 
VL_MSGPACK_IO_STR16 
VL_MSGPACK_IO_STR32 
VL_MSGPACK_IO_ARRAY16 
VL_MSGPACK_IO_ARRAY32 
VL_MSGPACK_IO_MAP16 
VL_MSGPACK_IO_MAP32 

Function Documentation

◆ vl_MsgPackEncodeFrame()

vl_uint8_t vl_MsgPackEncodeFrame ( vl_msgpack_encframe * frame,
vl_dsoffs_t * offset )
+ Here is the caller graph for this function:

◆ vl_MsgPackEncodePop()

vl_bool_t vl_MsgPackEncodePop ( vl_msgpack_encoder * enc)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vl_MsgPackEncodePush()

void vl_MsgPackEncodePush ( vl_msgpack_encoder * enc,
vl_bool_t isArray )
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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: