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
fcb55f84
Commit
fcb55f84
authored
Apr 26, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DatabasePrint: move PrintSongCount() to Count.cxx
parent
154e601f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
54 deletions
+112
-54
Makefile.am
Makefile.am
+1
-0
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+1
-0
Count.cxx
src/db/Count.cxx
+75
-0
Count.hxx
src/db/Count.hxx
+35
-0
DatabasePrint.cxx
src/db/DatabasePrint.cxx
+0
-48
DatabasePrint.hxx
src/db/DatabasePrint.hxx
+0
-6
No files found.
Makefile.am
View file @
fcb55f84
...
...
@@ -194,6 +194,7 @@ libmpd_a_SOURCES += \
src/queue/PlaylistUpdate.cxx
\
src/command/StorageCommands.cxx src/command/StorageCommands.hxx
\
src/command/DatabaseCommands.cxx src/command/DatabaseCommands.hxx
\
src/db/Count.cxx src/db/Count.hxx
\
src/db/LightSong.cxx src/db/LightSong.hxx
\
src/db/LightDirectory.hxx
\
src/db/update/UpdateDomain.cxx src/db/update/UpdateDomain.hxx
\
...
...
src/command/DatabaseCommands.cxx
View file @
fcb55f84
...
...
@@ -23,6 +23,7 @@
#include "db/DatabaseQueue.hxx"
#include "db/DatabasePlaylist.hxx"
#include "db/DatabasePrint.hxx"
#include "db/Count.hxx"
#include "db/Selection.hxx"
#include "CommandError.hxx"
#include "client/Client.hxx"
...
...
src/db/Count.cxx
0 → 100644
View file @
fcb55f84
/*
* Copyright (C) 2003-2014 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.
*/
#include "config.h"
#include "Count.hxx"
#include "Selection.hxx"
#include "Interface.hxx"
#include "client/Client.hxx"
#include "LightSong.hxx"
#include <functional>
struct
SearchStats
{
unsigned
n_songs
;
unsigned
long
total_time_s
;
};
static
void
PrintSearchStats
(
Client
&
client
,
const
SearchStats
&
stats
)
{
client_printf
(
client
,
"songs: %u
\n
"
"playtime: %lu
\n
"
,
stats
.
n_songs
,
stats
.
total_time_s
);
}
static
bool
stats_visitor_song
(
SearchStats
&
stats
,
const
LightSong
&
song
)
{
stats
.
n_songs
++
;
stats
.
total_time_s
+=
song
.
GetDuration
();
return
true
;
}
bool
PrintSongCount
(
Client
&
client
,
const
char
*
name
,
const
SongFilter
*
filter
,
Error
&
error
)
{
const
Database
*
db
=
client
.
GetDatabase
(
error
);
if
(
db
==
nullptr
)
return
false
;
const
DatabaseSelection
selection
(
name
,
true
,
filter
);
SearchStats
stats
;
stats
.
n_songs
=
0
;
stats
.
total_time_s
=
0
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
stats_visitor_song
,
std
::
ref
(
stats
),
_1
);
if
(
!
db
->
Visit
(
selection
,
f
,
error
))
return
false
;
PrintSearchStats
(
client
,
stats
);
return
true
;
}
src/db/Count.hxx
0 → 100644
View file @
fcb55f84
/*
* Copyright (C) 2003-2014 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_DB_COUNT_HXX
#define MPD_DB_COUNT_HXX
#include "Compiler.h"
class
Client
;
class
SongFilter
;
class
Error
;
gcc_nonnull
(
2
)
bool
PrintSongCount
(
Client
&
client
,
const
char
*
name
,
const
SongFilter
*
filter
,
Error
&
error
);
#endif
src/db/DatabasePrint.cxx
View file @
fcb55f84
...
...
@@ -168,54 +168,6 @@ db_selection_print(Client &client, const DatabaseSelection &selection,
return
db
->
Visit
(
selection
,
d
,
s
,
p
,
error
);
}
struct
SearchStats
{
unsigned
n_songs
;
unsigned
long
total_time_s
;
};
static
void
PrintSearchStats
(
Client
&
client
,
const
SearchStats
&
stats
)
{
client_printf
(
client
,
"songs: %u
\n
"
"playtime: %lu
\n
"
,
stats
.
n_songs
,
stats
.
total_time_s
);
}
static
bool
stats_visitor_song
(
SearchStats
&
stats
,
const
LightSong
&
song
)
{
stats
.
n_songs
++
;
stats
.
total_time_s
+=
song
.
GetDuration
();
return
true
;
}
bool
PrintSongCount
(
Client
&
client
,
const
char
*
name
,
const
SongFilter
*
filter
,
Error
&
error
)
{
const
Database
*
db
=
client
.
GetDatabase
(
error
);
if
(
db
==
nullptr
)
return
false
;
const
DatabaseSelection
selection
(
name
,
true
,
filter
);
SearchStats
stats
;
stats
.
n_songs
=
0
;
stats
.
total_time_s
=
0
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
stats_visitor_song
,
std
::
ref
(
stats
),
_1
);
if
(
!
db
->
Visit
(
selection
,
f
,
error
))
return
false
;
PrintSearchStats
(
client
,
stats
);
return
true
;
}
static
bool
PrintSongURIVisitor
(
Client
&
client
,
const
LightSong
&
song
)
{
...
...
src/db/DatabasePrint.hxx
View file @
fcb55f84
...
...
@@ -37,12 +37,6 @@ bool
db_selection_print
(
Client
&
client
,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
,
Error
&
error
);
gcc_nonnull
(
2
)
bool
PrintSongCount
(
Client
&
client
,
const
char
*
name
,
const
SongFilter
*
filter
,
Error
&
error
);
bool
PrintUniqueTags
(
Client
&
client
,
unsigned
type
,
uint32_t
group_mask
,
const
SongFilter
*
filter
,
...
...
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