diff options
Diffstat (limited to 'include/serd/node.h')
-rw-r--r-- | include/serd/node.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/serd/node.h b/include/serd/node.h index b95891c9..4aa4ec0a 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -84,8 +84,10 @@ typedef enum { /// Node flags, which ORed together make a #SerdNodeFlags 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 @@ -112,6 +114,17 @@ serd_new_substring(SerdNodeType type, 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_ALLOCATED +serd_new_literal(const char* SERD_NONNULL str, + const char* SERD_NULLABLE datatype, + const char* SERD_NULLABLE lang); + +/** Create a new URI node from a parsed URI. */ SERD_API SerdNode* SERD_ALLOCATED @@ -228,6 +241,26 @@ SERD_API SerdURIView serd_node_uri_view(const SerdNode* SERD_NONNULL node); /** + Return the optional datatype of a literal 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); + +/** + Return the optional language tag of a literal node. + + The language tag, if present, is a well-formed BCP 47 (RFC 4647) language + tag like "en-ca". Note that these must be handled case-insensitively, for + 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); + +/** @} @defgroup serd_node_operators Operators @{ |