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/Parser/PayloadParsers | |
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/Parser/PayloadParsers')
10 files changed, 14 insertions, 28 deletions
diff --git a/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp b/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp index 8a0ecd2..405c593 100644 --- a/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp +++ b/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -8,8 +8,6 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> - namespace Swift { BytestreamsParser::BytestreamsParser() : level(TopLevel) { diff --git a/Swiften/Parser/PayloadParsers/FormParser.cpp b/Swiften/Parser/PayloadParsers/FormParser.cpp index 5ea75c5..dff45df 100644 --- a/Swiften/Parser/PayloadParsers/FormParser.cpp +++ b/Swiften/Parser/PayloadParsers/FormParser.cpp @@ -7,8 +7,6 @@ #include <map> -#include <Swiften/Base/foreach.h> - namespace Swift { FormParser::FormParser() : level_(TopLevel), parsingItem_(false), parsingReported_(false), parsingOption_(false), hasReportedRef_(false){ @@ -190,15 +188,15 @@ void FormParser::handleEndElement(const std::string& element, const std::string& } else { if (currentPages_.size() > 0) { - foreach (std::shared_ptr<FormPage> page, currentPages_) { - foreach (std::string pageRef, page->getFieldRefs()) { + for (const auto& page : currentPages_) { + for (const auto& pageRef : page->getFieldRefs()) { if (pageRef == currentField_->getName()) { page->addField(currentField_); } } } - foreach (std::shared_ptr<FormSection> section, currentSections_) { - foreach (std::string sectionRef, section->getFieldRefs()) { + for (const auto& section : currentSections_) { + for (const auto& sectionRef : section->getFieldRefs()) { if (sectionRef == currentField_->getName()) { section->addField(currentField_); } diff --git a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp index a231397..b67556e 100644 --- a/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp +++ b/Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.cpp @@ -6,7 +6,6 @@ #include <Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/BlockListPayload.h> #include <Swiften/Elements/BlockPayload.h> #include <Swiften/Elements/UnblockPayload.h> @@ -167,7 +166,7 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() { factories_.push_back(std::make_shared<GenericPayloadParserFactory2<CarbonsSentParser> >("sent", "urn:xmpp:carbons:2", this)); factories_.push_back(std::make_shared<GenericPayloadParserFactory<CarbonsPrivateParser> >("private", "urn:xmpp:carbons:2")); - foreach(std::shared_ptr<PayloadParserFactory> factory, factories_) { + for (auto& factory : factories_) { addFactory(factory.get()); } defaultFactory_ = new RawXMLPayloadParserFactory(); @@ -177,7 +176,7 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() { FullPayloadParserFactoryCollection::~FullPayloadParserFactoryCollection() { setDefaultFactory(nullptr); delete defaultFactory_; - foreach(std::shared_ptr<PayloadParserFactory> factory, factories_) { + for (auto& factory : factories_) { removeFactory(factory.get()); } } diff --git a/Swiften/Parser/PayloadParsers/IBBParser.cpp b/Swiften/Parser/PayloadParsers/IBBParser.cpp index 4a6b841..9b6babc 100644 --- a/Swiften/Parser/PayloadParsers/IBBParser.cpp +++ b/Swiften/Parser/PayloadParsers/IBBParser.cpp @@ -8,7 +8,6 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/StringCodecs/Base64.h> namespace Swift { diff --git a/Swiften/Parser/PayloadParsers/MUCAdminPayloadParser.cpp b/Swiften/Parser/PayloadParsers/MUCAdminPayloadParser.cpp index 1fbff1c..bac2a78 100644 --- a/Swiften/Parser/PayloadParsers/MUCAdminPayloadParser.cpp +++ b/Swiften/Parser/PayloadParsers/MUCAdminPayloadParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Isode Limited. + * Copyright (c) 2011-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -8,13 +8,12 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/MUCOccupant.h> namespace Swift { void MUCAdminPayloadParser::handleTree(ParserElement::ref root) { - foreach (ParserElement::ref itemElement, root->getChildren("item", "http://jabber.org/protocol/muc#admin")) { + for (const auto& itemElement : root->getChildren("item", "http://jabber.org/protocol/muc#admin")) { MUCItem item = MUCItemParser::itemFromTree(itemElement); getPayloadInternal()->addItem(item); } diff --git a/Swiften/Parser/PayloadParsers/MUCDestroyPayloadParser.cpp b/Swiften/Parser/PayloadParsers/MUCDestroyPayloadParser.cpp index 95ff8c5..46bc9c5 100644 --- a/Swiften/Parser/PayloadParsers/MUCDestroyPayloadParser.cpp +++ b/Swiften/Parser/PayloadParsers/MUCDestroyPayloadParser.cpp @@ -1,13 +1,11 @@ /* - * Copyright (c) 2011 Isode Limited. + * Copyright (c) 2011-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/Parser/PayloadParsers/MUCDestroyPayloadParser.h> -#include <Swiften/Base/foreach.h> - namespace Swift { void MUCDestroyPayloadParser::handleTree(ParserElement::ref root) { diff --git a/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp b/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp index 00a5d4f..b1bf78e 100644 --- a/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp +++ b/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp @@ -8,7 +8,6 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/MUCOccupant.h> #include <Swiften/Parser/PayloadParserFactory.h> #include <Swiften/Parser/PayloadParserFactoryCollection.h> @@ -17,7 +16,7 @@ namespace Swift { void MUCUserPayloadParser::handleTree(ParserElement::ref root) { - foreach (ParserElement::ref child, root->getAllChildren()) { + for (const auto& child : root->getAllChildren()) { if (child->getName() == "item" && child->getNamespace() == root->getNamespace()) { MUCItem item = MUCItemParser::itemFromTree(child); getPayloadInternal()->addItem(item); diff --git a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp b/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp index 1b0c95d..ad66b3f 100644 --- a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp +++ b/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp @@ -13,8 +13,6 @@ #include <Swiften/Parser/PayloadParsers/FormParserFactory.h> #include <Swiften/Parser/PayloadParsers/FormParser.h> -#include <Swiften/Base/foreach.h> - #define FILE_TRANSFER_NS "http://jabber.org/protocol/si/profile/file-transfer" #define FEATURE_NEG_NS "http://jabber.org/protocol/feature-neg" @@ -93,7 +91,7 @@ void StreamInitiationParser::handleEndElement(const std::string& element, const FormField::ref field = std::dynamic_pointer_cast<FormField>(form->getField("stream-method")); if (field) { if (form->getType() == Form::FormType) { - foreach (const FormField::Option& option, field->getOptions()) { + for (const auto& option : field->getOptions()) { getPayloadInternal()->addProvidedMethod(option.value); } } diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp index 18597bd..f0cf68d 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp @@ -7,7 +7,6 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/MUCDestroyPayload.h> #include <Swiften/Parser/PayloadParsers/MUCUserPayloadParser.h> #include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> @@ -36,7 +35,7 @@ class MUCUserPayloadParserTest : public CppUnit::TestFixture MUCUserPayload::ref payload = std::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload()); - foreach (MUCUserPayload::StatusCode status, payload->getStatusCodes()) { + for (const auto& status : payload->getStatusCodes()) { if (status.code == 110) found110 = true; if (status.code == 210) found210 = true; } diff --git a/Swiften/Parser/PayloadParsers/VCardParser.cpp b/Swiften/Parser/PayloadParsers/VCardParser.cpp index 7867b2c..f8779d1 100644 --- a/Swiften/Parser/PayloadParsers/VCardParser.cpp +++ b/Swiften/Parser/PayloadParsers/VCardParser.cpp @@ -9,7 +9,6 @@ #include <cassert> #include <Swiften/Base/DateTime.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Parser/SerializingParser.h> #include <Swiften/StringCodecs/Base64.h> @@ -282,7 +281,7 @@ void VCardParser::handleCharacterData(const std::string& text) { std::string VCardParser::getElementHierarchy() const { std::string result; - foreach(const std::string& element, elementStack_) { + for (const auto& element : elementStack_) { result += "/" + element; } return result; |