aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/lv2plug.in/ns/ext
diff options
context:
space:
mode:
Diffstat (limited to 'lv2/lv2plug.in/ns/ext')
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/atom.ttl2
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/util.h39
2 files changed, 40 insertions, 1 deletions
diff --git a/lv2/lv2plug.in/ns/ext/atom/atom.ttl b/lv2/lv2plug.in/ns/ext/atom/atom.ttl
index e7ef5a8..ef37293 100644
--- a/lv2/lv2plug.in/ns/ext/atom/atom.ttl
+++ b/lv2/lv2plug.in/ns/ext/atom/atom.ttl
@@ -29,6 +29,8 @@
rdfs:label "Fix implicit conversions in forge.h that are invalid in C++11."
] , [
rdfs:label "Fix lv2_atom_object_next() on 32-bit platforms."
+ ] , [
+ rdfs:label "Add lv2_atom_object_body_get()."
]
]
] , [
diff --git a/lv2/lv2plug.in/ns/ext/atom/util.h b/lv2/lv2plug.in/ns/ext/atom/util.h
index 6ba178c..ac5eb2f 100644
--- a/lv2/lv2plug.in/ns/ext/atom/util.h
+++ b/lv2/lv2plug.in/ns/ext/atom/util.h
@@ -300,7 +300,44 @@ lv2_atom_object_query(const LV2_Atom_Object* object,
}
/**
- Variable argument version of lv2_atom_object_get().
+ Body only version of lv2_atom_object_get().
+*/
+static inline int
+lv2_atom_object_body_get(uint32_t size, const LV2_Atom_Object_Body* body, ...)
+{
+ int matches = 0;
+ int n_queries = 0;
+
+ /* Count number of keys so we can short-circuit when done */
+ va_list args;
+ va_start(args, body);
+ for (n_queries = 0; va_arg(args, uint32_t); ++n_queries) {
+ if (!va_arg(args, const LV2_Atom**)) {
+ return -1;
+ }
+ }
+ va_end(args);
+
+ LV2_ATOM_OBJECT_BODY_FOREACH(body, size, prop) {
+ va_start(args, body);
+ for (int i = 0; i < n_queries; ++i) {
+ uint32_t qkey = va_arg(args, uint32_t);
+ const LV2_Atom** qval = va_arg(args, const LV2_Atom**);
+ if (qkey == prop->key && !*qval) {
+ *qval = &prop->value;
+ if (++matches == n_queries) {
+ return matches;
+ }
+ break;
+ }
+ }
+ va_end(args);
+ }
+ return matches;
+}
+
+/**
+ Variable argument version of lv2_atom_object_query().
This is nicer-looking in code, but a bit more error-prone since it is not
type safe and the argument list must be terminated.