30trig_build_prolog (TRIGEncodeIterator *it,
char **res_p)
35 char *ns_tpl =
"@prefix %s: <%s> .\n";
38 for (
size_t i = 0; nsm[i]; i++) {
39 const char **ns = nsm[i];
40 size_t old_len = strlen (res);
41 size_t ns_len = strlen (ns[0]) + strlen (ns[1]) + strlen (ns_tpl);
42 char *tmp = realloc (res, old_len + ns_len + 1);
46 sprintf (res + old_len, ns_tpl, ns[0], ns[1]);
63 TRIGEncodeIterator *it = calloc (1,
sizeof (*it));
78 TRIGEncodeIterator *it = h;
84 if (it->pos ==
TRIG_POS_START)
return trig_build_prolog (it, res_p);
90 char *gr_uri_trig = NULL;
111 it->dset->store, gr_uri->
data);
112 out_size += strlen (gr_uri_trig) + 4;
121 log_info (
"End of store encoding.");
125 char *res = realloc (*res_p, out_size);
141 sprintf (res,
"}\n");
145 if (!gr_uri_trig) sprintf (res + offset,
"\n{\n");
147 sprintf (res + offset,
"\n%s {\n", gr_uri_trig);
163 TRIGEncodeIterator *it = h;
void VOLK_dataset_free(VOLK_Dataset *ds)
Free a dataset handle.
#define RCNL(exp)
Return NULL if exp returns a nonzero value.
#define NLNL(exp)
Log error and return NULL if exp is NULL.
#define NLRCCK(exp, _rc)
Return rc return code if exp is NULL.
#define VOLK_MEM_ERR
Memory allocation error.
#define VOLK_NORESULT
No result yielded.
#define VOLK_END
Loop end.
#define VOLK_OK
Generic success return code.
VOLK_rc VOLK_store_begin(VOLK_Store *store, VOLK_StoreFlags flags, void **txn)
Begin a transaction.
void VOLK_store_abort(VOLK_Store *store, void *txn)
Abort (roll back) a transaction.
bool VOLK_term_equals(const VOLK_Term *term1, const VOLK_Term *term2)
Compare two terms.
void VOLK_term_free(VOLK_Term *term)
VOLK_Term * VOLK_default_ctx
Default context.
VOLK_Term * VOLK_term_set_pop(VOLK_TermSet *ts)
Pop a term from a term set.
char * fmt_header(char *pfx)
Format an informational header.
@ VOLK_CODEC_NO_PROLOG
Do not generate prolog.
void VOLK_graph_free(VOLK_Graph *gr)
Free a graph.
VOLK_Graph * VOLK_graph_new(VOLK_Store *store, const char *uri_str)
Create new graph.
const char *** VOLK_nsmap_dump(void)
Dump all entries of the namespace map.
@ VOLK_STORE_TXN_RO
Start a read-only transaction.
VOLK_rc trig_encode_dset_iter(void *h, char **res_p)
Encode a chunk from a store.
void trig_encode_dset_done(void *h)
Finalize the store encoding loop.
void * trig_encode_dset_init(VOLK_Dataset *ds)
Initialize a store encoding loop.
VOLK_rc ttl_encode_term(const VOLK_Term *term, char **out_p)
Encode a single term as Turtle.
void ttl_encode_graph_done(void *h)
Finalize a TTL graph iteration.
VOLK_rc ttl_encode_graph_iter(void *h, char **res_p)
Run one encoding iteration.
void * ttl_encode_graph_init(const VOLK_Graph *gr, void *oh)
Initialize a TTL graph iteration.
Options passed to ttl_encode_graph_init().
char * data
URI, literal value, or BNode label.
void * txn
Store transaction.
TTLEncodeIterator * gr_it
Current graph iterator.
VOLK_Graph * gr
Current graph.
VOLK_rc rc
Internal return code.
TRIGPos pos
Encoder position.
VOLK_Dataset * dset
Dataset to encode.
@ TRIG_POS_END
End of overall encoding.
@ TRIG_POS_END_GR
Boundary between graphs.
@ TRIG_POS_START
Start of overall encoding.
@ TRIG_POS_START_BODY
After writing prolog.
@ TRIG_POS_GRAPH
Inside a graph.