diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/serd/attributes.h | 35 | ||||
-rw-r--r-- | include/serd/buffer.h | 18 | ||||
-rw-r--r-- | include/serd/caret.h | 28 | ||||
-rw-r--r-- | include/serd/env.h | 45 | ||||
-rw-r--r-- | include/serd/error.h | 12 | ||||
-rw-r--r-- | include/serd/event.h | 25 | ||||
-rw-r--r-- | include/serd/memory.h | 2 | ||||
-rw-r--r-- | include/serd/node.h | 94 | ||||
-rw-r--r-- | include/serd/reader.h | 49 | ||||
-rw-r--r-- | include/serd/sink.h | 70 | ||||
-rw-r--r-- | include/serd/statement.h | 61 | ||||
-rw-r--r-- | include/serd/status.h | 3 | ||||
-rw-r--r-- | include/serd/stream.h | 19 | ||||
-rw-r--r-- | include/serd/string.h | 11 | ||||
-rw-r--r-- | include/serd/string_view.h | 14 | ||||
-rw-r--r-- | include/serd/syntax.h | 5 | ||||
-rw-r--r-- | include/serd/uri.h | 19 | ||||
-rw-r--r-- | include/serd/world.h | 20 | ||||
-rw-r--r-- | include/serd/writer.h | 32 |
19 files changed, 288 insertions, 274 deletions
diff --git a/include/serd/attributes.h b/include/serd/attributes.h index 59063153..4ea4d41d 100644 --- a/include/serd/attributes.h +++ b/include/serd/attributes.h @@ -4,6 +4,8 @@ #ifndef SERD_ATTRIBUTES_H #define SERD_ATTRIBUTES_H +#include "zix/attributes.h" + /** @defgroup serd_attributes Attributes @ingroup serd_library @@ -43,41 +45,28 @@ // GCC function attributes #ifdef __GNUC__ -# define SERD_ALWAYS_INLINE_FUNC __attribute__((always_inline)) -# define SERD_CONST_FUNC __attribute__((const)) -# define SERD_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) -# define SERD_MALLOC_FUNC __attribute__((malloc)) # define SERD_NODISCARD __attribute__((warn_unused_result)) -# define SERD_PURE_FUNC __attribute__((pure)) #else -# define SERD_ALWAYS_INLINE_FUNC ///< Should absolutely always be inlined -# define SERD_CONST_FUNC ///< Only reads its parameters -# define SERD_LOG_FUNC(fmt, arg1) ///< Has printf-like parameters -# define SERD_MALLOC_FUNC ///< Allocates memory -# define SERD_NODISCARD ///< Returns a value that must be used -# define SERD_PURE_FUNC ///< Only reads memory +# define SERD_NODISCARD ///< Returns a value that must be used #endif -// Clang nullability annotations -#if defined(__clang__) && __clang_major__ >= 7 -# define SERD_NONNULL _Nonnull -# define SERD_NULLABLE _Nullable -# define SERD_ALLOCATED _Null_unspecified +// GCC print format attributes +#if defined(__MINGW32__) +# define SERD_LOG_FUNC(fmt, a0) __attribute__((format(gnu_printf, fmt, a0))) +#elif defined(__GNUC__) +# define SERD_LOG_FUNC(fmt, a0) __attribute__((format(printf, fmt, a0))) #else -# define SERD_NONNULL ///< A non-null pointer -# define SERD_NULLABLE ///< A nullable pointer -# define SERD_ALLOCATED ///< An allocated (possibly null) pointer -# define SERD_UNSPECIFIED ///< A pointer with unspecified nullability +# define SERD_LOG_FUNC(fmt, a0) ///< Has printf-like parameters #endif /// A pure function in the public API that only reads memory -#define SERD_PURE_API SERD_API SERD_PURE_FUNC +#define SERD_PURE_API SERD_API ZIX_PURE_FUNC /// A const function in the public API that is pure and only reads parameters -#define SERD_CONST_API SERD_API SERD_CONST_FUNC +#define SERD_CONST_API SERD_API ZIX_CONST_FUNC /// A malloc function in the public API that returns allocated memory -#define SERD_MALLOC_API SERD_API SERD_MALLOC_FUNC +#define SERD_MALLOC_API SERD_API ZIX_MALLOC_FUNC /** @} diff --git a/include/serd/buffer.h b/include/serd/buffer.h index f1bfa897..cf2170c3 100644 --- a/include/serd/buffer.h +++ b/include/serd/buffer.h @@ -5,6 +5,8 @@ #define SERD_BUFFER_H #include "serd/attributes.h" +#include "zix/allocator.h" +#include "zix/attributes.h" #include <stddef.h> @@ -21,8 +23,8 @@ SERD_BEGIN_DECLS /// A mutable buffer in memory typedef struct { - void* SERD_NULLABLE buf; ///< Buffer - size_t len; ///< Size of buffer in bytes + void* ZIX_NULLABLE buf; ///< Buffer + size_t len; ///< Size of buffer in bytes } SerdBuffer; /** @@ -34,10 +36,10 @@ typedef struct { retrieved with serd_buffer_sink_finish(). */ SERD_API size_t -serd_buffer_sink(const void* SERD_NONNULL buf, - size_t size, - size_t nmemb, - void* SERD_NONNULL stream); +serd_buffer_sink(const void* ZIX_NONNULL buf, + size_t size, + size_t nmemb, + void* ZIX_NONNULL stream); /** Finish writing to a buffer with serd_buffer_sink(). @@ -45,8 +47,8 @@ serd_buffer_sink(const void* SERD_NONNULL buf, The returned string is the result of the serialisation, which is null terminated (by this function) and owned by the caller. */ -SERD_API char* SERD_NONNULL -serd_buffer_sink_finish(SerdBuffer* SERD_NONNULL stream); +SERD_API char* ZIX_NONNULL +serd_buffer_sink_finish(SerdBuffer* ZIX_NONNULL stream); /** @} diff --git a/include/serd/caret.h b/include/serd/caret.h index 2ed77412..f8983899 100644 --- a/include/serd/caret.h +++ b/include/serd/caret.h @@ -6,6 +6,8 @@ #include "serd/attributes.h" #include "serd/node.h" +#include "zix/allocator.h" +#include "zix/attributes.h" #include <stdbool.h> @@ -33,23 +35,23 @@ typedef struct SerdCaretImpl SerdCaret; @param column The column number in the document (1-based) @return A new caret that must be freed with serd_caret_free() */ -SERD_API SerdCaret* SERD_ALLOCATED -serd_caret_new(const SerdNode* SERD_NONNULL document, - unsigned line, - unsigned column); +SERD_API SerdCaret* ZIX_ALLOCATED +serd_caret_new(const SerdNode* ZIX_NONNULL document, + unsigned line, + unsigned column); /// Return a copy of `caret` -SERD_API SerdCaret* SERD_ALLOCATED -serd_caret_copy(const SerdCaret* SERD_NULLABLE caret); +SERD_API SerdCaret* ZIX_ALLOCATED +serd_caret_copy(const SerdCaret* ZIX_NULLABLE caret); /// Free `caret` SERD_API void -serd_caret_free(SerdCaret* SERD_NULLABLE caret); +serd_caret_free(SerdCaret* ZIX_NULLABLE caret); /// Return true iff `lhs` is equal to `rhs` SERD_PURE_API bool -serd_caret_equals(const SerdCaret* SERD_NULLABLE lhs, - const SerdCaret* SERD_NULLABLE rhs); +serd_caret_equals(const SerdCaret* ZIX_NULLABLE lhs, + const SerdCaret* ZIX_NULLABLE rhs); /** Return the document URI or name. @@ -57,16 +59,16 @@ serd_caret_equals(const SerdCaret* SERD_NULLABLE lhs, This is typically a file URI, but may be a descriptive string node for statements that originate from streams. */ -SERD_PURE_API const SerdNode* SERD_NONNULL -serd_caret_document(const SerdCaret* SERD_NONNULL caret); +SERD_PURE_API const SerdNode* ZIX_NONNULL +serd_caret_document(const SerdCaret* ZIX_NONNULL caret); /// Return the one-relative line number in the document SERD_PURE_API unsigned -serd_caret_line(const SerdCaret* SERD_NONNULL caret); +serd_caret_line(const SerdCaret* ZIX_NONNULL caret); /// Return the zero-relative column number in the line SERD_PURE_API unsigned -serd_caret_column(const SerdCaret* SERD_NONNULL caret); +serd_caret_column(const SerdCaret* ZIX_NONNULL caret); /** @} diff --git a/include/serd/env.h b/include/serd/env.h index 404c96b6..bfbda520 100644 --- a/include/serd/env.h +++ b/include/serd/env.h @@ -9,6 +9,7 @@ #include "serd/sink.h" #include "serd/status.h" #include "serd/string_view.h" +#include "zix/attributes.h" #include <stdbool.h> @@ -24,28 +25,28 @@ SERD_BEGIN_DECLS typedef struct SerdEnvImpl SerdEnv; /// Create a new environment -SERD_API SerdEnv* SERD_ALLOCATED +SERD_API SerdEnv* ZIX_ALLOCATED serd_env_new(SerdStringView base_uri); /// Copy an environment -SERD_API SerdEnv* SERD_ALLOCATED -serd_env_copy(const SerdEnv* SERD_NULLABLE env); +SERD_API SerdEnv* ZIX_ALLOCATED +serd_env_copy(const SerdEnv* ZIX_NULLABLE env); /// Return true iff `a` is equal to `b` SERD_PURE_API bool -serd_env_equals(const SerdEnv* SERD_NULLABLE a, const SerdEnv* SERD_NULLABLE b); +serd_env_equals(const SerdEnv* ZIX_NULLABLE a, const SerdEnv* ZIX_NULLABLE b); /// Free `env` SERD_API void -serd_env_free(SerdEnv* SERD_NULLABLE env); +serd_env_free(SerdEnv* ZIX_NULLABLE env); /// Get the current base URI -SERD_PURE_API const SerdNode* SERD_NULLABLE -serd_env_base_uri(const SerdEnv* SERD_NULLABLE env); +SERD_PURE_API const SerdNode* ZIX_NULLABLE +serd_env_base_uri(const SerdEnv* ZIX_NULLABLE env); /// Set the current base URI SERD_API SerdStatus -serd_env_set_base_uri(SerdEnv* SERD_NONNULL env, SerdStringView uri); +serd_env_set_base_uri(SerdEnv* ZIX_NONNULL env, SerdStringView uri); /** Set a namespace prefix. @@ -55,9 +56,9 @@ serd_env_set_base_uri(SerdEnv* SERD_NONNULL env, SerdStringView uri); expand to "http://www.w3.org/2001/XMLSchema#decimal". */ SERD_API SerdStatus -serd_env_set_prefix(SerdEnv* SERD_NONNULL env, - SerdStringView name, - SerdStringView uri); +serd_env_set_prefix(SerdEnv* ZIX_NONNULL env, + SerdStringView name, + SerdStringView uri); /** Qualify `uri` into a CURIE if possible. @@ -65,32 +66,32 @@ serd_env_set_prefix(SerdEnv* SERD_NONNULL env, Returns null if `uri` can not be qualified (usually because no corresponding prefix is defined). */ -SERD_API SerdNode* SERD_ALLOCATED -serd_env_qualify(const SerdEnv* SERD_NULLABLE env, - const SerdNode* SERD_NULLABLE uri); +SERD_API SerdNode* ZIX_ALLOCATED +serd_env_qualify(const SerdEnv* ZIX_NULLABLE env, + const SerdNode* ZIX_NULLABLE uri); /** Expand `node`, which must be a CURIE or URI, to a full URI. Returns null if `node` can not be expanded. */ -SERD_API SerdNode* SERD_ALLOCATED -serd_env_expand(const SerdEnv* SERD_NULLABLE env, - const SerdNode* SERD_NULLABLE node); +SERD_API SerdNode* ZIX_ALLOCATED +serd_env_expand(const SerdEnv* ZIX_NULLABLE env, + const SerdNode* ZIX_NULLABLE node); /** Expand `node`, which must be a CURIE or URI, to a full URI. Returns null if `node` can not be expanded. */ -SERD_API SerdNode* SERD_ALLOCATED -serd_env_expand_node(const SerdEnv* SERD_NULLABLE env, - const SerdNode* SERD_NONNULL node); +SERD_API SerdNode* ZIX_ALLOCATED +serd_env_expand_node(const SerdEnv* ZIX_NULLABLE env, + const SerdNode* ZIX_NONNULL node); /// Write all prefixes in `env` to `sink` SERD_API SerdStatus -serd_env_write_prefixes(const SerdEnv* SERD_NONNULL env, - const SerdSink* SERD_NONNULL sink); +serd_env_write_prefixes(const SerdEnv* ZIX_NONNULL env, + const SerdSink* ZIX_NONNULL sink); /** @} diff --git a/include/serd/error.h b/include/serd/error.h index 7495ce3b..16b28e83 100644 --- a/include/serd/error.h +++ b/include/serd/error.h @@ -20,10 +20,10 @@ SERD_BEGIN_DECLS /// An error description typedef struct { - SerdStatus status; ///< Error code - const SerdCaret* SERD_NULLABLE caret; ///< File origin of error - const char* SERD_NONNULL fmt; ///< Printf-style format string - va_list* SERD_NONNULL args; ///< Arguments for fmt + SerdStatus status; ///< Error code + const SerdCaret* ZIX_NULLABLE caret; ///< File origin of error + const char* ZIX_NONNULL fmt; ///< Printf-style format string + va_list* ZIX_NONNULL args; ///< Arguments for fmt } SerdError; /** @@ -32,8 +32,8 @@ typedef struct { @param handle Handle for user data. @param error Error description. */ -typedef SerdStatus (*SerdErrorFunc)(void* SERD_NULLABLE handle, - const SerdError* SERD_NONNULL error); +typedef SerdStatus (*SerdErrorFunc)(void* ZIX_NULLABLE handle, + const SerdError* ZIX_NONNULL error); /** @} diff --git a/include/serd/event.h b/include/serd/event.h index 0c6437f6..f5399366 100644 --- a/include/serd/event.h +++ b/include/serd/event.h @@ -8,6 +8,7 @@ #include "serd/node.h" #include "serd/statement.h" #include "serd/status.h" +#include "zix/attributes.h" SERD_BEGIN_DECLS @@ -31,8 +32,8 @@ typedef enum { Emitted whenever the base URI changes. */ typedef struct { - SerdEventType type; ///< #SERD_BASE - const SerdNode* SERD_NONNULL uri; ///< Base URI + SerdEventType type; ///< #SERD_BASE + const SerdNode* ZIX_NONNULL uri; ///< Base URI } SerdBaseEvent; /** @@ -41,9 +42,9 @@ typedef struct { Emitted whenever a prefix is defined. */ typedef struct { - SerdEventType type; ///< #SERD_PREFIX - const SerdNode* SERD_NONNULL name; ///< Prefix name - const SerdNode* SERD_NONNULL uri; ///< Namespace URI + SerdEventType type; ///< #SERD_PREFIX + const SerdNode* ZIX_NONNULL name; ///< Prefix name + const SerdNode* ZIX_NONNULL uri; ///< Namespace URI } SerdPrefixEvent; /** @@ -52,9 +53,9 @@ typedef struct { Emitted for every statement. */ typedef struct { - SerdEventType type; ///< #SERD_STATEMENT - SerdStatementFlags flags; ///< Flags for pretty-printing - const SerdStatement* SERD_NONNULL statement; ///< Statement + SerdEventType type; ///< #SERD_STATEMENT + SerdStatementFlags flags; ///< Flags for pretty-printing + const SerdStatement* ZIX_NONNULL statement; ///< Statement } SerdStatementEvent; /** @@ -65,8 +66,8 @@ typedef struct { write a delimiter. */ typedef struct { - SerdEventType type; ///< #SERD_END - const SerdNode* SERD_NONNULL node; ///< Anonymous node that is finished + SerdEventType type; ///< #SERD_END + const SerdNode* ZIX_NONNULL node; ///< Anonymous node that is finished } SerdEndEvent; /** @@ -87,8 +88,8 @@ typedef union { } SerdEvent; /// Function for handling events -typedef SerdStatus (*SerdEventFunc)(void* SERD_NULLABLE handle, - const SerdEvent* SERD_NONNULL event); +typedef SerdStatus (*SerdEventFunc)(void* ZIX_NULLABLE handle, + const SerdEvent* ZIX_NONNULL event); /** @} diff --git a/include/serd/memory.h b/include/serd/memory.h index 1bbd649c..0e50c4e3 100644 --- a/include/serd/memory.h +++ b/include/serd/memory.h @@ -22,7 +22,7 @@ SERD_BEGIN_DECLS to the standard C free() function. */ SERD_API void -serd_free(void* SERD_NULLABLE ptr); +serd_free(void* ZIX_NULLABLE ptr); /** @} diff --git a/include/serd/node.h b/include/serd/node.h index 95638c68..98fb3d1a 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -8,6 +8,9 @@ #include "serd/string_view.h" #include "serd/uri.h" #include "serd/write_result.h" +#include "zix/allocator.h" +#include "zix/attributes.h" +#include "zix/string_view.h" #include <stdbool.h> #include <stddef.h> @@ -106,13 +109,13 @@ typedef uint32_t SerdNodeFlags; A "token" is a node that isn't a typed or tagged literal. This can be used to create URIs, blank nodes, CURIEs, and simple string literals. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_token(SerdNodeType type, SerdStringView string); /** Create a new string literal node. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_string(SerdStringView string); /** @@ -121,7 +124,7 @@ serd_new_string(SerdStringView string); A plain literal has no datatype, but may have a language tag. The `lang` may be empty, in which case this is equivalent to `serd_new_string()`. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_plain_literal(SerdStringView str, SerdStringView lang); /** @@ -131,29 +134,29 @@ serd_new_plain_literal(SerdStringView str, SerdStringView lang); `datatype` may be NULL, in which case this is equivalent to `serd_new_string()`. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_typed_literal(SerdStringView str, SerdStringView datatype_uri); /** Create a new node from a blank node label. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_blank(SerdStringView string); /// Create a new CURIE node -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_curie(SerdStringView string); /** Create a new URI node from a parsed URI. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_parsed_uri(SerdURIView uri); /** Create a new URI node from a string. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_uri(SerdStringView string); /** @@ -164,13 +167,13 @@ serd_new_uri(SerdStringView string); If `path` is relative, `hostname` is ignored. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_file_uri(SerdStringView path, SerdStringView hostname); /** Create a new canonical xsd:boolean node. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_boolean(bool b); /** @@ -186,8 +189,8 @@ serd_new_boolean(bool b); @param d The value for the new node. @param datatype Datatype of node, or NULL for xsd:decimal. */ -SERD_API SerdNode* SERD_ALLOCATED -serd_new_decimal(double d, const SerdNode* SERD_NULLABLE datatype); +SERD_API SerdNode* ZIX_ALLOCATED +serd_new_decimal(double d, const SerdNode* ZIX_NULLABLE datatype); /** Create a new canonical xsd:double literal. @@ -202,7 +205,7 @@ serd_new_decimal(double d, const SerdNode* SERD_NULLABLE datatype); @param d Double value to write. @return A literal node with datatype xsd:double. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_double(double d); /** @@ -214,7 +217,7 @@ serd_new_double(double d); @param f Float value of literal. @return A literal node with datatype xsd:float. */ -SERD_API SerdNode* SERD_ALLOCATED +SERD_API SerdNode* ZIX_ALLOCATED serd_new_float(float f); /** @@ -226,8 +229,8 @@ serd_new_float(float f); @param i Integer value of literal. @param datatype Datatype of node, or NULL for xsd:integer. */ -SERD_API SerdNode* SERD_ALLOCATED -serd_new_integer(int64_t i, const SerdNode* SERD_NULLABLE datatype); +SERD_API SerdNode* ZIX_ALLOCATED +serd_new_integer(int64_t i, const SerdNode* ZIX_NULLABLE datatype); /** Create a new canonical xsd:base64Binary literal. @@ -239,20 +242,20 @@ serd_new_integer(int64_t i, const SerdNode* SERD_NULLABLE datatype); @param size Size of `buf` in bytes. @param datatype Datatype of node, or null for xsd:base64Binary. */ -SERD_API SerdNode* SERD_ALLOCATED -serd_new_base64(const void* SERD_NONNULL buf, - size_t size, - const SerdNode* SERD_NULLABLE datatype); +SERD_API SerdNode* ZIX_ALLOCATED +serd_new_base64(const void* ZIX_NONNULL buf, + size_t size, + const SerdNode* ZIX_NULLABLE datatype); /// Return a deep copy of `node` -SERD_API SerdNode* SERD_ALLOCATED -serd_node_copy(const SerdNode* SERD_NULLABLE node); +SERD_API SerdNode* ZIX_ALLOCATED +serd_node_copy(const SerdNode* ZIX_NULLABLE node); /** Free any data owned by `node`. */ SERD_API void -serd_node_free(SerdNode* SERD_NULLABLE node); +serd_node_free(SerdNode* ZIX_NULLABLE node); /** @} @@ -262,19 +265,19 @@ serd_node_free(SerdNode* SERD_NULLABLE node); /// Return the type of a node SERD_PURE_API SerdNodeType -serd_node_type(const SerdNode* SERD_NONNULL node); +serd_node_type(const SerdNode* ZIX_NONNULL node); /// Return the length of a node's string in bytes, excluding the terminator SERD_PURE_API size_t -serd_node_length(const SerdNode* SERD_NULLABLE node); +serd_node_length(const SerdNode* ZIX_NULLABLE node); /// Return the additional flags of a node SERD_PURE_API SerdNodeFlags -serd_node_flags(const SerdNode* SERD_NONNULL node); +serd_node_flags(const SerdNode* ZIX_NONNULL node); /// Return the string contents of a node -SERD_CONST_API const char* SERD_NONNULL -serd_node_string(const SerdNode* SERD_NONNULL node); +SERD_CONST_API const char* ZIX_NONNULL +serd_node_string(const SerdNode* ZIX_NONNULL node); /** Return a view of the string in a node. @@ -283,7 +286,7 @@ serd_node_string(const SerdNode* SERD_NONNULL node); that can be used to get both in a single call. */ SERD_PURE_API SerdStringView -serd_node_string_view(const SerdNode* SERD_NONNULL node); +serd_node_string_view(const SerdNode* ZIX_NONNULL node); /** Return a parsed view of the URI in a node. @@ -297,7 +300,7 @@ serd_node_string_view(const SerdNode* SERD_NONNULL node); scope. */ SERD_PURE_API SerdURIView -serd_node_uri_view(const SerdNode* SERD_NONNULL node); +serd_node_uri_view(const SerdNode* ZIX_NONNULL node); /** Return the optional datatype of a literal node. @@ -305,8 +308,8 @@ serd_node_uri_view(const SerdNode* SERD_NONNULL node); The datatype, if present, is always a URI, typically something like <http://www.w3.org/2001/XMLSchema#boolean>. */ -SERD_PURE_API const SerdNode* SERD_NULLABLE -serd_node_datatype(const SerdNode* SERD_NONNULL node); +SERD_PURE_API const SerdNode* ZIX_NULLABLE +serd_node_datatype(const SerdNode* ZIX_NONNULL node); /** Return the optional language tag of a literal node. @@ -316,8 +319,8 @@ serd_node_datatype(const SerdNode* SERD_NONNULL node); example, the common form "en-CA" is valid, but lowercase is considered canonical here. */ -SERD_PURE_API const SerdNode* SERD_NULLABLE -serd_node_language(const SerdNode* SERD_NONNULL node); +SERD_PURE_API const SerdNode* ZIX_NULLABLE +serd_node_language(const SerdNode* ZIX_NONNULL node); /** Return the value of `node` as a boolean. @@ -328,7 +331,7 @@ serd_node_language(const SerdNode* SERD_NONNULL node); @return The value of `node` as a `bool`, or `false` on error. */ SERD_API bool -serd_get_boolean(const SerdNode* SERD_NONNULL node); +serd_get_boolean(const SerdNode* ZIX_NONNULL node); /** Return the value of `node` as a double. @@ -338,7 +341,7 @@ serd_get_boolean(const SerdNode* SERD_NONNULL node); @return The value of `node` as a `double`, or NaN on error. */ SERD_API double -serd_get_double(const SerdNode* SERD_NONNULL node); +serd_get_double(const SerdNode* ZIX_NONNULL node); /** Return the value of `node` as a float. @@ -348,7 +351,7 @@ serd_get_double(const SerdNode* SERD_NONNULL node); @return The value of `node` as a `float`, or NaN on error. */ SERD_API float -serd_get_float(const SerdNode* SERD_NONNULL node); +serd_get_float(const SerdNode* ZIX_NONNULL node); /** Return the value of `node` as a long (signed 64-bit integer). @@ -358,7 +361,7 @@ serd_get_float(const SerdNode* SERD_NONNULL node); @return The value of `node` as a `int64_t`, or 0 on error. */ SERD_API int64_t -serd_get_integer(const SerdNode* SERD_NONNULL node); +serd_get_integer(const SerdNode* ZIX_NONNULL node); /** Return the maximum size of a decoded binary node in bytes. @@ -369,7 +372,7 @@ serd_get_integer(const SerdNode* SERD_NONNULL node); the actual size of the data due to things like additional whitespace. */ SERD_PURE_API size_t -serd_get_base64_size(const SerdNode* SERD_NONNULL node); +serd_get_base64_size(const SerdNode* ZIX_NONNULL node); /** Decode a base64 node. @@ -387,9 +390,9 @@ serd_get_base64_size(const SerdNode* SERD_NONNULL node); along with the number of bytes required for successful decoding. */ SERD_API SerdWriteResult -serd_get_base64(const SerdNode* SERD_NONNULL node, - size_t buf_size, - void* SERD_NONNULL buf); +serd_get_base64(const SerdNode* ZIX_NONNULL node, + size_t buf_size, + void* ZIX_NONNULL buf); /** @} @@ -406,8 +409,8 @@ serd_get_base64(const SerdNode* SERD_NONNULL node, @return True if `a` and `b` point to equal nodes, or are both null. */ SERD_PURE_API bool -serd_node_equals(const SerdNode* SERD_NULLABLE a, - const SerdNode* SERD_NULLABLE b); +serd_node_equals(const SerdNode* ZIX_NULLABLE a, + const SerdNode* ZIX_NULLABLE b); /** Compare two nodes. @@ -419,8 +422,7 @@ serd_node_equals(const SerdNode* SERD_NULLABLE a, datatype, if present. */ SERD_PURE_API int -serd_node_compare(const SerdNode* SERD_NONNULL a, - const SerdNode* SERD_NONNULL b); +serd_node_compare(const SerdNode* ZIX_NONNULL a, const SerdNode* ZIX_NONNULL b); /** @} diff --git a/include/serd/reader.h b/include/serd/reader.h index 5df1acc9..c79d6a44 100644 --- a/include/serd/reader.h +++ b/include/serd/reader.h @@ -11,6 +11,7 @@ #include "serd/stream.h" #include "serd/syntax.h" #include "serd/world.h" +#include "zix/attributes.h" #include <stdbool.h> #include <stddef.h> @@ -36,11 +37,11 @@ typedef enum { typedef uint32_t SerdReaderFlags; /// Create a new RDF reader -SERD_API SerdReader* SERD_ALLOCATED -serd_reader_new(SerdWorld* SERD_NONNULL world, - SerdSyntax syntax, - SerdReaderFlags flags, - const SerdSink* SERD_NONNULL sink); +SERD_API SerdReader* ZIX_ALLOCATED +serd_reader_new(SerdWorld* ZIX_NONNULL world, + SerdSyntax syntax, + SerdReaderFlags flags, + const SerdSink* ZIX_NONNULL sink); /** Set a prefix to be added to all blank node identifiers. @@ -52,14 +53,14 @@ serd_reader_new(SerdWorld* SERD_NONNULL world, this can be avoided, while preserving blank node names. */ SERD_API void -serd_reader_add_blank_prefix(SerdReader* SERD_NONNULL reader, - const char* SERD_NULLABLE prefix); +serd_reader_add_blank_prefix(SerdReader* ZIX_NONNULL reader, + const char* ZIX_NULLABLE prefix); /// Prepare to read from the file at a local file `uri` SERD_API SerdStatus -serd_reader_start_file(SerdReader* SERD_NONNULL reader, - const char* SERD_NONNULL uri, - bool bulk); +serd_reader_start_file(SerdReader* ZIX_NONNULL reader, + const char* ZIX_NONNULL uri, + bool bulk); /** Prepare to read from a stream. @@ -68,18 +69,18 @@ serd_reader_start_file(SerdReader* SERD_NONNULL reader, with size 1 (i.e. `page_size` bytes). */ SERD_API SerdStatus -serd_reader_start_stream(SerdReader* SERD_NONNULL reader, - SerdReadFunc SERD_NONNULL read_func, - SerdStreamErrorFunc SERD_NONNULL error_func, - void* SERD_NONNULL stream, - const SerdNode* SERD_NULLABLE name, - size_t page_size); +serd_reader_start_stream(SerdReader* ZIX_NONNULL reader, + SerdReadFunc ZIX_NONNULL read_func, + SerdStreamErrorFunc ZIX_NONNULL error_func, + void* ZIX_NONNULL stream, + const SerdNode* ZIX_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, - const SerdNode* SERD_NULLABLE name); +serd_reader_start_string(SerdReader* ZIX_NONNULL reader, + const char* ZIX_NONNULL utf8, + const SerdNode* ZIX_NULLABLE name); /** Read a single "chunk" of data during an incremental read. @@ -90,7 +91,7 @@ serd_reader_start_string(SerdReader* SERD_NONNULL reader, directly from a pipe or socket. */ SERD_API SerdStatus -serd_reader_read_chunk(SerdReader* SERD_NONNULL reader); +serd_reader_read_chunk(SerdReader* ZIX_NONNULL reader); /** Read a complete document from the source. @@ -100,7 +101,7 @@ serd_reader_read_chunk(SerdReader* SERD_NONNULL reader); for incremental reading use serd_reader_read_chunk(). */ SERD_API SerdStatus -serd_reader_read_document(SerdReader* SERD_NONNULL reader); +serd_reader_read_document(SerdReader* ZIX_NONNULL reader); /** Finish reading from the source. @@ -108,7 +109,7 @@ serd_reader_read_document(SerdReader* SERD_NONNULL reader); This should be called before starting to read from another source. */ SERD_API SerdStatus -serd_reader_finish(SerdReader* SERD_NONNULL reader); +serd_reader_finish(SerdReader* ZIX_NONNULL reader); /** Skip over bytes in the input until a specific byte is encountered. @@ -120,7 +121,7 @@ serd_reader_finish(SerdReader* SERD_NONNULL reader); end of input is reached. */ SERD_API SerdStatus -serd_reader_skip_until_byte(SerdReader* SERD_NONNULL reader, uint8_t byte); +serd_reader_skip_until_byte(SerdReader* ZIX_NONNULL reader, uint8_t byte); /** Free `reader`. @@ -128,7 +129,7 @@ serd_reader_skip_until_byte(SerdReader* SERD_NONNULL reader, uint8_t byte); The reader will be finished via `serd_reader_finish()` if necessary. */ SERD_API void -serd_reader_free(SerdReader* SERD_NULLABLE reader); +serd_reader_free(SerdReader* ZIX_NULLABLE reader); /** @} diff --git a/include/serd/sink.h b/include/serd/sink.h index 09fa7858..58932435 100644 --- a/include/serd/sink.h +++ b/include/serd/sink.h @@ -9,6 +9,8 @@ #include "serd/node.h" #include "serd/statement.h" #include "serd/status.h" +#include "zix/allocator.h" +#include "zix/attributes.h" SERD_BEGIN_DECLS @@ -23,26 +25,26 @@ SERD_BEGIN_DECLS Called whenever the base URI of the serialisation changes. */ -typedef SerdStatus (*SerdBaseFunc)(void* SERD_NULLABLE handle, - const SerdNode* SERD_NONNULL uri); +typedef SerdStatus (*SerdBaseFunc)(void* ZIX_NULLABLE handle, + const SerdNode* ZIX_NONNULL uri); /** Sink function for namespace definitions. Called whenever a prefix is defined in the serialisation. */ -typedef SerdStatus (*SerdPrefixFunc)(void* SERD_NULLABLE handle, - const SerdNode* SERD_NONNULL name, - const SerdNode* SERD_NONNULL uri); +typedef SerdStatus (*SerdPrefixFunc)(void* ZIX_NULLABLE handle, + const SerdNode* ZIX_NONNULL name, + const SerdNode* ZIX_NONNULL uri); /** Sink function for statements. Called for every RDF statement in the serialisation. */ -typedef SerdStatus (*SerdStatementFunc)(void* SERD_NULLABLE handle, - SerdStatementFlags flags, - const SerdStatement* SERD_NONNULL +typedef SerdStatus (*SerdStatementFunc)(void* ZIX_NULLABLE handle, + SerdStatementFlags flags, + const SerdStatement* ZIX_NONNULL statement); /** @@ -52,14 +54,14 @@ typedef SerdStatus (*SerdStatementFunc)(void* SERD_NULLABLE handle, will no longer be referred to by any future statements (so the anonymous node is finished). */ -typedef SerdStatus (*SerdEndFunc)(void* SERD_NULLABLE handle, - const SerdNode* SERD_NONNULL node); +typedef SerdStatus (*SerdEndFunc)(void* ZIX_NULLABLE handle, + const SerdNode* ZIX_NONNULL node); /// An interface that receives a stream of RDF data typedef struct SerdSinkImpl SerdSink; /// Function to free an opaque handle -typedef void (*SerdFreeFunc)(void* SERD_NULLABLE ptr); +typedef void (*SerdFreeFunc)(void* ZIX_NULLABLE ptr); /** Create a new sink. @@ -68,50 +70,50 @@ typedef void (*SerdFreeFunc)(void* SERD_NULLABLE ptr); @param event_func Function that will be called for every event. @param free_handle Free function to call on handle in serd_sink_free(). */ -SERD_API SerdSink* SERD_ALLOCATED -serd_sink_new(void* SERD_NULLABLE handle, - SerdEventFunc SERD_NULLABLE event_func, - SerdFreeFunc SERD_NULLABLE free_handle); +SERD_API SerdSink* ZIX_ALLOCATED +serd_sink_new(void* ZIX_NULLABLE handle, + SerdEventFunc ZIX_NULLABLE event_func, + SerdFreeFunc ZIX_NULLABLE free_handle); /// Free `sink` SERD_API void -serd_sink_free(SerdSink* SERD_NULLABLE sink); +serd_sink_free(SerdSink* ZIX_NULLABLE sink); /// Send an event to the sink SERD_API SerdStatus -serd_sink_write_event(const SerdSink* SERD_NONNULL sink, - const SerdEvent* SERD_NONNULL event); +serd_sink_write_event(const SerdSink* ZIX_NONNULL sink, + const SerdEvent* ZIX_NONNULL event); /// Set the base URI SERD_API SerdStatus -serd_sink_write_base(const SerdSink* SERD_NONNULL sink, - const SerdNode* SERD_NONNULL uri); +serd_sink_write_base(const SerdSink* ZIX_NONNULL sink, + const SerdNode* ZIX_NONNULL uri); /// Set a namespace prefix SERD_API SerdStatus -serd_sink_write_prefix(const SerdSink* SERD_NONNULL sink, - const SerdNode* SERD_NONNULL name, - const SerdNode* SERD_NONNULL uri); +serd_sink_write_prefix(const SerdSink* ZIX_NONNULL sink, + const SerdNode* ZIX_NONNULL name, + const SerdNode* ZIX_NONNULL uri); /// Write a statement SERD_API SerdStatus -serd_sink_write_statement(const SerdSink* SERD_NONNULL sink, - SerdStatementFlags flags, - const SerdStatement* SERD_NONNULL statement); +serd_sink_write_statement(const SerdSink* ZIX_NONNULL sink, + SerdStatementFlags flags, + const SerdStatement* ZIX_NONNULL statement); /// Write a statement from individual nodes SERD_API SerdStatus -serd_sink_write(const SerdSink* SERD_NONNULL sink, - SerdStatementFlags flags, - const SerdNode* SERD_NONNULL subject, - const SerdNode* SERD_NONNULL predicate, - const SerdNode* SERD_NONNULL object, - const SerdNode* SERD_NULLABLE graph); +serd_sink_write(const SerdSink* ZIX_NONNULL sink, + SerdStatementFlags flags, + const SerdNode* ZIX_NONNULL subject, + const SerdNode* ZIX_NONNULL predicate, + const SerdNode* ZIX_NONNULL object, + const SerdNode* ZIX_NULLABLE graph); /// Mark the end of an anonymous node SERD_API SerdStatus -serd_sink_write_end(const SerdSink* SERD_NONNULL sink, - const SerdNode* SERD_NONNULL node); +serd_sink_write_end(const SerdSink* ZIX_NONNULL sink, + const SerdNode* ZIX_NONNULL node); /** @} diff --git a/include/serd/statement.h b/include/serd/statement.h index a1932796..2e8eddc2 100644 --- a/include/serd/statement.h +++ b/include/serd/statement.h @@ -7,6 +7,8 @@ #include "serd/attributes.h" #include "serd/caret.h" #include "serd/node.h" +#include "zix/allocator.h" +#include "zix/attributes.h" #include <stdbool.h> #include <stdint.h> @@ -60,45 +62,45 @@ typedef struct SerdStatementImpl SerdStatement; @param caret Optional caret at the origin of this statement @return A new statement that must be freed with serd_statement_free() */ -SERD_API SerdStatement* SERD_ALLOCATED -serd_statement_new(const SerdNode* SERD_NONNULL s, - const SerdNode* SERD_NONNULL p, - const SerdNode* SERD_NONNULL o, - const SerdNode* SERD_NULLABLE g, - const SerdCaret* SERD_NULLABLE caret); +SERD_API SerdStatement* ZIX_ALLOCATED +serd_statement_new(const SerdNode* ZIX_NONNULL s, + const SerdNode* ZIX_NONNULL p, + const SerdNode* ZIX_NONNULL o, + const SerdNode* ZIX_NULLABLE g, + const SerdCaret* ZIX_NULLABLE caret); /// Return a copy of `statement` -SERD_API SerdStatement* SERD_ALLOCATED -serd_statement_copy(const SerdStatement* SERD_NULLABLE statement); +SERD_API SerdStatement* ZIX_ALLOCATED +serd_statement_copy(const SerdStatement* ZIX_NULLABLE statement); /// Free `statement` SERD_API void -serd_statement_free(SerdStatement* SERD_NULLABLE statement); +serd_statement_free(SerdStatement* ZIX_NULLABLE statement); /// Return the given node of the statement -SERD_PURE_API const SerdNode* SERD_NULLABLE -serd_statement_node(const SerdStatement* SERD_NONNULL statement, - SerdField field); +SERD_PURE_API const SerdNode* ZIX_NULLABLE +serd_statement_node(const SerdStatement* ZIX_NONNULL statement, + SerdField field); /// Return the subject of the statement -SERD_PURE_API const SerdNode* SERD_NONNULL -serd_statement_subject(const SerdStatement* SERD_NONNULL statement); +SERD_PURE_API const SerdNode* ZIX_NONNULL +serd_statement_subject(const SerdStatement* ZIX_NONNULL statement); /// Return the predicate of the statement -SERD_PURE_API const SerdNode* SERD_NONNULL -serd_statement_predicate(const SerdStatement* SERD_NONNULL statement); +SERD_PURE_API const SerdNode* ZIX_NONNULL +serd_statement_predicate(const SerdStatement* ZIX_NONNULL statement); /// Return the object of the statement -SERD_PURE_API const SerdNode* SERD_NONNULL -serd_statement_object(const SerdStatement* SERD_NONNULL statement); +SERD_PURE_API const SerdNode* ZIX_NONNULL +serd_statement_object(const SerdStatement* ZIX_NONNULL statement); /// Return the graph of the statement -SERD_PURE_API const SerdNode* SERD_NULLABLE -serd_statement_graph(const SerdStatement* SERD_NONNULL statement); +SERD_PURE_API const SerdNode* ZIX_NULLABLE +serd_statement_graph(const SerdStatement* ZIX_NONNULL statement); /// Return the source location where the statement originated, or NULL -SERD_PURE_API const SerdCaret* SERD_NULLABLE -serd_statement_caret(const SerdStatement* SERD_NONNULL statement); +SERD_PURE_API const SerdCaret* ZIX_NULLABLE +serd_statement_caret(const SerdStatement* ZIX_NONNULL statement); /** Return true iff `a` is equal to `b`, ignoring statement caret metadata. @@ -107,8 +109,8 @@ serd_statement_caret(const SerdStatement* SERD_NONNULL statement); matching. */ SERD_PURE_API bool -serd_statement_equals(const SerdStatement* SERD_NULLABLE a, - const SerdStatement* SERD_NULLABLE b); +serd_statement_equals(const SerdStatement* ZIX_NULLABLE a, + const SerdStatement* ZIX_NULLABLE b); /** Return true iff the statement matches the given pattern. @@ -117,11 +119,12 @@ serd_statement_equals(const SerdStatement* SERD_NULLABLE a, statement matches if every node matches. */ SERD_PURE_API bool -serd_statement_matches(const SerdStatement* SERD_NONNULL statement, - const SerdNode* SERD_NULLABLE subject, - const SerdNode* SERD_NULLABLE predicate, - const SerdNode* SERD_NULLABLE object, - const SerdNode* SERD_NULLABLE graph); +serd_statement_matches(const SerdStatement* ZIX_NONNULL statement, + const SerdNode* ZIX_NULLABLE subject, + const SerdNode* ZIX_NULLABLE predicate, + const SerdNode* ZIX_NULLABLE object, + const SerdNode* ZIX_NULLABLE graph); + /** @} */ diff --git a/include/serd/status.h b/include/serd/status.h index e21297cd..c6047aff 100644 --- a/include/serd/status.h +++ b/include/serd/status.h @@ -5,6 +5,7 @@ #define SERD_STATUS_H #include "serd/attributes.h" +#include "zix/attributes.h" SERD_BEGIN_DECLS @@ -41,7 +42,7 @@ typedef enum { } SerdStatus; /// Return a string describing a status code -SERD_CONST_API const char* SERD_NONNULL +SERD_CONST_API const char* ZIX_NONNULL serd_strerror(SerdStatus status); /** diff --git a/include/serd/stream.h b/include/serd/stream.h index 992db552..4b3582f5 100644 --- a/include/serd/stream.h +++ b/include/serd/stream.h @@ -5,6 +5,7 @@ #define SERD_STREAM_H #include "serd/attributes.h" +#include "zix/attributes.h" #include <stddef.h> @@ -29,7 +30,7 @@ SERD_BEGIN_DECLS @return Non-zero if `stream` has encountered an error. */ -typedef int (*SerdStreamErrorFunc)(void* SERD_NONNULL stream); +typedef int (*SerdStreamErrorFunc)(void* ZIX_NONNULL stream); /** Function for reading input bytes from a stream. @@ -43,10 +44,10 @@ typedef int (*SerdStreamErrorFunc)(void* SERD_NONNULL stream); @param stream Stream to read from (FILE* for fread). @return Number of elements (bytes) read, which is short on error. */ -typedef size_t (*SerdReadFunc)(void* SERD_NONNULL buf, - size_t size, - size_t nmemb, - void* SERD_NONNULL stream); +typedef size_t (*SerdReadFunc)(void* ZIX_NONNULL buf, + size_t size, + size_t nmemb, + void* ZIX_NONNULL stream); /** Function for writing output bytes to a stream. @@ -60,10 +61,10 @@ typedef size_t (*SerdReadFunc)(void* SERD_NONNULL buf, @param stream Stream to write to (FILE* for fread). @return Number of elements (bytes) written, which is short on error. */ -typedef size_t (*SerdWriteFunc)(const void* SERD_NONNULL buf, - size_t size, - size_t nmemb, - void* SERD_NONNULL stream); +typedef size_t (*SerdWriteFunc)(const void* ZIX_NONNULL buf, + size_t size, + size_t nmemb, + void* ZIX_NONNULL stream); /** @} diff --git a/include/serd/string.h b/include/serd/string.h index f0b8e591..46da939d 100644 --- a/include/serd/string.h +++ b/include/serd/string.h @@ -6,6 +6,7 @@ #include "serd/attributes.h" #include "serd/node.h" +#include "zix/attributes.h" #include <stddef.h> @@ -25,7 +26,7 @@ SERD_BEGIN_DECLS @param flags (Output) Set to the applicable flags. */ SERD_API size_t -serd_strlen(const char* SERD_NONNULL str, SerdNodeFlags* SERD_NULLABLE flags); +serd_strlen(const char* ZIX_NONNULL str, SerdNodeFlags* ZIX_NULLABLE flags); /** Decode a base64 string. @@ -37,10 +38,10 @@ serd_strlen(const char* SERD_NONNULL str, SerdNodeFlags* SERD_NULLABLE flags); @param size Set to the size of the returned blob in bytes. @return A newly allocated blob which must be freed with serd_free(). */ -SERD_API void* SERD_ALLOCATED -serd_base64_decode(const char* SERD_NONNULL str, - size_t len, - size_t* SERD_NONNULL size); +SERD_API void* ZIX_ALLOCATED +serd_base64_decode(const char* ZIX_NONNULL str, + size_t len, + size_t* ZIX_NONNULL size); /** @} diff --git a/include/serd/string_view.h b/include/serd/string_view.h index cab25081..07b6dd69 100644 --- a/include/serd/string_view.h +++ b/include/serd/string_view.h @@ -24,12 +24,12 @@ SERD_BEGIN_DECLS of strings in-place and to avoid redundant string measurement. */ typedef struct { - const char* SERD_NONNULL data; ///< Start of string - size_t length; ///< Length of string in bytes + const char* ZIX_NONNULL data; ///< Start of string + size_t length; ///< Length of string in bytes } SerdStringView; /// Return a view of an empty string -SERD_ALWAYS_INLINE_FUNC SERD_CONST_FUNC static inline SerdStringView +ZIX_ALWAYS_INLINE_FUNC ZIX_CONST_FUNC static inline SerdStringView serd_empty_string(void) { const SerdStringView view = {"", 0U}; @@ -49,8 +49,8 @@ serd_empty_string(void) @param len Length of the substring in bytes, not including the trailing null terminator if present. */ -SERD_ALWAYS_INLINE_FUNC SERD_CONST_FUNC static inline SerdStringView -serd_substring(const char* const SERD_NONNULL str, const size_t len) +ZIX_ALWAYS_INLINE_FUNC ZIX_CONST_FUNC static inline SerdStringView +serd_substring(const char* const ZIX_NONNULL str, const size_t len) { const SerdStringView view = {str, len}; return view; @@ -63,9 +63,9 @@ serd_substring(const char* const SERD_NONNULL str, const size_t len) @param str Pointer to the start of a null-terminated C string, or null. */ -SERD_ALWAYS_INLINE_FUNC SERD_PURE_FUNC static inline SerdStringView +ZIX_ALWAYS_INLINE_FUNC ZIX_PURE_FUNC static inline SerdStringView // NOLINTNEXTLINE(clang-diagnostic-unused-function) -serd_string(const char* const SERD_NULLABLE str) +serd_string(const char* const ZIX_NULLABLE str) { return str ? serd_substring(str, strlen(str)) : serd_empty_string(); } diff --git a/include/serd/syntax.h b/include/serd/syntax.h index 62ba6571..c5ec19b3 100644 --- a/include/serd/syntax.h +++ b/include/serd/syntax.h @@ -5,6 +5,7 @@ #define SERD_SYNTAX_H #include "serd/attributes.h" +#include "zix/attributes.h" #include <stdbool.h> @@ -34,7 +35,7 @@ typedef enum { unknown. */ SERD_PURE_API SerdSyntax -serd_syntax_by_name(const char* SERD_NONNULL name); +serd_syntax_by_name(const char* ZIX_NONNULL name); /** Guess a syntax from a filename. @@ -43,7 +44,7 @@ serd_syntax_by_name(const char* SERD_NONNULL name); returned if the extension is not recognized. */ SERD_PURE_API SerdSyntax -serd_guess_syntax(const char* SERD_NONNULL filename); +serd_guess_syntax(const char* ZIX_NONNULL filename); /** Return whether a syntax can represent multiple graphs in one document. diff --git a/include/serd/uri.h b/include/serd/uri.h index 3170fa89..bee9fe78 100644 --- a/include/serd/uri.h +++ b/include/serd/uri.h @@ -7,6 +7,9 @@ #include "serd/attributes.h" #include "serd/stream.h" #include "serd/string_view.h" +#include "zix/allocator.h" +#include "zix/attributes.h" +#include "zix/string_view.h" #include <stdbool.h> #include <stddef.h> @@ -58,17 +61,17 @@ static const SerdURIView SERD_URI_NULL = @param hostname If non-NULL, set to the hostname, if present. @return A newly-allocated filesystem path. */ -SERD_API char* SERD_ALLOCATED -serd_parse_file_uri(const char* SERD_NONNULL uri, - char* SERD_NONNULL* SERD_NULLABLE hostname); +SERD_API char* ZIX_ALLOCATED +serd_parse_file_uri(const char* ZIX_NONNULL uri, + char* ZIX_NONNULL* ZIX_NULLABLE hostname); /// Return true iff `string` starts with a valid URI scheme SERD_PURE_API bool -serd_uri_string_has_scheme(const char* SERD_NONNULL string); +serd_uri_string_has_scheme(const char* ZIX_NONNULL string); /// Parse `string` and return a URI view that points into it SERD_PURE_API SerdURIView -serd_parse_uri(const char* SERD_NONNULL string); +serd_parse_uri(const char* ZIX_NONNULL string); /** Return reference `r` resolved against `base`. @@ -146,9 +149,9 @@ serd_uri_string_length(SerdURIView uri); `serd_uri_string_length(uri)` on error. */ SERD_API size_t -serd_write_uri(SerdURIView uri, - SerdWriteFunc SERD_NONNULL sink, - void* SERD_NONNULL stream); +serd_write_uri(SerdURIView uri, + SerdWriteFunc ZIX_NONNULL sink, + void* ZIX_NONNULL stream); /** @} diff --git a/include/serd/world.h b/include/serd/world.h index b4849fa2..4c51df73 100644 --- a/include/serd/world.h +++ b/include/serd/world.h @@ -8,6 +8,8 @@ #include "serd/error.h" #include "serd/node.h" #include "serd/status.h" +#include "zix/allocator.h" +#include "zix/attributes.h" #include <stddef.h> @@ -34,12 +36,12 @@ typedef struct { 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_MALLOC_API SerdWorld* ZIX_ALLOCATED serd_world_new(void); /// Free `world` SERD_API void -serd_world_free(SerdWorld* SERD_NULLABLE world); +serd_world_free(SerdWorld* ZIX_NULLABLE world); /** Return the current resource limits. @@ -50,7 +52,7 @@ serd_world_free(SerdWorld* SERD_NULLABLE world); most data. */ SERD_API SerdLimits -serd_world_limits(const SerdWorld* SERD_NONNULL world); +serd_world_limits(const SerdWorld* ZIX_NONNULL world); /** Set the current resource limits. @@ -60,7 +62,7 @@ serd_world_limits(const SerdWorld* SERD_NONNULL world); other function like serd_reader_new() that uses the current limits. */ SERD_API SerdStatus -serd_world_set_limits(SerdWorld* SERD_NONNULL world, SerdLimits limits); +serd_world_set_limits(SerdWorld* ZIX_NONNULL world, SerdLimits limits); /** Return a unique blank node. @@ -68,8 +70,8 @@ serd_world_set_limits(SerdWorld* SERD_NONNULL world, SerdLimits limits); The returned node is valid only until the next time serd_world_get_blank() is called or the world is destroyed. */ -SERD_API const SerdNode* SERD_NONNULL -serd_world_get_blank(SerdWorld* SERD_NONNULL world); +SERD_API const SerdNode* ZIX_NONNULL +serd_world_get_blank(SerdWorld* ZIX_NONNULL world); /** Set a function to be called when errors occur. @@ -78,9 +80,9 @@ serd_world_get_blank(SerdWorld* SERD_NONNULL world); 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_world_set_error_func(SerdWorld* ZIX_NONNULL world, + SerdErrorFunc ZIX_NULLABLE error_func, + void* ZIX_NULLABLE handle); /** @} diff --git a/include/serd/writer.h b/include/serd/writer.h index c5f50b0c..60220570 100644 --- a/include/serd/writer.h +++ b/include/serd/writer.h @@ -12,6 +12,8 @@ #include "serd/stream.h" #include "serd/syntax.h" #include "serd/world.h" +#include "zix/attributes.h" +#include "zix/string_view.h" #include <stdint.h> @@ -46,21 +48,21 @@ typedef enum { typedef uint32_t SerdWriterFlags; /// Create a new RDF writer -SERD_API SerdWriter* SERD_ALLOCATED -serd_writer_new(SerdWorld* SERD_NONNULL world, - SerdSyntax syntax, - SerdWriterFlags flags, - SerdEnv* SERD_NONNULL env, - SerdWriteFunc SERD_NONNULL ssink, - void* SERD_NULLABLE stream); +SERD_API SerdWriter* ZIX_ALLOCATED +serd_writer_new(SerdWorld* ZIX_NONNULL world, + SerdSyntax syntax, + SerdWriterFlags flags, + SerdEnv* ZIX_NONNULL env, + SerdWriteFunc ZIX_NONNULL ssink, + void* ZIX_NULLABLE stream); /// Free `writer` SERD_API void -serd_writer_free(SerdWriter* SERD_NULLABLE writer); +serd_writer_free(SerdWriter* ZIX_NULLABLE writer); /// Return a sink interface that emits statements via `writer` -SERD_CONST_API const SerdSink* SERD_NONNULL -serd_writer_sink(SerdWriter* SERD_NONNULL writer); +SERD_CONST_API const SerdSink* ZIX_NONNULL +serd_writer_sink(SerdWriter* ZIX_NONNULL writer); /** Set a prefix to be removed from matching blank node identifiers. @@ -69,8 +71,8 @@ serd_writer_sink(SerdWriter* SERD_NONNULL writer); to "undo" added prefixes. */ SERD_API void -serd_writer_chop_blank_prefix(SerdWriter* SERD_NONNULL writer, - const char* SERD_NULLABLE prefix); +serd_writer_chop_blank_prefix(SerdWriter* ZIX_NONNULL writer, + const char* ZIX_NULLABLE prefix); /** Set the current root URI. @@ -83,8 +85,8 @@ serd_writer_chop_blank_prefix(SerdWriter* SERD_NONNULL writer, it defaults to the base URI, so no up-references will be created at all. */ SERD_API SerdStatus -serd_writer_set_root_uri(SerdWriter* SERD_NONNULL writer, - const SerdNode* SERD_NULLABLE uri); +serd_writer_set_root_uri(SerdWriter* ZIX_NONNULL writer, + const SerdNode* ZIX_NULLABLE uri); /** Finish a write. @@ -93,7 +95,7 @@ serd_writer_set_root_uri(SerdWriter* SERD_NONNULL writer, that the output is a complete document. */ SERD_API SerdStatus -serd_writer_finish(SerdWriter* SERD_NONNULL writer); +serd_writer_finish(SerdWriter* ZIX_NONNULL writer); /** @} |