|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | ssdExportArray(root, path, out) _ssdExportArray(root, path, out, (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdImportArray(root, path, arr) _ssdImportArray(root, path, arr, (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdExportTypedArray(root, path, type, out, strict) |
| #define | ssdImportTypedArray(root, path, type, arr) _ssdImportTypedArray(root, path, stType(type), SAREF(arr), (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdCount(root, path, arrayonly) _ssdCount(root, path, arrayonly, (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdIndex(root, path, idx) _ssdIndex(root, path, idx, (SSDLockState*)&_ssdCurrentLockState->_is_SSDLockState) |
| #define | ssdAppend(root, path, createpath, val) _ssdAppend(root, path, createpath, val, (SSDLockState*)_ssdCurrentLockState) |
Functions for importing/exporting arrays and working with array nodes.
| #define ssdAppend | ( | root, | |
| path, | |||
| createpath, | |||
| val | |||
| ) | _ssdAppend(root, path, createpath, val, (SSDLockState*)_ssdCurrentLockState) |
bool ssdAppend(SSDNode *root, strref path, bool createpath, stvar val)
Appends a value to an array at the given path.
If the array doesn't exist and createpath is true, it will be created automatically.
| root | The root node |
| path | Path to the array node (NULL to append to root if it's an array) |
| createpath | If true, create the array if it doesn't exist |
| val | Value to append (copied) |
Example:
| #define ssdCount | ( | root, | |
| path, | |||
| arrayonly | |||
| ) | _ssdCount(root, path, arrayonly, (SSDLockState*)_ssdCurrentLockState) |
int32 ssdCount(SSDNode *root, strref path, bool arrayonly)
Returns the number of children/elements at the given path.
| root | The root node |
| path | Path to the node to count |
| arrayonly | If true, returns 0 for hashtable nodes |
| #define ssdExportArray | ( | root, | |
| path, | |||
| out | |||
| ) | _ssdExportArray(root, path, out, (SSDLockState*)_ssdCurrentLockState) |
bool ssdExportArray(SSDNode *root, strref path, sa_stvar *out)
Exports an array node to a dynamic array of stvars.
The output array must be either initialized or point to NULL. The function will populate it with copies of all values in the SSD array node.
| root | The root node |
| path | Path to the array node |
| out | Pointer to sa_stvar (initialized or NULL) |
| #define ssdExportTypedArray | ( | root, | |
| path, | |||
| type, | |||
| out, | |||
| strict | |||
| ) |
bool ssdExportTypedArray(SSDNode *root, strref path, type, sahandle out, bool strict)
Exports an array node to a typed dynamic array.
The output array must be either initialized or point to NULL. Values are converted to the specified element type during export.
| root | The root node |
| path | Path to the array node |
| type | The desired element type |
| out | Pointer to typed sarray (initialized or NULL) |
| strict | If true, fails on type mismatch; if false, skips incompatible items |
Example:
| #define ssdImportArray | ( | root, | |
| path, | |||
| arr | |||
| ) | _ssdImportArray(root, path, arr, (SSDLockState*)_ssdCurrentLockState) |
bool ssdImportArray(SSDNode *root, strref path, sa_stvar arr)
Imports a dynamic array of stvars into an array node.
Creates an array node at the specified path and populates it with the values.
| root | The root node |
| path | Path where to create/replace the array |
| arr | The source array of stvars |
| #define ssdImportTypedArray | ( | root, | |
| path, | |||
| type, | |||
| arr | |||
| ) | _ssdImportTypedArray(root, path, stType(type), SAREF(arr), (SSDLockState*)_ssdCurrentLockState) |
bool ssdImportTypedArray(SSDNode *root, strref path, type, sa_ref arr)
Imports a typed dynamic array into an array node.
| root | The root node |
| path | Path where to create/replace the array |
| type | The element type of the source array |
| arr | Reference to the source array |
| #define ssdIndex | ( | root, | |
| path, | |||
| idx | |||
| ) | _ssdIndex(root, path, idx, (SSDLockState*)&_ssdCurrentLockState->_is_SSDLockState) |
stvar *ssdIndex(SSDNode *root, strref path, int32 idx)
Gets a pointer to a specific array element by index.
CRITICAL: Like ssdPtr(), this requires a lock via ssdLockedTransaction(). The pointer is only valid while the lock is held.
| root | The root node |
| path | Path to the array node |
| idx | Array index to access |