|
CX Framework
Cross-platform C utility framework
|
Macros | |
| #define | stvarIs(svar, type) _stvarIs(svar, stType(type)) |
| #define | stvarObj(class, svar) (objDynCast(class, stvarObjInst(svar))) |
Functions | |
| string | stvarString (stvar *svar) |
| string * | stvarStringPtr (stvar *svar) |
| ObjInst * | stvarObjInst (stvar *svar) |
| ObjInst ** | stvarObjInstPtr (stvar *svar) |
Functions and macros for checking variant types and extracting values.
| #define stvarIs | ( | svar, | |
| type | |||
| ) | _stvarIs(svar, stType(type)) |
bool stvarIs(stvar *svar, type)
Check if a variant contains a value of the specified type.
Compares the variant's runtime type descriptor against the specified compile-time type. Returns false for NULL pointers.
| svar | Pointer to variant to check |
| type | Type name to check for (e.g., int32, string) |
Example:
| #define stvarObj | ( | class, | |
| svar | |||
| ) | (objDynCast(class, stvarObjInst(svar))) |
ClassName* stvarObj(ClassName, stvar *svar)
Extract typed object from variant with runtime type checking.
Retrieves the object from the variant and performs a dynamic cast to the specified class type. Returns NULL if the variant does not contain an object or if the object is not compatible with the target class.
| class | Target class name (e.g., MyClass) |
| svar | Pointer to variant |
Example:
ObjInst* stvarObjInst(stvar *svar)
Extract object instance from variant if it contains an object.
Returns the untyped object pointer if the variant contains an object. For typed access, use stvarObj() macro instead.
| svar | Pointer to variant |
Example:
Definition at line 343 of file stvar.h.
References stvarIs.
ObjInst** stvarObjInstPtr(stvar *svar)
Get pointer to object instance field within variant.
Returns a pointer to the object field inside the variant's data union. Returns NULL if the variant does not contain an object.
| svar | Pointer to variant |
Definition at line 359 of file stvar.h.
References stvarIs.
|
inline |
string stvarString(stvar *svar)
Extract string value from variant if it contains a string.
Convenience accessor that checks the type and returns the string value in one operation. Returns NULL if the variant does not contain a string or if the pointer is NULL.
| svar | Pointer to variant |
Example:
Definition at line 292 of file stvar.h.
References stvarIs.
|
inline |
string* stvarStringPtr(stvar *svar)
Get pointer to string value within variant.
Returns a pointer to the string field inside the variant's data union, allowing modification of the stored string. Returns NULL if the variant does not contain a string.
| svar | Pointer to variant |
Example:
Definition at line 318 of file stvar.h.
References stvarIs.