aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--serd/serd.h28
-rw-r--r--src/node.c24
2 files changed, 52 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h
index fdebc4d1..c0a8d013 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -603,6 +603,34 @@ SerdNode
serd_node_copy(const SerdNode* node);
/**
+ Return the type of a node (SERD_URI, SERD_BLANK, or SERD_LITERAL).
+*/
+SERD_API
+SerdType
+serd_node_type(const SerdNode* node);
+
+/**
+ Return the string value of a node.
+*/
+SERD_API
+const char*
+serd_node_string(const SerdNode* node);
+
+/**
+ Return the length of the string value of a node in bytes.
+*/
+SERD_API
+size_t
+serd_node_length(const SerdNode* node);
+
+/**
+ Return the flags (string properties) of a node.
+*/
+SERD_API
+SerdNodeFlags
+serd_node_flags(const SerdNode* node);
+
+/**
Return true iff `a` is equal to `b`.
*/
SERD_API
diff --git a/src/node.c b/src/node.c
index 7ad3523a..da0a7d21 100644
--- a/src/node.c
+++ b/src/node.c
@@ -350,6 +350,30 @@ serd_node_new_blob(const void* buf, size_t size, bool wrap_lines)
return node;
}
+SerdType
+serd_node_type(const SerdNode* node)
+{
+ return node ? node->type : SERD_NOTHING;
+}
+
+const char*
+serd_node_string(const SerdNode* node)
+{
+ return node->buf;
+}
+
+size_t
+serd_node_length(const SerdNode* node)
+{
+ return node->n_bytes;
+}
+
+SerdNodeFlags
+serd_node_flags(const SerdNode* node)
+{
+ return node->flags;
+}
+
void
serd_node_free(SerdNode* node)
{