summaryrefslogtreecommitdiffstats
path: root/slv2
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-05-08 03:30:37 +0000
committerDavid Robillard <d@drobilla.net>2007-05-08 03:30:37 +0000
commitf6ff6e487201bdd94e584397ce829daaa424aba9 (patch)
treeaedf571fe2c1db5d3d3cd1511805e51aca64a75e /slv2
parent816279720d70902bf1beba5a2aaaf135707ae77f (diff)
downloadlilv-f6ff6e487201bdd94e584397ce829daaa424aba9.tar.gz
lilv-f6ff6e487201bdd94e584397ce829daaa424aba9.tar.bz2
lilv-f6ff6e487201bdd94e584397ce829daaa424aba9.zip
Reworked simple query API to allow passing either QName or URI predicates.
Hack around a Rasqal bug for the above (URI predicates). Clean up exposed names for greppability and to not violate user namespace. Fixed slv2_plugin_get_value and slv2_plugin_get_value_for_resource. git-svn-id: http://svn.drobilla.net/lad/slv2@517 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'slv2')
-rw-r--r--slv2/plugin.h10
-rw-r--r--slv2/plugins.h4
-rw-r--r--slv2/types.h27
-rw-r--r--slv2/value.h63
4 files changed, 93 insertions, 11 deletions
diff --git a/slv2/plugin.h b/slv2/plugin.h
index 7e7c928..ace6e3b 100644
--- a/slv2/plugin.h
+++ b/slv2/plugin.h
@@ -137,10 +137,14 @@ slv2_plugin_get_class(SLV2Plugin plugin);
*
* Return value must be freed by caller with slv2_values_free.
*
+ * \a predicate must be either a URI or a QName.
+ * See \ref SLV2URIType documentation for examples.
+ *
* Time = Query
*/
SLV2Values
slv2_plugin_get_value(SLV2Plugin p,
+ SLV2URIType predicate_type,
const char* predicate);
@@ -156,13 +160,17 @@ slv2_plugin_get_value(SLV2Plugin p,
* May return NULL if the property was not found, or if object is not
* sensibly represented as an SLV2Values (e.g. blank nodes).
*
+ * \a predicate must be either a URI or a QName.
+ * See \ref SLV2URIType documentation for examples.
+ *
* Return value must be freed by caller with slv2_values_free.
*
* Time = Query
*/
SLV2Values
slv2_plugin_get_value_for_subject(SLV2Plugin p,
- const char* subject,
+ SLV2Value subject,
+ SLV2URIType predicate_type,
const char* predicate);
diff --git a/slv2/plugins.h b/slv2/plugins.h
index 2101eee..5663d6a 100644
--- a/slv2/plugins.h
+++ b/slv2/plugins.h
@@ -19,6 +19,7 @@
#ifndef __SLV2_PLUGINS_H__
#define __SLV2_PLUGINS_H__
+#include <slv2/types.h>
#include <slv2/plugin.h>
#ifdef __cplusplus
@@ -35,9 +36,6 @@ extern "C" {
*/
-typedef void* SLV2Plugins;
-
-
/** Free a plugin list.
*
* Freeing a plugin list does not destroy the plugins it contains (plugins
diff --git a/slv2/types.h b/slv2/types.h
index d55b81d..e5c10e2 100644
--- a/slv2/types.h
+++ b/slv2/types.h
@@ -33,7 +33,7 @@ extern "C" {
* to make the most common case simple. Use slv2_port_get_value(p, "rdf:type")
* if you need further class information.
*/
-typedef enum _PortClass {
+typedef enum _SLV2PortClass {
SLV2_UNKNOWN_PORT_CLASS,
SLV2_CONTROL_INPUT, /**< One input float per block */
SLV2_CONTROL_OUTPUT, /**< One output float per block */
@@ -44,20 +44,35 @@ typedef enum _PortClass {
} SLV2PortClass;
+/** The format of a URI string.
+ *
+ * Full URI: http://example.org/foo
+ * QName: lv2:Plugin
+ */
+typedef enum _SLV2URIType {
+ SLV2_URI,
+ SLV2_QNAME
+} SLV2URIType;
+
+
/** A port on a plugin. Opaque, but valid to compare to NULL. */
-typedef struct _Port* SLV2Port;
+typedef struct _SLV2Port* SLV2Port;
/** A plugin. Opaque, but valid to compare to NULL. */
-typedef struct _Plugin* SLV2Plugin;
+typedef struct _SLV2Plugin* SLV2Plugin;
+
+
+/** A collection of plugins. Opaque, but valid to compare to NULL. */
+typedef void* SLV2Plugins;
/** The world. Opaque, but valid to compare to NULL. */
-typedef struct _World* SLV2World;
+typedef struct _SLV2World* SLV2World;
/** A plugin class. Opaque, but valid to compare to NULL. */
-typedef struct _PluginClass* SLV2PluginClass;
+typedef struct _SLV2PluginClass* SLV2PluginClass;
/** A collection of plugin classes. Opaque, but valid to compare to NULL. */
@@ -65,7 +80,7 @@ typedef void* SLV2PluginClasses;
/** A typed value */
-typedef struct _Value* SLV2Value;
+typedef struct _SLV2Value* SLV2Value;
/** A collection of typed values. */
diff --git a/slv2/value.h b/slv2/value.h
index abc7a57..2d0fb51 100644
--- a/slv2/value.h
+++ b/slv2/value.h
@@ -31,12 +31,48 @@ extern "C" {
*/
+#if 0
+/** Wrap a URI string (e.g. "http://example.org/foo") as an SLV2Value.
+ *
+ * The result is returned by value and refers directly to \a uri, it
+ * does not need to be freed by the caller - calling slv2_value_free
+ * on the returned value will destroy \a uri.
+ */
+SLV2Value
+slv2_uri(const char* uri);
+
+
+/** Wrap a QName string (e.g. "lv2:Plugin") as an SLV2Value.
+ *
+ * The result is returned by value and refers directly to \a uri, it
+ * does not need to be freed by the caller - calling slv2_value_free
+ * on the returned value will destroy \a qname.
+ */
+SLV2Value
+slv2_qname(const char* qname);
+#endif
+
+
/** Return whether two values are equivalent.
*/
bool
slv2_value_equals(SLV2Value value, SLV2Value other);
+/** Return this value as a Turtle/SPARQL token.
+ * Examples:
+ * <http://example.org/foo>
+ * doap:name
+ * "this is a string"
+ * 1.0
+ * 1
+ *
+ * Returned string is newly allocation and must be freed by caller.
+ */
+char*
+slv2_value_get_turtle_token(SLV2Value value);
+
+
/** Return whether the value is a URI (resource).
*
* Time = O(1)
@@ -47,7 +83,8 @@ slv2_value_is_uri(SLV2Value value);
/** Return this value as a URI string, e.g. "http://example.org/foo".
*
- * Valid to call only if slv2_value_is_uri(\a value) returns true.
+ * Valid to call only if slv2_value_is_uri(\a value) or
+ * slv2_value_is_qname(\a value) returns true.
* Returned value is owned by \a value and must not be freed by caller.
*
* Time = O(1)
@@ -56,6 +93,30 @@ const char*
slv2_value_as_uri(SLV2Value value);
+#if 0
+/** Return whether the value is a QName ("qualified name", a prefixed URI).
+ *
+ * A QName will return true for both this, and slv2_value_is_uri.
+ * slv2_value_as_uri and slv2_value_as_qname will both return appropriately.
+ *
+ * Time = O(1)
+ */
+bool
+slv2_value_is_qname(SLV2Value value);
+
+
+/** Return this value as a QName string, e.g. "lv2:Plugin".
+ *
+ * Valid to call only if slv2_value_is_qname(\a value) returns true.
+ * Returned value is owned by \a value and must not be freed by caller.
+ *
+ * Time = O(1)
+ */
+const char*
+slv2_value_as_qname(SLV2Value value);
+#endif
+
+
/** Return whether this value is a literal (i.e. not a URI).
*
* Returns true if \a value is a string or numeric value.