diff options
author | David Robillard <d@drobilla.net> | 2018-12-20 13:02:24 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-12-19 20:57:43 -0500 |
commit | de5806d34301c0c1d9e61b3916e1bc8c106ad022 (patch) | |
tree | a3ebfc1a33aad2855fdd746b2250dbaaeaae73ef /src | |
parent | 05081ec8c56ab89540aa3ad4b1d96fc144a53c6c (diff) | |
download | serd-de5806d34301c0c1d9e61b3916e1bc8c106ad022.tar.gz serd-de5806d34301c0c1d9e61b3916e1bc8c106ad022.tar.bz2 serd-de5806d34301c0c1d9e61b3916e1bc8c106ad022.zip |
Add serd_node_compare()
Diffstat (limited to 'src')
-rw-r--r-- | src/node.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -367,6 +367,25 @@ serd_node_equals(const SerdNode* a, const SerdNode* b) return serd_node_total_size(b) == a_size && !memcmp(a, b, a_size); } +int +serd_node_compare(const SerdNode* a, const SerdNode* b) +{ + if (a == b) { + return 0; + } else if (!a) { + return -1; + } else if (!b) { + return 1; + } else if (a->type != b->type) { + return (a->type < b->type) ? -1 : 1; + } + + const int cmp = strcmp(serd_node_get_string(a), serd_node_get_string(b)); + return cmp ? cmp + : serd_node_compare(serd_node_maybe_get_meta_c(a), + serd_node_maybe_get_meta_c(b)); +} + static size_t serd_uri_string_length(const SerdURI* uri) { |