From 7b022006c47586dc00ed8bca85fcb0bdf5f9465d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Mar 2012 20:55:00 +0000 Subject: Add serd_chunk_sink for easy writing to a string. git-svn-id: http://svn.drobilla.net/serd/trunk@329 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- serd/serd.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'serd/serd.h') diff --git a/serd/serd.h b/serd/serd.h index 8cca4a3f..ba4e6fb5 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -696,12 +696,34 @@ serd_writer_free(SerdWriter* writer); A convenience sink function for writing to a FILE*. This function can be used as a SerdSink when writing to a FILE*. The - associated @c stream parameter must be a FILE* opened for writing. + @c stream parameter must be a FILE* opened for writing. */ SERD_API size_t serd_file_sink(const void* buf, size_t len, void* stream); +/** + A convenience sink function for writing to a string. + + This function can be used as a SerdSink to write to a SerdChunk which is + resized as necessary with realloc(). The @c stream parameter must point to + an initialized SerdChunk. When the write is finished, the string should be + retrieved with serd_chunk_sink_finish(). +*/ +SERD_API +size_t +serd_chunk_sink(const void* buf, size_t len, void* stream); + +/** + Finish a serialisation to a chunk with serd_chunk_sink(). + + The returned string is the result of the serialisation, which is NULL + terminated (by this function) and owned by the caller. +*/ +SERD_API +uint8_t* +serd_chunk_sink_finish(SerdChunk* stream); + /** Set a prefix to be removed from matching blank node identifiers. */ -- cgit v1.2.1