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-12-19 20:52:29 -0500
commit9577022620cab6005c7f46348c617898f068e479 (patch)
tree6620b339e0a9d1f2c49f0ce8ada71f37e9e4ba7c /serd
parent18f7a9afa3155437e18fd2d99c6c065a1e7299b9 (diff)
downloadserd-9577022620cab6005c7f46348c617898f068e479.tar.gz
serd-9577022620cab6005c7f46348c617898f068e479.tar.bz2
serd-9577022620cab6005c7f46348c617898f068e479.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 fbe67682..51248442 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -704,6 +704,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
@{
@@ -810,13 +821,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.
@@ -842,13 +847,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
@@ -974,6 +972,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
@@ -1048,41 +1053,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