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/Disco
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/Disco')
-rw-r--r--Swiften/Disco/CapsInfoGenerator.cpp11
-rw-r--r--Swiften/Disco/DiscoServiceWalker.cpp9
2 files changed, 9 insertions, 11 deletions
diff --git a/Swiften/Disco/CapsInfoGenerator.cpp b/Swiften/Disco/CapsInfoGenerator.cpp
index b4637c7..961ef43 100644
--- a/Swiften/Disco/CapsInfoGenerator.cpp
+++ b/Swiften/Disco/CapsInfoGenerator.cpp
@@ -8,7 +8,6 @@
#include <algorithm>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Elements/FormField.h>
@@ -30,28 +29,28 @@ CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const {
std::vector<DiscoInfo::Identity> identities(discoInfo.getIdentities());
std::sort(identities.begin(), identities.end());
- foreach (const DiscoInfo::Identity& identity, identities) {
+ for (const auto& identity : identities) {
serializedCaps += identity.getCategory() + "/" + identity.getType() + "/" + identity.getLanguage() + "/" + identity.getName() + "<";
}
std::vector<std::string> features(discoInfo.getFeatures());
std::sort(features.begin(), features.end());
- foreach (const std::string& feature, features) {
+ for (const auto& feature : features) {
serializedCaps += feature + "<";
}
- foreach(Form::ref extension, discoInfo.getExtensions()) {
+ for (const auto& extension : discoInfo.getExtensions()) {
serializedCaps += extension->getFormType() + "<";
std::vector<FormField::ref> fields(extension->getFields());
std::sort(fields.begin(), fields.end(), &compareFields);
- foreach(FormField::ref field, fields) {
+ for (const auto& field : fields) {
if (field->getName() == "FORM_TYPE") {
continue;
}
serializedCaps += field->getName() + "<";
std::vector<std::string> values(field->getValues());
std::sort(values.begin(), values.end());
- foreach(const std::string& value, values) {
+ for (const auto& value : values) {
serializedCaps += value + "<";
}
}
diff --git a/Swiften/Disco/DiscoServiceWalker.cpp b/Swiften/Disco/DiscoServiceWalker.cpp
index 761e6ab..a3f95d2 100644
--- a/Swiften/Disco/DiscoServiceWalker.cpp
+++ b/Swiften/Disco/DiscoServiceWalker.cpp
@@ -9,7 +9,6 @@
#include <boost/bind.hpp>
#include <Swiften/Base/Log.h>
-#include <Swiften/Base/foreach.h>
namespace Swift {
@@ -28,10 +27,10 @@ void DiscoServiceWalker::beginWalk() {
void DiscoServiceWalker::endWalk() {
if (active_) {
SWIFT_LOG(debug) << "Ending walk to " << service_ << std::endl;
- foreach (GetDiscoInfoRequest::ref request, pendingDiscoInfoRequests_) {
+ for (auto&& request : pendingDiscoInfoRequests_) {
request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoInfoResponse, this, _1, _2, request));
}
- foreach (GetDiscoItemsRequest::ref request, pendingDiscoItemsRequests_) {
+ for (auto&& request : pendingDiscoItemsRequests_) {
request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoItemsResponse, this, _1, _2, request));
}
active_ = false;
@@ -65,7 +64,7 @@ void DiscoServiceWalker::handleDiscoInfoResponse(std::shared_ptr<DiscoInfo> info
}
bool couldContainServices = false;
- foreach (DiscoInfo::Identity identity, info->getIdentities()) {
+ for (const auto& identity : info->getIdentities()) {
if (identity.getCategory() == "server") {
couldContainServices = true;
}
@@ -98,7 +97,7 @@ void DiscoServiceWalker::handleDiscoItemsResponse(std::shared_ptr<DiscoItems> it
handleDiscoError(request->getReceiver(), error);
return;
}
- foreach (DiscoItems::Item item, items->getItems()) {
+ for (auto&& item : items->getItems()) {
if (item.getNode().empty()) {
/* Don't look at noded items. It's possible that this will exclude some services,
* but I've never seen one in the wild, and it's an easy fix for not looping.