diff options
author | David Robillard <d@drobilla.net> | 2021-07-11 20:47:51 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | 6eb1fa15a06ab7de08e33add1540a45b83c5f0d8 (patch) | |
tree | 86d3cfedbf2ff76878eba6d14dc7fc259d1cbf46 /include/serd/world.h | |
parent | d1ba721d37af61f2b529faaa16bd20ba1e161b06 (diff) | |
download | serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.tar.gz serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.tar.bz2 serd-6eb1fa15a06ab7de08e33add1540a45b83c5f0d8.zip |
Add SerdWorld for shared library state
Diffstat (limited to 'include/serd/world.h')
-rw-r--r-- | include/serd/world.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/serd/world.h b/include/serd/world.h new file mode 100644 index 00000000..22ae57ed --- /dev/null +++ b/include/serd/world.h @@ -0,0 +1,51 @@ +// Copyright 2011-2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#ifndef SERD_WORLD_H +#define SERD_WORLD_H + +#include "serd/attributes.h" +#include "serd/error.h" + +SERD_BEGIN_DECLS + +/** + @defgroup serd_world World + @ingroup serd_library + @{ +*/ + +/// Global library state +typedef struct SerdWorldImpl SerdWorld; + +/** + Create a new Serd World. + + It is safe to use multiple worlds in one process, though no objects can be + shared between worlds. +*/ +SERD_MALLOC_API SerdWorld* SERD_ALLOCATED +serd_world_new(void); + +/// Free `world` +SERD_API void +serd_world_free(SerdWorld* SERD_NULLABLE world); + +/** + Set a function to be called when errors occur. + + The `error_func` 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_func(SerdWorld* SERD_NONNULL world, + SerdErrorFunc SERD_NULLABLE error_func, + void* SERD_NULLABLE handle); + +/** + @} +*/ + +SERD_END_DECLS + +#endif // SERD_WORLD_H |