diff options
author | David Robillard <d@drobilla.net> | 2018-02-04 12:40:45 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-05-27 18:18:55 +0200 |
commit | e0a6647ce80ee4116b5de7a0cde9a652c8e26cf1 (patch) | |
tree | df3e4d5238322abbeeb6874633c4149f82bc9cd5 | |
parent | 8ac55f3c07f72548435d1e55594ccb5094e25098 (diff) | |
download | serd-e0a6647ce80ee4116b5de7a0cde9a652c8e26cf1.tar.gz serd-e0a6647ce80ee4116b5de7a0cde9a652c8e26cf1.tar.bz2 serd-e0a6647ce80ee4116b5de7a0cde9a652c8e26cf1.zip |
Add node accessor API
-rw-r--r-- | serd/serd.h | 28 | ||||
-rw-r--r-- | src/node.c | 28 |
2 files changed, 56 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h index f753db84..1d217a3c 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -590,6 +590,34 @@ SerdNode serd_node_new_blob(const void* buf, size_t size, bool wrap_lines); /** + Return the type of a node (SERD_URI, SERD_BLANK, or SERD_LITERAL). +*/ +SERD_API +SerdType +serd_node_get_type(const SerdNode* node); + +/** + Return the string value of a node. +*/ +SERD_API +const char* +serd_node_get_string(const SerdNode* node); + +/** + Return the length of the string value of a node in bytes. +*/ +SERD_API +size_t +serd_node_get_length(const SerdNode* node); + +/** + Return the flags (string properties) of a node. +*/ +SERD_API +SerdNodeFlags +serd_node_get_flags(const SerdNode* node); + +/** Free any data owned by `node`. Note that if `node` is itself dynamically allocated (which is not the case @@ -384,6 +384,34 @@ serd_node_new_blob(const void* buf, size_t size, bool wrap_lines) } SERD_API +SerdType +serd_node_get_type(const SerdNode* node) +{ + return node ? node->type : SERD_NOTHING; +} + +SERD_API +const char* +serd_node_get_string(const SerdNode* node) +{ + return node->buf; +} + +SERD_API +size_t +serd_node_get_length(const SerdNode* node) +{ + return node->n_bytes; +} + +SERD_API +SerdNodeFlags +serd_node_get_flags(const SerdNode* node) +{ + return node->flags; +} + +SERD_API void serd_node_free(SerdNode* node) { |