diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2013-05-17 14:02:31 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2013-05-17 15:18:17 +0200 |
commit | 2f9ab8f2676da1ebf1729ff407f205e510b506da (patch) | |
tree | fe312fe9e240a3519d9e8c12cba7bd1c38b82d6e /src | |
parent | e5e6de8d3154cedcf008285e3169d0480ef73d03 (diff) |
mpdpp: make all consumers take values, not rvalue references
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.cpp | 2 | ||||
-rw-r--r-- | src/browser.cpp | 12 | ||||
-rw-r--r-- | src/helpers.h | 6 | ||||
-rw-r--r-- | src/media_library.cpp | 16 | ||||
-rw-r--r-- | src/mpdpp.cpp | 4 | ||||
-rw-r--r-- | src/mpdpp.h | 8 | ||||
-rw-r--r-- | src/mutable_song.cpp | 2 | ||||
-rw-r--r-- | src/mutable_song.h | 2 | ||||
-rw-r--r-- | src/outputs.cpp | 2 | ||||
-rw-r--r-- | src/playlist_editor.cpp | 8 | ||||
-rw-r--r-- | src/search_engine.cpp | 6 | ||||
-rw-r--r-- | src/sel_items_adder.cpp | 2 | ||||
-rw-r--r-- | src/server_info.cpp | 8 | ||||
-rw-r--r-- | src/status.cpp | 2 | ||||
-rw-r--r-- | src/tag_editor.cpp | 6 | ||||
-rw-r--r-- | src/visualizer.cpp | 2 |
16 files changed, 38 insertions, 50 deletions
diff --git a/src/actions.cpp b/src/actions.cpp index a93dab10..5fd0b169 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1263,7 +1263,7 @@ void EditLibraryTag::run() assert(set); bool success = true; std::string dir_to_update; - Mpd.CommitSearchSongs([set, &dir_to_update, &new_tag, &success](MPD::Song &&s) { + Mpd.CommitSearchSongs([set, &dir_to_update, &new_tag, &success](MPD::Song s) { if (!success) return; MPD::MutableSong ms = s; diff --git a/src/browser.cpp b/src/browser.cpp index 4328f055..a5f06ce2 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -337,18 +337,14 @@ MPD::SongList Browser::getSelectedSongs() else # endif // !WIN32 { - Mpd.GetDirectoryRecursive(item.name, [&result](MPD::Song &&s) { - result.push_back(s); - }); + Mpd.GetDirectoryRecursive(item.name, vectorMoveInserter(result)); } } else if (item.type == itSong) result.push_back(*item.song); else if (item.type == itPlaylist) { - Mpd.GetPlaylistContent(item.name, [&result](MPD::Song &&s) { - result.push_back(s); - }); + Mpd.GetPlaylistContent(item.name, vectorMoveInserter(result)); } }; for (auto it = w.begin(); it != w.end(); ++it) @@ -415,9 +411,7 @@ void Browser::GetDirectory(std::string dir, std::string subdir) if (isLocal()) GetLocalDirectory(list, itsBrowsedDir, false); else - Mpd.GetDirectory(dir, [&list](MPD::Item &&item) { - list.push_back(item); - }); + Mpd.GetDirectory(dir, vectorMoveInserter(list)); # else list = Mpd.GetDirectory(dir); # endif // !WIN32 diff --git a/src/helpers.h b/src/helpers.h index 1a851c85..988f6d4b 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -334,6 +334,12 @@ void clearPlaylist(NC::Menu<MPD::Song> &m, F delete_fun, G clear_fun) clear_fun(Mpd); } +template <typename ItemT> +std::function<void (ItemT)> vectorMoveInserter(std::vector<ItemT> &v) +{ + return [&](ItemT item) { v.push_back(std::move(item)); }; +} + template <typename Iterator> std::string getSharedDirectory(Iterator first, Iterator last) { assert(first != last); diff --git a/src/media_library.cpp b/src/media_library.cpp index fe986be7..0cc30f52 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -256,7 +256,7 @@ void MediaLibrary::update() Albums.clearSearchResults(); m_albums_update_request = false; std::map<std::tuple<std::string, std::string, std::string>, time_t> albums; - Mpd.GetDirectoryRecursive("/", [&albums](MPD::Song &&s) { + Mpd.GetDirectoryRecursive("/", [&albums](MPD::Song s) { unsigned idx = 0; std::string tag = s.get(Config.media_lib_primary_tag, idx); do @@ -298,7 +298,7 @@ void MediaLibrary::update() Tags.clearSearchResults(); m_tags_update_request = false; std::map<std::string, time_t> tags; - Mpd.GetDirectoryRecursive("/", [&tags](MPD::Song &&s) { + Mpd.GetDirectoryRecursive("/", [&tags](MPD::Song s) { unsigned idx = 0; std::string tag = s.get(Config.media_lib_primary_tag, idx); do @@ -336,7 +336,7 @@ void MediaLibrary::update() Mpd.StartSearch(true); Mpd.AddSearch(Config.media_lib_primary_tag, primary_tag); std::map<std::tuple<std::string, std::string>, time_t> albums; - Mpd.CommitSearchSongs([&albums](MPD::Song &&s) { + Mpd.CommitSearchSongs([&albums](MPD::Song s) { auto key = std::make_tuple(s.getAlbum(), s.getDate()); auto it = albums.find(key); if (it == albums.end()) @@ -388,7 +388,7 @@ void MediaLibrary::update() } withUnfilteredMenuReapplyFilter(Songs, [this, &album]() { size_t idx = 0; - Mpd.CommitSearchSongs([this, &idx](MPD::Song &&s) { + Mpd.CommitSearchSongs([this, &idx](MPD::Song s) { bool is_playlist = myPlaylist->checkForSong(s); if (idx < Songs.size()) { @@ -714,9 +714,7 @@ MPD::SongList MediaLibrary::getSelectedSongs() auto tag_handler = [&result](const std::string &tag) { Mpd.StartSearch(true); Mpd.AddSearch(Config.media_lib_primary_tag, tag); - Mpd.CommitSearchSongs([&result](MPD::Song &&s) { - result.push_back(s); - }); + Mpd.CommitSearchSongs(vectorMoveInserter(result)); }; for (auto it = Tags.begin(); it != Tags.end(); ++it) if (it->isSelected()) @@ -741,9 +739,7 @@ MPD::SongList MediaLibrary::getSelectedSongs() Mpd.AddSearch(MPD_TAG_ALBUM, sc.entry().album()); Mpd.AddSearch(MPD_TAG_DATE, sc.entry().date()); size_t begin = result.size(); - Mpd.CommitSearchSongs([&result](MPD::Song &&s) { - result.push_back(s); - }); + Mpd.CommitSearchSongs(vectorMoveInserter(result)); std::sort(result.begin()+begin, result.end(), SortSongs(false)); } } diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 900006a8..2ecb3fdd 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -640,7 +640,7 @@ void Connection::Add(const std::string &path) bool Connection::AddRandomTag(mpd_tag_type tag, size_t number) { StringList tags; - GetList(tag, [&tags](std::string &&tag_name) { + GetList(tag, [&tags](std::string tag_name) { tags.push_back(tag_name); }); if (number > tags.size()) @@ -658,7 +658,7 @@ bool Connection::AddRandomTag(mpd_tag_type tag, size_t number) StartSearch(1); AddSearch(tag, *it++); SongList songs; - CommitSearchSongs([&songs](MPD::Song &&s) { + CommitSearchSongs([&songs](MPD::Song s) { songs.push_back(s); }); StartCommandsList(); diff --git a/src/mpdpp.h b/src/mpdpp.h index 42beaf02..68a71447 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -148,10 +148,10 @@ class Connection { typedef void (*ErrorHandler) (Connection *, int, const char *, void *); - typedef std::function<void(Item &&)> ItemConsumer; - typedef std::function<void(Output &&)> OutputConsumer; - typedef std::function<void(Song &&)> SongConsumer; - typedef std::function<void(std::string &&)> StringConsumer; + typedef std::function<void(Item)> ItemConsumer; + typedef std::function<void(Output)> OutputConsumer; + typedef std::function<void(Song)> SongConsumer; + typedef std::function<void(std::string)> StringConsumer; public: Connection(); diff --git a/src/mutable_song.cpp b/src/mutable_song.cpp index 3c3cc7c0..fbf89179 100644 --- a/src/mutable_song.cpp +++ b/src/mutable_song.cpp @@ -200,7 +200,7 @@ void MutableSong::clearModifications() m_tags.clear(); } -void MutableSong::replaceTag(mpd_tag_type tag_type, std::string &&orig_value, const std::string &value, unsigned idx) +void MutableSong::replaceTag(mpd_tag_type tag_type, std::string orig_value, const std::string &value, unsigned idx) { Tag tag(tag_type, idx); if (value == orig_value) diff --git a/src/mutable_song.h b/src/mutable_song.h index 53c4d13c..cdc35eec 100644 --- a/src/mutable_song.h +++ b/src/mutable_song.h @@ -91,7 +91,7 @@ private: unsigned m_idx; }; - void replaceTag(mpd_tag_type tag_type, std::string &&orig_value, + void replaceTag(mpd_tag_type tag_type, std::string orig_value, const std::string &value, unsigned idx); template <typename F> diff --git a/src/outputs.cpp b/src/outputs.cpp index 8aeac486..bb634eed 100644 --- a/src/outputs.cpp +++ b/src/outputs.cpp @@ -99,7 +99,7 @@ void Outputs::mouseButtonPressed(MEVENT me) void Outputs::FetchList() { w.clear(); - Mpd.GetOutputs([this](MPD::Output &&output) { + Mpd.GetOutputs([this](MPD::Output output) { w.addItem(output, output.isEnabled()); }); if (myScreen == this) diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index 1ce14db2..8f45cf8e 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -133,7 +133,7 @@ void PlaylistEditor::update() Playlists.clearSearchResults(); withUnfilteredMenuReapplyFilter(Playlists, [this]() { size_t idx = 0; - Mpd.GetPlaylists([this, &idx](std::string &&playlist) { + Mpd.GetPlaylists([this, &idx](std::string playlist) { if (idx < Playlists.size()) Playlists[idx].value() = playlist; else @@ -154,7 +154,7 @@ void PlaylistEditor::update() Content.clearSearchResults(); withUnfilteredMenuReapplyFilter(Content, [this]() { size_t idx = 0; - Mpd.GetPlaylistContent(Playlists.current().value(), [this, &idx](MPD::Song &&s) { + Mpd.GetPlaylistContent(Playlists.current().value(), [this, &idx](MPD::Song s) { if (idx < Content.size()) { Content[idx].value() = s; @@ -459,9 +459,7 @@ MPD::SongList PlaylistEditor::getSelectedSongs() if (it->isSelected()) { any_selected = true; - Mpd.GetPlaylistContent(it->value(), [&result](MPD::Song &&s) { - result.push_back(s); - }); + Mpd.GetPlaylistContent(it->value(), vectorMoveInserter(result)); } } // we don't check for empty result here as it's possible that diff --git a/src/search_engine.cpp b/src/search_engine.cpp index 9e795a3e..382ecedb 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -434,7 +434,7 @@ void SearchEngine::Search() Mpd.AddSearch(MPD_TAG_DATE, itsConstraints[9]); if (!itsConstraints[10].empty()) Mpd.AddSearch(MPD_TAG_COMMENT, itsConstraints[10]); - Mpd.CommitSearchSongs([this](MPD::Song &&s) { + Mpd.CommitSearchSongs([this](MPD::Song s) { w.addItem(s); }); return; @@ -442,9 +442,7 @@ void SearchEngine::Search() MPD::SongList list; if (Config.search_in_db) - Mpd.GetDirectoryRecursive("/", [&list](MPD::Song &&s) { - list.push_back(s); - }); + Mpd.GetDirectoryRecursive("/", vectorMoveInserter(list)); else list.insert(list.end(), myPlaylist->main().beginV(), myPlaylist->main().endV()); diff --git a/src/sel_items_adder.cpp b/src/sel_items_adder.cpp index b14a6978..0212d61a 100644 --- a/src/sel_items_adder.cpp +++ b/src/sel_items_adder.cpp @@ -198,7 +198,7 @@ void SelectedItemsAdder::populatePlaylistSelector(BaseScreen *old_screen) if (old_screen != myBrowser || !myBrowser->isLocal()) { size_t begin = m_playlist_selector.size(); - Mpd.GetPlaylists([this](std::string &&playlist) { + Mpd.GetPlaylists([this](std::string playlist) { m_playlist_selector.addItem(Entry(playlist, std::bind(&Self::addToExistingPlaylist, this, playlist) )); diff --git a/src/server_info.cpp b/src/server_info.cpp index c7ec3e9b..bab07c74 100644 --- a/src/server_info.cpp +++ b/src/server_info.cpp @@ -48,12 +48,8 @@ void ServerInfo::switchTo() itsURLHandlers.clear(); itsTagTypes.clear(); - Mpd.GetURLHandlers([this](std::string &&handler) { - itsURLHandlers.push_back(handler); - }); - Mpd.GetTagTypes([this](std::string &&tag_type) { - itsTagTypes.push_back(tag_type); - }); + Mpd.GetURLHandlers(vectorMoveInserter(itsURLHandlers)); + Mpd.GetTagTypes(vectorMoveInserter(itsTagTypes)); } else switchToPreviousScreen(); diff --git a/src/status.cpp b/src/status.cpp index a43b7cd1..4badb49a 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -272,7 +272,7 @@ void Status::Changes::playlist() myPlaylist->main().resizeList(playlist_length); } - Mpd.GetPlaylistChanges(myPlaylist->oldVersion(), [](MPD::Song &&s) { + Mpd.GetPlaylistChanges(myPlaylist->oldVersion(), [](MPD::Song s) { size_t pos = s.getPosition(); if (pos < myPlaylist->main().size()) { diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 2c6979ab..be640f22 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -238,7 +238,7 @@ void TagEditor::update() Dirs->addItem(std::make_pair("..", getParentDirectory(itsBrowsedDir))); else Dirs->addItem(std::make_pair(".", "/")); - Mpd.GetDirectories(itsBrowsedDir, [this](std::string &&directory) { + Mpd.GetDirectories(itsBrowsedDir, [this](std::string directory) { Dirs->addItem(std::make_pair(getBasename(directory), directory)); if (directory == itsHighlightedDir) Dirs->highlight(Dirs->size()-1); @@ -251,7 +251,7 @@ void TagEditor::update() if (Tags->reallyEmpty()) { Tags->reset(); - Mpd.GetSongs(Dirs->current().value().second, [this](MPD::Song &&s) { + Mpd.GetSongs(Dirs->current().value().second, [this](MPD::Song s) { Tags->addItem(s); }); std::sort(Tags->beginV(), Tags->endV(), @@ -277,7 +277,7 @@ void TagEditor::enterPressed() if (w == Dirs) { bool has_subdirs = false; - Mpd.GetDirectories(Dirs->current().value().second, [&has_subdirs](std::string &&) { + Mpd.GetDirectories(Dirs->current().value().second, [&has_subdirs](std::string) { has_subdirs = true; }); if (has_subdirs) diff --git a/src/visualizer.cpp b/src/visualizer.cpp index 1e14400a..d1d1d6c7 100644 --- a/src/visualizer.cpp +++ b/src/visualizer.cpp @@ -216,7 +216,7 @@ void Visualizer::FindOutputID() if (!Config.visualizer_output_name.empty()) { size_t idx = 0; - Mpd.GetOutputs([this, &idx](MPD::Output &&output) { + Mpd.GetOutputs([this, &idx](MPD::Output output) { if (output.name() == Config.visualizer_output_name) m_output_id = idx; ++idx; |