Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
19dd1a25
Commit
19dd1a25
authored
Nov 04, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{decoder,archive,playlist}/plugin: pass std::string_view to SupportsMimeType()
parent
53396c0e
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
28 additions
and
36 deletions
+28
-36
ArchiveList.cxx
src/archive/ArchiveList.cxx
+1
-3
ArchiveList.hxx
src/archive/ArchiveList.hxx
+3
-1
FingerprintCommands.cxx
src/command/FingerprintCommands.cxx
+1
-1
DecoderList.cxx
src/decoder/DecoderList.cxx
+1
-1
DecoderList.hxx
src/decoder/DecoderList.hxx
+3
-1
DecoderPlugin.cxx
src/decoder/DecoderPlugin.cxx
+2
-12
DecoderPlugin.hxx
src/decoder/DecoderPlugin.hxx
+4
-3
Thread.cxx
src/decoder/Thread.cxx
+1
-1
PlaylistPlugin.cxx
src/playlist/PlaylistPlugin.cxx
+1
-1
PlaylistPlugin.hxx
src/playlist/PlaylistPlugin.hxx
+1
-1
PlaylistRegistry.cxx
src/playlist/PlaylistRegistry.cxx
+2
-6
PlaylistRegistry.hxx
src/playlist/PlaylistRegistry.hxx
+5
-3
PlaylistStream.cxx
src/playlist/PlaylistStream.cxx
+3
-2
No files found.
src/archive/ArchiveList.cxx
View file @
19dd1a25
...
...
@@ -55,10 +55,8 @@ static bool archive_plugins_enabled[std::max(n_archive_plugins, std::size_t(1))]
if (archive_plugins_enabled[archive_plugin_iterator - archive_plugins])
const
ArchivePlugin
*
archive_plugin_from_suffix
(
const
char
*
suffix
)
noexcept
archive_plugin_from_suffix
(
std
::
string_view
suffix
)
noexcept
{
assert
(
suffix
!=
nullptr
);
archive_plugins_for_each_enabled
(
plugin
)
if
(
plugin
->
suffixes
!=
nullptr
&&
StringArrayContainsCase
(
plugin
->
suffixes
,
suffix
))
...
...
src/archive/ArchiveList.hxx
View file @
19dd1a25
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_ARCHIVE_LIST_HXX
#define MPD_ARCHIVE_LIST_HXX
#include <string_view>
struct
ArchivePlugin
;
extern
const
ArchivePlugin
*
const
archive_plugins
[];
...
...
@@ -33,7 +35,7 @@ extern const ArchivePlugin *const archive_plugins[];
/* interface for using plugins */
const
ArchivePlugin
*
archive_plugin_from_suffix
(
const
char
*
suffix
)
noexcept
;
archive_plugin_from_suffix
(
std
::
string_view
suffix
)
noexcept
;
const
ArchivePlugin
*
archive_plugin_from_name
(
const
char
*
name
)
noexcept
;
...
...
src/command/FingerprintCommands.cxx
View file @
19dd1a25
...
...
@@ -124,7 +124,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
...
...
src/decoder/DecoderList.cxx
View file @
19dd1a25
...
...
@@ -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
);
...
...
src/decoder/DecoderList.hxx
View file @
19dd1a25
...
...
@@ -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
src/decoder/DecoderPlugin.cxx
View file @
19dd1a25
...
...
@@ -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
);
}
src/decoder/DecoderPlugin.hxx
View file @
19dd1a25
...
...
@@ -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
);
}
};
...
...
src/decoder/Thread.cxx
View file @
19dd1a25
...
...
@@ -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
...
...
src/playlist/PlaylistPlugin.cxx
View file @
19dd1a25
...
...
@@ -29,7 +29,7 @@ PlaylistPlugin::SupportsScheme(StringView scheme) const noexcept
}
bool
PlaylistPlugin
::
SupportsSuffix
(
const
char
*
suffix
)
const
noexcept
PlaylistPlugin
::
SupportsSuffix
(
StringView
suffix
)
const
noexcept
{
return
suffixes
!=
nullptr
&&
StringArrayContainsCase
(
suffixes
,
suffix
);
...
...
src/playlist/PlaylistPlugin.hxx
View file @
19dd1a25
...
...
@@ -126,7 +126,7 @@ struct PlaylistPlugin {
* Does the plugin announce the specified file name suffix?
*/
gcc_pure
gcc_nonnull_all
bool
SupportsSuffix
(
const
char
*
suffix
)
const
noexcept
;
bool
SupportsSuffix
(
StringView
suffix
)
const
noexcept
;
/**
* Does the plugin announce the specified MIME type?
...
...
src/playlist/PlaylistRegistry.cxx
View file @
19dd1a25
...
...
@@ -238,10 +238,8 @@ playlist_list_open_stream_mime(InputStreamPtr &&is, const char *full_mime)
}
std
::
unique_ptr
<
SongEnumerator
>
playlist_list_open_stream_suffix
(
InputStreamPtr
&&
is
,
const
char
*
suffix
)
playlist_list_open_stream_suffix
(
InputStreamPtr
&&
is
,
std
::
string_view
suffix
)
{
assert
(
suffix
!=
nullptr
);
playlist_plugins_for_each_enabled
(
plugin
)
{
if
(
plugin
->
open_stream
!=
nullptr
&&
plugin
->
SupportsSuffix
(
suffix
))
{
...
...
@@ -289,10 +287,8 @@ playlist_list_open_stream(InputStreamPtr &&is, const char *uri)
}
const
PlaylistPlugin
*
FindPlaylistPluginBySuffix
(
const
char
*
suffix
)
noexcept
FindPlaylistPluginBySuffix
(
std
::
string_view
suffix
)
noexcept
{
assert
(
suffix
!=
nullptr
);
playlist_plugins_for_each_enabled
(
plugin
)
{
if
(
plugin
->
SupportsSuffix
(
suffix
))
return
plugin
;
...
...
src/playlist/PlaylistRegistry.hxx
View file @
19dd1a25
...
...
@@ -24,6 +24,8 @@
#include "thread/Mutex.hxx"
#include "util/Compiler.h"
#include <string_view>
struct
ConfigData
;
struct
PlaylistPlugin
;
class
SongEnumerator
;
...
...
@@ -74,7 +76,7 @@ std::unique_ptr<SongEnumerator>
playlist_list_open_uri
(
const
char
*
uri
,
Mutex
&
mutex
);
std
::
unique_ptr
<
SongEnumerator
>
playlist_list_open_stream_suffix
(
InputStreamPtr
&&
is
,
const
char
*
suffix
);
playlist_list_open_stream_suffix
(
InputStreamPtr
&&
is
,
std
::
string_view
suffix
);
/**
* Opens a playlist from an input stream.
...
...
@@ -88,7 +90,7 @@ playlist_list_open_stream(InputStreamPtr &&is, const char *uri);
gcc_pure
const
PlaylistPlugin
*
FindPlaylistPluginBySuffix
(
const
char
*
suffix
)
noexcept
;
FindPlaylistPluginBySuffix
(
std
::
string_view
suffix
)
noexcept
;
/**
* Determines if there is a playlist plugin which can handle the
...
...
@@ -96,7 +98,7 @@ FindPlaylistPluginBySuffix(const char *suffix) noexcept;
*/
gcc_pure
inline
bool
playlist_suffix_supported
(
const
char
*
suffix
)
noexcept
playlist_suffix_supported
(
std
::
string_view
suffix
)
noexcept
{
return
FindPlaylistPluginBySuffix
(
suffix
)
!=
nullptr
;
}
...
...
src/playlist/PlaylistStream.cxx
View file @
19dd1a25
...
...
@@ -23,6 +23,7 @@
#include "input/InputStream.hxx"
#include "input/LocalOpen.hxx"
#include "fs/Path.hxx"
#include "util/StringView.hxx"
#include "util/UriExtract.hxx"
#include "Log.hxx"
...
...
@@ -39,12 +40,12 @@ try {
return
nullptr
;
const
auto
suffix_utf8
=
Path
::
FromFS
(
suffix
).
ToUTF8Throw
();
if
(
!
playlist_suffix_supported
(
suffix_utf8
.
c_str
()
))
if
(
!
playlist_suffix_supported
(
suffix_utf8
))
return
nullptr
;
auto
is
=
OpenLocalInputStream
(
path
,
mutex
);
return
playlist_list_open_stream_suffix
(
std
::
move
(
is
),
suffix_utf8
.
c_str
()
);
suffix_utf8
);
}
catch
(...)
{
LogError
(
std
::
current_exception
());
return
nullptr
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment