aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-11 20:58:38 +0000
committerDavid Robillard <d@drobilla.net>2011-12-11 20:58:38 +0000
commit6e4a3a9ea93155e74da4b00fd7cf1b88b2d08f5f (patch)
treed0c8a0018719d957c10e73b2b0cc5765f09b11e9 /serd
parent4f2be9d332594f1fdd494437e6f7d5468c1c6022 (diff)
downloadserd-6e4a3a9ea93155e74da4b00fd7cf1b88b2d08f5f.tar.gz
serd-6e4a3a9ea93155e74da4b00fd7cf1b88b2d08f5f.tar.bz2
serd-6e4a3a9ea93155e74da4b00fd7cf1b88b2d08f5f.zip
Add SerdBulkSink for writing bulk output and corresponding serdi -B option.
git-svn-id: http://svn.drobilla.net/serd/trunk@242 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h52
1 files changed, 46 insertions, 6 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 79f164ea..94499a4d 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -267,10 +267,55 @@ serd_strlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags);
/**
@}
- @name URI
+ @name Sink
@{
*/
+/**
+ Sink function for raw string output.
+*/
+typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream);
+
+/**
+ Sink adapter that writes blocks to the target sink.
+
+ This is itself a SerdSink which can be used with any SerdSink as a target to
+ transparently write chunked I/O to the output sink. This can significantly
+ improve write performance when the target is a file or similar resource.
+*/
+typedef struct SerdBulkSinkImpl SerdBulkSink;
+
+/**
+ Create a new bulk sink adapter.
+ @param sink Target sink where completed blocks will be written.
+ @param stream Stream parameter for target sink.
+ @param block_size Size of blocks to write, and internal buffer size.
+*/
+SERD_API
+SerdBulkSink*
+serd_bulk_sink_new(SerdSink sink, void* stream, size_t block_size);
+
+/**
+ Free a bulk sink adapter.
+*/
+SERD_API
+void
+serd_bulk_sink_free(SerdBulkSink* bsink);
+
+/**
+ Write data to a bulk sink adapter.
+
+ This function may safely be cast to SerdSink.
+*/
+SERD_API
+size_t
+serd_bulk_sink_write(const void* buf, size_t len, SerdBulkSink* bsink);
+
+/**
+ @}
+ @name URI
+ @{
+*/
static const SerdURI SERD_URI_NULL = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
/**
@@ -302,11 +347,6 @@ void
serd_uri_resolve(const SerdURI* uri, const SerdURI* base, SerdURI* out);
/**
- Sink function for raw string output.
-*/
-typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream);
-
-/**
Serialise @c uri with a series of calls to @c sink.
*/
SERD_API