summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-04-04 14:41:44 (GMT)
committerTobias Markmann <tm@ayena.de>2016-04-04 14:41:44 (GMT)
commit3c560e31b0f168da917e8d566db01fd1cd997d86 (patch)
treea6d1c5c276d3571c6303a31af9f3cefd34b13d52 /Swiften/Elements
parent4f3821a090931499b9c68b3b3ad785a98ea9d742 (diff)
downloadswift-3c560e31b0f168da917e8d566db01fd1cd997d86.zip
swift-3c560e31b0f168da917e8d566db01fd1cd997d86.tar.bz2
Modernize code to use range based for loops using clang-tidy
Run 'clang-tidy -fix -checks=modernize-loop-convert' on all source code files on OS X. This does not modernize platform specific code on Linux and Windows Test-Information: Code builds and unit tests pass on OS X 10.11.4. Change-Id: I65b99e0978cfab8ca6de2a3e5342e7a81416c12c
Diffstat (limited to 'Swiften/Elements')
-rw-r--r--Swiften/Elements/JingleContentPayload.h8
-rw-r--r--Swiften/Elements/JinglePayload.h8
-rw-r--r--Swiften/Elements/Stanza.cpp6
-rw-r--r--Swiften/Elements/Stanza.h8
4 files changed, 15 insertions, 15 deletions
diff --git a/Swiften/Elements/JingleContentPayload.h b/Swiften/Elements/JingleContentPayload.h
index 286e08b..744ac09 100644
--- a/Swiften/Elements/JingleContentPayload.h
+++ b/Swiften/Elements/JingleContentPayload.h
@@ -72,8 +72,8 @@ namespace Swift {
template<typename T>
std::shared_ptr<T> getDescription() const {
- for (size_t i = 0; i < descriptions.size(); ++i) {
- std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(descriptions[i]));
+ for (const auto& description : descriptions) {
+ std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(description));
if (result) {
return result;
}
@@ -83,8 +83,8 @@ namespace Swift {
template<typename T>
std::shared_ptr<T> getTransport() const {
- for (size_t i = 0; i < transports.size(); ++i) {
- std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(transports[i]));
+ for (const auto& transport : transports) {
+ std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(transport));
if (result) {
return result;
}
diff --git a/Swiften/Elements/JinglePayload.h b/Swiften/Elements/JinglePayload.h
index d1dfb44..a1e8500 100644
--- a/Swiften/Elements/JinglePayload.h
+++ b/Swiften/Elements/JinglePayload.h
@@ -124,8 +124,8 @@ namespace Swift {
template<typename T>
const std::vector<std::shared_ptr<T> > getPayloads() const {
std::vector<std::shared_ptr<T> > matched_payloads;
- for (std::vector<std::shared_ptr<Payload> >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) {
- std::shared_ptr<T> result = std::dynamic_pointer_cast<T>(*i);
+ for (const auto& payload : payloads) {
+ std::shared_ptr<T> result = std::dynamic_pointer_cast<T>(payload);
if (result) {
matched_payloads.push_back(result);
}
@@ -138,8 +138,8 @@ namespace Swift {
template<typename T>
const std::shared_ptr<T> getPayload() const {
std::shared_ptr<T> result;
- for (std::vector<std::shared_ptr<Payload> >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) {
- result = std::dynamic_pointer_cast<T>(*i);
+ for (const auto& payload : payloads) {
+ result = std::dynamic_pointer_cast<T>(payload);
if (result) {
return result;
}
diff --git a/Swiften/Elements/Stanza.cpp b/Swiften/Elements/Stanza.cpp
index 5d1229c..f5a1b58 100644
--- a/Swiften/Elements/Stanza.cpp
+++ b/Swiften/Elements/Stanza.cpp
@@ -58,9 +58,9 @@ boost::optional<boost::posix_time::ptime> Stanza::getTimestamp() const {
boost::optional<boost::posix_time::ptime> Stanza::getTimestampFrom(const JID& jid) const {
std::vector< std::shared_ptr<Delay> > delays = getPayloads<Delay>();
- for (size_t i = 0; i < delays.size(); ++i) {
- if (delays[i]->getFrom() == jid) {
- return delays[i]->getStamp();
+ for (auto& delay : delays) {
+ if (delay->getFrom() == jid) {
+ return delay->getStamp();
}
}
return getTimestamp();
diff --git a/Swiften/Elements/Stanza.h b/Swiften/Elements/Stanza.h
index 2df64a1..9a69696 100644
--- a/Swiften/Elements/Stanza.h
+++ b/Swiften/Elements/Stanza.h
@@ -33,8 +33,8 @@ namespace Swift {
template<typename T>
std::shared_ptr<T> getPayload() const {
- for (size_t i = 0; i < payloads_.size(); ++i) {
- std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(payloads_[i]));
+ for (const auto& payload : payloads_) {
+ std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(payload));
if (result) {
return result;
}
@@ -45,8 +45,8 @@ namespace Swift {
template<typename T>
std::vector< std::shared_ptr<T> > getPayloads() const {
std::vector< std::shared_ptr<T> > results;
- for (size_t i = 0; i < payloads_.size(); ++i) {
- std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(payloads_[i]));
+ for (const auto& payload : payloads_) {
+ std::shared_ptr<T> result(std::dynamic_pointer_cast<T>(payload));
if (result) {
results.push_back(result);
}