summaryrefslogtreecommitdiffstats
path: root/slv2/query.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-02-12 05:48:51 +0000
committerDavid Robillard <d@drobilla.net>2009-02-12 05:48:51 +0000
commitd9b5f38ffb9c0d0a6841368e7d52a71b9819d087 (patch)
tree80ad4b7fd2570c3467afe709573b750374babf11 /slv2/query.h
parent10f3dcb136761169d738343608fc09491118ea22 (diff)
downloadlilv-d9b5f38ffb9c0d0a6841368e7d52a71b9819d087.tar.gz
lilv-d9b5f38ffb9c0d0a6841368e7d52a71b9819d087.tar.bz2
lilv-d9b5f38ffb9c0d0a6841368e7d52a71b9819d087.zip
Generic plugin query API.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1930 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'slv2/query.h')
-rw-r--r--slv2/query.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/slv2/query.h b/slv2/query.h
new file mode 100644
index 0000000..aa25436
--- /dev/null
+++ b/slv2/query.h
@@ -0,0 +1,89 @@
+/* SLV2
+ * Copyright (C) 2008 Dave 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
+
+
+/** Query a plugin with an arbitrary SPARQL string.
+ */
+SLV2Results
+slv2_plugin_query_sparql(SLV2Plugin plugin,
+ const char* sparql_str);
+
+
+/** Free query results.
+ */
+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.
+ */
+unsigned
+slv2_results_size(SLV2Results results);
+
+
+/** Return true iff the end of \a results has been reached.
+ */
+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.
+ * \return NULL if binding value can not be expressed as an SLV2Value.
+ */
+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 '?').
+ * \return NULL if binding value can not be expressed as an SLV2Value.
+ */
+SLV2Value
+slv2_results_get_binding_value_by_name(SLV2Results results, const char* name);
+
+
+/** Return the name of a binding in \a results.
+ * Indices correspond to selected variables in the query in order of appearance.
+ */
+const char*
+slv2_results_get_binding_name(SLV2Results results, unsigned index);
+
+
+/** Increment \a results to the next match.
+ */
+void
+slv2_results_next(SLV2Results results);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+
+#endif /* __SLV2_QUERY_H__ */