encoder/List: replace encoder_plugins_for_each() with a container class
This commit is contained in:
parent
040c4a8560
commit
c64b4838dc
|
@ -180,8 +180,9 @@ static void version()
|
||||||
#ifdef ENABLE_ENCODER
|
#ifdef ENABLE_ENCODER
|
||||||
"\n"
|
"\n"
|
||||||
"Encoder plugins:\n");
|
"Encoder plugins:\n");
|
||||||
encoder_plugins_for_each(plugin)
|
for (const auto &plugin : GetAllEncoderPlugins()) {
|
||||||
fmt::print(" {}", plugin->name);
|
fmt::print(" {}", plugin.name);
|
||||||
|
}
|
||||||
fmt::print("\n"
|
fmt::print("\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,10 @@ constinit const EncoderPlugin *const encoder_plugins[] = {
|
||||||
const EncoderPlugin *
|
const EncoderPlugin *
|
||||||
encoder_plugin_get(const char *name)
|
encoder_plugin_get(const char *name)
|
||||||
{
|
{
|
||||||
encoder_plugins_for_each(plugin)
|
for (const auto &plugin : GetAllEncoderPlugins()) {
|
||||||
if (strcmp(plugin->name, name) == 0)
|
if (strcmp(plugin.name, name) == 0)
|
||||||
return plugin;
|
return &plugin;
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
// Copyright The Music Player Daemon Project
|
// Copyright The Music Player Daemon Project
|
||||||
|
|
||||||
#ifndef MPD_ENCODER_LIST_HXX
|
#pragma once
|
||||||
#define MPD_ENCODER_LIST_HXX
|
|
||||||
|
#include "util/DereferenceIterator.hxx"
|
||||||
|
#include "util/TerminatedArray.hxx"
|
||||||
|
|
||||||
struct EncoderPlugin;
|
struct EncoderPlugin;
|
||||||
|
|
||||||
extern const EncoderPlugin *const encoder_plugins[];
|
extern const EncoderPlugin *const encoder_plugins[];
|
||||||
|
|
||||||
#define encoder_plugins_for_each(plugin) \
|
static inline auto
|
||||||
for (const EncoderPlugin *plugin, \
|
GetAllEncoderPlugins() noexcept
|
||||||
*const*encoder_plugin_iterator = &encoder_plugins[0]; \
|
{
|
||||||
(plugin = *encoder_plugin_iterator) != nullptr; \
|
return DereferenceContainerAdapter{TerminatedArray<const EncoderPlugin *const, nullptr>{encoder_plugins}};
|
||||||
++encoder_plugin_iterator)
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up an encoder plugin by its name.
|
* Looks up an encoder plugin by its name.
|
||||||
|
@ -23,5 +25,3 @@ extern const EncoderPlugin *const encoder_plugins[];
|
||||||
*/
|
*/
|
||||||
const EncoderPlugin *
|
const EncoderPlugin *
|
||||||
encoder_plugin_get(const char *name);
|
encoder_plugin_get(const char *name);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue