diff options
author | David Robillard <d@drobilla.net> | 2021-03-01 19:38:01 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | c2e59da8865a8c5719b8ddaf5f68204729a8ebab (patch) | |
tree | 4a8c2eb24c4a274eac41a226df6679a6319b6ac4 /src/reader.c | |
parent | b631e7a3d6a807aaf4919396b62ba96e1a9f0bd9 (diff) | |
download | serd-c2e59da8865a8c5719b8ddaf5f68204729a8ebab.tar.gz serd-c2e59da8865a8c5719b8ddaf5f68204729a8ebab.tar.bz2 serd-c2e59da8865a8c5719b8ddaf5f68204729a8ebab.zip |
Add SerdSink interface and hide implementations
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/src/reader.c b/src/reader.c index c7919ca6..284de45d 100644 --- a/src/reader.c +++ b/src/reader.c @@ -143,14 +143,12 @@ emit_statement(SerdReader* const reader, const ReadContext ctx, const Ref o) graph = reader->default_graph; } - const SerdStatus st = !reader->statement_func - ? SERD_SUCCESS - : reader->statement_func(reader->handle, - *ctx.flags, - graph, - deref(reader, ctx.subject), - deref(reader, ctx.predicate), - deref(reader, o)); + const SerdStatus st = serd_sink_write(reader->sink, + *ctx.flags, + deref(reader, ctx.subject), + deref(reader, ctx.predicate), + deref(reader, o), + graph); *ctx.flags &= SERD_ANON_CONT | SERD_LIST_CONT; // Preserve only cont flags return st; @@ -164,26 +162,16 @@ read_doc(SerdReader* const reader) } SerdReader* -serd_reader_new(const SerdSyntax syntax, - void* const handle, - void (*const free_handle)(void*), - const SerdBaseFunc base_func, - const SerdPrefixFunc prefix_func, - const SerdStatementFunc statement_func, - const SerdEndFunc end_func) +serd_reader_new(const SerdSyntax syntax, const SerdSink* const sink) { - SerdReader* me = (SerdReader*)calloc(1, sizeof(SerdReader)); - me->handle = handle; - me->free_handle = free_handle; - me->base_func = base_func; - me->prefix_func = prefix_func; - me->statement_func = statement_func; - me->end_func = end_func; - me->default_graph = NULL; - me->stack = serd_stack_new(SERD_PAGE_SIZE); - me->syntax = syntax; - me->next_id = 1; - me->strict = true; + SerdReader* me = (SerdReader*)calloc(1, sizeof(SerdReader)); + + me->sink = sink; + me->default_graph = NULL; + me->stack = serd_stack_new(SERD_PAGE_SIZE); + me->syntax = syntax; + me->next_id = 1; + me->strict = true; me->rdf_first = push_node(me, SERD_URI, NS_RDF "first", 48); me->rdf_rest = push_node(me, SERD_URI, NS_RDF "rest", 47); @@ -224,18 +212,9 @@ serd_reader_free(SerdReader* const reader) #endif free(reader->stack.buf); free(reader->bprefix); - if (reader->free_handle) { - reader->free_handle(reader->handle); - } free(reader); } -void* -serd_reader_handle(const SerdReader* const reader) -{ - return reader->handle; -} - void serd_reader_add_blank_prefix(SerdReader* const reader, const char* const prefix) { |