diff options
author | David Robillard <d@drobilla.net> | 2018-07-08 18:46:38 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-13 23:04:01 -0500 |
commit | 480bcd2744779686916763e9a5a876afd43643b4 (patch) | |
tree | b6ee99ad336a3967e85b911eedad331b8155cbf2 /include/serd | |
parent | cbb04334e5f422ab28d12f7a4c8a60eda1c94a89 (diff) | |
download | serd-480bcd2744779686916763e9a5a876afd43643b4.tar.gz serd-480bcd2744779686916763e9a5a876afd43643b4.tar.bz2 serd-480bcd2744779686916763e9a5a876afd43643b4.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 9a414b11..66f22cbd 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -258,6 +258,9 @@ serd_strlen(const char* SERD_NONNULL str, SerdNodeFlags* SERD_NULLABLE flags); @{ */ +/// A sink for bytes that receives text output +typedef struct SerdByteSinkImpl SerdByteSink; + /** Function to detect I/O stream errors. @@ -302,6 +305,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 @{ |