diff options
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -247,6 +247,30 @@ serd_node_equals(const SerdNode* a, const SerdNode* b) return false; } +/** Compare nodes, considering NULL a match iff `wildcards` is true. */ +int +serd_node_compare(const SerdNode* a, const SerdNode* b, bool wildcards) +{ + if (a == b) { + return 0; + } else if (!a || !b) { + return wildcards ? 0 : (a < b) ? -1 : (a > b) ? 1 : 0; + } else if (a->type != b->type) { + return a->type - b->type; + } + + int cmp = strcmp(serd_node_get_string(a), serd_node_get_string(b)); + if (cmp) { + return cmp; + } + + cmp = serd_node_compare(serd_node_maybe_get_meta_c(a), + serd_node_maybe_get_meta_c(b), + false); + + return cmp; +} + static size_t serd_uri_string_length(const SerdURI* uri) { |