|
CX Framework
Cross-platform C utility framework
|
Data Structures | |
| struct | SerResolved |
Typedefs | |
| typedef enum SerNodeKindEnum | SerNodeKind |
| typedef struct SerResolved | SerResolved |
| typedef bool(* | SerTypeResolver) (SerResolved *out, strref name, void *user) |
Enumerations | |
| enum | SerNodeKindEnum { SER_Invalid = 0 , SER_EOF , SER_Null , SER_Bool , SER_Int , SER_Uint , SER_Real , SER_Str , SER_Bytes , SER_ArrayBegin , SER_ArrayEnd , SER_MapBegin , SER_MapKey , SER_MapEnd , SER_TypeTag , SER_RefDef , SER_RefUse } |
Functions | |
| bool | serStructSetResolver (SerResolved *out, strref name, void *user) |
| bool | serClassSetResolver (SerResolved *out, strref name, void *user) |
| bool | serObjClassResolver (SerResolved *out, strref name, void *user) |
| typedef enum SerNodeKindEnum SerNodeKind |
A node in the abstract data model.
Every cx value decomposes into a sequence of these, and is reassembled from the same sequence. The vocabulary is deliberately close to CBOR's: rich enough to be lossless in a binary format, small enough that the JSON projection is a short table.
A backend is free to ignore nodes it has no use for – a schema-locked binary stream ignores SER_TypeTag – and to reject ones it cannot represent, which it declares by not advertising the matching capability.
| typedef struct SerResolved SerResolved |
The result of resolving a wire type name.
A resolver returns more than an stype because for a nominal type the stype alone is useless for constructing an instance – every class resolves to _sti_object – so the reader also needs the StructInfo or ObjClassInfo that describes how to allocate one.
| typedef bool(* SerTypeResolver) (SerResolved *out, strref name, void *user) |
Resolves a wire type name to something the reader can construct.
| out | Receives the resolved type on success |
| name | Wire type name, as it appeared in a type tag |
| user | Opaque value supplied when the resolver was registered |
| enum SerNodeKindEnum |
A node in the abstract data model.
Every cx value decomposes into a sequence of these, and is reassembled from the same sequence. The vocabulary is deliberately close to CBOR's: rich enough to be lossless in a binary format, small enough that the JSON projection is a short table.
A backend is free to ignore nodes it has no use for – a schema-locked binary stream ignores SER_TypeTag – and to reject ones it cannot represent, which it declares by not advertising the matching capability.
| bool serClassSetResolver | ( | SerResolved * | out, |
| strref | name, | ||
| void * | user | ||
| ) |
Resolves a class name through a ClassSet.
The class counterpart of serStructSetResolver, over the set cxautogen emits for a classset declaration. A slot declared object[SomeSet] consults its own set without any registration; this is for the other case, where a document's top-level value, or a slot declared as bare object, has to resolve against the same vocabulary.
| out | Receives the resolved class |
| name | Wire type name |
| user | The ClassSet to search |
| bool serObjClassResolver | ( | SerResolved * | out, |
| strref | name, | ||
| void * | user | ||
| ) |
Resolves a class name through a NULL-terminated array of ObjClassInfo*.
The same thing as serClassSetResolver for a list a consumer assembles itself rather than declaring in a .cxh: a class list is a handful of &X_clsinfo it already has the symbols for. Classes without a wire name never match: not having one is exactly what "this class
does not serialize" means.
| out | Receives the resolved class |
| name | Wire type name |
| user | NULL-terminated array of ObjClassInfo pointers to search |
Example:
| bool serStructSetResolver | ( | SerResolved * | out, |
| strref | name, | ||
| void * | user | ||
| ) |
Resolves a struct name through a StructSet.
Register with serReaderAddResolver(r, serStructSetResolver, &MySet_structset) to let a reader construct any struct in the set from its wire name. cxautogen emits one StructSet per structset declaration, sorted for binary search.
A member declared structp[MySet] does not need this: the set travels with the slot, and the traverser resolves through it directly. Register it for the cases a declaration cannot cover – a dynamic value at the top level of a document, or a bare structp slot.
| out | Receives the resolved struct type |
| name | Wire type name |
| user | The StructSet to search |