diff options
author | David Robillard <d@drobilla.net> | 2018-04-29 15:24:05 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-25 15:58:21 +0100 |
commit | bcf32f9b340083c97dc2c2b144b971bb1de06a23 (patch) | |
tree | 9f9726c0e6bae3dc50fba8c0be0c3fbd9876444f /serd | |
parent | f2a19949d0da60465e2d68b5e66a52e0d970ebd1 (diff) | |
download | serd-bcf32f9b340083c97dc2c2b144b971bb1de06a23.tar.gz serd-bcf32f9b340083c97dc2c2b144b971bb1de06a23.tar.bz2 serd-bcf32f9b340083c97dc2c2b144b971bb1de06a23.zip |
Add SerdWorld for shared library state
Diffstat (limited to 'serd')
-rw-r--r-- | serd/serd.h | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/serd/serd.h b/serd/serd.h index a7601f9a..1462ebbd 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -56,6 +56,13 @@ extern "C" { */ /** + World. + + The World represents all library state shared between various objects. +*/ +typedef struct SerdWorldImpl SerdWorld; + +/** Environment. Represents the state required to resolve a CURIE or relative URI, e.g. the @@ -724,6 +731,41 @@ typedef struct SerdSink { /** @} + @name World + @{ +*/ + +/** + Create a new Serd World. + + It is safe to use multiple worlds in one process, though no objects can be + shared between worlds. +*/ +SERD_API +SerdWorld* +serd_world_new(void); + +/** + Free `world`. +*/ +SERD_API +void +serd_world_free(SerdWorld* world); + +/** + Set a function to be called when errors occur. + + The `error_sink` will be called with `handle` as its first argument. If + no error function is set, errors are printed to stderr. +*/ +SERD_API +void +serd_world_set_error_sink(SerdWorld* world, + SerdErrorSink error_sink, + void* handle); + +/** + @} @name Environment @{ */ @@ -829,7 +871,7 @@ serd_env_foreach(const SerdEnv* env, */ SERD_API SerdReader* -serd_reader_new(SerdSyntax syntax, const SerdSink* sink); +serd_reader_new(SerdWorld* world, SerdSyntax syntax, const SerdSink* sink); /** Enable or disable strict parsing. @@ -843,18 +885,6 @@ void serd_reader_set_strict(SerdReader* reader, bool strict); /** - Set a function to be called when errors occur during reading. - - The `error_sink` will be called with `handle` as its first argument. If - no error function is set, errors are printed to stderr in GCC style. -*/ -SERD_API -void -serd_reader_set_error_sink(SerdReader* reader, - SerdErrorSink error_sink, - void* error_handle); - -/** Set a prefix to be added to all blank node identifiers. This is useful when multiple files are to be parsed into the same output @@ -965,7 +995,8 @@ serd_reader_free(SerdReader* reader); */ SERD_API SerdWriter* -serd_writer_new(SerdSyntax syntax, +serd_writer_new(SerdWorld* world, + SerdSyntax syntax, SerdStyle style, SerdEnv* env, const SerdURI* base_uri, @@ -1016,18 +1047,6 @@ char* serd_buffer_sink_finish(SerdBuffer* stream); /** - Set a function to be called when errors occur during writing. - - The `error_sink` will be called with `handle` as its first argument. If - no error function is set, errors are printed to stderr. -*/ -SERD_API -void -serd_writer_set_error_sink(SerdWriter* writer, - SerdErrorSink error_sink, - void* error_handle); - -/** Set a prefix to be removed from matching blank node identifiers. */ SERD_API |