aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-10 19:29:22 +0200
committerDavid Robillard <d@drobilla.net>2019-04-13 19:15:32 +0200
commit38ab5fbb4dd2bc6cb24b80cc346546677f3d2813 (patch)
tree29e885fd426c0c8745b3daf72b18ca2e6380fcc8 /serd
parent19b358a447cf62da8aff1f4ef0235b04f39499eb (diff)
downloadserd-38ab5fbb4dd2bc6cb24b80cc346546677f3d2813.tar.gz
serd-38ab5fbb4dd2bc6cb24b80cc346546677f3d2813.tar.bz2
serd-38ab5fbb4dd2bc6cb24b80cc346546677f3d2813.zip
Add SerdSink interface and hide individual function implementations
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h68
1 files changed, 19 insertions, 49 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 3698d30c..e90d43e7 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -711,6 +711,17 @@ typedef SerdStatus (*SerdEndSink)(void* handle,
const SerdNode* node);
/**
+ An interface that receives a stream of RDF data.
+*/
+typedef struct SerdSink {
+ void* handle;
+ SerdBaseSink base;
+ SerdPrefixSink prefix;
+ SerdStatementSink statement;
+ SerdEndSink end;
+} SerdSink;
+
+/**
@}
@name Environment
@{
@@ -817,13 +828,7 @@ serd_env_foreach(const SerdEnv* env,
*/
SERD_API
SerdReader*
-serd_reader_new(SerdSyntax syntax,
- void* handle,
- void (*free_handle)(void*),
- SerdBaseSink base_sink,
- SerdPrefixSink prefix_sink,
- SerdStatementSink statement_sink,
- SerdEndSink end_sink);
+serd_reader_new(SerdSyntax syntax, const SerdSink* sink);
/**
Enable or disable strict parsing.
@@ -849,13 +854,6 @@ serd_reader_set_error_sink(SerdReader* reader,
void* error_handle);
/**
- Return the `handle` passed to serd_reader_new().
-*/
-SERD_API
-void*
-serd_reader_get_handle(const SerdReader* reader);
-
-/**
Set a prefix to be added to all blank node identifiers.
This is useful when multiple files are to be parsed into the same output
@@ -981,6 +979,13 @@ void
serd_writer_free(SerdWriter* writer);
/**
+ Return a sink interface that emits statements via `writer`.
+*/
+SERD_API
+const SerdSink*
+serd_writer_get_sink(SerdWriter* writer);
+
+/**
Return the env used by `writer`.
*/
SERD_API
@@ -1055,41 +1060,6 @@ serd_writer_set_root_uri(SerdWriter* writer,
const SerdNode* uri);
/**
- Set a namespace prefix (and emit directive if applicable).
-
- Note this function can be safely casted to SerdPrefixSink.
-*/
-SERD_API
-SerdStatus
-serd_writer_set_prefix(SerdWriter* writer,
- const SerdNode* name,
- const SerdNode* uri);
-
-/**
- Write a statement.
-
- Note this function can be safely casted to SerdStatementSink.
-*/
-SERD_API
-SerdStatus
-serd_writer_write_statement(SerdWriter* writer,
- SerdStatementFlags flags,
- const SerdNode* graph,
- const SerdNode* subject,
- const SerdNode* predicate,
- const SerdNode* object);
-
-/**
- Mark the end of an anonymous node's description.
-
- Note this function can be safely casted to SerdEndSink.
-*/
-SERD_API
-SerdStatus
-serd_writer_end_anon(SerdWriter* writer,
- const SerdNode* node);
-
-/**
Finish a write.
*/
SERD_API