diff options
author | David Robillard <d@drobilla.net> | 2011-05-03 05:31:23 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-05-03 05:31:23 +0000 |
commit | 2b2f150447c2d3bde17cbe5d95b9902b7ef6e040 (patch) | |
tree | e99b31b70b61a9c3d827aa87e38bb596fd016c73 /src/world.c | |
parent | 5ea7474cad2748fad2a8e0f414c02ec56cb82dff (diff) | |
download | lilv-2b2f150447c2d3bde17cbe5d95b9902b7ef6e040.tar.gz lilv-2b2f150447c2d3bde17cbe5d95b9902b7ef6e040.tar.bz2 lilv-2b2f150447c2d3bde17cbe5d95b9902b7ef6e040.zip |
Replace lilv_plugin_get_value_for_subject with lilv_world_find_nodes.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3247 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/world.c')
-rw-r--r-- | src/world.c | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/src/world.c b/src/world.c index fbe86ff..0de3e38 100644 --- a/src/world.c +++ b/src/world.c @@ -201,36 +201,66 @@ lilv_world_set_option(LilvWorld* world, } static SordIter* -lilv_world_find_statements(LilvWorld* world, - SordModel* model, - const SordNode* subject, - const SordNode* predicate, - const SordNode* object, - const SordNode* graph) +lilv_world_find_statements(const LilvWorld* world, + SordModel* model, + const SordNode* subject, + const SordNode* predicate, + const SordNode* object, + const SordNode* graph) { SordQuad pat = { subject, predicate, object, graph }; return sord_find(model, pat); } +LILV_API +LilvNodes* +lilv_world_find_nodes(LilvWorld* world, + const LilvNode* subject, + const LilvNode* predicate, + const LilvNode* object) +{ + if (!lilv_node_is_uri(subject) && !lilv_node_is_blank(subject)) { + LILV_ERRORF("Subject `%s' is not a resource\n", subject->str_val); + return NULL; + } + if (!lilv_node_is_uri(predicate)) { + LILV_ERRORF("Predicate `%s' is not a URI\n", predicate->str_val); + return NULL; + } + + SordNode* subject_node = (lilv_node_is_uri(subject)) + ? sord_node_copy(subject->val.uri_val) + : sord_new_blank(world->world, + (const uint8_t*)lilv_node_as_blank(subject)); + + LilvNodes* ret = lilv_world_query_values_internal(world, + subject_node, + predicate->val.uri_val, + NULL); + + sord_node_free(world->world, subject_node); + return ret; +} + SordIter* -lilv_world_query(LilvWorld* world, - const SordNode* subject, - const SordNode* predicate, - const SordNode* object) +lilv_world_query_internal(LilvWorld* world, + const SordNode* subject, + const SordNode* predicate, + const SordNode* object) { return lilv_world_find_statements(world, world->model, subject, predicate, object, NULL); } LilvNodes* -lilv_world_query_values(LilvWorld* world, - const SordNode* subject, - const SordNode* predicate, - const SordNode* object) +lilv_world_query_values_internal(LilvWorld* world, + const SordNode* subject, + const SordNode* predicate, + const SordNode* object) { return lilv_nodes_from_stream_objects( world, - lilv_world_query(world, subject, predicate, object)); + lilv_world_query_internal(world, subject, predicate, object)); } static SerdNode |