diff options
author | David Robillard <d@drobilla.net> | 2018-05-10 19:29:22 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:58 +0100 |
commit | 79bd5c789631ea51071564813046e34b304e1bc7 (patch) | |
tree | 8c58ef6692972eb41d0894a6267d3868217cd2a4 /serd | |
parent | ce6fbad56fb6970fe507186d6560ad4fac981d74 (diff) | |
download | serd-79bd5c789631ea51071564813046e34b304e1bc7.tar.gz serd-79bd5c789631ea51071564813046e34b304e1bc7.tar.bz2 serd-79bd5c789631ea51071564813046e34b304e1bc7.zip |
Add SerdSink interface and hide individual function implementations
Diffstat (limited to 'serd')
-rw-r--r-- | serd/serd.h | 68 |
1 files changed, 19 insertions, 49 deletions
diff --git a/serd/serd.h b/serd/serd.h index fa43f7c6..0cc64090 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 @{ @@ -809,13 +820,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. @@ -841,13 +846,6 @@ serd_reader_set_error_sink(SerdReader* reader, void* error_handle); /** - Return the `handle` passed to serd_reader_new(). -*/ -SERD_API -void* -serd_reader_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 @@ -973,6 +971,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 @@ -1047,41 +1052,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 |