{decoder,archive,playlist}/plugin: pass std::string_view to SupportsMimeType()

This commit is contained in:
Max Kellermann
2020-11-04 20:29:25 +01:00
parent 53396c0e50
commit 19dd1a25d7
13 changed files with 28 additions and 36 deletions

View File

@@ -175,7 +175,7 @@ decoder_plugin_deinit_all() noexcept
}
bool
decoder_plugins_supports_suffix(const char *suffix) noexcept
decoder_plugins_supports_suffix(std::string_view suffix) noexcept
{
return decoder_plugins_try([suffix](const DecoderPlugin &plugin){
return plugin.SupportsSuffix(suffix);

View File

@@ -22,6 +22,8 @@
#include "util/Compiler.h"
#include <string_view>
struct ConfigData;
struct DecoderPlugin;
@@ -98,6 +100,6 @@ decoder_plugins_for_each_enabled(F f)
*/
gcc_pure gcc_nonnull_all
bool
decoder_plugins_supports_suffix(const char *suffix) noexcept;
decoder_plugins_supports_suffix(std::string_view suffix) noexcept;
#endif

View File

@@ -37,25 +37,15 @@ DecoderPlugin::SupportsUri(const char *uri) const noexcept
}
bool
DecoderPlugin::SupportsSuffix(const char *suffix) const noexcept
DecoderPlugin::SupportsSuffix(std::string_view suffix) const noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(suffix != nullptr);
#endif
return suffixes != nullptr &&
StringArrayContainsCase(suffixes, suffix);
}
bool
DecoderPlugin::SupportsMimeType(const char *mime_type) const noexcept
DecoderPlugin::SupportsMimeType(std::string_view mime_type) const noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(mime_type != nullptr);
#endif
return mime_types != nullptr &&
StringArrayContainsCase(mime_types, mime_type);
}

View File

@@ -25,6 +25,7 @@
#include <forward_list> // IWYU pragma: export
#include <set>
#include <string>
#include <string_view>
struct ConfigBlock;
class InputStream;
@@ -252,15 +253,15 @@ struct DecoderPlugin {
* Does the plugin announce the specified file name suffix?
*/
gcc_pure gcc_nonnull_all
bool SupportsSuffix(const char *suffix) const noexcept;
bool SupportsSuffix(std::string_view suffix) const noexcept;
/**
* Does the plugin announce the specified MIME type?
*/
gcc_pure gcc_nonnull_all
bool SupportsMimeType(const char *mime_type) const noexcept;
bool SupportsMimeType(std::string_view mime_type) const noexcept;
bool SupportsContainerSuffix(const char *suffix) const noexcept {
bool SupportsContainerSuffix(std::string_view suffix) const noexcept {
return container_scan != nullptr && SupportsSuffix(suffix);
}
};

View File

@@ -172,7 +172,7 @@ decoder_check_plugin_mime(const DecoderPlugin &plugin,
const char *mime_type = is.GetMimeType();
return mime_type != nullptr &&
plugin.SupportsMimeType(GetMimeTypeBase(mime_type).c_str());
plugin.SupportsMimeType(GetMimeTypeBase(mime_type));
}
gcc_pure