|
libsnobol4 1.0.2
High-performance SNOBOL4-style pattern matching library
|
Runtime-owned associative table objects for SNOBOL4. More...


Go to the source code of this file.
Classes | |
| struct | table_entry |
| struct | snobol_table |
Macros | |
| #define | TABLE_INITIAL_CAPACITY 16 |
Typedefs | |
| typedef struct table_entry | table_entry_t |
| typedef struct snobol_table | snobol_table_t |
Functions | |
| snobol_table_t * | table_create (const char *name) |
| Create a new runtime table. | |
| snobol_table_t * | table_retain (snobol_table_t *table) |
| Increment table reference count. | |
| void | table_release (snobol_table_t *table) |
| Decrement table reference count and free if zero. | |
| bool | table_set (snobol_table_t *table, const char *key, const char *value) |
| Insert or update a key-value pair. | |
| const char * | table_get (const snobol_table_t *table, const char *key) |
| Look up a value by key. | |
| bool | table_has (const snobol_table_t *table, const char *key) |
| Check if a key exists in the table. | |
| bool | table_delete (snobol_table_t *table, const char *key) |
| Delete a key from the table. | |
| bool | table_set_ex (snobol_table_t *table, const char *key, size_t key_len, const char *value, size_t value_len) |
| Insert or update a key-value pair (NUL-safe byte-exact variants). | |
| const char * | table_get_ex (const snobol_table_t *table, const char *key, size_t key_len, size_t *out_len) |
| Look up a value by key (NUL-safe). | |
| bool | table_has_ex (const snobol_table_t *table, const char *key, size_t key_len) |
| Check if a key exists in the table (NUL-safe). | |
| bool | table_delete_ex (snobol_table_t *table, const char *key, size_t key_len) |
| Delete a key from the table (NUL-safe). | |
| uint32_t | table_hash_string (const char *str) |
| Hash function for strings (FNV-1a). | |
| uint32_t | table_hash_bytes (const char *str, size_t len) |
| Hash function for byte-exact strings (FNV-1a, NUL-safe). | |
| void | table_clear (snobol_table_t *table) |
| Clear all entries from the table. | |
| size_t | table_size (const snobol_table_t *table) |
| Get the number of active entries. | |
| const char * | table_name (const snobol_table_t *table) |
| Get the table name (for debugging). | |
Runtime-owned associative table objects for SNOBOL4.
Ownership/Lifetime Rules:
Definition in file table.h.
| typedef struct snobol_table snobol_table_t |
| typedef struct table_entry table_entry_t |
| void table_clear | ( | snobol_table_t * | table | ) |
Clear all entries from the table.
| table | Table to clear |
| snobol_table_t * table_create | ( | const char * | name | ) |
Create a new runtime table.
| name | Optional name for debugging (can be NULL) |
Ownership: Caller owns the returned table and must call table_release()
| bool table_delete | ( | snobol_table_t * | table, |
| const char * | key ) |
Delete a key from the table.
| table | Table to modify |
| key | Key to delete |
| bool table_delete_ex | ( | snobol_table_t * | table, |
| const char * | key, | ||
| size_t | key_len ) |
Delete a key from the table (NUL-safe).
| table | Table to modify |
| key | Key to delete |
| key_len | Byte length of key |
| const char * table_get | ( | const snobol_table_t * | table, |
| const char * | key ) |
Look up a value by key.
| table | Table to query |
| key | Key to look up |
Ownership: Returned pointer is owned by the table, do not free The pointer remains valid until the entry is modified or deleted
| const char * table_get_ex | ( | const snobol_table_t * | table, |
| const char * | key, | ||
| size_t | key_len, | ||
| size_t * | out_len ) |
Look up a value by key (NUL-safe).
| table | Table to query |
| key | Key to look up |
| key_len | Byte length of key |
| out_len | Set to the byte length of the returned value (may be NULL) |
Ownership: Returned pointer is owned by the table, do not free The pointer remains valid until the entry is modified or deleted
| bool table_has | ( | const snobol_table_t * | table, |
| const char * | key ) |
Check if a key exists in the table.
| table | Table to query |
| key | Key to check |
| bool table_has_ex | ( | const snobol_table_t * | table, |
| const char * | key, | ||
| size_t | key_len ) |
Check if a key exists in the table (NUL-safe).
| table | Table to query |
| key | Key to check |
| key_len | Byte length of key |
| uint32_t table_hash_bytes | ( | const char * | str, |
| size_t | len ) |
Hash function for byte-exact strings (FNV-1a, NUL-safe).
| str | Bytes to hash |
| len | Byte length |
| uint32_t table_hash_string | ( | const char * | str | ) |
Hash function for strings (FNV-1a).
| str | String to hash |
| const char * table_name | ( | const snobol_table_t * | table | ) |
Get the table name (for debugging).
| table | Table to query |
| void table_release | ( | snobol_table_t * | table | ) |
Decrement table reference count and free if zero.
| table | Table to release |
When refcount reaches 0, all entries and the table itself are freed
| snobol_table_t * table_retain | ( | snobol_table_t * | table | ) |
Increment table reference count.
| table | Table to retain |
Use when sharing table ownership with another owner
| bool table_set | ( | snobol_table_t * | table, |
| const char * | key, | ||
| const char * | value ) |
Insert or update a key-value pair.
| table | Table to modify |
| key | String key (copied) |
| value | String value (copied), or NULL to delete |
Ownership: Table takes ownership of copies of key and value
| bool table_set_ex | ( | snobol_table_t * | table, |
| const char * | key, | ||
| size_t | key_len, | ||
| const char * | value, | ||
| size_t | value_len ) |
Insert or update a key-value pair (NUL-safe byte-exact variants).
| table | Table to modify |
| key | String key (copied) |
| key_len | Byte length of key (may contain NULs) |
| value | String value (copied), or NULL to delete |
| value_len | Byte length of value |
Ownership: Table takes ownership of copies of key and value
| size_t table_size | ( | const snobol_table_t * | table | ) |
Get the number of active entries.
| table | Table to query |