Veritable Lasagna
An Allocator & Data Structure Library for C.
|
Go to the source code of this file.
Data Structures | |
struct | vl_msgpack |
MessagePack Document Object Model. More... | |
Macros | |
#define | VL_MSGPACK_ITER_INVALID VL_HASHTABLE_ITER_INVALID |
#define | VL_MSGPACK_EXT_NONE -127 |
#define | VL_MSGPACK_FOREACH_CHILD(packPtr, parentIter, childIterSymbol) |
#define | vlMsgPackRoot(packPtr) ((packPtr)->root) |
Macro to retrieve the root of the MessagePack DOM. | |
Typedefs | |
typedef vl_hash_iter | vl_msgpack_iter |
Enumerations | |
enum | vl_msgpack_type { VL_MSGPACK_NIL , VL_MSGPACK_BOOL , VL_MSGPACK_INT , VL_MSGPACK_UINT , VL_MSGPACK_FLOAT32 , VL_MSGPACK_FLOAT64 , VL_MSGPACK_STRING , VL_MSGPACK_BINARY , VL_MSGPACK_ARRAY , VL_MSGPACK_MAP , VL_MSGPACK_EXT } |
All MessagePack Types. More... | |
Functions | |
void | vlMsgPackInit (vl_msgpack *pack) |
Initializes the specified MessagePack DOM. | |
void | vlMsgPackFree (vl_msgpack *pack) |
Frees the specified MessagePack DOM. | |
vl_msgpack * | vlMsgPackNew () |
Allocates and initializes a MessagePack DOM. | |
void | vlMsgPackDelete (vl_msgpack *pack) |
Deletes the specified MessagePack DOM. | |
void | vlMsgPackClear (vl_msgpack *pack) |
Clears the MessagePack DOM, resetting it for reuse. | |
vl_msgpack * | vlMsgPackClone (vl_msgpack *src, vl_msgpack *dest) |
Clones the specified MessagePack DOM to another. | |
vl_msgpack_iter | vlMsgPackParent (vl_msgpack *pack, vl_msgpack_iter iter) |
Retrieves the parent node of a given node in the MessagePack DOM. | |
vl_dsidx_t | vlMsgPackTotalChildren (vl_msgpack *pack, vl_msgpack_iter iter) |
Retrieves the total number of children of a given node. | |
vl_msgpack_iter | vlMsgPackFirstChild (vl_msgpack *pack, vl_msgpack_iter iter) |
Retrieves the first child of a given node. | |
vl_msgpack_iter | vlMsgPackNextSibling (vl_msgpack *pack, vl_msgpack_iter iter) |
Retrieves the next sibling of a given node. | |
vl_msgpack_iter | vlMsgPackPrevSibling (vl_msgpack *pack, vl_msgpack_iter iter) |
Retrieves the previous sibling of a given node. | |
vl_msgpack_type | vlMsgPackType (vl_msgpack *pack, vl_msgpack_iter iter) |
Retrieves the type of a given node in the MessagePack DOM. | |
vl_int8_t | vlMsgPackExtType (vl_msgpack *pack, vl_msgpack_iter iter) |
Retrieves the extension type of a MessagePack EXT node. | |
vl_msgpack_iter | vlMsgPackInsertExt (vl_msgpack *pack, vl_msgpack_type type, vl_int8_t subType, vl_msgpack_iter parent, const void *keyPtr, vl_memsize_t keyLen, const void *dataPtr, vl_memsize_t dataLen) |
Inserts a new element into the MessagePack DOM with an extended type. | |
void | vlMsgPackRemove (vl_msgpack *pack, vl_msgpack_iter iter) |
Removes an element from the MessagePack DOM. | |
vl_msgpack_iter | vlMsgPackFindChild (vl_msgpack *pack, vl_msgpack_iter parent, const void *key, vl_memsize_t keyLen) |
Finds a child element by key. | |
vl_msgpack_iter | vlMsgPackFindChildIndexed (vl_msgpack *pack, vl_msgpack_iter iter, vl_dsidx_t idx) |
Finds a child element by index. | |
const vl_transient * | vlMsgPackSampleKey (vl_msgpack *pack, vl_msgpack_iter iter, vl_memsize_t *size) |
Retrieves the key associated with an element. | |
vl_transient * | vlMsgPackSampleValue (vl_msgpack *pack, vl_msgpack_iter iter, vl_memsize_t *size) |
Retrieves the value associated with an element. | |
struct vl_msgpack |
MessagePack Document Object Model.
An in-memory, hierarchical representation of a complete MessagePack.
This structure represents an N-Tree with parent-child relationships that accurately represents a MessagePack structure. It is implemented using a hierarchical hash table for nodes and parent-child relationships, using separate arena allocator for node values. Nodes in this structure are dynamically typed.
The design of this structure is NOT completely compliant with the MessagePack spec. It requires the two following rules to be enforced:
All strings in and out of this structure, keys or values, are assumed to be UTF-8 encoded.
Data Fields | ||
---|---|---|
vl_hashtable | nodes | |
vl_msgpack_iter | root | |
vl_arena | values |
#define VL_MSGPACK_EXT_NONE -127 |
#define VL_MSGPACK_FOREACH_CHILD | ( | packPtr, | |
parentIter, | |||
childIterSymbol ) |
#define VL_MSGPACK_ITER_INVALID VL_HASHTABLE_ITER_INVALID |
#define vlMsgPackRoot | ( | packPtr | ) | ((packPtr)->root) |
Macro to retrieve the root of the MessagePack DOM.
This macro provides access to the root node of the DOM. The root node is always a map.
packPtr | A pointer to the MessagePack DOM instance. |
typedef vl_hash_iter vl_msgpack_iter |
enum vl_msgpack_type |
All MessagePack Types.
void vlMsgPackClear | ( | vl_msgpack * | pack | ) |
Clears the MessagePack DOM, resetting it for reuse.
This function resets the MessagePack DOM instance without deallocating memory. Previously allocated memory remains available for reuse, improving performance when repeatedly decoding into the same structure.
pack | The MessagePack DOM instance to clear. |
vl_msgpack * vlMsgPackClone | ( | vl_msgpack * | src, |
vl_msgpack * | dest ) |
Clones the specified MessagePack DOM to another.
Clones the entirety of the src MessagePack to the dest MessagePack.
The 'src' DOM must be non-null and initialized. The 'dest' DOM may be null, but if it is not null it must be initialized.
If the 'dest' table pointer is null, a new DOM is created via vlMsgPackNew.
src | source DOM pointer |
dest | destination DOM pointer |
void vlMsgPackDelete | ( | vl_msgpack * | pack | ) |
Deletes the specified MessagePack DOM.
The specified MessagePack must have been initialized via vlMsgPackNew before calling this function.
pack | pointer to DOM |
vl_int8_t vlMsgPackExtType | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Retrieves the extension type of a MessagePack EXT node.
pack | The MessagePack DOM instance. |
iter | The iterator pointing to the current node. |
vl_msgpack_iter vlMsgPackFindChild | ( | vl_msgpack * | pack, |
vl_msgpack_iter | parent, | ||
const void * | key, | ||
vl_memsize_t | keyLen ) |
Finds a child element by key.
This function searches for a child under the given parent node with a matching key.
pack | The MessagePack DOM instance. |
parent | The parent node to search in. |
key | Pointer to the key data. |
keyLen | Length of the key. |
vl_msgpack_iter vlMsgPackFindChildIndexed | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter, | ||
vl_dsidx_t | idx ) |
Finds a child element by index.
This function retrieves the indexed child from a parent container. The parent must be an array.
pack | The MessagePack DOM instance. |
iter | The parent node. |
idx | The zero-based index of the child. |
vl_msgpack_iter vlMsgPackFirstChild | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Retrieves the first child of a given node.
pack | The MessagePack DOM instance. |
iter | The iterator pointing to the current node. |
void vlMsgPackFree | ( | vl_msgpack * | pack | ) |
Frees the specified MessagePack DOM.
The specified MessagePack must have been initialized via vlMsgPackInit before calling this function.
pack | pointer to DOM |
void vlMsgPackInit | ( | vl_msgpack * | pack | ) |
Initializes the specified MessagePack DOM.
pack | pointer to DOM |
vl_msgpack_iter vlMsgPackInsertExt | ( | vl_msgpack * | pack, |
vl_msgpack_type | type, | ||
vl_int8_t | subType, | ||
vl_msgpack_iter | parent, | ||
const void * | keyPtr, | ||
vl_memsize_t | keyLen, | ||
const void * | dataPtr, | ||
vl_memsize_t | dataLen ) |
Inserts a new element into the MessagePack DOM with an extended type.
This function inserts an element of the specified MessagePack type and optional extended type under a given parent node. The key and value are copied into the internal storage, allowing external memory to be safely freed after insertion.
pack | The MessagePack DOM instance. |
type | The type of the inserted element. |
subType | The extended type (used for MessagePack ext types). |
parent | The parent node where the element is inserted. |
keyPtr | Pointer to the key data. |
keyLen | Length of the key. |
dataPtr | Pointer to the value data. |
dataLen | Length of the value. |
vl_msgpack * vlMsgPackNew | ( | ) |
Allocates and initializes a MessagePack DOM.
The returned pointer is to be deleted via vlMsgPackDelete.
vl_msgpack_iter vlMsgPackNextSibling | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Retrieves the next sibling of a given node.
pack | The MessagePack DOM instance. |
iter | The iterator pointing to the current node. |
vl_msgpack_iter vlMsgPackParent | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Retrieves the parent node of a given node in the MessagePack DOM.
pack | The MessagePack DOM instance. |
iter | The iterator pointing to the current node. |
vl_msgpack_iter vlMsgPackPrevSibling | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Retrieves the previous sibling of a given node.
pack | The MessagePack DOM instance. |
iter | The iterator pointing to the current node. |
void vlMsgPackRemove | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Removes an element from the MessagePack DOM.
This function removes the specified element and all its children from the DOM. Memory may be reused depending on the allocator's behavior.
pack | The MessagePack DOM instance. |
iter | Iterator pointing to the element to be removed. |
const vl_transient * vlMsgPackSampleKey | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter, | ||
vl_memsize_t * | size ) |
Retrieves the key associated with an element.
This function returns a pointer to the key data of the given element. The key may move if modifications occur in the DOM, so users should not store this pointer for long-term access.
pack | The MessagePack DOM instance. |
iter | The element iterator. |
size | Pointer to receive the key size (optional, can be NULL). |
vl_transient * vlMsgPackSampleValue | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter, | ||
vl_memsize_t * | size ) |
Retrieves the value associated with an element.
This function returns a pointer to the value data of the given element. The value may move if modifications occur in the DOM, so users should not store this pointer for long-term access.
pack | The MessagePack DOM instance. |
iter | The element iterator. |
size | Pointer to receive the value size (optional, can be NULL). |
vl_dsidx_t vlMsgPackTotalChildren | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Retrieves the total number of children of a given node.
pack | The MessagePack DOM instance. |
iter | The iterator pointing to the current node. |
vl_msgpack_type vlMsgPackType | ( | vl_msgpack * | pack, |
vl_msgpack_iter | iter ) |
Retrieves the type of a given node in the MessagePack DOM.
pack | The MessagePack DOM instance. |
iter | The iterator pointing to the current node. |