diff options
author | David Robillard <d@drobilla.net> | 2021-02-20 13:53:52 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:24 -0500 |
commit | 2607dd857a2a518ba472208bf0237c6cd0c59b32 (patch) | |
tree | 3bd44d99a2d0e82e9b13dff4053b29fe0b1f11ba | |
parent | 6f03ae92415a7758fdc74f6720ec4955bc67fc0c (diff) | |
download | serd-2607dd857a2a518ba472208bf0237c6cd0c59b32.tar.gz serd-2607dd857a2a518ba472208bf0237c6cd0c59b32.tar.bz2 serd-2607dd857a2a518ba472208bf0237c6cd0c59b32.zip |
Add serd_node_string_view()
-rw-r--r-- | include/serd/serd.h | 10 | ||||
-rw-r--r-- | src/node.c | 8 |
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 @@ -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) { |