aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-06-15 15:15:55 -0400
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit0aff74b23f4d85d7f157f25d399c14b6a78e998b (patch)
tree917ef773266f5b9417a1c394f2f8451ae774a49c /serd
parent9baa0127ea016c3ee409a64563b960cff135bbdb (diff)
downloadserd-0aff74b23f4d85d7f157f25d399c14b6a78e998b.tar.gz
serd-0aff74b23f4d85d7f157f25d399c14b6a78e998b.tar.bz2
serd-0aff74b23f4d85d7f157f25d399c14b6a78e998b.zip
Make SerdSink opaque
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h63
1 files changed, 52 insertions, 11 deletions
diff --git a/serd/serd.h b/serd/serd.h
index be3ea586..deef03da 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -103,6 +103,11 @@ typedef struct SerdReaderImpl SerdReader;
typedef struct SerdWriterImpl SerdWriter;
/**
+ An interface that receives a stream of RDF data.
+*/
+typedef struct SerdSinkImpl SerdSink;
+
+/**
Return status code.
*/
typedef enum {
@@ -831,17 +836,6 @@ 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 World
@{
@@ -970,6 +964,53 @@ serd_env_foreach(const SerdEnv* env,
*/
/**
+ Create a new sink.
+
+ Initially, the sink has no set functions and will do nothing. Use the
+ serd_sink_set_*_func functions to set handlers for various events.
+
+ @param handle Opaque handle that will be passed to sink functions.
+*/
+SERD_API
+SerdSink*
+serd_sink_new(void* handle);
+
+/**
+ Free `sink`.
+*/
+SERD_API
+void
+serd_sink_free(SerdSink* sink);
+
+/**
+ Set a function to be called when the base URI changes.
+*/
+SERD_API
+SerdStatus
+serd_sink_set_base_func(SerdSink* sink, SerdBaseSink base_func);
+
+/**
+ Set a function to be called when a namespace prefix is defined.
+*/
+SERD_API
+SerdStatus
+serd_sink_set_prefix_func(SerdSink* sink, SerdPrefixSink prefix_func);
+
+/**
+ Set a function to be called when a statement is emitted.
+*/
+SERD_API
+SerdStatus
+serd_sink_set_statement_func(SerdSink* sink, SerdStatementSink statement_func);
+
+/**
+ Set a function to be called when an anonymous node ends.
+*/
+SERD_API
+SerdStatus
+serd_sink_set_end_func(SerdSink* sink, SerdEndSink end_func);
+
+/**
Set the base URI.
Simple wrapper for the `SerdBaseSink` of `sink`.