From 9d312ab208f797a69c8366f4a961d6cb3228cecb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 4 Jan 2013 00:02:09 +0100 Subject: PlaylistFile: reuse classes PlaylistInfo and PlaylistVector .. instead of rolling own classes. --- src/OtherCommands.cxx | 2 +- src/PlaylistCommands.cxx | 3 ++- src/PlaylistFile.cxx | 10 ++++++---- src/PlaylistFile.hxx | 13 +++---------- src/PlaylistInfo.hxx | 2 ++ src/PlaylistVector.hxx | 1 + 6 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/OtherCommands.cxx b/src/OtherCommands.cxx index 32d51c42e..9de616759 100644 --- a/src/OtherCommands.cxx +++ b/src/OtherCommands.cxx @@ -57,7 +57,7 @@ extern "C" { #include static void -print_spl_list(Client *client, const PlaylistFileList &list) +print_spl_list(Client *client, const PlaylistVector &list) { for (const auto &i : list) { client_printf(client, "playlist: %s\n", i.name.c_str()); diff --git a/src/PlaylistCommands.cxx b/src/PlaylistCommands.cxx index a684e4a3b..d2defff3f 100644 --- a/src/PlaylistCommands.cxx +++ b/src/PlaylistCommands.cxx @@ -24,6 +24,7 @@ #include "PlaylistPrint.hxx" #include "PlaylistSave.hxx" #include "PlaylistFile.hxx" +#include "PlaylistVector.hxx" #include "PlaylistQueue.hxx" #include "TimePrint.hxx" #include "ClientInternal.hxx" @@ -40,7 +41,7 @@ extern "C" { #include static void -print_spl_list(Client *client, const PlaylistFileList &list) +print_spl_list(Client *client, const PlaylistVector &list) { for (const auto &i : list) { client_printf(client, "playlist: %s\n", i.name.c_str()); diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index 03cd59d67..de12518d9 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -20,6 +20,8 @@ #include "config.h" #include "PlaylistFile.hxx" #include "PlaylistSave.hxx" +#include "PlaylistInfo.hxx" +#include "PlaylistVector.hxx" #include "DatabasePlugin.hxx" #include "DatabaseGlue.hxx" #include "song.h" @@ -140,7 +142,7 @@ playlist_errno(GError **error_r) } static bool -LoadPlaylistFileInfo(PlaylistFileInfo &info, +LoadPlaylistFileInfo(PlaylistInfo &info, const char *parent_path_fs, const char *name_fs) { size_t name_length = strlen(name_fs); @@ -172,10 +174,10 @@ LoadPlaylistFileInfo(PlaylistFileInfo &info, return true; } -PlaylistFileList +PlaylistVector ListPlaylistFiles(GError **error_r) { - PlaylistFileList list; + PlaylistVector list; const char *parent_path_fs = spl_map(error_r); if (parent_path_fs == NULL) @@ -187,7 +189,7 @@ ListPlaylistFiles(GError **error_r) return list; } - PlaylistFileInfo info; + PlaylistInfo info; struct dirent *ent; while ((ent = readdir(dir)) != NULL) { if (LoadPlaylistFileInfo(info, parent_path_fs, ent->d_name)) diff --git a/src/PlaylistFile.hxx b/src/PlaylistFile.hxx index 6df5a46d3..3f63253ad 100644 --- a/src/PlaylistFile.hxx +++ b/src/PlaylistFile.hxx @@ -20,7 +20,6 @@ #ifndef MPD_PLAYLIST_FILE_HXX #define MPD_PLAYLIST_FILE_HXX -#include #include #include @@ -28,14 +27,8 @@ #include struct song; - -struct PlaylistFileInfo { - std::string name; - - time_t mtime; -}; - -typedef std::list PlaylistFileList; +struct PlaylistInfo; +class PlaylistVector; typedef std::vector PlaylistFileContents; @@ -60,7 +53,7 @@ spl_valid_name(const char *name_utf8); * Returns a list of stored_playlist_info struct pointers. Returns * NULL if an error occurred. */ -PlaylistFileList +PlaylistVector ListPlaylistFiles(GError **error_r); PlaylistFileContents diff --git a/src/PlaylistInfo.hxx b/src/PlaylistInfo.hxx index a50cdd445..96e4f6db9 100644 --- a/src/PlaylistInfo.hxx +++ b/src/PlaylistInfo.hxx @@ -50,6 +50,8 @@ struct PlaylistInfo { } }; + PlaylistInfo() = default; + template PlaylistInfo(N &&_name, time_t _mtime) :name(std::forward(_name)), mtime(_mtime) {} diff --git a/src/PlaylistVector.hxx b/src/PlaylistVector.hxx index 0a4cd95b3..d10c90fda 100644 --- a/src/PlaylistVector.hxx +++ b/src/PlaylistVector.hxx @@ -37,6 +37,7 @@ public: using std::list::empty; using std::list::begin; using std::list::end; + using std::list::push_back; using std::list::erase; /** -- cgit v1.2.3