LMMS
Loading...
Searching...
No Matches
lv2_util.h
Go to the documentation of this file.
1/*
2 Copyright 2016 David Robillard <http://drobilla.net>
3
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.
7
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.
15*/
16
22
23#include <string.h>
24
25#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
26
27#ifdef __cplusplus
28extern "C" {
29#else
30# include <stdbool.h>
31#endif
32
40static inline void*
41lv2_features_data(const LV2_Feature*const* features,
42 const char* const uri)
43{
44 if (features) {
45 for (const LV2_Feature*const* f = features; *f; ++f) {
46 if (!strcmp(uri, (*f)->URI)) {
47 return (*f)->data;
48 }
49 }
50 }
51 return NULL;
52}
53
76static inline const char*
77lv2_features_query(const LV2_Feature* const* features, ...)
78{
79 va_list args;
80 va_start(args, features);
81
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);
86
87 *data = lv2_features_data(features, uri);
88 if (required && !*data) {
89 return uri;
90 }
91 }
92
93 return NULL;
94}
95
96#ifdef __cplusplus
97} /* extern "C" */
98#endif
99
#define NULL
Definition CarlaBridgeFormat.cpp:30
unsigned f
Definition inflate.c:1572
static const char * lv2_features_query(const LV2_Feature *const *features,...)
Definition lv2_util.h:77
static void * lv2_features_data(const LV2_Feature *const *features, const char *const uri)
Definition lv2_util.h:41
JSAMPIMAGE data
Definition jpeglib.h:945
static SordNode * uri(SordWorld *world, int num)
Definition sord_test.c:47
Definition lv2.h:157