From 380c2bca89cd0190f8fa94753869b8c0ba45d921 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 1 Apr 2018 20:33:33 +0200 Subject: Merge datatype and/or language into node This moves closer to the sord API, and is more convenient in most cases. --- serd/serd.h | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'serd') diff --git a/serd/serd.h b/serd/serd.h index 40ae6c4d..05b850a9 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -201,8 +201,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; /** @@ -459,6 +461,16 @@ SERD_API 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); + /** Return a deep copy of `node`. */ @@ -601,6 +613,20 @@ SERD_API size_t serd_node_get_length(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 the flags (string properties) of a node. */ @@ -660,9 +686,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. @@ -1051,9 +1075,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. -- cgit v1.2.1