Volksdata 1.0b7
RDF library
Loading...
Searching...
No Matches
RDF encoder & decoder module
Collaboration diagram for RDF encoder & decoder module:

Data Structures

struct  VOLK_Codec
 Codec structure. More...

Typedefs

typedef VOLK_rc(* term_enc_fn_t) (const VOLK_Term *term, char **rep)
 Term encoder callback type.
typedef void *(* gr_encode_init_fn_t) (const VOLK_Graph *gr)
 Initialize a graph encoding loop.
typedef VOLK_rc(* gr_encode_iter_fn_t) (void *it, char **res)
 Perform one encoding iteration.
typedef void(* gr_encode_done_fn_t) (void *it)
 Finalize an encoding operation.
typedef VOLK_rc(* term_decode_fn_t) (const char *rep, VOLK_Term **term)
 Prototype for decoding a string into a VOLK_Term.
typedef VOLK_rc(* gr_decode_fn_t) (FILE *fh, const char *sh, VOLK_Graph **gr, size_t *ct, char **err)
 Prototype for decoding a complete RDF document file into a graph.

Detailed Description

Typedef Documentation

◆ term_enc_fn_t

typedef VOLK_rc(* term_enc_fn_t) (const VOLK_Term *term, char **rep)

Term encoder callback type.

Parameters
[in]termSingle term handle.
[out]repPointer to a string to be filled with the encoded term. The string is reallocated and, if reused for multiple calls to this function, it only needs to be freed after the last call. It should be initialized to NULL at the beginning.
Returns
VOLK_OK on successful encoding; <0 for other errors.

Definition at line 197 of file codec.h.

◆ gr_encode_init_fn_t

typedef void *(* gr_encode_init_fn_t) (const VOLK_Graph *gr)

Initialize a graph encoding loop.

This prototype is to be implemented by graph encoding loops. It should create an iterator and perform all initial setup for finding triples.

Implementations MUST set the "codec" member of the iterator to the address of the codec that generated it.

Parameters
[in]grThe graph to be encoded. The graph's namespace map is used by the codec for namespace prefixing. The graph may only be freed after the loop is finalized.
Returns
A codec iterator handle to be passed to a gr_encode_iter_fn_t function and, eventually, to a gr_encode_done_fn_t function. This structure is opaque and defined by each codec according to its own needs.

Definition at line 216 of file codec.h.

◆ gr_encode_iter_fn_t

typedef VOLK_rc(* gr_encode_iter_fn_t) (void *it, char **res)

Perform one encoding iteration.

Implementations of this prototype MUST perform all the steps to encode one or more complete triples into an RDF fragment representing those triples. The input and output units are up to the implementation and a caller SHOULD assume that multiple lines may be yielded at each iteration.

Parameters
[in]itIterator handle.
[out]resHandle to be populated with a string obtained from encoding. The output data should be UTF-8 encoded. This pointer must be initialized (even to NULL) and should be eventually freed manually at the end of the loop. It is reallocated at each iteration, so memory from a previous iteration may be overwritten with new data.
Returns
VOLK_OK if a new token was processed; VOLK_END if the end of the loop was reached.

Definition at line 237 of file codec.h.

◆ gr_encode_done_fn_t

typedef void(* gr_encode_done_fn_t) (void *it)

Finalize an encoding operation.

Implementations SHOULD use this function to perform all necessary steps to clean up memory and free the iterator handle after a graph has been completely encoded.

Parameters
[in]itIterator handle.

Definition at line 248 of file codec.h.

◆ term_decode_fn_t

typedef VOLK_rc(* term_decode_fn_t) (const char *rep, VOLK_Term **term)

Prototype for decoding a string into a VOLK_Term.

Implementations MAY ignore any other tokens after finding the first one.

Parameters
[in]repNT representation of the term.
[out]termPointer to the term handle to be created. Implementaions SHOULD return NULL on a parse error.
Returns
Implementations MUST return VOLK_OK on success and a negative value on parsing error.

Definition at line 263 of file codec.h.

◆ gr_decode_fn_t

typedef VOLK_rc(* gr_decode_fn_t) (FILE *fh, const char *sh, VOLK_Graph **gr, size_t *ct, char **err)

Prototype for decoding a complete RDF document file into a graph.

Implementations SHOULD consume data from the file handle in chunks and MAY read a string handle .

Parameters
[in]fhOpen file handle pointing to the RDF data. Implementations MUST NOT close the file handle. This is exclusive with sh.
[in]shstring handle for the RDF data. This is exclusive with fh. If both are specified, fh has precedence.
[out]grPointer to a graph handle to be generated from decoding. The handle need not be initialized. The graph URI will be randomly assigned and can be changed at a later time.
[out]ctIf not NULL, it MAY be populated with the number of triples parsed (which may be different from the resulting graph size). Implementations MAY choose not not use this, and they MUST account for the value to be NULL.
[out]errPointer to error info string. If no error occurs, it yields NULL.
Returns
Implementations MUST return VOLK_OK on success and a negative value on parsing error.

Definition at line 292 of file codec.h.