1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2018 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 struct mpd_connection;
31 struct FileListEntry {
33 struct mpd_entity *entity;
35 explicit FileListEntry(struct mpd_entity *_entity)
39 FileListEntry(FileListEntry &&src)
41 entity(std::exchange(src.entity, nullptr)) {}
43 FileListEntry &operator=(FileListEntry &&src) {
46 swap(entity, src.entity);
51 bool operator<(const FileListEntry &other) const;
55 using Vector = std::vector<FileListEntry>;
61 using size_type = Vector::size_type;
65 FileList(const FileList &) = delete;
66 FileList &operator=(const FileList &) = delete;
68 size_type size() const {
69 return entries.size();
73 return entries.empty();
76 FileListEntry &operator[](size_type i) {
80 const FileListEntry &operator[](size_type i) const {
84 FileListEntry &emplace_back(struct mpd_entity *entity);
86 void MoveFrom(FileList &&src);
89 * Sort the whole list.
94 * Eliminates duplicate songs from the FileList.
96 void RemoveDuplicateSongs();
99 int FindSong(const struct mpd_song &song) const;
102 int FindDirectory(const char *name) const;
105 * Receives entities from the connection, and appends them to the
106 * specified FileList. This does not finish the response, and does
107 * not check for errors.
109 void Receive(struct mpd_connection &connection);
113 * Creates a new FileList and receives entities from the connection.
114 * This does not finish the response, and does not check for errors.
117 filelist_new_recv(struct mpd_connection *connection);