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 /Swiften/Network
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 'Swiften/Network')
-rw-r--r--Swiften/Network/BOSHConnectionPool.cpp13
-rw-r--r--Swiften/Network/ChainedConnector.cpp1
-rw-r--r--Swiften/Network/DummyTimerFactory.cpp3
-rw-r--r--Swiften/Network/HTTPConnectProxiedConnection.cpp7
-rw-r--r--Swiften/Network/NetworkEnvironment.cpp5
-rw-r--r--Swiften/Network/PlatformDomainNameServiceQuery.cpp3
-rw-r--r--Swiften/Network/UnixProxyProvider.cpp1
-rw-r--r--Swiften/Network/WindowsNetworkEnvironment.cpp5
8 files changed, 14 insertions, 24 deletions
diff --git a/Swiften/Network/BOSHConnectionPool.cpp b/Swiften/Network/BOSHConnectionPool.cpp
index 9ce40d3..e4ca471 100644
--- a/Swiften/Network/BOSHConnectionPool.cpp
+++ b/Swiften/Network/BOSHConnectionPool.cpp
@@ -12,7 +12,6 @@
#include <Swiften/Base/Log.h>
#include <Swiften/Base/SafeString.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Network/CachingDomainNameResolver.h>
#include <Swiften/Network/HTTPConnectProxiedConnectionFactory.h>
@@ -40,13 +39,13 @@ BOSHConnectionPool::BOSHConnectionPool(const URL& boshURL, DomainNameResolver* r
BOSHConnectionPool::~BOSHConnectionPool() {
/* Don't do a normal close here. Instead kill things forcibly, as close() or writeFooter() will already have been called */
std::vector<BOSHConnection::ref> connectionCopies = connections;
- foreach (BOSHConnection::ref connection, connectionCopies) {
+ for (auto&& connection : connectionCopies) {
if (connection) {
destroyConnection(connection);
connection->disconnect();
}
}
- foreach (ConnectionFactory* factory, myConnectionFactories) {
+ for (auto factory : myConnectionFactories) {
delete factory;
}
delete resolver;
@@ -116,7 +115,7 @@ void BOSHConnectionPool::close() {
else {
pendingTerminate = true;
std::vector<BOSHConnection::ref> connectionCopies = connections;
- foreach (BOSHConnection::ref connection, connectionCopies) {
+ for (auto&& connection : connectionCopies) {
if (connection) {
connection->disconnect();
}
@@ -157,7 +156,7 @@ void BOSHConnectionPool::handleConnectFinished(bool error, BOSHConnection::ref c
BOSHConnection::ref BOSHConnectionPool::getSuitableConnection() {
BOSHConnection::ref suitableConnection;
- foreach (BOSHConnection::ref connection, connections) {
+ for (auto&& connection : connections) {
if (connection->isReadyToSend()) {
suitableConnection = connection;
break;
@@ -187,7 +186,7 @@ void BOSHConnectionPool::tryToSendQueuedData() {
rid++;
suitableConnection->setRID(rid);
SafeByteArray data;
- foreach (const SafeByteArray& datum, dataQueue) {
+ for (const auto& datum : dataQueue) {
data.insert(data.end(), datum.begin(), datum.end());
}
suitableConnection->write(data);
@@ -204,7 +203,7 @@ void BOSHConnectionPool::tryToSendQueuedData() {
if (!pendingTerminate) {
/* Ensure there's always a session waiting to read data for us */
bool pending = false;
- foreach (BOSHConnection::ref connection, connections) {
+ for (auto&& connection : connections) {
if (connection && !connection->isReadyToSend()) {
pending = true;
}
diff --git a/Swiften/Network/ChainedConnector.cpp b/Swiften/Network/ChainedConnector.cpp
index fbea868..ea55db3 100644
--- a/Swiften/Network/ChainedConnector.cpp
+++ b/Swiften/Network/ChainedConnector.cpp
@@ -11,7 +11,6 @@
#include <boost/bind.hpp>
#include <Swiften/Base/Log.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Network/ConnectionFactory.h>
#include <Swiften/Network/Connector.h>
diff --git a/Swiften/Network/DummyTimerFactory.cpp b/Swiften/Network/DummyTimerFactory.cpp
index cdc776c..0bad7be 100644
--- a/Swiften/Network/DummyTimerFactory.cpp
+++ b/Swiften/Network/DummyTimerFactory.cpp
@@ -8,7 +8,6 @@
#include <algorithm>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Network/Timer.h>
namespace Swift {
@@ -49,7 +48,7 @@ std::shared_ptr<Timer> DummyTimerFactory::createTimer(int milliseconds) {
void DummyTimerFactory::setTime(int time) {
assert(time > currentTime);
- foreach(std::shared_ptr<DummyTimer> timer, timers) {
+ for (auto&& timer : timers) {
if (timer->getAlarmTime() > currentTime && timer->getAlarmTime() <= time && timer->isRunning) {
timer->onTick();
}
diff --git a/Swiften/Network/HTTPConnectProxiedConnection.cpp b/Swiften/Network/HTTPConnectProxiedConnection.cpp
index b9ab604..b5e521b 100644
--- a/Swiften/Network/HTTPConnectProxiedConnection.cpp
+++ b/Swiften/Network/HTTPConnectProxiedConnection.cpp
@@ -24,7 +24,6 @@
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/String.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Network/ConnectionFactory.h>
#include <Swiften/Network/HTTPTrafficFilter.h>
#include <Swiften/Network/HostAddressPort.h>
@@ -68,8 +67,7 @@ void HTTPConnectProxiedConnection::initializeProxy() {
append(data, createSafeByteArray("\r\n"));
}
else if (!nextHTTPRequestHeaders_.empty()) {
- typedef std::pair<std::string, std::string> StringPair;
- foreach(const StringPair& headerField, nextHTTPRequestHeaders_) {
+ for (const auto& headerField : nextHTTPRequestHeaders_) {
append(data, createSafeByteArray(headerField.first));
append(data, createSafeByteArray(": "));
append(data, createSafeByteArray(headerField.second));
@@ -101,11 +99,10 @@ void HTTPConnectProxiedConnection::parseHTTPHeader(const std::string& data, std:
}
void HTTPConnectProxiedConnection::sendHTTPRequest(const std::string& statusLine, const std::vector<std::pair<std::string, std::string> >& headerFields) {
- typedef std::pair<std::string, std::string> HTTPHeaderField;
std::stringstream request;
request << statusLine << "\r\n";
- foreach (const HTTPHeaderField& field, headerFields) {
+ for (const auto& field : headerFields) {
request << field.first << ":" << field.second << "\r\n";
}
request << "\r\n";
diff --git a/Swiften/Network/NetworkEnvironment.cpp b/Swiften/Network/NetworkEnvironment.cpp
index 19f727c..87883c1 100644
--- a/Swiften/Network/NetworkEnvironment.cpp
+++ b/Swiften/Network/NetworkEnvironment.cpp
@@ -6,7 +6,6 @@
#include <Swiften/Network/NetworkEnvironment.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Network/HostAddress.h>
#include <Swiften/Network/NetworkInterface.h>
@@ -17,9 +16,9 @@ NetworkEnvironment::~NetworkEnvironment() {
HostAddress NetworkEnvironment::getLocalAddress() const {
std::vector<NetworkInterface> networkInterfaces = getNetworkInterfaces();
- foreach (const NetworkInterface& iface, networkInterfaces) {
+ for (const auto& iface : networkInterfaces) {
if (!iface.isLoopback()) {
- foreach (const HostAddress& address, iface.getAddresses()) {
+ for (const auto& address : iface.getAddresses()) {
if (address.getRawAddress().is_v4()) {
return address;
}
diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
index 71611f5..5cffcdb 100644
--- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp
+++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2015 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -29,7 +29,6 @@
#include <Swiften/Base/ByteArray.h>
#include <Swiften/EventLoop/EventLoop.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/BoostRandomGenerator.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Network/PlatformDomainNameResolver.h>
diff --git a/Swiften/Network/UnixProxyProvider.cpp b/Swiften/Network/UnixProxyProvider.cpp
index 6c23add..e6afa3d 100644
--- a/Swiften/Network/UnixProxyProvider.cpp
+++ b/Swiften/Network/UnixProxyProvider.cpp
@@ -12,7 +12,6 @@
#include <Swiften/Network/UnixProxyProvider.h>
-#include <Swiften/Base/foreach.h>
#if defined(HAVE_GCONF)
# include "Swiften/Network/GConfProxyProvider.h"
#endif
diff --git a/Swiften/Network/WindowsNetworkEnvironment.cpp b/Swiften/Network/WindowsNetworkEnvironment.cpp
index 6ce41de..e90a5c6 100644
--- a/Swiften/Network/WindowsNetworkEnvironment.cpp
+++ b/Swiften/Network/WindowsNetworkEnvironment.cpp
@@ -22,7 +22,6 @@
#include <winsock2.h>
#include <Swiften/Base/ByteArray.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Network/HostAddress.h>
#include <Swiften/Network/NetworkInterface.h>
@@ -65,8 +64,8 @@ std::vector<NetworkInterface> WindowsNetworkEnvironment::getNetworkInterfaces()
}
}
- for (std::map<std::string,NetworkInterface>::const_iterator i = interfaces.begin(); i != interfaces.end(); ++i) {
- result.push_back(i->second);
+ for (const auto& interface : interfaces) {
+ result.push_back(interface.second);
}
return result;
}