diff options
author | David Robillard <d@drobilla.net> | 2018-07-08 18:46:38 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:05 -0500 |
commit | eb0700d313915e2b291bdb91271c2e7ec3d9ba84 (patch) | |
tree | 9032a2e68945346f6bf1b64872a73540b07bd016 /include/serd | |
parent | a79d62b9f8c0a75efe56d135a0f08b898969338d (diff) | |
download | serd-eb0700d313915e2b291bdb91271c2e7ec3d9ba84.tar.gz serd-eb0700d313915e2b291bdb91271c2e7ec3d9ba84.tar.bz2 serd-eb0700d313915e2b291bdb91271c2e7ec3d9ba84.zip |
Expose SerdByteSink in public API
Diffstat (limited to 'include/serd')
-rw-r--r-- | include/serd/serd.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h index dd88a23f..b724e810 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -102,6 +102,9 @@ typedef struct SerdWriterImpl SerdWriter; /// An interface that receives a stream of RDF data typedef struct SerdSinkImpl SerdSink; +/// A sink for bytes that receives string output +typedef struct SerdByteSinkImpl SerdByteSink; + /// Return status code typedef enum { SERD_SUCCESS, ///< No error @@ -401,6 +404,41 @@ typedef size_t (*SerdWriteFunc)(const void* SERD_NONNULL buf, void* SERD_NONNULL stream); /** + Create a new byte sink. + + @param write_func Function called with bytes to consume. + @param stream Context parameter passed to `sink`. + @param block_size Number of bytes to write per call. +*/ +SERD_API +SerdByteSink* SERD_ALLOCATED +serd_byte_sink_new(SerdWriteFunc SERD_NONNULL write_func, + void* SERD_NULLABLE stream, + size_t block_size); + +/** + Write to `sink`. + + Compatible with SerdWriteFunc. +*/ +SERD_API +size_t +serd_byte_sink_write(const void* SERD_NONNULL buf, + size_t size, + size_t nmemb, + SerdByteSink* SERD_NONNULL sink); + +/// Flush any pending output in `sink` to the underlying write function +SERD_API +void +serd_byte_sink_flush(SerdByteSink* SERD_NONNULL sink); + +/// Free `sink` +SERD_API +void +serd_byte_sink_free(SerdByteSink* SERD_NULLABLE sink); + +/** @} @defgroup serd_syntax Syntax Utilities @{ |