summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/port.c48
-rw-r--r--src/slv2_internal.h1
-rw-r--r--src/world.c2
3 files changed, 27 insertions, 24 deletions
diff --git a/src/port.c b/src/port.c
index 3e072ed..2902af9 100644
--- a/src/port.c
+++ b/src/port.c
@@ -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;
}
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index f25018e..45d3fc7 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -168,6 +168,7 @@ struct _SLV2World {
librdf_node* lv2_index_node;
librdf_node* lv2_symbol_node;
librdf_node* rdf_a_node;
+ librdf_node* rdf_value_node;
librdf_node* rdfs_class_node;
librdf_node* rdfs_label_node;
librdf_node* rdfs_seealso_node;
diff --git a/src/world.c b/src/world.c
index e4f292c..c47d2e3 100644
--- a/src/world.c
+++ b/src/world.c
@@ -71,6 +71,7 @@ slv2_world_new_internal(SLV2World world)
world->lv2_index_node = NEW_URI(SLV2_NS_LV2 "index");
world->lv2_symbol_node = NEW_URI(SLV2_NS_LV2 "symbol");
world->rdf_a_node = NEW_URI(SLV2_NS_RDF "type");
+ world->rdf_value_node = NEW_URI(SLV2_NS_RDF "value");
world->rdfs_class_node = NEW_URI(SLV2_NS_RDFS "Class");
world->rdfs_label_node = NEW_URI(SLV2_NS_RDFS "label");
world->rdfs_seealso_node = NEW_URI(SLV2_NS_RDFS "seeAlso");
@@ -173,6 +174,7 @@ slv2_world_free(SLV2World world)
librdf_free_node(world->lv2_index_node);
librdf_free_node(world->lv2_symbol_node);
librdf_free_node(world->rdf_a_node);
+ librdf_free_node(world->rdf_value_node);
librdf_free_node(world->rdfs_label_node);
librdf_free_node(world->rdfs_seealso_node);
librdf_free_node(world->rdfs_subclassof_node);