ttypt/corm.h(3)corm

NAME

ttypt/corm.h - Public header for the Corm library.

SYNOPSIS

#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include './cormr.h'

Data Structures

struct corm_record_field_t

Describes a single field in a record layout.

Macros

#define CM_MISS ((uint32_t)-1)

Sentinel value for notfound"orerrorconditions.

#define CM_RECORD_MASK 0x0000FF00u

Macro and mask for record-aware maps.

#define CM_REFERENCE 6

Record field type constants.

#define CM_MULTI_REFERENCE 7
#define CM_VSTR 8

Typedefs

typedef void corm_assoc_t(const void **skey, const void *const pkey, const void *const value, void *userdata)

Association callback type.

typedef size_t corm_assoc_multi_t(const void **skeys, size_t max_skeys, const void *pkey, const void *value, void *userdata)

Multi-key association callback type.

typedef size_t corm_measure_t(const void *data)

Callback to measure variable-size keys.

typedef int corm_cmp_t(const void *const a, const void *const b, size_t len)

Comparison callback type.

typedef corm_record_field_t corm_field_t

Concise aliases for record schema operations.

Enumerations

enum corm_flags { CM_AINDEX = 1, CM_MIRROR = 2, CM_PGET = 4, CM_SORTED = 8, CM_MULTIVALUE = 16, CM_NOGROW = 32 }

Corm flags.

enum corm_tbi { CM_PTR = 0, CM_HNDL = 1, CM_STR = 2, CM_U32 = 3 }

Built-in type identifiers.

enum corm_if { CM_RANGE = 1, CM_RANGE_GE = 2 }

Iterator flags.

Functions

uint32_t corm_open (const char *filename, const char *database, uint32_t ktype, uint32_t vtype, uint32_t mask, uint32_t flags)

Open a database.

uint32_t corm_get_vtype (uint32_t hd)

Returns the value type (vtype) of a map.

uint32_t corm_get_ktype (uint32_t hd)

Returns the key type (ktype) of a map.

size_t corm_type_len (uint32_t type_id)

Returns the fixed length of a type, or 0 if variable.

void corm_save (void)

Write all file-backed maps to disk.

void corm_close (uint32_t hd)

Close a map and free its resources.

const void * corm_get (uint32_t hd, const void *const key)

Retrieve a value by key.

void corm_get_copy (uint32_t hd, const void *const key, void *dst)

Copy a value into a caller buffer.

int corm_read (uint32_t hd, const void *const key, void *dst, size_t max_sz)

Non-aborting safe record retrieval with guaranteed zero-initialization.

uint32_t corm_put (uint32_t hd, const void *const key, const void *const value)

Insert or update a pair.

void corm_del (uint32_t hd, const void *const key)

Delete an entry by key.

void corm_del_all (uint32_t hd, const void *const key)

Delete all entries with the specified key.

int corm_del_value (uint32_t hd, const void *const key, const void *const value)

Delete the first entry with this key whose value matches.

void corm_drop (uint32_t hd)

Remove all entries from a map.

void corm_assoc (uint32_t hd, uint32_t link, corm_assoc_t cb, void *userdata)

Make an association between tables.

void corm_assoc_multi (uint32_t hd, uint32_t link, corm_assoc_multi_t cb, void *userdata)

Make a multi-key association between tables.

uint32_t corm_iter (uint32_t hd, const void *const key, uint32_t flags)

Start iteration.

int corm_next (const void **key, const void **value, uint32_t cur_id)

Fetch next key/value.

int corm_next_copy (void *key, void *value, uint32_t cur_id)

Fetch next key/value, copied into caller buffers.

void corm_fin (uint32_t cur_id)

End iteration early.

uint32_t corm_get_multi (uint32_t hd, const void *key)

Start iteration over all values for a key.

uint32_t corm_count (uint32_t hd, const void *key)

Count entries matching a key.

uint32_t corm_reg (size_t len)

Register a fixed-length type.

void corm_cmp_set (uint32_t ref, corm_cmp_t *cmp)

Assign comparison function to a type.

uint32_t corm_mreg (corm_measure_t *measure)

Register a variable-length type.

uint32_t corm_blob_type (void)

Canonical measured type for length-prefixed binary blobs (uint32_t len + data).

size_t corm_len (uint32_t type_id, const void *data)

Get the byte length of an element.

uint32_t corm_record_register (const char *name, size_t struct_size, const corm_record_field_t *fields, size_t field_count)

Register a record layout describing a C struct.

uint32_t corm_record_type_id (uint32_t record_id)

Get the struct type ID registered for a record.

const char * corm_get_key (uint32_t hd, uint32_t pos)

Get the string key at a given position number.

uint32_t corm_pos (uint32_t hd, const char *key)

Get the position number for a given key string.

size_t corm_inv_get (uint32_t hd, const char *field_name, uint32_t target_pos, uint32_t *out, size_t max)

Query the inverse index for a reference field.

void corm_record_field_set_target_hd (uint32_t record_id, const char *field_name, uint32_t target_hd)

Set the target head handle for reference resolution.

uint32_t corm_field_put (uint32_t hd, const char *item_id, const char *field_name, const char *value)

Put a field value into a record-aware map, auto-resolving references when the field is CM_REFERENCE / CM_MULTI_REFERENCE and target_hd is set.

const char * corm_field_get (uint32_t hd, const char *item_id, const char *field_name)

Get a field value from a record-aware map, auto-resolving references when the field is CM_REFERENCE.

void corm_htok_set_tok_decoder (corm_htok_tok_decoder_fn fn)

Register an optional token decoder callback for HTOK token-packed fields.

int corm_htok_pack (const char *json_str, size_t json_len, uint8_t **out_bytes, size_t *out_len)

Pack a JSON string representation of a memory envelope into HTOK v4 binary bytes.

int corm_htok_unpack (const uint8_t *bytes, size_t len, char **out_json, size_t *out_json_len)

Unpack an HTOK v4 binary buffer into a clean JSON string representation.

Detailed Description

Public header for the Corm library.

Declares the API for Corm โ€” associative containers with optional persistence, mirror maps and sorted iteration.

Macro Definition Documentation

#define CM_MISS ((uint32_t)-1)

Sentinel value for "not found" or error conditions. Returned by corm_reg(), corm_mreg() when type limit is reached, and used internally to indicate missing entries. Equal to UINT32_MAX.

Author

Generated automatically by Doxygen for corm from the source code.