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]);
64 log_error (
"Store is not context-aware.");
67 TRIGEncodeIterator *it;
86 TRIGEncodeIterator *it = h;
89 if (it->pos ==
TRIG_POS_START)
return trig_build_prolog (it, res_p);
95 char *gr_uri_trig = NULL;
109 out_size += strlen (gr_uri_trig) + 4;
117 char *tmp = realloc (*res_p, out_size);
130 sprintf (*res_p,
"}\n");
135 sprintf (*res_p + offset,
"\n%s {\n", gr_uri_trig);
136 offset += strlen (gr_uri_trig) + 3;
140 *res_p[offset] =
'0';
152 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.
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 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.
void VOLK_term_set_free(VOLK_TermSet *ts)
Free a term set.
void VOLK_term_free(VOLK_Term *term)
VOLK_Term * VOLK_term_set_pop(VOLK_TermSet *ts)
Pop a term from a term set.
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_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.
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)
void ttl_encode_graph_done(void *h)
VOLK_rc ttl_encode_graph_iter(void *h, char **res_p)
void * ttl_encode_graph_init(const VOLK_Graph *gr, VOLK_CodecFlags flags)