aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/core/lv2_util.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-07-07 18:59:32 -0400
committerDavid Robillard <d@drobilla.net>2022-07-17 18:14:00 -0400
commit1eccbe4355685b322194df72b5de2382d5290b3b (patch)
tree0677b5c2f577a5024c351a164527f4bdd91a639b /lv2/core/lv2_util.h
parentd4a970f6962dda28133290194832b726b566ddab (diff)
downloadlv2-1eccbe4355685b322194df72b5de2382d5290b3b.tar.xz
Rearrange source tree to be directly usable by dependants
This allows the LV2 source distribution to be used as an include path for compilers and an LV2_PATH for applications, at the expense of self-contained bundles. That's a nice idea, but it made LV2 itself weird and annoying to depend on. This rearranges things so that directories in the source tree correspond more closely to installation directories. To make this possible, the "aux" directory in the documentation output has been changed to "style", to avoid the reserved name "aux" on Windows.
Diffstat (limited to 'lv2/core/lv2_util.h')
-rw-r--r--lv2/core/lv2_util.h103
1 files changed, 0 insertions, 103 deletions
diff --git a/lv2/core/lv2_util.h b/lv2/core/lv2_util.h
deleted file mode 100644
index f3766aa..0000000
--- a/lv2/core/lv2_util.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Copyright 2016 David Robillard <d@drobilla.net>
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-
-/**
- @defgroup util Utilities
- @ingroup lv2core
- @{
-*/
-
-#include "lv2/core/lv2.h"
-
-#include <stdarg.h>
-#include <stdbool.h>
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- Return the data for a feature in a features array.
-
- If the feature is not found, NULL is returned. Note that this function is
- only useful for features with data, and can not detect features that are
- present but have NULL data.
-*/
-static inline void*
-lv2_features_data(const LV2_Feature* const* features, const char* const uri)
-{
- if (features) {
- for (const LV2_Feature* const* f = features; *f; ++f) {
- if (!strcmp(uri, (*f)->URI)) {
- return (*f)->data;
- }
- }
- }
- return NULL;
-}
-
-/**
- Query a features array.
-
- This function allows getting several features in one call, and detect
- missing required features, with the same caveat of lv2_features_data().
-
- The arguments should be a series of const char* uri, void** data, bool
- required, terminated by a NULL URI. The data pointers MUST be initialized
- to NULL. For example:
-
- @code
- LV2_URID_Log* log = NULL;
- LV2_URID_Map* map = NULL;
- const char* missing = lv2_features_query(
- features,
- LV2_LOG__log, &log, false,
- LV2_URID__map, &map, true,
- NULL);
- @endcode
-
- @return NULL on success, otherwise the URI of this missing feature.
-*/
-static inline const char*
-lv2_features_query(const LV2_Feature* const* features, ...)
-{
- va_list args;
- va_start(args, features);
-
- const char* uri = NULL;
- while ((uri = va_arg(args, const char*))) {
- void** data = va_arg(args, void**);
- bool required = (bool)va_arg(args, int);
-
- *data = lv2_features_data(features, uri);
- if (required && !*data) {
- va_end(args);
- return uri;
- }
- }
-
- va_end(args);
- return NULL;
-}
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-/**
- @}
-*/