aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/serd/serd.h10
-rw-r--r--src/node.c8
2 files changed, 18 insertions, 0 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index d62b6e2c..2087114f 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -594,6 +594,16 @@ SERD_PURE_API
size_t
serd_node_length(const SerdNode* SERD_NULLABLE node);
+/**
+ Return a view of the string in a node.
+
+ This is a convenience wrapper for serd_node_string() and serd_node_length()
+ that can be used to get both in a single call.
+*/
+SERD_PURE_API
+SerdStringView
+serd_node_string_view(const SerdNode* SERD_NONNULL node);
+
/// Return the flags (string properties) of a node
SERD_PURE_API
SerdNodeFlags
diff --git a/src/node.c b/src/node.c
index 14efddd3..69034603 100644
--- a/src/node.c
+++ b/src/node.c
@@ -499,6 +499,14 @@ serd_node_length(const SerdNode* node)
return node->n_bytes;
}
+SerdStringView
+serd_node_string_view(const SerdNode* SERD_NONNULL node)
+{
+ const SerdStringView result = {(const char*)(node + 1), node->n_bytes};
+
+ return result;
+}
+
const SerdNode*
serd_node_datatype(const SerdNode* node)
{