|
CX Framework
Cross-platform C utility framework
|
Data Structures | |
| struct | stvp |
Macros | |
| #define | stvp(typen, pval) ((stvp) { stCheckedPtrArg(typen, pval), NULL }) |
| #define | stvpk(key, typen, pval) ((stvp) { stCheckedPtrArg(typen, pval), #key }) |
| #define | stvpNone ((stvp) { NULL, NULL, NULL }) |
Typedefs | |
| typedef struct stvp | stvp |
Type-safe variadic destinations, for functions that fill in caller variables rather than reading them.
An stvp is the mirror image of an stvar: where a variant carries a value into a call, an stvp carries a place to put one back out. It pairs a type descriptor with a pointer into the caller's own storage, plus an optional key naming the field it should receive.
An stvp owns nothing, allocates nothing, and lives exactly as long as the call it appears in.
The two are not interchangeable. stvar is a full value container. stvp is a calling convention for a typed pointer to a value.
The same array-of-struct method stvar uses for input arguments:
| #define stvp | ( | typen, | |
| pval | |||
| ) | ((stvp) { stCheckedPtrArg(typen, pval), NULL }) |
stvp stvp(type, pval)
Create a positional destination binding.
The pointer is type-checked against the named type at compile time, exactly as stvar() checks a value.
| typen | Type name (e.g., int32, string) |
| pval | Pointer to the variable that receives the value |
Example:
| #define stvpk | ( | key, | |
| typen, | |||
| pval | |||
| ) | ((stvp) { stCheckedPtrArg(typen, pval), #key }) |
Create a destination binding tagged with a key name.
Identical to stvp() except that the destination also carries a name, so the receiver fills it in by name rather than by position. The key is written as a bare token and stringized, same as stvark().
| key | Key name as a bare token (not a string literal) |
| typen | Type name (e.g., int32, string) |
| pval | Pointer to the variable that receives the value |
Example:
| #define stvpNone ((stvp) { NULL, NULL, NULL }) |
stvp stvpNone
A destination binding that binds nothing.
A variadic call cannot portably be given zero arguments, so this is what to pass when there is genuinely nothing to fill in - matching a pattern purely to find out whether it matches, for instance. Receivers skip it.
Example: