summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-29 16:40:00 +0000
committerDavid Robillard <d@drobilla.net>2011-01-29 16:40:00 +0000
commitc11f087573cc734a924ece762b9f7e2bc55b58f7 (patch)
treef5241d24386877900c41c93e10b8a05be04c8112 /src
parent39b0b60bcadacf15aef036db05417aa4dbfcd322 (diff)
downloadlilv-c11f087573cc734a924ece762b9f7e2bc55b58f7.tar.gz
lilv-c11f087573cc734a924ece762b9f7e2bc55b58f7.tar.bz2
lilv-c11f087573cc734a924ece762b9f7e2bc55b58f7.zip
Non-SPARQL version of slv2_world_load_specifications.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2847 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/slv2_internal.h1
-rw-r--r--src/world.c77
2 files changed, 44 insertions, 34 deletions
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index e735800..ea6c2c5 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -159,6 +159,7 @@ struct _SLV2World {
librdf_node* lv2_index_node;
librdf_node* lv2_symbol_node;
librdf_node* rdf_a_node;
+ librdf_node* rdfs_seealso_node;
librdf_node* xsd_integer_node;
librdf_node* xsd_decimal_node;
};
diff --git a/src/world.c b/src/world.c
index b211414..1952689 100644
--- a/src/world.c
+++ b/src/world.c
@@ -57,15 +57,16 @@ slv2_world_new_internal(SLV2World world)
#define NEW_URI(uri) librdf_new_node_from_uri_string(world->world, uri);
- world->lv2_specification_node = NEW_URI(SLV2_NS_LV2 "Specification");
- world->lv2_plugin_node = NEW_URI(SLV2_NS_LV2 "Plugin");
- world->lv2_binary_node = NEW_URI(SLV2_NS_LV2 "binary");
- world->lv2_port_node = NEW_URI(SLV2_NS_LV2 "port");
- 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->xsd_integer_node = NEW_URI(SLV2_NS_XSD "integer");
- world->xsd_decimal_node = NEW_URI(SLV2_NS_XSD "decimal");
+ world->lv2_specification_node = NEW_URI(SLV2_NS_LV2 "Specification");
+ world->lv2_plugin_node = NEW_URI(SLV2_NS_LV2 "Plugin");
+ world->lv2_binary_node = NEW_URI(SLV2_NS_LV2 "binary");
+ world->lv2_port_node = NEW_URI(SLV2_NS_LV2 "port");
+ 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->rdfs_seealso_node = NEW_URI(SLV2_NS_RDFS "seeAlso");
+ world->xsd_integer_node = NEW_URI(SLV2_NS_XSD "integer");
+ world->xsd_decimal_node = NEW_URI(SLV2_NS_XSD "decimal");
world->lv2_plugin_class = slv2_plugin_class_new(world, NULL,
librdf_node_get_uri(world->lv2_plugin_node), "Plugin");
@@ -146,6 +147,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->rdfs_seealso_node);
librdf_free_node(world->xsd_integer_node);
librdf_free_node(world->xsd_decimal_node);
@@ -450,33 +452,40 @@ slv2_plugin_class_compare_by_uri(const void* a, const void* b)
void
slv2_world_load_specifications(SLV2World world)
{
- unsigned char* query_string = (unsigned char*)
- "PREFIX : <http://lv2plug.in/ns/lv2core#>\n"
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
- "SELECT DISTINCT ?spec ?data WHERE {\n"
- " ?spec a :Specification ;\n"
- " rdfs:seeAlso ?data .\n"
- "}\n";
-
- librdf_query* q = librdf_new_query(world->world, "sparql", NULL, query_string, NULL);
-
- librdf_query_results* results = librdf_query_execute(q, world->model);
-
- while (!librdf_query_results_finished(results)) {
- librdf_node* spec_node = librdf_query_results_get_binding_value(results, 0);
- librdf_node* data_node = librdf_query_results_get_binding_value(results, 1);
- librdf_uri* data_uri = librdf_node_get_uri(data_node);
-
- slv2_world_load_file(world, data_uri);
-
- librdf_free_node(spec_node);
- librdf_free_node(data_node);
+ librdf_statement* q = librdf_new_statement_from_nodes(
+ world->world,
+ NULL,
+ librdf_new_node_from_node(world->rdf_a_node),
+ librdf_new_node_from_node(world->lv2_specification_node));
+
+ librdf_stream* specs = librdf_model_find_statements(world->model, q);
+ while (!librdf_stream_end(specs)) {
+ librdf_statement* s = librdf_stream_get_object(specs);
+ librdf_node* spec_node = librdf_statement_get_subject(s);
+
+ librdf_statement* r = librdf_new_statement_from_nodes(
+ world->world,
+ librdf_new_node_from_node(spec_node),
+ librdf_new_node_from_node(world->rdfs_seealso_node),
+ NULL);
+
+ librdf_stream* files = librdf_model_find_statements(world->model, r);
+ while (!librdf_stream_end(files)) {
+ librdf_statement* t = librdf_stream_get_object(files);
+ librdf_node* file_node = librdf_statement_get_object(t);
+ librdf_uri* file_uri = librdf_node_get_uri(file_node);
+
+ slv2_world_load_file(world, file_uri);
+
+ librdf_stream_next(files);
+ }
+ librdf_free_stream(files);
+ librdf_free_statement(r);
- librdf_query_results_next(results);
+ librdf_stream_next(specs);
}
-
- librdf_free_query_results(results);
- librdf_free_query(q);
+ librdf_free_stream(specs);
+ librdf_free_statement(q);
}