diff options
author | David Robillard <d@drobilla.net> | 2011-01-30 21:40:26 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-30 21:40:26 +0000 |
commit | d2ca87e3f2b8e38222f9c2a9f3235e4d270528c7 (patch) | |
tree | a123a427159fe57f90d00d9d846b24b7e7f283e8 | |
parent | 23ef7a21c277ba5e864748d8e61ff3e20054758f (diff) | |
download | lilv-d2ca87e3f2b8e38222f9c2a9f3235e4d270528c7.tar.gz lilv-d2ca87e3f2b8e38222f9c2a9f3235e4d270528c7.tar.bz2 lilv-d2ca87e3f2b8e38222f9c2a9f3235e4d270528c7.zip |
Remove all use of, and API support for, SPARQL.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2875 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | doc/reference.doxygen.in | 1 | ||||
-rw-r--r-- | slv2/query.h | 105 | ||||
-rw-r--r-- | slv2/slv2.h | 1 | ||||
-rw-r--r-- | src/plugin.c | 1 | ||||
-rw-r--r-- | src/port.c | 1 | ||||
-rw-r--r-- | src/query.c | 177 | ||||
-rw-r--r-- | src/slv2_internal.h | 5 | ||||
-rw-r--r-- | test/slv2_test.c | 19 | ||||
-rw-r--r-- | wscript | 4 |
10 files changed, 4 insertions, 313 deletions
@@ -1,8 +1,9 @@ -slv2 (0.6.7) unstable; urgency=low +slv2 (0.6.9) unstable; urgency=low * Parse all files with their own URI as a base URI (allowing proper reference to other things in the same bundle) * Support relative URIs returned from lv2_descriptor in libraries * Remove nonsensical slv2_plugin_get_properties and slv2_plugin_get_hints + * Remove all use of SPARQL (including API that provided SPARQL support) -- David Robillard <d@drobilla.net> (UNRELEASED) diff --git a/doc/reference.doxygen.in b/doc/reference.doxygen.in index c89e69a..12d57cc 100644 --- a/doc/reference.doxygen.in +++ b/doc/reference.doxygen.in @@ -576,7 +576,6 @@ INPUT = @SLV2_SRCDIR@/doc/mainpage.dox \ @SLV2_SRCDIR@/slv2/pluginui.h \ @SLV2_SRCDIR@/slv2/pluginuiinstance.h \ @SLV2_SRCDIR@/slv2/port.h \ - @SLV2_SRCDIR@/slv2/query.h \ @SLV2_SRCDIR@/slv2/scalepoint.h \ @SLV2_SRCDIR@/slv2/slv2.h \ @SLV2_SRCDIR@/slv2/types.h \ diff --git a/slv2/query.h b/slv2/query.h deleted file mode 100644 index 93d6f14..0000000 --- a/slv2/query.h +++ /dev/null @@ -1,105 +0,0 @@ -/* SLV2 - * Copyright (C) 2008-2009 David Robillard <http://drobilla.net> - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __SLV2_QUERY_H__ -#define __SLV2_QUERY_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** \addtogroup slv2_data - * @{ - */ - - -/** Query a plugin with an arbitrary SPARQL string. - */ -SLV2_API -SLV2Results -slv2_plugin_query_sparql(SLV2Plugin plugin, - const char* sparql_str); - - -/** Free query results. - */ -SLV2_API -void -slv2_results_free(SLV2Results results); - - -/** Return the number of matches in \a results. - * Note this should not be used to iterate over a result set (since it will - * iterate to the end of \a results and rewinding is impossible). - * Instead, use slv2_results_next and slv2_results_finished repeatedly. - */ -SLV2_API -unsigned -slv2_results_size(SLV2Results results); - - -/** Return true iff the end of \a results has been reached. - */ -SLV2_API -bool -slv2_results_finished(SLV2Results results); - - -/** Return a binding in \a results by index. - * Indices correspond to selected variables in the query in order of appearance. - * Returned value must be freed by caller with slv2_value_free. - * \return NULL if binding value can not be expressed as an SLV2Value. - */ -SLV2_API -SLV2Value -slv2_results_get_binding_value(SLV2Results results, unsigned index); - - -/** Return a binding in \a results by name. - * \a name corresponds to the name of the SPARQL variable (without the '?'). - * Returned value must be freed by caller with slv2_value_free. - * \return NULL if binding value can not be expressed as an SLV2Value. - */ -SLV2_API -SLV2Value -slv2_results_get_binding_value_by_name(SLV2Results results, const char* name); - - -/** Return the name of a binding in \a results. - * Returned value is shared and must not be freed by caller. - * Indices correspond to selected variables in the query in order of appearance. - */ -SLV2_API -const char* -slv2_results_get_binding_name(SLV2Results results, unsigned index); - - -/** Increment \a results to the next match. - */ -SLV2_API -void -slv2_results_next(SLV2Results results); - - -/** @} */ - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* __SLV2_QUERY_H__ */ diff --git a/slv2/slv2.h b/slv2/slv2.h index f64fcb5..ffb9567 100644 --- a/slv2/slv2.h +++ b/slv2/slv2.h @@ -30,7 +30,6 @@ extern "C" { #include "slv2/pluginui.h" #include "slv2/pluginuiinstance.h" #include "slv2/port.h" -#include "slv2/query.h" #include "slv2/scalepoint.h" #include "slv2/types.h" #include "slv2/util.h" diff --git a/src/plugin.c b/src/plugin.c index a7e211e..6f68102 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -30,7 +30,6 @@ #include "slv2/collections.h" #include "slv2/plugin.h" #include "slv2/pluginclass.h" -#include "slv2/query.h" #include "slv2/util.h" #include "slv2_internal.h" @@ -25,7 +25,6 @@ #include "slv2/types.h" #include "slv2/collections.h" #include "slv2/port.h" -#include "slv2/query.h" #include "slv2/util.h" #include "slv2_internal.h" diff --git a/src/query.c b/src/query.c index 3fb0ce9..187bf5d 100644 --- a/src/query.c +++ b/src/query.c @@ -25,187 +25,10 @@ #include "slv2/types.h" #include "slv2/collections.h" #include "slv2/plugin.h" -#include "slv2/query.h" #include "slv2/util.h" #include "slv2_internal.h" -static const char* slv2_query_prefixes = - "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" - "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" - "PREFIX doap: <http://usefulinc.com/ns/doap#>\n" - "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" - "PREFIX lv2: <http://lv2plug.in/ns/lv2core#>\n" - "PREFIX lv2ev: <http://lv2plug.in/ns/ext/event#>\n"; - - -SLV2Values -slv2_query_get_variable_bindings(SLV2World world, - SLV2Results results, - int variable) -{ - SLV2Values result = NULL; - - if (!librdf_query_results_finished(results->rdf_results)) - result = slv2_values_new(); - - while (!librdf_query_results_finished(results->rdf_results)) { - librdf_node* node = librdf_query_results_get_binding_value(results->rdf_results, variable); - - if (node == NULL) { - SLV2_ERRORF("Variable %d bound to NULL.\n", variable); - librdf_query_results_next(results->rdf_results); - continue; - } - - SLV2Value val = slv2_value_new_librdf_node(world, node); - if (val) - raptor_sequence_push(result, val); - - librdf_free_node(node); - librdf_query_results_next(results->rdf_results); - } - - return result; -} - - -unsigned -slv2_results_size(SLV2Results results) -{ - size_t count = 0; - - while (!slv2_results_finished(results)) { - ++count; - slv2_results_next(results); - } - - return count; -} - - -SLV2Results -slv2_plugin_query_sparql(SLV2Plugin plugin, - const char* sparql_str) -{ - slv2_plugin_load_if_necessary(plugin); - - librdf_uri* base_uri = slv2_value_as_librdf_uri(plugin->plugin_uri); - - char* query_str = slv2_strjoin(slv2_query_prefixes, sparql_str, NULL); - - librdf_query* query = librdf_new_query(plugin->world->world, "sparql", NULL, - (const uint8_t*)query_str, base_uri); - - if (!query) { - SLV2_ERRORF("Failed to create query:\n%s", query_str); - return NULL; - } - - librdf_query_results* results = librdf_query_execute(query, plugin->rdf); - - librdf_free_query(query); - free(query_str); - - SLV2Results ret = (SLV2Results)malloc(sizeof(struct _SLV2Results)); - ret->world = plugin->world; - ret->rdf_results = results; - - return ret; -} - - -void -slv2_results_free(SLV2Results results) -{ - librdf_free_query_results(results->rdf_results); - free(results); -} - - -bool -slv2_results_finished(SLV2Results results) -{ - return librdf_query_results_finished(results->rdf_results); -} - - -SLV2Value -slv2_results_get_binding_value(SLV2Results results, unsigned index) -{ - return slv2_value_new_librdf_node(results->world, - librdf_query_results_get_binding_value( - results->rdf_results, index)); -} - - -SLV2Value -slv2_results_get_binding_value_by_name(SLV2Results results, const char* name) -{ - return slv2_value_new_librdf_node(results->world, - librdf_query_results_get_binding_value_by_name( - results->rdf_results, name)); -} - - -const char* -slv2_results_get_binding_name(SLV2Results results, unsigned index) -{ - return librdf_query_results_get_binding_name(results->rdf_results, index); -} - - -void -slv2_results_next(SLV2Results results) -{ - librdf_query_results_next(results->rdf_results); -} - - -/** Query a single variable */ -SLV2Values -slv2_plugin_query_variable(SLV2Plugin plugin, - const char* sparql_str, - unsigned variable) -{ - assert(variable < INT_MAX); - - SLV2Results results = slv2_plugin_query_sparql(plugin, sparql_str); - - SLV2Values ret = slv2_query_get_variable_bindings(plugin->world, - results, (int)variable); - - slv2_results_free(results); - - return ret; -} - - -/** Run a query and count number of matches. - * - * More efficient than slv2_plugin_simple_query if you're only interested - * in the number of results (ie slv2_plugin_num_ports). - * - * Note the result of this function is probably meaningless unless the query - * is a SELECT DISTINCT. - */ -unsigned -slv2_plugin_query_count(SLV2Plugin plugin, - const char* sparql_str) -{ - SLV2Results results = slv2_plugin_query_sparql(plugin, sparql_str); - - unsigned ret = 0; - - if (results) { - ret = slv2_results_size(results); - slv2_results_free(results); - } - - return ret; -} - - librdf_stream* slv2_plugin_find_statements(SLV2Plugin plugin, librdf_node* subject, diff --git a/src/slv2_internal.h b/src/slv2_internal.h index af748bb..35a8f12 100644 --- a/src/slv2_internal.h +++ b/src/slv2_internal.h @@ -279,11 +279,6 @@ void slv2_scale_point_free(SLV2ScalePoint point); /* ********* Query Results********* */ -struct _SLV2Results { - SLV2World world; - librdf_query_results* rdf_results; -}; - SLV2Values slv2_values_from_stream_i18n(SLV2Plugin p, librdf_stream* stream); diff --git a/test/slv2_test.c b/test/slv2_test.c index 3d30327..aafb3dd 100644 --- a/test/slv2_test.c +++ b/test/slv2_test.c @@ -693,19 +693,6 @@ test_plugin() SLV2UIs uis = slv2_plugin_get_uis(plug); TEST_ASSERT(slv2_uis_size(uis) == 0); - SLV2Results results = slv2_plugin_query_sparql(plug, -"SELECT ?name WHERE { <> doap:maintainer [ foaf:name ?name ] }"); - TEST_ASSERT(!slv2_results_finished(results)); - TEST_ASSERT(!strcmp(slv2_results_get_binding_name(results, 0), "name")); - SLV2Value val = slv2_results_get_binding_value(results, 0); - TEST_ASSERT(!strcmp(slv2_value_as_string(val), "David Robillard")); - slv2_value_free(val); - val = slv2_results_get_binding_value_by_name(results, "name"); - TEST_ASSERT(!strcmp(slv2_value_as_string(val), "David Robillard")); - slv2_value_free(val); - - slv2_results_free(results); - slv2_uis_free(uis); slv2_values_free(thing_names); slv2_value_free(thing_uri); @@ -806,12 +793,6 @@ test_port() TEST_ASSERT(!strcmp(slv2_value_as_string(slv2_values_get_at(homepages, 0)), "http://example.org/someplug")); - TEST_ASSERT(slv2_plugin_query_count(plug, "SELECT DISTINCT ?bin WHERE {\n" - "<> lv2:binary ?bin . }") == 1); - - TEST_ASSERT(slv2_plugin_query_count(plug, "SELECT DISTINCT ?parent WHERE {\n" - "<> rdfs:subClassOf ?parent . }") == 0); - SLV2Value min, max, def; slv2_port_get_range(plug, p, &def, &min, &max); TEST_ASSERT(def); @@ -3,7 +3,7 @@ import autowaf import Options # Version of this package (even if built as a child) -SLV2_VERSION = '0.6.8' +SLV2_VERSION = '0.6.9' # Library version (UNIX style major, minor, micro) # major increment <=> incompatible changes @@ -28,7 +28,7 @@ SLV2_VERSION = '0.6.8' # 0.6.2 = 9,1,1 # 0.6.4 = 9,2,0 # 0.6.6 = 9,2,0 -SLV2_LIB_VERSION = '9.3.0' +SLV2_LIB_VERSION = '10.0.0' # Variables for 'waf dist' APPNAME = 'slv2' |