CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches

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)
 

Detailed Description

Functions for reading values from the tree.

Macro Definition Documentation

◆ ssdCopyOut

#define ssdCopyOut (   root,
  path,
  vtype,
  val_copy_out 
)
Value:
_ssdCopyOut(root, \
path, \
stCheckedPtrArg(vtype, val_copy_out), \
(SSDLockState*)_ssdCurrentLockState)
#define stCheckedPtrArg(type, val)
Definition stype.h:1100

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.

Parameters
rootThe root node to search from
pathPath to the value
vtypeThe expected/desired type for the output
val_copy_outPointer to destination variable
Returns
true if value was found and converted successfully

Example:

int32 count;
if (ssdCopyOut(root, _S"stats/count", int32, &count)) {
// use count
}
#define ssdCopyOut(root, path, vtype, val_copy_out)
Definition ssdtree.h:267
#define _S
Creates a static ASCII string from a string literal.
Definition strbase.h:392

Definition at line 267 of file ssdtree.h.

◆ ssdCopyOutD

#define ssdCopyOutD (   root,
  path,
  vtype,
  val_copy_out,
  def 
)
Value:
_ssdCopyOutD(root, \
path, \
stCheckedPtrArg(vtype, val_copy_out), \
stArg(vtype, def), \
(SSDLockState*)_ssdCurrentLockState)
#define stArg(type, val)
Definition stype.h:937

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.

Parameters
rootThe root node to search from
pathPath to the value
vtypeThe expected/desired type for the output
val_copy_outPointer to destination variable
defDefault value to use on failure
Returns
true if value was found and converted, false if default was used

Definition at line 287 of file ssdtree.h.

◆ ssdGet

#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().

Parameters
rootThe root node to search from
pathPath to the value (NULL for root node)
outOutput stvar (caller must destroy with stDestroy)
Returns
true if the value was found, false otherwise

Definition at line 217 of file ssdtree.h.

◆ ssdGetD

#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.

Parameters
rootThe root node to search from
pathPath to the value
outOutput stvar (caller must destroy with stDestroy)
defDefault value to use if path doesn't exist
Returns
true if value was found, false if default was used

Definition at line 240 of file ssdtree.h.

◆ ssdStringOut

#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.

Parameters
rootThe root node
pathPath to the string value
outPointer to string variable (will be destroyed and replaced)
Returns
true if the value was found and copied, false otherwise

Definition at line 363 of file ssdtree.h.

◆ ssdStringOutD

#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.

Parameters
rootThe root node
pathPath to the string value
outPointer to string variable (will be destroyed and replaced)
defDefault string to use if value not found
Returns
true if value was found, false if default was used

Definition at line 384 of file ssdtree.h.

◆ ssdVal

#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

Parameters
typeThe desired return type
rootThe root node
pathPath to the value
defDefault value if not found or conversion fails
Returns
The value or default

Example:

int32 port = ssdVal(int32, root, _S"server/port", 8080);
bool enabled = ssdVal(bool, root, _S"server/enabled", false);
#define ssdVal(type, root, path, def)
Definition ssdtree.h:343

Definition at line 343 of file ssdtree.h.