diff options
author | Tobias Markmann <tm@ayena.de> | 2016-11-23 07:09:39 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-11-23 11:30:02 (GMT) |
commit | e405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch) | |
tree | 9118ef838ebfaec1df90ec24761944b5d833774c /Swiften/Roster | |
parent | 8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff) | |
download | swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.zip swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.tar.bz2 |
Migrate remaining Swiften/Base/foreach.h use to range-based for loop
Test-Information:
Build on macOS 10.12.1 and all tests pass.
Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
Diffstat (limited to 'Swiften/Roster')
-rw-r--r-- | Swiften/Roster/XMPPRosterController.cpp | 7 | ||||
-rw-r--r-- | Swiften/Roster/XMPPRosterImpl.cpp | 8 |
2 files changed, 6 insertions, 9 deletions
diff --git a/Swiften/Roster/XMPPRosterController.cpp b/Swiften/Roster/XMPPRosterController.cpp index 57b0645..8ee9755 100644 --- a/Swiften/Roster/XMPPRosterController.cpp +++ b/Swiften/Roster/XMPPRosterController.cpp @@ -9,7 +9,6 @@ #include <boost/bind.hpp> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/RosterItemPayload.h> #include <Swiften/Queries/IQRouter.h> #include <Swiften/Roster/GetRosterRequest.h> @@ -51,7 +50,7 @@ void XMPPRosterController::requestRoster() { void XMPPRosterController::handleRosterReceived(std::shared_ptr<RosterPayload> rosterPayload, bool initial, std::shared_ptr<RosterPayload> previousRoster) { if (rosterPayload) { - foreach(const RosterItemPayload& item, rosterPayload->getItems()) { + for (const auto& item : rosterPayload->getItems()) { //Don't worry about the updated case, the XMPPRoster sorts that out. if (item.getSubscription() == RosterItemPayload::Remove) { xmppRoster_->removeContact(item.getJID()); @@ -62,7 +61,7 @@ void XMPPRosterController::handleRosterReceived(std::shared_ptr<RosterPayload> r } else if (previousRoster) { // The cached version hasn't changed; emit all items - foreach(const RosterItemPayload& item, previousRoster->getItems()) { + for (const auto& item : previousRoster->getItems()) { if (item.getSubscription() != RosterItemPayload::Remove) { xmppRoster_->addContact(item.getJID(), item.getName(), item.getGroups(), item.getSubscription()); } @@ -83,7 +82,7 @@ void XMPPRosterController::saveRoster(const std::string& version) { std::vector<XMPPRosterItem> items = xmppRoster_->getItems(); std::shared_ptr<RosterPayload> roster(new RosterPayload()); roster->setVersion(version); - foreach(const XMPPRosterItem& item, items) { + for (const auto& item : items) { roster->addItem(RosterItemPayload(item.getJID(), item.getName(), item.getSubscription(), item.getGroups())); } rosterStorage_->setRoster(roster); diff --git a/Swiften/Roster/XMPPRosterImpl.cpp b/Swiften/Roster/XMPPRosterImpl.cpp index 9a2ea7a..74f634f 100644 --- a/Swiften/Roster/XMPPRosterImpl.cpp +++ b/Swiften/Roster/XMPPRosterImpl.cpp @@ -1,13 +1,11 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Roster/XMPPRosterImpl.h> -#include <Swiften/Base/foreach.h> - namespace Swift { XMPPRosterImpl::XMPPRosterImpl() { @@ -78,7 +76,7 @@ RosterItemPayload::Subscription XMPPRosterImpl::getSubscriptionStateForJID(const std::vector<XMPPRosterItem> XMPPRosterImpl::getItems() const { std::vector<XMPPRosterItem> result; - foreach(const RosterMap::value_type& entry, entries_) { + for (const auto& entry : entries_) { result.push_back(entry.second); } return result; @@ -96,7 +94,7 @@ boost::optional<XMPPRosterItem> XMPPRosterImpl::getItem(const JID& jid) const { std::set<std::string> XMPPRosterImpl::getGroups() const { std::set<std::string> result; - foreach(const RosterMap::value_type& entry, entries_) { + for (const auto& entry : entries_) { std::vector<std::string> groups = entry.second.getGroups(); result.insert(groups.begin(), groups.end()); } |