diff options
author | David Robillard <d@drobilla.net> | 2020-08-14 16:05:10 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:24 -0500 |
commit | 6f03ae92415a7758fdc74f6720ec4955bc67fc0c (patch) | |
tree | 027582bca0844f8fe650db707eb14dc3b46c7598 /include | |
parent | 194d6f42583745c3fde6387b14abab2311b4f0b7 (diff) | |
download | serd-6f03ae92415a7758fdc74f6720ec4955bc67fc0c.tar.gz serd-6f03ae92415a7758fdc74f6720ec4955bc67fc0c.tar.bz2 serd-6f03ae92415a7758fdc74f6720ec4955bc67fc0c.zip |
Merge datatype/language into node
This moves closer to the sord API, and is more convenient in most cases.
Diffstat (limited to 'include')
-rw-r--r-- | include/serd/serd.h | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h index 2ccedcba..d62b6e2c 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -169,8 +169,10 @@ typedef enum { /// Flags indicating certain string properties relevant to serialisation typedef enum { - SERD_HAS_NEWLINE = 1u << 0u, ///< Contains line breaks ('\\n' or '\\r') - SERD_HAS_QUOTE = 1u << 1u ///< Contains quotes ('"') + SERD_HAS_NEWLINE = 1u << 0u, ///< Contains line breaks ('\\n' or '\\r') + SERD_HAS_QUOTE = 1u << 1u, ///< Contains quotes ('"') + SERD_HAS_DATATYPE = 1u << 2u, ///< Literal node has datatype + SERD_HAS_LANGUAGE = 1u << 3u ///< Literal node has language } SerdNodeFlag; /// Bitwise OR of SerdNodeFlag values @@ -451,7 +453,21 @@ serd_new_substring(SerdNodeType type, const char* SERD_NULLABLE str, size_t len); -/// Simple wrapper for serd_new_uri() to resolve a URI node +/** + Create a new literal node from `str`. + + Either `datatype` or `lang` can be given, but not both, unless `datatype` is + rdf:langString in which case it is ignored. +*/ +SERD_API +SerdNode* SERD_ALLOCATED +serd_new_literal(const char* SERD_NONNULL str, + const char* SERD_NULLABLE datatype, + const char* SERD_NULLABLE lang); + +/** + Simple wrapper for serd_new_uri() to resolve a URI node. +*/ SERD_API SerdNode* SERD_ALLOCATED serd_new_uri_from_node(const SerdNode* SERD_NONNULL uri_node, @@ -583,6 +599,16 @@ SERD_PURE_API SerdNodeFlags serd_node_flags(const SerdNode* SERD_NONNULL node); +/// Return the datatype of a literal node, or NULL +SERD_PURE_API +const SerdNode* SERD_NULLABLE +serd_node_datatype(const SerdNode* SERD_NONNULL node); + +/// Return the language tag of a literal node, or NULL +SERD_PURE_API +const SerdNode* SERD_NULLABLE +serd_node_language(const SerdNode* SERD_NONNULL node); + /// Return true iff `a` is equal to `b` SERD_PURE_API bool @@ -626,15 +652,12 @@ typedef SerdStatus (*SerdPrefixSink)(void* SERD_NULLABLE handle, Called for every RDF statement in the serialisation. */ -typedef SerdStatus (*SerdStatementSink)( - void* SERD_NULLABLE handle, - SerdStatementFlags flags, - const SerdNode* SERD_NULLABLE graph, - const SerdNode* SERD_NONNULL subject, - const SerdNode* SERD_NONNULL predicate, - const SerdNode* SERD_NONNULL object, - const SerdNode* SERD_NULLABLE object_datatype, - const SerdNode* SERD_NULLABLE object_lang); +typedef SerdStatus (*SerdStatementSink)(void* SERD_NULLABLE handle, + SerdStatementFlags flags, + const SerdNode* SERD_NULLABLE graph, + const SerdNode* SERD_NONNULL subject, + const SerdNode* SERD_NONNULL predicate, + const SerdNode* SERD_NONNULL object); /** Sink (callback) for anonymous node end markers @@ -1017,9 +1040,7 @@ serd_writer_write_statement(SerdWriter* SERD_NONNULL writer, const SerdNode* SERD_NULLABLE graph, const SerdNode* SERD_NONNULL subject, const SerdNode* SERD_NONNULL predicate, - const SerdNode* SERD_NONNULL object, - const SerdNode* SERD_NULLABLE datatype, - const SerdNode* SERD_NULLABLE lang); + const SerdNode* SERD_NONNULL object); /** Mark the end of an anonymous node's description. |