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

Functions

SerWriterserSsdWriterCreate (flags_t flags)
 
SSDNode * serSsdWriterRoot (SerWriter *w)
 
SerReader * serSsdReaderCreate (SSDNode *root, flags_t flags)
 

Detailed Description

An SSD tree is a backend like any other, which bridges the schema'd and schema-free halves of cx: struct to SSDNode on the way out, SSDNode to struct on the way back.

It is also the abstraction's sanity check. A tree builder is about as different from a byte stream as a backend can be, and the data model accommodates it without special-casing – no encoding, no parsing, nothing but the vocabulary itself.

Function Documentation

◆ serSsdReaderCreate()

SerReader * serSsdReaderCreate ( SSDNode *  root,
flags_t  flags 
)

Creates a reader over an existing SSD tree.

Parameters
rootRoot node to read from; a reference is acquired for the reader's lifetime
flagsSerFlagsEnum options
Returns
A new reader; destroy with serReaderDestroy()

Example:

SerReader *r = serSsdReaderCreate(tree, 0);
MyStruct out;
structInit(MyStruct, &out);
serRead(r, MyStruct, &out);
void serReaderDestroy(SerReader **r)
#define serRead(r, type, pval)
Definition serreader.h:192
SerReader * serSsdReaderCreate(SSDNode *root, flags_t flags)
#define structInit(structname, s)
Definition struct.h:118

◆ serSsdWriterCreate()

SerWriter * serSsdWriterCreate ( flags_t  flags)

Creates a writer that builds an SSD tree.

The tree is created by the writer and owned by it until serSsdWriterRoot() is called, so unlike the byte-stream backends there is no caller-supplied transport.

Parameters
flagsSerFlagsEnum options; none are specific to this backend
Returns
A new writer; destroy with serWriterDestroy()

Example:

serWrite(w, MyStruct, val);
SSDNode *tree = serSsdWriterRoot(w);
// ... use tree ...
objRelease(&tree);
#define objRelease(pinst)
Definition objclass.h:257
SSDNode * serSsdWriterRoot(SerWriter *w)
SerWriter * serSsdWriterCreate(flags_t flags)
bool serWriterFinish(SerWriter *w)
#define serWrite(w, type, val)
Definition serwriter.h:188
void serWriterDestroy(SerWriter **w)

◆ serSsdWriterRoot()

SSDNode * serSsdWriterRoot ( SerWriter w)

Returns the tree the writer built.

Call after serWriterFinish(). The caller receives a new reference and must release it; the writer keeps its own, so the tree survives serWriterDestroy().

Parameters
wWriter to take the result from
Returns
The root node, or NULL if nothing was written