PlaylistFile: reuse classes PlaylistInfo and PlaylistVector

.. instead of rolling own classes.
This commit is contained in:
Max Kellermann 2013-01-04 00:02:09 +01:00
parent 06be0a1997
commit 9d312ab208
6 changed files with 15 additions and 16 deletions

View File

@ -57,7 +57,7 @@ extern "C" {
#include <string.h>
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());

View File

@ -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 <stdlib.h>
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());

View File

@ -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))

View File

@ -20,7 +20,6 @@
#ifndef MPD_PLAYLIST_FILE_HXX
#define MPD_PLAYLIST_FILE_HXX
#include <list>
#include <vector>
#include <string>
@ -28,14 +27,8 @@
#include <time.h>
struct song;
struct PlaylistFileInfo {
std::string name;
time_t mtime;
};
typedef std::list<PlaylistFileInfo> PlaylistFileList;
struct PlaylistInfo;
class PlaylistVector;
typedef std::vector<std::string> 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

View File

@ -50,6 +50,8 @@ struct PlaylistInfo {
}
};
PlaylistInfo() = default;
template<typename N>
PlaylistInfo(N &&_name, time_t _mtime)
:name(std::forward<N>(_name)), mtime(_mtime) {}

View File

@ -37,6 +37,7 @@ public:
using std::list<PlaylistInfo>::empty;
using std::list<PlaylistInfo>::begin;
using std::list<PlaylistInfo>::end;
using std::list<PlaylistInfo>::push_back;
using std::list<PlaylistInfo>::erase;
/**