diff options
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 @{ |