Queue: add FindIdByUri()
authorMax Kellermann <max@musicpd.org>
Tue, 4 Sep 2018 08:20:04 +0000 (10:20 +0200)
committerMax Kellermann <max@musicpd.org>
Tue, 4 Sep 2018 08:20:04 +0000 (10:20 +0200)
src/Queue.hxx

index a9a190e..76f0630 100644 (file)
@@ -123,6 +123,20 @@ struct MpdQueue {
        int FindByUri(const struct mpd_song &song) const {
                return FindByUri(mpd_song_get_uri(&song));
        }
+
+       /**
+        * Like FindByUri(), but return the song id, not the song position
+        *
+        * @return the song id
+        */
+       template<typename U>
+       gcc_pure
+       int FindIdByUri(U &&uri) const {
+               int i = FindByUri(std::forward<U>(uri));
+               if (i >= 0)
+                       i = mpd_song_get_id(items[i].get());
+               return i;
+       }
 };
 
 #endif