summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS7
-rw-r--r--lilv/lilv.h28
-rw-r--r--src/node.c4
-rw-r--r--src/port.c15
-rw-r--r--src/world.c16
-rw-r--r--test/lilv_test.c6
-rw-r--r--wscript2
7 files changed, 74 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 2da319e..8b2446b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
-lilv (0.15.0) unstable;
+lilv (0.15.1) unstable;
- * Add lilv_world_ask() for simply checking if a statement exists
+ * Add lilv_world_ask() for easily checking if a statement exists
+ * Add lilv_world_get() and lilv_port_get() for easily getting one value
* Add lilv_nodes_merge()
* Make lilv_plugin_get_port_by_designation() return a const pointer
* Require a URI for lilv_state_to_string() and fail gracefully otherwise
@@ -17,7 +18,7 @@ lilv (0.15.0) unstable;
* lilvmm.hpp: Add several missing methods
* Update to waf 1.7.8 and autowaf r90 (install docs to versioned directory)
- -- David Robillard <d@drobilla.net> Sat, 02 Feb 2013 15:10:18 -0500
+ -- David Robillard <d@drobilla.net> Sun, 10 Feb 2013 01:10:12 -0500
lilv (0.14.4) stable;
diff --git a/lilv/lilv.h b/lilv/lilv.h
index 6719e67..f2dd17a 100644
--- a/lilv/lilv.h
+++ b/lilv/lilv.h
@@ -650,6 +650,21 @@ lilv_world_find_nodes(LilvWorld* world,
const LilvNode* object);
/**
+ Find a single node that matches a pattern.
+ Exactly one of @p subject, @p predicate, @p object must be NULL.
+ This function is equivalent to
+ lilv_nodes_get_first(lilv_world_find_nodes(...)) but simplifies the common
+ case of only wanting a single value.
+ @return the first matching node, or NULL if no matches are found.
+*/
+LILV_API
+LilvNode*
+lilv_world_get(LilvWorld* world,
+ const LilvNode* subject,
+ const LilvNode* predicate,
+ const LilvNode* object);
+
+/**
Return true iff a statement matching a certain pattern exists.
This is useful for checking if particular statement exists without having to
@@ -1058,6 +1073,19 @@ lilv_port_get_value(const LilvPlugin* plugin,
const LilvNode* predicate);
/**
+ Get a single property value of a port.
+
+ This is equivalent to lilv_nodes_get_first(lilv_port_get_value(...)) but is
+ simpler to use in the common case of only caring about one value. The
+ caller is responsible for freeing the returned node.
+*/
+LILV_API
+LilvNode*
+lilv_port_get(const LilvPlugin* plugin,
+ const LilvPort* port,
+ const LilvNode* predicate);
+
+/**
Return the LV2 port properties of a port.
*/
LILV_API
diff --git a/src/node.c b/src/node.c
index 495bb49..7b22873 100644
--- a/src/node.c
+++ b/src/node.c
@@ -92,6 +92,10 @@ lilv_node_new(LilvWorld* world, LilvNodeType type, const char* str)
LilvNode*
lilv_node_new_from_node(LilvWorld* world, const SordNode* node)
{
+ if (!node) {
+ return NULL;
+ }
+
LilvNode* result = NULL;
SordNode* datatype_uri = NULL;
LilvNodeType type = LILV_VALUE_STRING;
diff --git a/src/port.c b/src/port.c
index 00896df..48d87dd 100644
--- a/src/port.c
+++ b/src/port.c
@@ -127,6 +127,21 @@ lilv_port_get_value(const LilvPlugin* p,
}
LILV_API
+LilvNode*
+lilv_port_get(const LilvPlugin* p,
+ const LilvPort* port,
+ const LilvNode* predicate)
+{
+ LilvNodes* values = lilv_port_get_value(p, port, predicate);
+
+ LilvNode* value = lilv_node_duplicate(
+ values ? lilv_nodes_get_first(values) : NULL);
+
+ lilv_nodes_free(values);
+ return value;
+}
+
+LILV_API
uint32_t
lilv_port_get_index(const LilvPlugin* p,
const LilvPort* port)
diff --git a/src/world.c b/src/world.c
index a3f59ed..147690b 100644
--- a/src/world.c
+++ b/src/world.c
@@ -201,6 +201,22 @@ lilv_world_find_nodes(LilvWorld* world,
object ? object->node : NULL);
}
+LILV_API
+LilvNode*
+lilv_world_get(LilvWorld* world,
+ const LilvNode* subject,
+ const LilvNode* predicate,
+ const LilvNode* object)
+{
+ return lilv_node_new_from_node(
+ world,
+ sord_get(world->model,
+ subject ? subject->node : NULL,
+ predicate ? predicate->node : NULL,
+ object ? object->node : NULL,
+ NULL));
+}
+
SordIter*
lilv_world_query_internal(LilvWorld* world,
const SordNode* subject,
diff --git a/test/lilv_test.c b/test/lilv_test.c
index 0033885..0a505b0 100644
--- a/test/lilv_test.c
+++ b/test/lilv_test.c
@@ -711,6 +711,8 @@ test_plugin(void)
TEST_ASSERT(thing_name);
TEST_ASSERT(lilv_node_is_string(thing_name));
TEST_ASSERT(!strcmp(lilv_node_as_string(thing_name), "Something else"));
+ LilvNode* thing_name2 = lilv_world_get(world, thing_uri, name_p, NULL);
+ TEST_ASSERT(lilv_node_equals(thing_name, thing_name2));
LilvUIs* uis = lilv_plugin_get_uis(plug);
TEST_ASSERT(lilv_uis_size(uis) == 0);
@@ -729,6 +731,7 @@ test_plugin(void)
lilv_nodes_free(thing_names);
lilv_node_free(thing_uri);
+ lilv_node_free(thing_name2);
lilv_node_free(name_p);
lilv_node_free(control_class);
lilv_node_free(audio_class);
@@ -849,6 +852,9 @@ test_port(void)
LilvNodes* comments = lilv_port_get_value(plug, p, rdfs_comment);
TEST_ASSERT(!strcmp(lilv_node_as_string(lilv_nodes_get_first(comments)),
"comment"));
+ LilvNode* comment = lilv_port_get(plug, p, rdfs_comment);
+ TEST_ASSERT(!strcmp(lilv_node_as_string(comment), "comment"));
+ lilv_node_free(comment);
lilv_nodes_free(comments);
setenv("LANG", "fr", 1);
diff --git a/wscript b/wscript
index e666f43..4df9917 100644
--- a/wscript
+++ b/wscript
@@ -9,7 +9,7 @@ import waflib.extras.autowaf as autowaf
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
-LILV_VERSION = '0.15.0'
+LILV_VERSION = '0.15.1'
LILV_MAJOR_VERSION = '0'
# Mandatory waf variables