diff options
author | David Robillard <d@drobilla.net> | 2018-05-12 13:28:47 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-05-27 21:10:20 +0200 |
commit | 582bfbe1cb0a6aa833f56c5bd8cf42abe5c5d13a (patch) | |
tree | b866ca44592cc07a34fcad8ce18c29259fb39199 /src/node.c | |
parent | f48dac14b6533b4cdd4804513216f4f11de36d9a (diff) | |
download | serd-582bfbe1cb0a6aa833f56c5bd8cf42abe5c5d13a.tar.gz serd-582bfbe1cb0a6aa833f56c5bd8cf42abe5c5d13a.tar.bz2 serd-582bfbe1cb0a6aa833f56c5bd8cf42abe5c5d13a.zip |
WIP: Add model
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) { |