NAME
corm_constants - Corm constants
- Constant definitions for flags and built-in types.
SYNOPSIS
Macros
Macro and mask for record-aware maps.
Record field type constants.
Enumerations
Corm flags.
Built-in type identifiers.
Iterator flags.
Detailed Description
Constant definitions for flags and built-in types.
See also
Corm get, put, del and drop
corm_assoc
Corm iteration
Corm type customization
Macro Definition Documentation
#define CM_MULTI_REFERENCE 7
-separated positions in char[max_size].
#define CM_RECORD_MASK 0x0000FF00u
Macro and mask for record-aware maps. Pass CM_RECORD(record_id) as the flags parameter to corm_open to enable record-aware access. The map must have ktype=CM_STR and vtype equal to the struct type ID returned by corm_record_type_id(record_id).
When a map is record-aware, keys containing ':' are treated as composite keys "struct_key:field_name" and resolve to a pointer directly into the stored struct's pool allocation at the field's byte offset. This allows whole-struct storage and per-field access to coexist without data duplication.
#define CM_REFERENCE 6
Record field type constants. These are only meaningful as corm_record_field_t.type values, NOT as key/value types for corm_open(). Single uint32_t position in target's map.
#define CM_VSTR 8
Variable-length string stored outside the struct.
Enumeration Type Documentation
enum corm_flags
Corm flags.
Enumerator
- CM_AINDEX
- Auto–index for NULL keys. When enabled, passing NULL as the key to corm_put generates auto-incrementing IDs.
- CM_MIRROR
- Create reverse-lookup (secondary) map. The mirror map handle is always primary_hd + 1 and swaps keys/values.
CM_MIRROR is useful when you need bidirectional lookup (key→value and value→key) and is commonly used with file persistence.
The mirror map is automatically closed when you close the primary map via corm_close(hd).
- CM_PGET
- For associated maps: default to obtaining primary keys instead of values. Used internally for mirror maps and essential for creating value→key secondary indexes.
When a secondary map has CM_PGET, corm_get() returns the primary key instead of the primary value. This allows secondary indexes to map from values back to keys.
- CM_SORTED
- Enable sorted index support (B-tree search). Enables ordered iteration. Index is automatically rebuilt on modifications (put/del operations mark it dirty).
Performance Note: The sorted index is rebuilt from scratch whenever it's marked dirty and iteration is requested. This makes the first iteration after modifications O(n log n) instead of O(n).
- CM_MULTIVALUE
- Allow duplicate keys in sorted maps. Enables multi-value lookups where multiple entries can share the same key.
REQUIRES CM_SORTED: This flag cannot be used without CM_SORTED. corm_open() will return CM_MISS if CM_MULTIVALUE is set without CM_SORTED.
Behavior:
- corm_put() with an existing key ADDS a new entry (does not replace)
- corm_get() returns the FIRST matching value
- corm_get_multi() returns cursor to iterate over ALL matching values
- corm_count() returns the number of entries for a key
- corm_del() deletes only the FIRST matching entry
- corm_del_all() deletes ALL entries with the specified key
Use Case: Secondary indexes via corm_assoc() where multiple primary entries map to the same secondary key.
- CM_NOGROW
- Disable auto-grow. When set and the map reaches capacity, inserts return CM_MISS instead of growing the table. Use for memory-constrained environments or fixed-size tables.
enum corm_if
Iterator flags.
Enumerator
- CM_RANGE
- Continue iteration even if key differs from the initial. Behavior depends on whether CM_SORTED was set on the map:
- With CM_SORTED: performs ordered range scan from the starting key onwards (B-tree ordered iteration)
- Without CM_SORTED: performs linear scan through the hash table, comparing keys with the initial key using the type's comparison function
- CM_RANGE_GE
- Lower-bound range: with CM_RANGE on a CM_SORTED map, start iteration at the first key >= the starting key and continue to the end (all entries in ascending key order, duplicates included). Unlike plain CM_RANGE, this applies to CM_MULTIVALUE maps too (plain CM_RANGE on a MULTIVALUE map iterates only the duplicates of the one exact starting key). Requires CM_SORTED; on unsorted maps it degrades to a full linear scan.
enum corm_tbi
Built-in type identifiers.
Enumerator
- CM_PTR
- Pointer (hashed).
- CM_HNDL
- Opaque handle. Uses value directly as hash (no transformation).
- CM_STR
- String contents hash and compare.
- CM_U32
- 32-bit unsigned integer (hash and mask).
Author
Generated automatically by Doxygen for corm from the source code.