2 Copyright 2016 David Robillard <http://drobilla.net>
4 Permission to use, copy, modify, and/or distribute this software for any
5 purpose with or without fee is hereby granted, provided that the above
6 copyright notice and this permission notice appear in all copies.
8 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 @defgroup util Utilities
25 #include "lv2/lv2plug.in/ns/lv2core/lv2.h"
34 Return the data for a feature in a features array.
36 If the feature is not found, NULL is returned. Note that this function is
37 only useful for features with data, and can not detect features that are
38 present but have NULL data.
41 lv2_features_data(const LV2_Feature
*const* features
,
42 const char* const uri
)
45 for (const LV2_Feature
*const* f
= features
; *f
; ++f
) {
46 if (!strcmp(uri
, (*f
)->URI
)) {
55 Query a features array.
57 This function allows getting several features in one call, and detect
58 missing required features, with the same caveat of lv2_features_data().
60 The arguments should be a series of const char* uri, void** data, bool
61 required, terminated by a NULL URI. The data pointers MUST be initialized
65 LV2_URID_Log* log = NULL;
66 LV2_URID_Map* map = NULL;
67 const char* missing = lv2_features_query(
69 LV2_LOG__log, &log, false,
70 LV2_URID__map, &map, true,
74 @return NULL on success, otherwise the URI of this missing feature.
76 static inline const char*
77 lv2_features_query(const LV2_Feature
* const* features
, ...)
80 va_start(args
, features
);
82 const char* uri
= NULL
;
83 while ((uri
= va_arg(args
, const char*))) {
84 void** data
= va_arg(args
, void**);
85 bool required
= va_arg(args
, int);
87 *data
= lv2_features_data(features
, uri
);
88 if (required
&& !*data
) {