diff options
author | David Robillard <d@drobilla.net> | 2018-04-01 20:33:33 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-06-21 18:12:03 +0200 |
commit | 7d25d7319564fe0b1c89690a99d033952df8e55f (patch) | |
tree | 74b1f1aa77dfdfe8b7751531f588dd080d3a1e0d /serd | |
parent | 27ee06024c2d54a2340e83e5c90e919f8764ae0f (diff) | |
download | serd-7d25d7319564fe0b1c89690a99d033952df8e55f.tar.gz serd-7d25d7319564fe0b1c89690a99d033952df8e55f.tar.bz2 serd-7d25d7319564fe0b1c89690a99d033952df8e55f.zip |
Merge datatype and/or language into node
This moves closer to the sord API, and is more convenient in most cases.
Diffstat (limited to 'serd')
-rw-r--r-- | serd/serd.h | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/serd/serd.h b/serd/serd.h index c848cdfe..5e327f2c 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -193,8 +193,10 @@ typedef enum { Flags indicating certain string properties relevant to serialisation. */ typedef enum { - SERD_HAS_NEWLINE = 1, /**< Contains line breaks ('\\n' or '\\r') */ - SERD_HAS_QUOTE = 1 << 1 /**< Contains quotes ('"') */ + SERD_HAS_NEWLINE = 1, /**< Contains line breaks ('\\n' or '\\r') */ + SERD_HAS_QUOTE = 1 << 1, /**< Contains quotes ('"') */ + SERD_HAS_DATATYPE = 1 << 2, /**< Literal node has datatype */ + SERD_HAS_LANGUAGE = 1 << 3 /**< Literal node has language */ } SerdNodeFlag; /** @@ -452,6 +454,16 @@ SerdNode* serd_node_new_substring(SerdType type, const char* str, size_t len); /** + 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_node_new_literal(const char* str, const char* datatype, const char* lang); + +/** Simple wrapper for serd_node_new_uri() to resolve a URI node. */ SERD_API @@ -601,6 +613,20 @@ SerdNodeFlags serd_node_get_flags(const SerdNode* node); /** + Return the datatype of a literal node, or NULL. +*/ +SERD_API +const SerdNode* +serd_node_get_datatype(const SerdNode* node); + +/** + Return the language tag of a literal node, or NULL. +*/ +SERD_API +const SerdNode* +serd_node_get_language(const SerdNode* node); + +/** Return true iff `a` is equal to `b`. */ SERD_API @@ -649,9 +675,7 @@ typedef SerdStatus (*SerdStatementSink)(void* handle, const SerdNode* graph, const SerdNode* subject, const SerdNode* predicate, - const SerdNode* object, - const SerdNode* object_datatype, - const SerdNode* object_lang); + const SerdNode* object); /** Sink (callback) for anonymous node end markers. @@ -1040,9 +1064,7 @@ serd_writer_write_statement(SerdWriter* writer, const SerdNode* graph, const SerdNode* subject, const SerdNode* predicate, - const SerdNode* object, - const SerdNode* datatype, - const SerdNode* lang); + const SerdNode* object); /** Mark the end of an anonymous node's description. |