aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-16 12:42:58 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit2f2f791edb3ae4ccb825db548050461568570e03 (patch)
tree69be27d0d5fc7bac9897550185e02b579eaaf197 /serd
parent45358052fb4fa254f06d0d704a27c5ed9608cc58 (diff)
downloadserd-2f2f791edb3ae4ccb825db548050461568570e03.tar.gz
serd-2f2f791edb3ae4ccb825db548050461568570e03.tar.bz2
serd-2f2f791edb3ae4ccb825db548050461568570e03.zip
Simplify reader interface
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h55
1 files changed, 18 insertions, 37 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 4f0d8a6b..1333b61a 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -25,7 +25,6 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include <stdio.h>
#ifdef SERD_SHARED
# ifdef _WIN32
@@ -847,34 +846,26 @@ serd_reader_read_file(SerdReader* reader,
const char* uri);
/**
- Start an incremental read from a file handle.
+ Prepare to read from a stream.
- Iff `bulk` is true, `file` will be read a page at a time. This is more
- efficient, but uses a page of memory and means that an entire page of input
- must be ready before any callbacks will fire. To react as soon as input
- arrives, set `bulk` to false.
+ The `read_func` is guaranteed to only be called for `page_size` elements
+ with size 1 (i.e. `page_size` bytes).
*/
SERD_API
SerdStatus
-serd_reader_start_stream(SerdReader* reader,
- FILE* file,
- const char* name,
- bool bulk);
+serd_reader_start_stream(SerdReader* reader,
+ SerdSource read_func,
+ SerdStreamErrorFunc error_func,
+ void* stream,
+ const char* name,
+ size_t page_size);
/**
- Start an incremental read from a user-specified source.
-
- The `read_func` is guaranteed to only be called for `page_size` elements
- with size 1 (i.e. `page_size` bytes).
+ Prepare to read from a string.
*/
SERD_API
SerdStatus
-serd_reader_start_source_stream(SerdReader* reader,
- SerdSource read_func,
- SerdStreamErrorFunc error_func,
- void* stream,
- const char* name,
- size_t page_size);
+serd_reader_start_string(SerdReader* reader, const char* utf8);
/**
Read a single "chunk" of data during an incremental read.
@@ -889,32 +880,22 @@ SerdStatus
serd_reader_read_chunk(SerdReader* reader);
/**
- Finish an incremental read from a file handle.
-*/
-SERD_API
-SerdStatus
-serd_reader_end_stream(SerdReader* reader);
+ Read a complete document from the source.
-/**
- Read `file`.
+ This function will continue pulling from the source until a complete
+ document has been read. Note that this may block when used with streams,
+ for incremental reading use serd_reader_read_chunk().
*/
SERD_API
SerdStatus
-serd_reader_read_file_handle(SerdReader* reader,
- FILE* file,
- const char* name);
+serd_reader_read_document(SerdReader* reader);
/**
- Read a user-specified byte source.
+ Finish reading from the source.
*/
SERD_API
SerdStatus
-serd_reader_read_source(SerdReader* reader,
- SerdSource source,
- SerdStreamErrorFunc error,
- void* stream,
- const char* name,
- size_t page_size);
+serd_reader_end_stream(SerdReader* reader);
/**
Read `utf8`.