From 42bba40baff4973b5ffcb2dd7cdb9771d907ecc2 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 1 Nov 2014 22:20:34 +0100 Subject: [PATCH] mpd: add Playlist --- src/mpdpp.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/mpdpp.h b/src/mpdpp.h index ac4034c9..915bb3cc 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -121,6 +121,51 @@ private: std::shared_ptr m_status; }; +struct Playlist +{ + Playlist() { } + Playlist(mpd_playlist *playlist) : m_playlist(playlist, mpd_playlist_free) { } + + Playlist(const Playlist &rhs) : m_playlist(rhs.m_playlist) { } + Playlist(Playlist &&rhs) : m_playlist(std::move(rhs.m_playlist)) { } + Playlist &operator=(Playlist rhs) + { + m_playlist = std::move(rhs.m_playlist); + return *this; + } + + bool operator==(const Playlist &rhs) + { + if (empty() && rhs.empty()) + return true; + else if (!empty() && !rhs.empty()) + return strcmp(path(), rhs.path()) == 0 + && lastModified() == rhs.lastModified(); + else + return false; + } + bool operator!=(const Playlist &rhs) + { + return !(*this == rhs); + } + + const char *path() const + { + assert(m_playlist.get() != nullptr); + return mpd_playlist_get_path(m_playlist.get()); + } + time_t lastModified() const + { + assert(m_playlist.get() != nullptr); + return mpd_playlist_get_last_modified(m_playlist.get()); + } + + bool empty() const { return m_playlist.get() == nullptr; } + +private: + std::shared_ptr m_playlist; +}; + struct Item { std::shared_ptr song;