summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-09-29 03:10:19 +0000
committerDavid Robillard <d@drobilla.net>2008-09-29 03:10:19 +0000
commit6ad5c37141cedcf00ef46ca2fd6bd141eca81d60 (patch)
tree8a9c401b1b7dbccca21b313b2c352304784d2938
parent82aa51e246d65348e9e88902c6f82b18a3b7453a (diff)
downloadlilv-6ad5c37141cedcf00ef46ca2fd6bd141eca81d60.tar.gz
lilv-6ad5c37141cedcf00ef46ca2fd6bd141eca81d60.tar.bz2
lilv-6ad5c37141cedcf00ef46ca2fd6bd141eca81d60.zip
Add slv2_port_get_value.
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1533 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ChangeLog7
-rw-r--r--slv2/port.h10
-rw-r--r--src/port.c38
3 files changed, 55 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 26de243..e870051 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+slv2 (9999) unstable; urgency=low
+
+ * NOT YET RELEASED
+ * Add slv2_port_get_value (analogous to slv2_plugin_get_value).
+
+ -- Dave Robillard <dave@drobilla.net> Sun, 01 Jan 9999 00:00:00 -0400
+
slv2 (0.6.0) unstable; urgency=low
* Rework API to reduce dependence of SLV2 on specific LV2 features
diff --git a/slv2/port.h b/slv2/port.h
index a55a1a8..1497884 100644
--- a/slv2/port.h
+++ b/slv2/port.h
@@ -38,6 +38,16 @@ extern "C" {
* Time = Query
*/
SLV2Values
+slv2_port_get_value(SLV2Plugin plugin,
+ SLV2Port port,
+ SLV2Value predicate);
+
+
+/** Port analog of slv2_plugin_get_value_by_qname.
+ *
+ * Time = Query
+ */
+SLV2Values
slv2_port_get_value_by_qname(SLV2Plugin plugin,
SLV2Port port,
const char* property_uri);
diff --git a/src/port.c b/src/port.c
index 9166fcc..cffbd0e 100644
--- a/src/port.c
+++ b/src/port.c
@@ -150,6 +150,44 @@ slv2_port_get_value_by_qname(SLV2Plugin p,
}
+SLV2Values
+slv2_port_get_value(SLV2Plugin p,
+ SLV2Port port,
+ SLV2Value predicate)
+{
+ char* query = NULL;
+
+ /* Hack around broken RASQAL, full URI predicates don't work :/ */
+
+ if (predicate->type == SLV2_VALUE_URI) {
+ query = slv2_strjoin(
+ "PREFIX slv2predicate: <", slv2_value_as_string(predicate), ">",
+ "SELECT DISTINCT ?value WHERE { \n"
+ "<", slv2_value_as_uri(p->plugin_uri), "> lv2:port ?port .\n"
+ "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\";\n\t",
+ " slv2predicate: ?value .\n"
+ "}\n", NULL);
+ } else if (predicate->type == SLV2_VALUE_QNAME) {
+ query = slv2_strjoin(
+ "SELECT DISTINCT ?value WHERE { \n"
+ "<", slv2_value_as_uri(p->plugin_uri), "> lv2:port ?port .\n"
+ "?port lv2:symbol \"", slv2_value_as_string(port->symbol), "\";\n\t",
+ slv2_value_as_string(predicate), " ?value .\n"
+ "}\n", NULL);
+ } else {
+ fprintf(stderr, "slv2_port_get_value error: "
+ "predicate is not a URI or QNAME\n");
+ return NULL;
+ }
+
+ SLV2Values result = slv2_plugin_query_variable(p, query, 0);
+
+ free(query);
+
+ return result;
+}
+
+
SLV2Value
slv2_port_get_symbol(SLV2Plugin p,
SLV2Port port)