
Data Structures | |
| struct | VOLK_Codec |
| Codec structure. More... | |
Macros | |
| #define | CHUNK_SIZE 4096 |
Typedefs | |
| typedef VOLK_rc(* | decode_dset_fn_t) (FILE *fh, const char *sh, VOLK_Dataset *ds, void *udata) |
| Prototype for decoding a dataset. | |
| typedef VOLK_rc(* | decode_gr_fn_t) (FILE *fh, const char *sh, VOLK_Graph *gr) |
| Prototype for decoding a complete RDF document file into a graph. | |
| typedef VOLK_rc(* | decode_term_fn_t) (const char *rep, VOLK_Term **term) |
| Prototype for decoding a string into a VOLK_Term. | |
| typedef void(* | encode_dset_done_fn_t) (void *it) |
| Finalize a dataset encoding operation. | |
| typedef void *(* | encode_dset_init_fn_t) (VOLK_Dataset *dset) |
| Initialize a dataset encoding loop. | |
| typedef VOLK_rc(* | encode_dset_iter_fn_t) (void *it, char **res) |
| Perform one dataset encoding iteration. | |
| typedef void(* | encode_gr_done_fn_t) (void *it) |
| Finalize a graph encoding operation. | |
| typedef void *(* | encode_gr_init_fn_t) (const VOLK_Graph *gr, void *udata) |
| Initialize a graph encoding loop. | |
| typedef VOLK_rc(* | encode_gr_iter_fn_t) (void *it, char **res) |
| Perform one graph encoding iteration. | |
| typedef VOLK_rc(* | encode_term_fn_t) (const VOLK_Term *term, char **rep) |
| Term encoder prototype. | |
Enumerations | |
| enum | VOLK_CodecFeatures { VOLK_CODEC_FEAT_ENCODE_TERM = 1<<0 , VOLK_CODEC_FEAT_DECODE_TERM = 1<<1 , VOLK_CODEC_FEAT_ENCODE_GR = 1<<2 , VOLK_CODEC_FEAT_DECODE_GR = 1<<3 , VOLK_CODEC_FEAT_ENCODE_DS = 1<<4 , VOLK_CODEC_FEAT_DECODE_DS = 1<<5 , VOLK_CODEC_FEAT_ENCODE_STORE = 1<<6 , VOLK_CODEC_FEAT_DECODE_STORE = 1<<7 } |
| Feature flags applicable to a codec. More... | |
| enum | VOLK_CodecFlags { VOLK_CODEC_NO_PROLOG = 1<<0 , CODEC_EXT_TXN = 1<<1 , VOLK_CODEC_INDENT = 1<<2 } |
| Parse error information. More... | |
Functions | |
| VOLK_rc | escape_lit (const char *in, char **out) |
| Add escape character (backslash) to illegal literal characters. | |
| char * | fmt_header (char *pfx) |
| Format an informational header. | |
| uint8_t * | uint8_dup (const uint8_t *str) |
| strdup() for unsigned char. | |
| uint8_t * | uint8_ndup (const uint8_t *str, size_t size) |
| strndup() for unsigned char. | |
| char | unescape_char (const char c) |
| Unescape a single character. | |
| uint8_t * | unescape_unicode (const uint8_t *esc_str, size_t size) |
| Replace \uxxxx and \Uxxxxxxxx with Unicode bytes. | |
| #define CHUNK_SIZE 4096 |
Max data size passed to the scanner and parser at each iteration.
Definition at line 78 of file codec_interface.h.
| typedef VOLK_rc(* decode_dset_fn_t) (FILE *fh, const char *sh, VOLK_Dataset *ds, void *udata) |
Prototype for decoding a dataset.
| [in] | fh | Open file handle pointing to the RDF data. Implementations MUST NOT close the file handle. This is mutually exclusive with sh. |
| [in] | sh | string handle for the RDF data. This is mutually exclusive with fh. If both are specified, fh has precedence. |
| [in] | ds | Dataset handle to be populated. The dataset MUST be initialized and MAY be not empty. |
| [in] | udata | User data that may be used by implementations. |
Definition at line 397 of file codec_interface.h.
| typedef VOLK_rc(* decode_gr_fn_t) (FILE *fh, const char *sh, VOLK_Graph *gr) |
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.
| [in] | fh | Open file handle pointing to the RDF data. Implementations MUST NOT close the file handle. This is exclusive with sh. |
| [in] | sh | string handle for the RDF data. This is exclusive with fh. If both are specified, fh has precedence. |
| [out] | gr | Graph handle to be populated with decoded data. The graph MUST be initialized and MAY be non-empty. |
Definition at line 379 of file codec_interface.h.
Prototype for decoding a string into a VOLK_Term.
Implementations MAY ignore any other tokens after finding the first one.
| [in] | rep | NT representation of the term. |
| [out] | term | Pointer to the term handle to be created. Implementaions SHOULD return NULL on a parse error. |
Definition at line 359 of file codec_interface.h.
| typedef void(* encode_dset_done_fn_t) (void *it) |
Finalize a dataset 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.
| [in] | it | Iterator handle. |
Definition at line 339 of file codec_interface.h.
| typedef void *(* encode_dset_init_fn_t) (VOLK_Dataset *dset) |
Initialize a dataset encoding loop.
This prototype is to be implemented by dataset encoding loops. A dataset is passed here and will feed the encode_dset_iter_fn_t loop one call at a time.
| [in] | dset | Dataset to loop through. The loop MUST take ownership of the handle and MUST free it in encode_dset_done_fn_t. |
Definition at line 308 of file codec_interface.h.
| typedef VOLK_rc(* encode_dset_iter_fn_t) (void *it, char **res) |
Perform one dataset encoding iteration.
Implementations of this prototype MUST perform all the steps to encode one complete graph into an RDF fragment representing that graph.
| [in] | it | Iterator handle. |
| [out] | res | Handle 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 by the caller at the end of the loop. Implementations MAY reallocate this memory at each iteration, and users SHOULD expect that memory from a previous iteration may be overwritten with new data. |
Definition at line 328 of file codec_interface.h.
| typedef void(* encode_gr_done_fn_t) (void *it) |
Finalize a graph 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.
| [in] | it | Iterator handle. |
Definition at line 293 of file codec_interface.h.
| typedef void *(* encode_gr_init_fn_t) (const VOLK_Graph *gr, void *udata) |
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.
| [in] | gr | The 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. |
| [in] | udata | Additional data passed to the iterator. Implementations MAY decide whether and how to use this. |
Definition at line 260 of file codec_interface.h.
| typedef VOLK_rc(* encode_gr_iter_fn_t) (void *it, char **res) |
Perform one graph 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.
| [in] | it | Iterator handle. |
| [out] | res | Handle 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. Implementations MAY reallocate this memory at each iteration, and users SHOULD expect that memory from a previous iteration may be overwritten with new data. |
Definition at line 282 of file codec_interface.h.
Term encoder prototype.
| [in] | term | Single term handle. |
| [out] | rep | Pointer 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 MUST be initialized to NULL at the beginning. |
Definition at line 240 of file codec_interface.h.
| enum VOLK_CodecFeatures |
Feature flags applicable to a codec.
Definition at line 104 of file codec_interface.h.
| enum VOLK_CodecFlags |
Parse error information.
Option flags passed to codec function calls.
Definition at line 93 of file codec_interface.h.
| VOLK_rc escape_lit | ( | const char * | in, |
| char ** | out ) |
Add escape character (backslash) to illegal literal characters.
| [in] | in | Input string. |
| [out] | out | Output string. |
Definition at line 81 of file codec_interface.c.
| char * fmt_header | ( | char * | pfx | ) |
Format an informational header.
The information includes software version and current date. It is terminated by a newline + NUL and prefixed with the string specified in pfx. It is NOT prefixed by any comment characters.
| [in] | pfx | Prefix to add to the string. It may be a comment starter, such as # . |
Definition at line 116 of file codec_interface.c.
|
inline |
strdup() for unsigned char.
This is to be used with uint8_t sequences considered to be UTF-8 sequences, requird by re2c (it won't work with byte sequences containing NUL).
Definition at line 128 of file codec_interface.h.
|
inline |
strndup() for unsigned char.
This is to be used with uint8_t sequences considered to be UTF-8 sequences, requird by re2c (it won't work with byte sequences containing NUL).
Definition at line 138 of file codec_interface.h.
|
inline |
Unescape a single character.
Convert escaped special characters such as \t, \n, etc. into their corresponding code points.
Non-special characters are returned unchanged.
| [in] | c | Character to unescape. Note that this is the single character after \\endiskip. |
Definition at line 184 of file codec_interface.h.
| uint8_t * unescape_unicode | ( | const uint8_t * | esc_str, |
| size_t | size ) |
Replace \uxxxx and \Uxxxxxxxx with Unicode bytes.
| [in] | esc_str | Escaped string. |
| [in] | size | Maximum number of characters to scan, à la strncpy(). |
Definition at line 11 of file codec_interface.c.