diff options
author | David Robillard <d@drobilla.net> | 2011-01-30 04:35:41 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-30 04:35:41 +0000 |
commit | 73d4c34f7756a36c078a11c639328a7eef474ecb (patch) | |
tree | b60639fae8cd86a1b6d75d9aaaa283c3309f3b6c /src/port.c | |
parent | 98cd625a7ba5eb91d473c1fe1504c7a9c050ef86 (diff) | |
download | lilv-73d4c34f7756a36c078a11c639328a7eef474ecb.tar.gz lilv-73d4c34f7756a36c078a11c639328a7eef474ecb.tar.bz2 lilv-73d4c34f7756a36c078a11c639328a7eef474ecb.zip |
Non-SPARQL version of slv2_port_get_scale_points.
SLV2 is SPARQL free!
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2868 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/port.c')
-rw-r--r-- | src/port.c | 48 |
1 files changed, 24 insertions, 24 deletions
@@ -307,40 +307,40 @@ slv2_port_get_range(SLV2Plugin p, SLV2ScalePoints slv2_port_get_scale_points(SLV2Plugin p, - SLV2Port port) + SLV2Port port) { - char* query = slv2_strjoin( - "SELECT DISTINCT ?value ?label WHERE {\n" - "<", slv2_value_as_uri(p->plugin_uri), "> lv2:port ?port .\n" - "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\" ;\n", - " lv2:scalePoint ?point .\n" - "?point rdf:value ?value ;\n" - " rdfs:label ?label .\n" - "\n}", NULL); - - SLV2Results results = slv2_plugin_query_sparql(p, query); + librdf_node* port_node = slv2_port_get_node(p, port); + librdf_stream* points = slv2_plugin_find_statements( + p, + port_node, + librdf_new_node_from_uri_string(p->world->world, SLV2_NS_LV2 "scalePoint"), + NULL); SLV2ScalePoints ret = NULL; - - if (!slv2_results_finished(results)) + if (!librdf_stream_end(points)) ret = slv2_scale_points_new(); - while (!slv2_results_finished(results)) { - SLV2Value value = slv2_results_get_binding_value(results, 0); - SLV2Value label = slv2_results_get_binding_value(results, 1); - - if (value && label) - raptor_sequence_push(ret, slv2_scale_point_new(value, label)); + for (; !librdf_stream_end(points); librdf_stream_next(points)) { + librdf_statement* s = librdf_stream_get_object(points); + librdf_node* point = librdf_statement_get_object(s); - slv2_results_next(results); - } + SLV2Value value = slv2_plugin_get_unique( + p, + librdf_new_node_from_node(point), + librdf_new_node_from_node(p->world->rdf_value_node)); - slv2_results_free(results); + SLV2Value label = slv2_plugin_get_unique( + p, + librdf_new_node_from_node(point), + librdf_new_node_from_node(p->world->rdfs_label_node)); - free(query); + if (value && label) { + raptor_sequence_push(ret, slv2_scale_point_new(value, label)); + } + } + librdf_free_stream(points); assert(!ret || slv2_values_size(ret) > 0); - return ret; } |