From 0c7ba16331f4219dba705acd19d0cd3599e4e50d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 3 Feb 2011 20:08:22 +0000 Subject: Add ability to set blank node prefix for parsing multiple files without conflict. git-svn-id: http://svn.drobilla.net/sord/trunk@16 3d64ff67-21c5-427c-a301-fe4f08042e5a --- sord/sord.h | 6 ++++-- src/sordi.c | 2 +- src/syntax.c | 13 ++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sord/sord.h b/sord/sord.h index 5b05587..2d702a6 100644 --- a/sord/sord.h +++ b/sord/sord.h @@ -360,14 +360,16 @@ SORD_API bool sord_read_file(Sord sord, const uint8_t* uri, - const SordNode graph); + const SordNode graph, + const uint8_t* blank_prefix); SORD_API bool sord_read_file_handle(Sord sord, FILE* fd, const uint8_t* base_uri, - const SordNode graph); + const SordNode graph, + const uint8_t* blank_prefix); /** @} */ diff --git a/src/sordi.c b/src/sordi.c index ac05a2a..f304b9e 100644 --- a/src/sordi.c +++ b/src/sordi.c @@ -121,7 +121,7 @@ main(int argc, char** argv) Sord sord = sord_new(); sord_open(sord); - bool success = sord_read_file(sord, input, NULL); + bool success = sord_read_file(sord, input, NULL, NULL); printf("loaded %u statements\n", sord_num_nodes(sord)); diff --git a/src/syntax.c b/src/syntax.c index 4a6567d..47e2d52 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -180,7 +180,8 @@ SORD_API bool sord_read_file(Sord sord, const uint8_t* input, - const SordNode graph) + const SordNode graph, + const uint8_t* blank_prefix) { const uint8_t* filename = NULL; if (serd_uri_string_has_scheme(input)) { @@ -203,7 +204,8 @@ sord_read_file(Sord sord, return 1; } - const bool success = sord_read_file_handle(sord, in_fd, input, graph); + const bool success = sord_read_file_handle( + sord, in_fd, input, graph, blank_prefix); fclose(in_fd); return success; @@ -214,7 +216,8 @@ bool sord_read_file_handle(Sord sord, FILE* fd, const uint8_t* base_uri_str_in, - const SordNode graph) + const SordNode graph, + const uint8_t* blank_prefix) { size_t base_uri_n_bytes = 0; uint8_t* base_uri_str = copy_string(base_uri_str_in, &base_uri_n_bytes); @@ -236,6 +239,10 @@ sord_read_file_handle(Sord sord, SERD_TURTLE, &state, event_base, event_prefix, event_statement, NULL); + if (blank_prefix) { + serd_reader_set_blank_prefix(state.reader, blank_prefix); + } + const bool success = serd_reader_read_file(state.reader, fd, base_uri_str); serd_reader_free(state.reader); -- cgit v1.2.1