aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.c')
-rw-r--r--src/reader.c51
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)
{