summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-11-23 07:09:39 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-23 11:30:02 (GMT)
commite405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch)
tree9118ef838ebfaec1df90ec24761944b5d833774c /Slimber
parent8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff)
downloadswift-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 'Slimber')
-rw-r--r--Slimber/LinkLocalPresenceManager.cpp9
-rw-r--r--Slimber/MainController.cpp3
-rw-r--r--Slimber/MenuletController.cpp4
-rw-r--r--Slimber/Server.cpp18
4 files changed, 15 insertions, 19 deletions
diff --git a/Slimber/LinkLocalPresenceManager.cpp b/Slimber/LinkLocalPresenceManager.cpp
index f166b38..ec5f2cd 100644
--- a/Slimber/LinkLocalPresenceManager.cpp
+++ b/Slimber/LinkLocalPresenceManager.cpp
@@ -8,7 +8,6 @@
#include <boost/bind.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/Presence.h>
#include <Swiften/Elements/RosterPayload.h>
#include <Swiften/LinkLocal/LinkLocalServiceBrowser.h>
@@ -25,7 +24,7 @@ LinkLocalPresenceManager::LinkLocalPresenceManager(LinkLocalServiceBrowser* brow
}
boost::optional<LinkLocalService> LinkLocalPresenceManager::getServiceForJID(const JID& j) const {
- foreach(const LinkLocalService& service, browser->getServices()) {
+ for (const auto& service : browser->getServices()) {
if (service.getJID() == j) {
return service;
}
@@ -52,7 +51,7 @@ void LinkLocalPresenceManager::handleServiceRemoved(const LinkLocalService& serv
std::shared_ptr<RosterPayload> LinkLocalPresenceManager::getRoster() const {
std::shared_ptr<RosterPayload> roster(new RosterPayload());
- foreach(const LinkLocalService& service, browser->getServices()) {
+ for (const auto& service : browser->getServices()) {
roster->addItem(getRosterItem(service));
}
return roster;
@@ -60,14 +59,14 @@ std::shared_ptr<RosterPayload> LinkLocalPresenceManager::getRoster() const {
std::vector<std::shared_ptr<Presence> > LinkLocalPresenceManager::getAllPresence() const {
std::vector<std::shared_ptr<Presence> > result;
- foreach(const LinkLocalService& service, browser->getServices()) {
+ for (const auto& service : browser->getServices()) {
result.push_back(getPresence(service));
}
return result;
}
RosterItemPayload LinkLocalPresenceManager::getRosterItem(const LinkLocalService& service) const {
- return RosterItemPayload(service.getJID(), getRosterName(service), RosterItemPayload::Both);
+ return RosterItemPayload(service.getJID(), getRosterName(service), RosterItemPayload::Both);
}
std::string LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const {
diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp
index dcec6d5..cd36132 100644
--- a/Slimber/MainController.cpp
+++ b/Slimber/MainController.cpp
@@ -9,7 +9,6 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h>
#include <Swiften/LinkLocal/LinkLocalService.h>
#include <Swiften/LinkLocal/LinkLocalServiceBrowser.h>
@@ -88,7 +87,7 @@ void MainController::handleSelfConnected(bool b) {
void MainController::handleServicesChanged() {
std::vector<std::string> names;
- foreach(const LinkLocalService& service, linkLocalServiceBrowser->getServices()) {
+ for (const auto& service : linkLocalServiceBrowser->getServices()) {
std::string description = service.getDescription();
if (description != service.getName()) {
description += " (" + service.getName() + ")";
diff --git a/Slimber/MenuletController.cpp b/Slimber/MenuletController.cpp
index fdf2fc7..5ea5bc9 100644
--- a/Slimber/MenuletController.cpp
+++ b/Slimber/MenuletController.cpp
@@ -8,8 +8,6 @@
#include <string>
-#include <Swiften/Base/foreach.h>
-
#include <Slimber/Menulet.h>
MenuletController::MenuletController(Menulet* menulet) :
@@ -41,7 +39,7 @@ void MenuletController::update() {
else {
menulet->setIcon("UsersOnline");
menulet->addItem("Online users:");
- foreach(const std::string& user, linkLocalUsers) {
+ for (const auto& user : linkLocalUsers) {
menulet->addItem(std::string(" ") + user);
}
}
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp
index 7e24abe..3bc3112 100644
--- a/Slimber/Server.cpp
+++ b/Slimber/Server.cpp
@@ -6,13 +6,13 @@
#include <Slimber/Server.h>
+#include <cassert>
#include <string>
#include <boost/bind.hpp>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/String.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/IQ.h>
#include <Swiften/Elements/Presence.h>
#include <Swiften/Elements/RosterPayload.h>
@@ -111,11 +111,11 @@ void Server::stop(boost::optional<ServerError> e) {
serverFromClientSession->finishSession();
}
serverFromClientSession.reset();
- foreach(std::shared_ptr<Session> session, linkLocalSessions) {
+ for (auto&& session : linkLocalSessions) {
session->finishSession();
}
linkLocalSessions.clear();
- foreach(std::shared_ptr<LinkLocalConnector> connector, connectors) {
+ for (auto&& connector : connectors) {
connector->cancel();
}
connectors.clear();
@@ -123,7 +123,7 @@ void Server::stop(boost::optional<ServerError> e) {
if (serverFromNetworkConnectionServer) {
serverFromNetworkConnectionServer->stop();
- foreach(boost::signals2::connection& connection, serverFromNetworkConnectionServerSignalConnections) {
+ for (auto&& connection : serverFromNetworkConnectionServerSignalConnections) {
connection.disconnect();
}
serverFromNetworkConnectionServerSignalConnections.clear();
@@ -131,7 +131,7 @@ void Server::stop(boost::optional<ServerError> e) {
}
if (serverFromClientConnectionServer) {
serverFromClientConnectionServer->stop();
- foreach(boost::signals2::connection& connection, serverFromClientConnectionServerSignalConnections) {
+ for (auto&& connection : serverFromClientConnectionServerSignalConnections) {
connection.disconnect();
}
serverFromClientConnectionServerSignalConnections.clear();
@@ -218,7 +218,7 @@ void Server::handleElementReceived(std::shared_ptr<ToplevelElement> element, std
if (iq->getType() == IQ::Get) {
session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), presenceManager->getRoster()));
rosterRequested = true;
- foreach(const std::shared_ptr<Presence> presence, presenceManager->getAllPresence()) {
+ for (const auto& presence : presenceManager->getAllPresence()) {
session->sendElement(presence);
}
}
@@ -314,7 +314,7 @@ void Server::handleConnectFinished(std::shared_ptr<LinkLocalConnector> connector
new OutgoingLinkLocalSession(
selfJID, connector->getService().getJID(), connector->getConnection(),
&payloadParserFactories, &payloadSerializers, &xmlParserFactory));
- foreach(const std::shared_ptr<ToplevelElement> element, connector->getQueuedElements()) {
+ for (const auto& element : connector->getQueuedElements()) {
outgoingSession->queueElement(element);
}
registerLinkLocalSession(outgoingSession);
@@ -333,7 +333,7 @@ void Server::registerLinkLocalSession(std::shared_ptr<Session> session) {
}
std::shared_ptr<Session> Server::getLinkLocalSessionForJID(const JID& jid) {
- foreach(const std::shared_ptr<Session> session, linkLocalSessions) {
+ for (const auto& session : linkLocalSessions) {
if (session->getRemoteJID() == jid) {
return session;
}
@@ -342,7 +342,7 @@ std::shared_ptr<Session> Server::getLinkLocalSessionForJID(const JID& jid) {
}
std::shared_ptr<LinkLocalConnector> Server::getLinkLocalConnectorForJID(const JID& jid) {
- foreach(const std::shared_ptr<LinkLocalConnector> connector, connectors) {
+ for (const auto& connector : connectors) {
if (connector->getService().getJID() == jid) {
return connector;
}