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 d5de67d2..805d41a7 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -132,14 +132,12 @@ emit_statement(SerdReader* reader, ReadContext ctx, 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;
@@ -166,26 +164,16 @@ serd_reader_read_document(SerdReader* reader)
}
SerdReader*
-serd_reader_new(SerdSyntax syntax,
- void* handle,
- void (*free_handle)(void*),
- SerdBaseFunc base_func,
- SerdPrefixFunc prefix_func,
- SerdStatementFunc statement_func,
- SerdEndFunc end_func)
+serd_reader_new(SerdSyntax syntax, const SerdSink* 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);
@@ -226,18 +214,9 @@ serd_reader_free(SerdReader* 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* reader)
-{
- return reader->handle;
-}
-
void
serd_reader_add_blank_prefix(SerdReader* reader, const char* prefix)
{