summaryrefslogtreecommitdiffstats
path: root/slv2
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-28 06:02:12 +0000
committerDavid Robillard <d@drobilla.net>2011-04-28 06:02:12 +0000
commit2a16021425dab995e902d133b060ebcf6c59a00c (patch)
tree042783cc69184323d799da5db497461d108f6a89 /slv2
parent00ceff504269034db8e1bfb54a97b5732c2dadce (diff)
downloadlilv-2a16021425dab995e902d133b060ebcf6c59a00c.tar.gz
lilv-2a16021425dab995e902d133b060ebcf6c59a00c.tar.bz2
lilv-2a16021425dab995e902d133b060ebcf6c59a00c.zip
More future-proof collection APIs.
Make all iterator actions occur through a collection specific function. Verbose, and a low of API, but allows for the possibility of different collection implementation types (given a choice between verbosity and no type safety, I'll take verbosity). git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3211 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'slv2')
-rw-r--r--slv2/slv2.h89
1 files changed, 54 insertions, 35 deletions
diff --git a/slv2/slv2.h b/slv2/slv2.h
index 5ea2bf2..96f4662 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -307,37 +307,24 @@ slv2_value_as_bool(SLV2Value value);
@{
*/
-/* Iter */
+/* Collections */
typedef void* SLV2Iter;
-
-/** Increment @a i to point at the next element in the collection. */
-SLV2_API
-SLV2Iter
-slv2_iter_next(SLV2Iter i);
-
-/** Return true iff @a i is at the end of the collection. */
-SLV2_API
-bool
-slv2_iter_end(SLV2Iter i);
-
-/* Collection */
-
typedef void* SLV2Collection;
-SLV2_API
-SLV2Iter
-slv2_collection_begin(SLV2Collection collection);
-
-SLV2_API
-void*
-slv2_collection_get(SLV2Collection collection,
- SLV2Iter i);
-
-#define SLV2_FOREACH(iter, collection) \
- for (SLV2Iter (iter) = slv2_collection_begin(collection); \
- !slv2_iter_end(iter); \
- (iter) = slv2_iter_next(iter))
+/**
+ Iterate over each element of a collection.
+ @code
+ SLV2_FOREACH(plugin_classes, i, classes) {
+ SLV2PluginClass c = slv2_plugin_classes_get(classes, i);
+ // ...
+ }
+ @endcode
+*/
+#define SLV2_FOREACH(colltype, iter, collection) \
+ for (SLV2Iter (iter) = slv2_ ## colltype ## _begin(collection); \
+ !slv2_ ## colltype ## _is_end(collection, iter); \
+ (iter) = slv2_ ## colltype ## _next(collection, iter))
/* SLV2PluginClasses */
@@ -357,6 +344,14 @@ SLV2_API
SLV2PluginClass
slv2_plugin_classes_get(SLV2PluginClasses collection, SLV2Iter i);
+SLV2_API
+SLV2Iter
+slv2_plugin_classes_next(SLV2PluginClasses collection, SLV2Iter i);
+
+SLV2_API
+bool
+slv2_plugin_classes_is_end(SLV2PluginClasses collection, SLV2Iter i);
+
SLV2_DEPRECATED
SLV2_API
SLV2PluginClass
@@ -365,10 +360,6 @@ slv2_plugin_classes_get_at(SLV2PluginClasses collection, unsigned index);
/* SLV2ScalePoints */
SLV2_API
-SLV2ScalePoints
-slv2_scale_points_new(void);
-
-SLV2_API
void
slv2_scale_points_free(SLV2ScalePoints collection);
@@ -384,6 +375,14 @@ SLV2_API
SLV2ScalePoint
slv2_scale_points_get(SLV2ScalePoints collection, SLV2Iter i);
+SLV2_API
+SLV2Iter
+slv2_scale_points_next(SLV2ScalePoints collection, SLV2Iter i);
+
+SLV2_API
+bool
+slv2_scale_points_is_end(SLV2ScalePoints collection, SLV2Iter i);
+
SLV2_DEPRECATED
SLV2_API
SLV2ScalePoint
@@ -407,6 +406,14 @@ SLV2_API
SLV2UI
slv2_uis_get(SLV2UIs collection, SLV2Iter i);
+SLV2_API
+SLV2Iter
+slv2_uis_next(SLV2UIs collection, SLV2Iter i);
+
+SLV2_API
+bool
+slv2_uis_is_end(SLV2UIs collection, SLV2Iter i);
+
SLV2_DEPRECATED
SLV2_API
SLV2UI
@@ -415,10 +422,6 @@ slv2_uis_get_at(SLV2UIs collection, unsigned index);
/* Values */
SLV2_API
-SLV2ScalePoints
-slv2_values_new(void);
-
-SLV2_API
void
slv2_values_free(SLV2Values collection);
@@ -435,6 +438,14 @@ SLV2Value
slv2_values_get(SLV2Values collection, SLV2Iter i);
SLV2_API
+SLV2Iter
+slv2_values_next(SLV2Values collection, SLV2Iter i);
+
+SLV2_API
+bool
+slv2_values_is_end(SLV2Values collection, SLV2Iter i);
+
+SLV2_API
SLV2Value
slv2_values_get_first(SLV2Values collection);
@@ -457,6 +468,14 @@ SLV2_API
SLV2Plugin
slv2_plugins_get(SLV2Plugins collection, SLV2Iter i);
+SLV2_API
+SLV2Iter
+slv2_plugins_next(SLV2Plugins collection, SLV2Iter i);
+
+SLV2_API
+bool
+slv2_plugins_is_end(SLV2Plugins collection, SLV2Iter i);
+
SLV2_DEPRECATED
SLV2_API
SLV2Plugin