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
94aed92e
Commit
94aed92e
authored
6 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/Set: move code to ApplyTagWithFallback()
parent
6b9966e9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
9 deletions
+57
-9
Makefile.am
Makefile.am
+1
-0
Fallback.hxx
src/tag/Fallback.hxx
+43
-0
Set.cxx
src/tag/Set.cxx
+13
-9
No files found.
Makefile.am
View file @
94aed92e
...
@@ -977,6 +977,7 @@ libtag_a_SOURCES =\
...
@@ -977,6 +977,7 @@ libtag_a_SOURCES =\
src/tag/TagItem.hxx
\
src/tag/TagItem.hxx
\
src/tag/TagHandler.cxx src/tag/TagHandler.hxx
\
src/tag/TagHandler.cxx src/tag/TagHandler.hxx
\
src/tag/Mask.hxx
\
src/tag/Mask.hxx
\
src/tag/Fallback.hxx
\
src/tag/Settings.cxx src/tag/Settings.hxx
\
src/tag/Settings.cxx src/tag/Settings.hxx
\
src/tag/TagConfig.cxx src/tag/TagConfig.hxx
\
src/tag/TagConfig.cxx src/tag/TagConfig.hxx
\
src/tag/TagNames.c
\
src/tag/TagNames.c
\
...
...
This diff is collapsed.
Click to expand it.
src/tag/Fallback.hxx
0 → 100644
View file @
94aed92e
/*
* Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_TAG_FALLBACK_HXX
#define MPD_TAG_FALLBACK_HXX
#include <utility>
template
<
typename
F
>
bool
ApplyTagFallback
(
TagType
type
,
F
&&
f
)
noexcept
{
if
(
type
==
TAG_ALBUM_ARTIST
)
/* fall back to "Artist" if no "AlbumArtist" was found */
return
f
(
TAG_ARTIST
);
return
false
;
}
template
<
typename
F
>
bool
ApplyTagWithFallback
(
TagType
type
,
F
&&
f
)
noexcept
{
return
f
(
type
)
||
ApplyTagFallback
(
type
,
std
::
forward
<
F
>
(
f
));
}
#endif
This diff is collapsed.
Click to expand it.
src/tag/Set.cxx
View file @
94aed92e
...
@@ -18,17 +18,20 @@
...
@@ -18,17 +18,20 @@
*/
*/
#include "Set.hxx"
#include "Set.hxx"
#include "Fallback.hxx"
#include "TagBuilder.hxx"
#include "TagBuilder.hxx"
#include "util/StringView.hxx"
#include "util/StringView.hxx"
#include <functional>
#include <assert.h>
#include <assert.h>
/**
/**
* Copy all tag items of the specified type.
* Copy all tag items of the specified type.
*/
*/
static
bool
static
bool
CopyTagItem
(
TagBuilder
&
dest
,
TagType
dest_type
,
CopyTagItem
2
(
TagBuilder
&
dest
,
TagType
dest_type
,
const
Tag
&
src
,
TagType
src_type
)
const
Tag
&
src
,
TagType
src_type
)
{
{
bool
found
=
false
;
bool
found
=
false
;
...
@@ -49,9 +52,9 @@ CopyTagItem(TagBuilder &dest, TagType dest_type,
...
@@ -49,9 +52,9 @@ CopyTagItem(TagBuilder &dest, TagType dest_type,
static
void
static
void
CopyTagItem
(
TagBuilder
&
dest
,
const
Tag
&
src
,
TagType
type
)
CopyTagItem
(
TagBuilder
&
dest
,
const
Tag
&
src
,
TagType
type
)
{
{
if
(
!
CopyTagItem
(
dest
,
type
,
src
,
type
)
&&
ApplyTagWithFallback
(
type
,
type
==
TAG_ALBUM_ARTIST
)
std
::
bind
(
CopyTagItem2
,
std
::
ref
(
dest
),
type
,
CopyTagItem
(
dest
,
type
,
src
,
TAG_ARTIST
);
std
::
cref
(
src
),
std
::
placeholders
::
_1
)
);
}
}
/**
/**
...
@@ -105,9 +108,10 @@ TagSet::InsertUnique(const Tag &tag,
...
@@ -105,9 +108,10 @@ TagSet::InsertUnique(const Tag &tag,
assert
((
group_mask
&
(
tag_mask_t
(
1
)
<<
unsigned
(
type
)))
==
0
);
assert
((
group_mask
&
(
tag_mask_t
(
1
)
<<
unsigned
(
type
)))
==
0
);
if
(
!
CheckUnique
(
type
,
tag
,
type
,
group_mask
)
&&
if
(
!
ApplyTagWithFallback
(
type
,
(
type
!=
TAG_ALBUM_ARTIST
||
std
::
bind
(
&
TagSet
::
CheckUnique
,
this
,
/* fall back to "Artist" if no "AlbumArtist" was found */
type
,
std
::
cref
(
tag
),
!
CheckUnique
(
type
,
tag
,
TAG_ARTIST
,
group_mask
)))
std
::
placeholders
::
_1
,
group_mask
)))
InsertUnique
(
tag
,
type
,
""
,
group_mask
);
InsertUnique
(
tag
,
type
,
""
,
group_mask
);
}
}
This diff is collapsed.
Click to expand it.
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