31trig_build_prolog (TRIGEncodeIterator *it,
char **res_p)
36 char *ns_tpl =
"@prefix %s: <%s> .\n";
39 for (
size_t i = 0; nsm[i]; i++) {
40 const char **ns = nsm[i];
41 size_t old_len = strlen (res);
42 size_t ns_len = strlen (ns[0]) + strlen (ns[1]) + strlen (ns_tpl);
43 char *tmp = realloc (res, old_len + ns_len + 1);
47 sprintf (res + old_len, ns_tpl, ns[0], ns[1]);
65 log_error (
"Store is not context-aware.");
68 TRIGEncodeIterator *it;
86 TRIGEncodeIterator *it = h;
91 if (it->pos ==
TRIG_POS_START)
return trig_build_prolog (it, res_p);
97 char *gr_uri_trig = NULL;
119 out_size += strlen (gr_uri_trig) + 4;
127 log_info (
"End of store encoding.");
131 char *res = realloc (*res_p, out_size);
147 sprintf (res,
"}\n");
151 if (!gr_uri_trig) sprintf (res + offset,
"\n{\n");
153 sprintf (res + offset,
"\n%s {\n", gr_uri_trig);
169 TRIGEncodeIterator *it = h;
char * fmt_header(char *pfx)
Format an informational header.
@ VOLK_CODEC_NO_PROLOG
Do not generate prolog.
VOLK_TermSet * VOLK_graph_list_txn(void *txn, VOLK_Store *store)
List all graph URIs in a store.
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.
#define RCNL(exp)
Return NULL if exp returns a nonzero value.
#define NLNL(exp)
Log error and return NULL if exp is NULL.
#define CALLOC_GUARD(var, rc)
Allocate one pointer with calloc and return rc if it fails.
#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_STORE_TXN_RO
Start a read-only transaction.
VOLK_StoreFeature VOLK_store_features(const VOLK_Store *store)
Feature flags belonging to the store interface.
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.
struct hashmap VOLK_TermSet
a set of unique terms.
bool VOLK_term_equals(const VOLK_Term *term1, const VOLK_Term *term2)
Compare two terms.
void VOLK_term_set_free(VOLK_TermSet *ts)
Free a term set.
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.
void * trig_encode_store_init(VOLK_Store *store)
Initialize a store encoding loop.
void trig_encode_store_done(void *h)
Finalize the store encoding loop.
VOLK_rc trig_encode_store_iter(void *h, char **res_p)
Encode a chunk from a store.
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.
VOLK_TermSet * gr_uri_ts
Term set of named graph URIs.
TTLEncodeIterator * gr_it
Current graph iterator.
VOLK_Store * store
Store pointer for store encoding.
VOLK_Graph * gr
Current graph.
VOLK_rc rc
Internal return code.
TRIGPos pos
Encoder position.
@ 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.