|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | ssdGet(root, path, out) _ssdGet(root, path, out, (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdGetD(root, path, out, def) _ssdGetD(root, path, out, def, (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdCopyOut(root, path, vtype, val_copy_out) |
| #define | ssdCopyOutD(root, path, vtype, val_copy_out, def) |
| #define | ssdVal(type, root, path, def) _ssdVal_##type(root, path, def, (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdStringOut(root, path, out) _ssdStringOut(root, path, out, (SSDLockState*)_ssdCurrentLockState) |
| #define | ssdStringOutD(root, path, out, def) _ssdStringOutD(root, path, out, def, (SSDLockState*)_ssdCurrentLockState) |
Functions for reading values from the tree.
| #define ssdCopyOut | ( | root, | |
| path, | |||
| vtype, | |||
| val_copy_out | |||
| ) |
bool ssdCopyOut(SSDNode *root, strref path, vtype, val_copy_out)
Retrieves a value from the tree and copies it to an arbitrary destination, with type conversion.
This function is useful when you need the value in a specific type and want automatic conversion from the stored representation.
| root | The root node to search from |
| path | Path to the value |
| vtype | The expected/desired type for the output |
| val_copy_out | Pointer to destination variable |
Example:
| #define ssdCopyOutD | ( | root, | |
| path, | |||
| vtype, | |||
| val_copy_out, | |||
| def | |||
| ) |
bool ssdCopyOutD(SSDNode *root, strref path, vtype, val_copy_out, def)
Variant of ssdCopyOut that provides a default value if conversion fails or path doesn't exist.
| root | The root node to search from |
| path | Path to the value |
| vtype | The expected/desired type for the output |
| val_copy_out | Pointer to destination variable |
| def | Default value to use on failure |
| #define ssdGet | ( | root, | |
| path, | |||
| out | |||
| ) | _ssdGet(root, path, out, (SSDLockState*)_ssdCurrentLockState) |
bool ssdGet(SSDNode *root, strref path, stvar *out)
Retrieves a value from the tree as an stvar.
IMPORTANT: The output stvar must be destroyed with stDestroy() to avoid memory leaks when the value is a string, object, or a subtree (hashtable/array). For simpler access without memory management, use ssdPtr() or the convenience functions like ssdVal().
| root | The root node to search from |
| path | Path to the value (NULL for root node) |
| out | Output stvar (caller must destroy with stDestroy) |
| #define ssdGetD | ( | root, | |
| path, | |||
| out, | |||
| def | |||
| ) | _ssdGetD(root, path, out, def, (SSDLockState*)_ssdCurrentLockState) |
bool ssdGetD(SSDNode *root, strref path, stvar *out, stvar def)
Variant of ssdGet that provides a default value if the path doesn't exist.
If the value is not found, the default is copied to out and the function returns false.
| root | The root node to search from |
| path | Path to the value |
| out | Output stvar (caller must destroy with stDestroy) |
| def | Default value to use if path doesn't exist |
| #define ssdStringOut | ( | root, | |
| path, | |||
| out | |||
| ) | _ssdStringOut(root, path, out, (SSDLockState*)_ssdCurrentLockState) |
bool ssdStringOut(SSDNode *root, strref path, string *out)
Retrieves a string value, copying it into the provided string variable.
The output string is automatically destroyed before being populated with the new value.
| root | The root node |
| path | Path to the string value |
| out | Pointer to string variable (will be destroyed and replaced) |
| #define ssdStringOutD | ( | root, | |
| path, | |||
| out, | |||
| def | |||
| ) | _ssdStringOutD(root, path, out, def, (SSDLockState*)_ssdCurrentLockState) |
bool ssdStringOutD(SSDNode *root, strref path, string *out, strref def)
Retrieves a string value with a default if not found.
The output string is automatically destroyed before being populated.
| root | The root node |
| path | Path to the string value |
| out | Pointer to string variable (will be destroyed and replaced) |
| def | Default string to use if value not found |
| #define ssdVal | ( | type, | |
| root, | |||
| path, | |||
| def | |||
| ) | _ssdVal_##type(root, path, def, (SSDLockState*)_ssdCurrentLockState) |
type ssdVal(type, SSDNode *root, strref path, type def)
Type-specific convenience function for getting primitive values with a default.
This function automatically converts and returns the value as the specified type. If the value doesn't exist or can't be converted, the default is returned.
Supported types: bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64
| type | The desired return type |
| root | The root node |
| path | Path to the value |
| def | Default value if not found or conversion fails |
Example: