aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd/node.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-14 16:05:10 +0200
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commit672e90382da08efa8f593fdc9081e31d0e548fa0 (patch)
tree3f70c13dda1e60e7b058c750002ec320bfaa6a73 /include/serd/node.h
parentfff826f406e0b9975fd8672041e50dd1a342339f (diff)
downloadserd-672e90382da08efa8f593fdc9081e31d0e548fa0.tar.gz
serd-672e90382da08efa8f593fdc9081e31d0e548fa0.tar.bz2
serd-672e90382da08efa8f593fdc9081e31d0e548fa0.zip
Merge datatype/language into node
This moves closer to the sord API, and is more convenient in most cases.
Diffstat (limited to 'include/serd/node.h')
-rw-r--r--include/serd/node.h37
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
@{