From b8eb516e97042ca9559aaa506becf504180df0a8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Dec 2011 04:59:14 +0000 Subject: Fix lilv_world_find_nodes to work with wildcard subjects. Add lilv_plugin_get_related to get resources related to plugins that are not directly rdfs:seeAlso linked (e.g. presets). Add lilv_world_load_resource for related resources (e.g. presets). Print presets in lv2info. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3877 a436a847-0d15-0410-975c-d299462d15a1 --- src/plugin.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/plugin.c') diff --git a/src/plugin.c b/src/plugin.c index f8cf054..b305291 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -828,6 +828,35 @@ lilv_plugin_get_uis(const LilvPlugin* p) } } +LILV_API +LilvNodes* +lilv_plugin_get_related(const LilvPlugin* plugin, const LilvNode* type) +{ + LilvWorld* const world = plugin->world; + LilvNodes* const related = lilv_world_find_nodes( + world, NULL, world->lv2_applies_to_val, lilv_plugin_get_uri(plugin)); + + if (!type) { + return related; + } + + LilvNodes* matches = lilv_nodes_new(); + LILV_FOREACH(nodes, i, related) { + LilvNode* node = lilv_collection_get(related, i); + SordIter* titer = lilv_world_query_internal( + world, node->val.uri_val, world->rdf_a_node, type->val.uri_val); + if (!sord_iter_end(titer)) { + zix_tree_insert(matches, + lilv_node_new_from_node(world, node->val.uri_val), + NULL); + } + sord_iter_free(titer); + } + + lilv_nodes_free(related); + return matches; +} + static size_t file_sink(const void* buf, size_t len, void* stream) { -- cgit v1.2.1