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
6c06244e
Commit
6c06244e
authored
Oct 22, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/Count: move code to tag/VisitCallback.hxx
parent
53448e46
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
16 deletions
+61
-16
Makefile.am
Makefile.am
+1
-0
Count.cxx
src/db/Count.cxx
+8
-16
VisitFallback.hxx
src/tag/VisitFallback.hxx
+52
-0
No files found.
Makefile.am
View file @
6c06244e
...
@@ -978,6 +978,7 @@ libtag_a_SOURCES =\
...
@@ -978,6 +978,7 @@ libtag_a_SOURCES =\
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/Fallback.hxx
\
src/tag/VisitFallback.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
\
...
...
src/db/Count.cxx
View file @
6c06244e
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#include "client/Response.hxx"
#include "client/Response.hxx"
#include "LightSong.hxx"
#include "LightSong.hxx"
#include "tag/Tag.hxx"
#include "tag/Tag.hxx"
#include "tag/Fallback.hxx"
#include "tag/
Visit
Fallback.hxx"
#include <functional>
#include <functional>
#include <map>
#include <map>
...
@@ -73,24 +73,15 @@ stats_visitor_song(SearchStats &stats, const LightSong &song)
...
@@ -73,24 +73,15 @@ stats_visitor_song(SearchStats &stats, const LightSong &song)
stats
.
total_duration
+=
duration
;
stats
.
total_duration
+=
duration
;
}
}
static
bool
static
void
CollectGroupCounts
(
TagCountMap
&
map
,
TagType
group
,
const
Tag
&
tag
)
CollectGroupCounts
(
TagCountMap
&
map
,
const
Tag
&
tag
,
const
char
*
value
)
noexcept
{
{
bool
found
=
false
;
auto
r
=
map
.
insert
(
std
::
make_pair
(
value
,
SearchStats
()));
for
(
const
auto
&
item
:
tag
)
{
if
(
item
.
type
==
group
)
{
auto
r
=
map
.
insert
(
std
::
make_pair
(
item
.
value
,
SearchStats
()));
SearchStats
&
s
=
r
.
first
->
second
;
SearchStats
&
s
=
r
.
first
->
second
;
++
s
.
n_songs
;
++
s
.
n_songs
;
if
(
!
tag
.
duration
.
IsNegative
())
if
(
!
tag
.
duration
.
IsNegative
())
s
.
total_duration
+=
tag
.
duration
;
s
.
total_duration
+=
tag
.
duration
;
found
=
true
;
}
}
return
found
;
}
}
static
void
static
void
...
@@ -99,9 +90,10 @@ GroupCountVisitor(TagCountMap &map, TagType group, const LightSong &song)
...
@@ -99,9 +90,10 @@ GroupCountVisitor(TagCountMap &map, TagType group, const LightSong &song)
assert
(
song
.
tag
!=
nullptr
);
assert
(
song
.
tag
!=
nullptr
);
const
Tag
&
tag
=
*
song
.
tag
;
const
Tag
&
tag
=
*
song
.
tag
;
ApplyTagWithFallback
(
group
,
VisitTagWithFallback
(
tag
,
group
,
std
::
bind
(
CollectGroupCounts
,
std
::
ref
(
map
),
std
::
bind
(
CollectGroupCounts
,
std
::
ref
(
map
),
std
::
placeholders
::
_1
,
std
::
cref
(
tag
)));
std
::
cref
(
tag
),
std
::
placeholders
::
_1
));
}
}
void
void
...
...
src/tag/VisitFallback.hxx
0 → 100644
View file @
6c06244e
/*
* 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_VISIT_FALLBACK_HXX
#define MPD_TAG_VISIT_FALLBACK_HXX
#include "Fallback.hxx"
#include "Tag.hxx"
template
<
typename
F
>
bool
VisitTagType
(
const
Tag
&
tag
,
TagType
type
,
F
&&
f
)
noexcept
{
bool
found
=
false
;
for
(
const
auto
&
item
:
tag
)
{
if
(
item
.
type
==
type
)
{
found
=
true
;
f
(
item
.
value
);
}
}
return
found
;
}
template
<
typename
F
>
bool
VisitTagWithFallback
(
const
Tag
&
tag
,
TagType
type
,
F
&&
f
)
noexcept
{
return
ApplyTagWithFallback
(
type
,
[
&
](
TagType
type2
)
{
return
VisitTagType
(
tag
,
type2
,
f
);
});
}
#endif
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