diff options
author | David Robillard <d@drobilla.net> | 2020-08-16 12:42:58 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:24 -0500 |
commit | 9a8e06aa5bdc62ed589bd8ed5789bd059cec0700 (patch) | |
tree | ba5263262fad84c5f58bd60f3c6f6fcba30d6516 /include/serd/serd.h | |
parent | d4ae57afbd7da668dbf89f7b7e66e2f064437a98 (diff) | |
download | serd-9a8e06aa5bdc62ed589bd8ed5789bd059cec0700.tar.gz serd-9a8e06aa5bdc62ed589bd8ed5789bd059cec0700.tar.bz2 serd-9a8e06aa5bdc62ed589bd8ed5789bd059cec0700.zip |
Simplify reader interface
Diffstat (limited to 'include/serd/serd.h')
-rw-r--r-- | include/serd/serd.h | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h index c2c9d52d..000a8ef8 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -23,7 +23,6 @@ #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdio.h> #if defined(_WIN32) && !defined(SERD_STATIC) && defined(SERD_INTERNAL) # define SERD_API __declspec(dllexport) @@ -877,34 +876,25 @@ serd_reader_read_file(SerdReader* SERD_NONNULL reader, const char* SERD_NONNULL uri); /** - Start an incremental read from a file handle. - - 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. -*/ -SERD_API -SerdStatus -serd_reader_start_stream(SerdReader* SERD_NONNULL reader, - FILE* SERD_NONNULL file, - const char* SERD_NULLABLE name, - bool bulk); - -/** - Start an incremental read from a user-specified source. + Prepare to read from a stream. 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_source_stream(SerdReader* SERD_NONNULL reader, - SerdSource SERD_NONNULL read_func, - SerdStreamErrorFunc SERD_NONNULL error_func, - void* SERD_NONNULL stream, - const char* SERD_NULLABLE name, - size_t page_size); +serd_reader_start_stream(SerdReader* SERD_NONNULL reader, + SerdSource SERD_NONNULL read_func, + SerdStreamErrorFunc SERD_NONNULL error_func, + void* SERD_NONNULL stream, + const char* SERD_NULLABLE name, + size_t page_size); + +/// Prepare to read from a string +SERD_API +SerdStatus +serd_reader_start_string(SerdReader* SERD_NONNULL reader, + const char* SERD_NONNULL utf8); /** Read a single "chunk" of data during an incremental read @@ -918,27 +908,21 @@ SERD_API SerdStatus serd_reader_read_chunk(SerdReader* SERD_NONNULL reader); -/// Finish an incremental read from a file handle -SERD_API -SerdStatus -serd_reader_end_stream(SerdReader* SERD_NONNULL 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* SERD_NONNULL reader, - FILE* SERD_NONNULL file, - const char* SERD_NULLABLE name); +serd_reader_read_document(SerdReader* SERD_NONNULL reader); -/// Read a user-specified byte source +/// Finish reading from the source SERD_API SerdStatus -serd_reader_read_source(SerdReader* SERD_NONNULL reader, - SerdSource SERD_NONNULL source, - SerdStreamErrorFunc SERD_NONNULL error, - void* SERD_NONNULL stream, - const char* SERD_NULLABLE name, - size_t page_size); +serd_reader_end_stream(SerdReader* SERD_NONNULL reader); /// Read `utf8` SERD_API |