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/Serializer | |
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/Serializer')
46 files changed, 77 insertions, 138 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp index 93eab75..78bb0eb 100644 --- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp @@ -10,7 +10,6 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -22,7 +21,7 @@ BytestreamsSerializer::BytestreamsSerializer() { std::string BytestreamsSerializer::serializePayload(std::shared_ptr<Bytestreams> bytestreams) const { XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams"); queryElement.setAttribute("sid", bytestreams->getStreamID()); - foreach(const Bytestreams::StreamHost& streamHost, bytestreams->getStreamHosts()) { + for (const auto& streamHost : bytestreams->getStreamHosts()) { std::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost")); streamHostElement->setAttribute("host", streamHost.host); streamHostElement->setAttribute("jid", streamHost.jid.toString()); diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp index e1dd6ed..25a70f6 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/FormSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -50,14 +49,14 @@ std::string CommandSerializer::serializePayload(std::shared_ptr<Command> command actions += " execute='" + executeAction + "'"; } actions += ">"; - foreach (Command::Action action, command->getAvailableActions()) { + for (const auto& action : command->getAvailableActions()) { actions += "<" + actionToString(action) + "/>"; } actions += "</actions>"; commandElement.addNode(std::make_shared<XMLRawTextNode>(actions)); } - foreach (Command::Note note, command->getNotes()) { + for (const auto& note : command->getNotes()) { std::shared_ptr<XMLElement> noteElement(new XMLElement("note")); std::string type; switch (note.type) { diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp index 73e2585..06cad2b 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/FormSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -23,7 +22,7 @@ std::string DiscoInfoSerializer::serializePayload(std::shared_ptr<DiscoInfo> dis if (!discoInfo->getNode().empty()) { queryElement.setAttribute("node", discoInfo->getNode()); } - foreach(const DiscoInfo::Identity& identity, discoInfo->getIdentities()) { + for (const auto& identity : discoInfo->getIdentities()) { std::shared_ptr<XMLElement> identityElement(new XMLElement("identity")); if (!identity.getLanguage().empty()) { identityElement->setAttribute("xml:lang", identity.getLanguage()); @@ -33,12 +32,12 @@ std::string DiscoInfoSerializer::serializePayload(std::shared_ptr<DiscoInfo> dis identityElement->setAttribute("type", identity.getType()); queryElement.addNode(identityElement); } - foreach(const std::string& feature, discoInfo->getFeatures()) { + for (const auto& feature : discoInfo->getFeatures()) { std::shared_ptr<XMLElement> featureElement(new XMLElement("feature")); featureElement->setAttribute("var", feature); queryElement.addNode(featureElement); } - foreach(const Form::ref extension, discoInfo->getExtensions()) { + for (const auto& extension : discoInfo->getExtensions()) { queryElement.addNode(std::make_shared<XMLRawTextNode>(FormSerializer().serialize(extension))); } return queryElement.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp index 1b734dc..a8eafef 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> namespace Swift { @@ -21,7 +20,7 @@ std::string DiscoItemsSerializer::serializePayload(std::shared_ptr<DiscoItems> d if (!discoItems->getNode().empty()) { queryElement.setAttribute("node", discoItems->getNode()); } - foreach(const DiscoItems::Item& item, discoItems->getItems()) { + for (const auto& item : discoItems->getItems()) { std::shared_ptr<XMLElement> itemElement(new XMLElement("item")); itemElement->setAttribute("name", item.getName()); itemElement->setAttribute("jid", item.getJID()); diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp index ed010b4..f723ead 100644 --- a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp @@ -11,7 +11,6 @@ #include <Swiften/Base/Algorithm.h> #include <Swiften/Base/String.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -52,33 +51,33 @@ std::string FormSerializer::serializePayload(std::shared_ptr<Form> form) const if (!form->getInstructions().empty()) { multiLineify(form->getInstructions(), "instructions", formElement); } - foreach(std::shared_ptr<FormPage> page, form->getPages()) { + for (const auto& page : form->getPages()) { formElement->addNode(pageToXML(page)); } - foreach(std::shared_ptr<FormField> field, form->getFields()) { + for (const auto& field : form->getFields()) { formElement->addNode(fieldToXML(field, true)); } if (!form->getReportedFields().empty()) { std::shared_ptr<XMLElement> reportedElement(new XMLElement("reported")); - foreach(FormField::ref field, form->getReportedFields()) { + for (const auto& field : form->getReportedFields()) { reportedElement->addNode(fieldToXML(field, true)); } formElement->addNode(reportedElement); } - foreach(Form::FormItem item, form->getItems()) { + for (const auto& item : form->getItems()) { std::shared_ptr<XMLElement> itemElement(new XMLElement("item")); - foreach(FormField::ref field, item) { + for (const auto& field : item) { itemElement->addNode(fieldToXML(field, false)); } formElement->addNode(itemElement); } - foreach(const FormText::text text, form->getTextElements()) { + for (const auto& text : form->getTextElements()) { formElement->addNode(textToXML(text)); } - foreach (std::shared_ptr<FormField> field, fields_) { + for (const auto& field : fields_) { formElement->addNode(fieldToXML(field,true)); } @@ -103,17 +102,18 @@ std::shared_ptr<XMLElement> FormSerializer::pageToXML(std::shared_ptr<FormPage> if (!page->getLabel().empty()) { pageElement->setAttribute("label", page->getLabel()); } - foreach(const FormText::text text, page->getTextElements()) { + for (const auto& text : page->getTextElements()) { pageElement->addNode(textToXML(text)); } - foreach (const std::shared_ptr<FormField> field, page->getFields()) { + for (const auto& field : page->getFields()) { pageElement->addNode(fieldRefToXML(field->getName())); fields_.push_back(field); } - foreach(const FormReportedRef::ref reportedRef, page->getReportedRefs()) { + for (const auto& reportedRef: page->getReportedRefs()) { + (void)reportedRef; pageElement->addNode(std::make_shared<XMLElement>("reportedref")); } - foreach(const FormSection::section section, page->getChildSections()) { + for (const auto& section : page->getChildSections()) { pageElement->addNode(sectionToXML(section)); } return pageElement; @@ -124,17 +124,18 @@ std::shared_ptr<XMLElement> FormSerializer::sectionToXML(std::shared_ptr<FormSec if (!section->getLabel().empty()) { sectionElement->setAttribute("label", section->getLabel()); } - foreach(const FormText::text text, section->getTextElements()) { + for (const auto& text : section->getTextElements()) { sectionElement->addNode(textToXML(text)); } - foreach(const std::shared_ptr<FormField> field, section->getFields()) { + for (const auto& field : section->getFields()) { sectionElement->addNode(fieldRefToXML(field->getName())); fields_.push_back(field); } - foreach(const FormReportedRef::ref reportedRef, section->getReportedRefs()) { + for (const auto& reportedRef : section->getReportedRefs()) { + (void)reportedRef; sectionElement->addNode(std::make_shared<XMLElement>("reportedref")); } - foreach(const FormSection::section childSection, section->getChildSections()) { + for (const auto& childSection : section->getChildSections()) { sectionElement->addNode(sectionToXML(childSection)); } return sectionElement; @@ -175,13 +176,13 @@ std::shared_ptr<XMLElement> FormSerializer::fieldToXML(std::shared_ptr<FormField if (!fieldType.empty() && withTypeAttribute) { fieldElement->setAttribute("type", fieldType); } - foreach (const std::string& value, field->getValues()) { + for (const auto& value : field->getValues()) { std::shared_ptr<XMLElement> valueElement = std::make_shared<XMLElement>("value"); valueElement->addNode(std::make_shared<XMLTextNode>(value)); fieldElement->addNode(valueElement); } - foreach (const FormField::Option& option, field->getOptions()) { + for (const auto& option : field->getOptions()) { std::shared_ptr<XMLElement> optionElement(new XMLElement("option")); if (!option.label.empty()) { optionElement->setAttribute("label", option.label); @@ -199,7 +200,7 @@ void FormSerializer::multiLineify(const std::string& text, const std::string& el std::string unRdText(text); erase(unRdText, '\r'); std::vector<std::string> lines = String::split(unRdText, '\n'); - foreach (std::string line, lines) { + for (const auto& line : lines) { std::shared_ptr<XMLElement> lineElement(new XMLElement(elementName)); lineElement->addNode(std::make_shared<XMLTextNode>(line)); element->addNode(lineElement); diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp index 175de1e..cf0b54c 100644 --- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp +++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp @@ -6,7 +6,6 @@ #include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/BlockListPayload.h> #include <Swiften/Elements/BlockPayload.h> #include <Swiften/Elements/UnblockPayload.h> @@ -165,13 +164,13 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() { serializers_.push_back(new IsodeIQDelegationSerializer(this)); - foreach(PayloadSerializer* serializer, serializers_) { + for (auto serializer : serializers_) { addSerializer(serializer); } } FullPayloadSerializerCollection::~FullPayloadSerializerCollection() { - foreach(PayloadSerializer* serializer, serializers_) { + for (auto serializer : serializers_) { removeSerializer(serializer); delete serializer; } diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp index 36d82a2..e41ff8c 100644 --- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp @@ -11,7 +11,6 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> #include <Swiften/StringCodecs/Base64.h> diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp index 31b023f..04b7c56 100644 --- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/FormSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp index 02e0f2a..39eb149 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleContentPayloadSerializer.cpp @@ -15,7 +15,6 @@ #include <memory> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.h> #include <Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.h> @@ -38,7 +37,7 @@ std::string JingleContentPayloadSerializer::serializePayload(std::shared_ptr<Jin JingleFileTransferDescriptionSerializer ftSerializer; JingleFileTransferDescription::ref filetransfer; - foreach(JingleDescription::ref desc, payload->getDescriptions()) { + for (auto&& desc : payload->getDescriptions()) { if ((filetransfer = std::dynamic_pointer_cast<JingleFileTransferDescription>(desc))) { payloadXML.addNode(std::make_shared<XMLRawTextNode>(ftSerializer.serializePayload(filetransfer))); } @@ -54,7 +53,7 @@ std::string JingleContentPayloadSerializer::serializePayload(std::shared_ptr<Jin JingleS5BTransportPayloadSerializer s5bSerializer; JingleS5BTransportPayload::ref s5b; - foreach(JingleTransportPayload::ref transport, payload->getTransports()) { + for (auto&& transport : payload->getTransports()) { if ((ibb = std::dynamic_pointer_cast<JingleIBBTransportPayload>(transport))) { payloadXML.addNode(std::make_shared<XMLRawTextNode>(ibbSerializer.serializePayload(ibb))); } else if ((s5b = std::dynamic_pointer_cast<JingleS5BTransportPayload>(transport))) { diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp index b002482..27e3b33 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferDescriptionSerializer.cpp @@ -17,7 +17,6 @@ #include <boost/lexical_cast.hpp> #include <Swiften/Base/DateTime.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp index d78d7df..35a0a6e 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp @@ -11,7 +11,6 @@ #include <boost/lexical_cast.hpp> #include <Swiften/Base/DateTime.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -54,7 +53,7 @@ std::string JingleFileTransferFileInfoSerializer::serializePayload(std::shared_p fileElement.addNode(std::make_shared<XMLElement>("size", "", boost::lexical_cast<std::string>(fileInfo->getSize()))); } - foreach (JingleFileTransferFileInfo::HashElementMap::value_type hashElement, fileInfo->getHashes()) { + for (const auto& hashElement : fileInfo->getHashes()) { std::shared_ptr<XMLElement> hash = std::make_shared<XMLElement>("hash", "urn:xmpp:hashes:1", Base64::encode(hashElement.second)); hash->setAttribute("algo", hashElement.first); fileElement.addNode(hash); diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp index 1f6ead7..7629721 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferHashSerializer.cpp @@ -16,7 +16,6 @@ #include <memory> #include <string> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp index 52e6c16..9930e44 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp @@ -16,7 +16,6 @@ #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLNode.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp index 8b37929..aaac757 100644 --- a/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.cpp @@ -15,7 +15,6 @@ #include <memory> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/JingleContentPayload.h> #include <Swiften/Elements/JingleFileTransferDescription.h> #include <Swiften/Elements/JingleFileTransferHash.h> @@ -41,7 +40,7 @@ std::string JinglePayloadSerializer::serializePayload(std::shared_ptr<JinglePayl std::vector<std::shared_ptr<Payload> > payloads = payload->getPayloads(); if (!payloads.empty()) { - foreach(std::shared_ptr<Payload> subPayload, payloads) { + for (auto&& subPayload : payloads) { PayloadSerializer* serializer = serializers->getPayloadSerializer(subPayload); if (serializer) { jinglePayload.addNode(std::make_shared<XMLRawTextNode>(serializer->serialize(subPayload))); diff --git a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp index 61447cd..5e74d8e 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp @@ -17,7 +17,6 @@ #include <boost/lexical_cast.hpp> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLNode.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -35,7 +34,7 @@ std::string JingleS5BTransportPayloadSerializer::serializePayload(std::shared_pt payloadXML.setAttribute("dstaddr", payload->getDstAddr()); } - foreach(JingleS5BTransportPayload::Candidate candidate, payload->getCandidates()) { + for (const auto& candidate : payload->getCandidates()) { std::shared_ptr<XMLElement> candidateXML = std::make_shared<XMLElement>("candidate"); candidateXML->setAttribute("cid", candidate.cid); candidateXML->setAttribute("host", candidate.hostPort.getAddress().toString()); diff --git a/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp index 385c181..157c99e 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.cpp @@ -9,7 +9,6 @@ #include <memory> #include <sstream> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -21,7 +20,7 @@ MUCAdminPayloadSerializer::MUCAdminPayloadSerializer() : GenericPayloadSerialize std::string MUCAdminPayloadSerializer::serializePayload(std::shared_ptr<MUCAdminPayload> payload) const { XMLElement mucElement("query", "http://jabber.org/protocol/muc#admin"); - foreach (const MUCItem& item, payload->getItems()) { + for (const auto& item : payload->getItems()) { mucElement.addNode(MUCItemSerializer::itemToElement(item)); } return mucElement.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp index 3d807be..96116c7 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCDestroyPayloadSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp index 4b978af..2004f4c 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCInvitationPayloadSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp index 52ab489..f0f3cfa 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp @@ -9,7 +9,6 @@ #include <memory> #include <sstream> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/MUCItemSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -23,14 +22,14 @@ MUCUserPayloadSerializer::MUCUserPayloadSerializer(PayloadSerializerCollection* std::string MUCUserPayloadSerializer::serializePayload(std::shared_ptr<MUCUserPayload> payload) const { XMLElement mucElement("x", "http://jabber.org/protocol/muc#user"); - foreach (const MUCUserPayload::StatusCode statusCode, payload->getStatusCodes()) { + for (const auto& statusCode : payload->getStatusCodes()) { std::shared_ptr<XMLElement> statusElement(new XMLElement("status")); std::ostringstream code; code << statusCode.code; statusElement->setAttribute("code", code.str()); mucElement.addNode(statusElement); } - foreach (const MUCItem& item, payload->getItems()) { + for (const auto& item : payload->getItems()) { mucElement.addNode(MUCItemSerializer::itemToElement(item)); } diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp index 87a2eeb..fc410fb 100644 --- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp index 07b427c..9c810da 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.cpp @@ -4,13 +4,10 @@ * See the COPYING file for more information. */ - - #include <Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubAffiliationSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -32,7 +29,7 @@ std::string PubSubAffiliationsSerializer::serializePayload(std::shared_ptr<PubSu if (payload->getNode()) { element.setAttribute("node", *payload->getNode()); } - foreach(std::shared_ptr<PubSubAffiliation> item, payload->getAffiliations()) { + for (const auto& item : payload->getAffiliations()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubAffiliationSerializer(serializers).serialize(item))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp index 61b6cb5..2743ff6 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp @@ -4,13 +4,10 @@ * See the COPYING file for more information. */ - - #include <Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -34,7 +31,7 @@ std::string PubSubEventItemSerializer::serializePayload(std::shared_ptr<PubSubEv if (payload->getPublisher()) { element.setAttribute("publisher", *payload->getPublisher()); } - foreach(std::shared_ptr<Payload> item, payload->getData()) { + for (const auto& item : payload->getData()) { element.addNode(std::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item))); } if (payload->getID()) { diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp index c8704ea..67d611b 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.cpp @@ -4,13 +4,10 @@ * See the COPYING file for more information. */ - - #include <Swiften/Serializer/PayloadSerializers/PubSubEventItemsSerializer.h> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h> #include <Swiften/Serializer/PayloadSerializers/PubSubEventRetractSerializer.h> @@ -31,10 +28,10 @@ std::string PubSubEventItemsSerializer::serializePayload(std::shared_ptr<PubSubE } XMLElement element("items", "http://jabber.org/protocol/pubsub#event"); element.setAttribute("node", payload->getNode()); - foreach(std::shared_ptr<PubSubEventItem> item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubEventItemSerializer(serializers).serialize(item))); } - foreach(std::shared_ptr<PubSubEventRetract> item, payload->getRetracts()) { + for (const auto& item : payload->getRetracts()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubEventRetractSerializer(serializers).serialize(item))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp index d0b14ae..51b8b46 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/PubSubEventCollectionSerializer.h> #include <Swiften/Serializer/PayloadSerializers/PubSubEventConfigurationSerializer.h> #include <Swiften/Serializer/PayloadSerializers/PubSubEventDeleteSerializer.h> @@ -38,7 +37,7 @@ std::string PubSubEventSerializer::serializePayload(std::shared_ptr<PubSubEvent> } XMLElement element("event", "http://jabber.org/protocol/pubsub#event"); std::shared_ptr<PubSubEventPayload> p = payload->getPayload(); - foreach(std::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) { + for (const auto& serializer : pubsubSerializers) { if (serializer->canSerialize(p)) { element.addNode(std::make_shared<XMLRawTextNode>(serializer->serialize(p))); } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp index d2e5977..a202c88 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp @@ -4,13 +4,10 @@ * See the COPYING file for more information. */ - - #include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -28,7 +25,7 @@ std::string PubSubItemSerializer::serializePayload(std::shared_ptr<PubSubItem> p return ""; } XMLElement element("item", "http://jabber.org/protocol/pubsub"); - foreach(std::shared_ptr<Payload> item, payload->getData()) { + for (const auto& item : payload->getData()) { element.addNode(std::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item))); } if (!payload->getID().empty()) { diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp index ae6433a..9786f51 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp @@ -4,8 +4,6 @@ * See the COPYING file for more information. */ - - #include <Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.h> #include <memory> @@ -13,7 +11,6 @@ #include <boost/lexical_cast.hpp> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -36,7 +33,7 @@ std::string PubSubItemsSerializer::serializePayload(std::shared_ptr<PubSubItems> SWIFT_LOG(warning) << "Serializing PubSubItems with empty node attribute"; } element.setAttribute("node", payload->getNode()); - foreach(std::shared_ptr<PubSubItem> item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item))); } if (payload->getMaximumItems()) { diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp index 7810e2f..b9f6bcc 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.cpp @@ -6,10 +6,8 @@ #include <Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h> -#include <cassert> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -29,7 +27,7 @@ std::string PubSubOwnerAffiliationsSerializer::serializePayload(std::shared_ptr< } XMLElement element("affiliations", "http://jabber.org/protocol/pubsub#owner"); element.setAttribute("node", payload->getNode()); - foreach(std::shared_ptr<PubSubOwnerAffiliation> item, payload->getAffiliations()) { + for (const auto& item : payload->getAffiliations()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubOwnerAffiliationSerializer(serializers).serialize(item))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp index cacd8d9..b2dfd21 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerPubSubSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/PubSubOwnerAffiliationsSerializer.h> #include <Swiften/Serializer/PayloadSerializers/PubSubOwnerConfigureSerializer.h> #include <Swiften/Serializer/PayloadSerializers/PubSubOwnerDefaultSerializer.h> @@ -38,7 +37,7 @@ std::string PubSubOwnerPubSubSerializer::serializePayload(std::shared_ptr<PubSub } XMLElement element("pubsub", "http://jabber.org/protocol/pubsub#owner"); std::shared_ptr<PubSubOwnerPayload> p = payload->getPayload(); - foreach(std::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) { + for (const auto& serializer : pubsubSerializers) { if (serializer->canSerialize(p)) { element.addNode(std::make_shared<XMLRawTextNode>(serializer->serialize(p))); } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp index 9a6ca32..a5940f6 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.cpp @@ -6,10 +6,8 @@ #include <Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionsSerializer.h> -#include <cassert> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubOwnerSubscriptionSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -29,7 +27,7 @@ std::string PubSubOwnerSubscriptionsSerializer::serializePayload(std::shared_ptr } XMLElement element("subscriptions", "http://jabber.org/protocol/pubsub#owner"); element.setAttribute("node", payload->getNode()); - foreach(std::shared_ptr<PubSubOwnerSubscription> item, payload->getSubscriptions()) { + for (const auto& item : payload->getSubscriptions()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubOwnerSubscriptionSerializer(serializers).serialize(item))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp index 871845f..ce8706d 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.cpp @@ -4,13 +4,10 @@ * See the COPYING file for more information. */ - - #include <Swiften/Serializer/PayloadSerializers/PubSubPublishSerializer.h> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -30,7 +27,7 @@ std::string PubSubPublishSerializer::serializePayload(std::shared_ptr<PubSubPubl } XMLElement element("publish", "http://jabber.org/protocol/pubsub"); element.setAttribute("node", payload->getNode()); - foreach(std::shared_ptr<PubSubItem> item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp index 99b425e..c82089a 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -28,7 +27,7 @@ std::string PubSubRetractSerializer::serializePayload(std::shared_ptr<PubSubRetr } XMLElement element("retract", "http://jabber.org/protocol/pubsub"); element.setAttribute("node", payload->getNode()); - foreach(std::shared_ptr<PubSubItem> item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item))); } if (payload->isNotify().is_initialized()) { diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp index dbef36e..648c5a3 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubSerializer.cpp @@ -4,13 +4,10 @@ * See the COPYING file for more information. */ - - #include <Swiften/Serializer/PayloadSerializers/PubSubSerializer.h> #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubAffiliationsSerializer.h> #include <Swiften/Serializer/PayloadSerializers/PubSubConfigureSerializer.h> @@ -52,7 +49,7 @@ std::string PubSubSerializer::serializePayload(std::shared_ptr<PubSub> payload) } XMLElement element("pubsub", "http://jabber.org/protocol/pubsub"); std::shared_ptr<PubSubPayload> p = payload->getPayload(); - foreach(std::shared_ptr<PayloadSerializer> serializer, pubsubSerializers) { + for (const auto& serializer : pubsubSerializers) { if (serializer->canSerialize(p)) { element.addNode(std::make_shared<XMLRawTextNode>(serializer->serialize(p))); if (std::shared_ptr<PubSubCreate> create = std::dynamic_pointer_cast<PubSubCreate>(p)) { diff --git a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp index e154109..6e01881 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionsSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> #include <Swiften/Serializer/PayloadSerializers/PubSubSubscriptionSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> @@ -30,7 +29,7 @@ std::string PubSubSubscriptionsSerializer::serializePayload(std::shared_ptr<PubS if (payload->getNode()) { element.setAttribute("node", *payload->getNode()); } - foreach(std::shared_ptr<PubSubSubscription> item, payload->getSubscriptions()) { + for (const auto& item : payload->getSubscriptions()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubSubscriptionSerializer(serializers).serialize(item))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp index 24cc301..c7fdc5b 100644 --- a/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/RosterItemExchangeSerializer.cpp @@ -14,7 +14,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -26,7 +25,7 @@ RosterItemExchangeSerializer::RosterItemExchangeSerializer() : GenericPayloadSer std::string RosterItemExchangeSerializer::serializePayload(std::shared_ptr<RosterItemExchangePayload> roster) const { XMLElement queryElement("x", "http://jabber.org/protocol/rosterx"); - foreach(const RosterItemExchangePayload::Item& item, roster->getItems()) { + for (const auto& item : roster->getItems()) { std::shared_ptr<XMLElement> itemElement(new XMLElement("item")); itemElement->setAttribute("jid", item.getJID()); itemElement->setAttribute("name", item.getName()); @@ -37,7 +36,7 @@ std::string RosterItemExchangeSerializer::serializePayload(std::shared_ptr<Roste case RosterItemExchangePayload::Item::Delete: itemElement->setAttribute("action", "delete"); break; } - foreach(const std::string& group, item.getGroups()) { + for (const auto& group : item.getGroups()) { std::shared_ptr<XMLElement> groupElement(new XMLElement("group")); groupElement->addNode(std::make_shared<XMLTextNode>(group)); itemElement->addNode(groupElement); diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp index 8c857ab..e706542 100644 --- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -23,7 +22,7 @@ std::string RosterSerializer::serializePayload(std::shared_ptr<RosterPayload> ro if (roster->getVersion()) { queryElement.setAttribute("ver", *roster->getVersion()); } - foreach(const RosterItemPayload& item, roster->getItems()) { + for (const auto& item : roster->getItems()) { std::shared_ptr<XMLElement> itemElement(new XMLElement("item")); itemElement->setAttribute("jid", item.getJID()); itemElement->setAttribute("name", item.getName()); @@ -40,7 +39,7 @@ std::string RosterSerializer::serializePayload(std::shared_ptr<RosterPayload> ro itemElement->setAttribute("ask", "subscribe"); } - foreach(const std::string& group, item.getGroups()) { + for (const auto& group : item.getGroups()) { std::shared_ptr<XMLElement> groupElement(new XMLElement("group")); groupElement->addNode(std::make_shared<XMLTextNode>(group)); itemElement->addNode(groupElement); diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp index 6e55f46..befd76d 100644 --- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/FormSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -41,7 +40,7 @@ std::string SearchPayloadSerializer::serializePayload(std::shared_ptr<SearchPayl searchElement.addNode(XMLElement::ref(new XMLElement("email", "", *searchPayload->getEMail()))); } - foreach(const SearchPayload::Item& item, searchPayload->getItems()) { + for (const auto& item : searchPayload->getItems()) { XMLElement::ref itemElement(new XMLElement("item")); itemElement->setAttribute("jid", item.jid); itemElement->addNode(XMLElement::ref(new XMLElement("first", "", item.first))); diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp index 97c5411..b8faf73 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -36,7 +35,7 @@ std::string SecurityLabelSerializer::serializePayload(std::shared_ptr<SecurityLa labelElement->addNode(std::make_shared<XMLRawTextNode>(label->getLabel())); element.addNode(labelElement); - foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) { + for (const auto& equivalentLabel : label->getEquivalentLabels()) { std::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel")); equivalentLabelElement->addNode(std::make_shared<XMLRawTextNode>(equivalentLabel)); element.addNode(equivalentLabelElement); diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp index e8d2a1b..36401a6 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -29,7 +28,7 @@ std::string SecurityLabelsCatalogSerializer::serializePayload(std::shared_ptr<Se if (!catalog->getDescription().empty()) { element.setAttribute("desc", catalog->getDescription()); } - foreach (const SecurityLabelsCatalog::Item& item, catalog->getItems()) { + for (const auto& item : catalog->getItems()) { std::shared_ptr<XMLElement> itemElement(new XMLElement("item")); itemElement->setAttribute("selector", item.getSelector()); if (item.getIsDefault()) { diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp index 31720f7..ffebcf4 100644 --- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -20,7 +19,7 @@ StorageSerializer::StorageSerializer() : GenericPayloadSerializer<Storage>() { std::string StorageSerializer::serializePayload(std::shared_ptr<Storage> storage) const { XMLElement storageElement("storage", "storage:bookmarks"); - foreach(const Storage::Room& room, storage->getRooms()) { + for (const auto& room : storage->getRooms()) { std::shared_ptr<XMLElement> conferenceElement(new XMLElement("conference")); conferenceElement->setAttribute("name", room.name); conferenceElement->setAttribute("jid", room.jid); @@ -38,7 +37,7 @@ std::string StorageSerializer::serializePayload(std::shared_ptr<Storage> storage storageElement.addNode(conferenceElement); } - foreach(const Storage::URL& url, storage->getURLs()) { + for (const auto& url : storage->getURLs()) { std::shared_ptr<XMLElement> urlElement(new XMLElement("url")); urlElement->setAttribute("name", url.name); urlElement->setAttribute("url", url.url); diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp index e15ab77..ba296f9 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp @@ -17,7 +17,6 @@ #include <boost/lexical_cast.hpp> #include <Swiften/Base/DateTime.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> #include <Swiften/Serializer/XML/XMLTextNode.h> diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp index fcfb063..3faa5b7 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp @@ -10,7 +10,6 @@ #include <memory> #include <boost/lexical_cast.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> @@ -54,7 +53,7 @@ std::string StreamInitiationSerializer::serializePayload(std::shared_ptr<StreamI Form::ref form(new Form(Form::FormType)); FormField::ref field = std::make_shared<FormField>(FormField::ListSingleType); field->setName("stream-method"); - foreach(const std::string& method, streamInitiation->getProvidedMethods()) { + for (const auto& method : streamInitiation->getProvidedMethods()) { field->addOption(FormField::Option("", method)); } form->addField(field); diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp index a1393cb..725d125 100644 --- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp @@ -9,7 +9,6 @@ #include <memory> #include <Swiften/Base/DateTime.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -47,7 +46,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr<VCard> vcard) con } queryElement.addNode(nameElement); } - foreach(const VCard::EMailAddress& emailAddress, vcard->getEMailAddresses()) { + for (const auto& emailAddress : vcard->getEMailAddresses()) { std::shared_ptr<XMLElement> emailElement(new XMLElement("EMAIL")); emailElement->addNode(std::make_shared<XMLElement>("USERID", "", emailAddress.address)); if (emailAddress.isHome) { @@ -84,7 +83,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr<VCard> vcard) con queryElement.addNode(std::make_shared<XMLElement>("BDAY", "", dateTimeToString(vcard->getBirthday()))); } - foreach(const VCard::Telephone& telephone, vcard->getTelephones()) { + for (const auto& telephone : vcard->getTelephones()) { std::shared_ptr<XMLElement> telElement(new XMLElement("TEL")); telElement->addNode(std::make_shared<XMLElement>("NUMBER", "", telephone.number)); if (telephone.isHome) { @@ -129,7 +128,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr<VCard> vcard) con queryElement.addNode(telElement); } - foreach(const VCard::Address& address, vcard->getAddresses()) { + for (const auto& address : vcard->getAddresses()) { std::shared_ptr<XMLElement> adrElement = std::make_shared<XMLElement>("ADR"); if (!address.poBox.empty()) { adrElement->addNode(std::make_shared<XMLElement>("POBOX", "", address.poBox)); @@ -177,10 +176,10 @@ std::string VCardSerializer::serializePayload(std::shared_ptr<VCard> vcard) con queryElement.addNode(adrElement); } - foreach(const VCard::AddressLabel& addressLabel, vcard->getAddressLabels()) { + for (const auto& addressLabel : vcard->getAddressLabels()) { std::shared_ptr<XMLElement> labelElement = std::make_shared<XMLElement>("LABEL"); - foreach(const std::string& line, addressLabel.lines) { + for (const auto& line : addressLabel.lines) { labelElement->addNode(std::make_shared<XMLElement>("LINE", "", line)); } @@ -208,7 +207,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr<VCard> vcard) con queryElement.addNode(labelElement); } - foreach(const JID& jid, vcard->getJIDs()) { + for (const auto& jid : vcard->getJIDs()) { queryElement.addNode(std::make_shared<XMLElement>("JID", "", jid.toString())); } @@ -216,28 +215,28 @@ std::string VCardSerializer::serializePayload(std::shared_ptr<VCard> vcard) con queryElement.addNode(std::make_shared<XMLElement>("DESC", "", vcard->getDescription())); } - foreach(const VCard::Organization& org, vcard->getOrganizations()) { + for (const auto& org : vcard->getOrganizations()) { std::shared_ptr<XMLElement> orgElement = std::make_shared<XMLElement>("ORG"); if (!org.name.empty()) { orgElement->addNode(std::make_shared<XMLElement>("ORGNAME", "", org.name)); } if (!org.units.empty()) { - foreach(const std::string& unit, org.units) { + for (const auto& unit : org.units) { orgElement->addNode(std::make_shared<XMLElement>("ORGUNIT", "", unit)); } } queryElement.addNode(orgElement); } - foreach(const std::string& title, vcard->getTitles()) { + for (const auto& title : vcard->getTitles()) { queryElement.addNode(std::make_shared<XMLElement>("TITLE", "", title)); } - foreach(const std::string& role, vcard->getRoles()) { + for (const auto& role : vcard->getRoles()) { queryElement.addNode(std::make_shared<XMLElement>("ROLE", "", role)); } - foreach(const std::string& url, vcard->getURLs()) { + for (const auto& url : vcard->getURLs()) { queryElement.addNode(std::make_shared<XMLElement>("URL", "", url)); } diff --git a/Swiften/Serializer/StanzaSerializer.cpp b/Swiften/Serializer/StanzaSerializer.cpp index 6440fbb..f2f5529 100644 --- a/Swiften/Serializer/StanzaSerializer.cpp +++ b/Swiften/Serializer/StanzaSerializer.cpp @@ -10,7 +10,6 @@ #include <typeinfo> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/Stanza.h> #include <Swiften/Serializer/PayloadSerializer.h> #include <Swiften/Serializer/PayloadSerializerCollection.h> @@ -47,7 +46,7 @@ SafeByteArray StanzaSerializer::serialize(std::shared_ptr<ToplevelElement> eleme setStanzaSpecificAttributes(stanza, stanzaElement); std::string serializedPayloads; - foreach (const std::shared_ptr<Payload>& payload, stanza->getPayloads()) { + for (const auto& payload : stanza->getPayloads()) { PayloadSerializer* serializer = payloadSerializers_->getPayloadSerializer(payload); if (serializer) { serializedPayloads += serializer->serialize(payload); diff --git a/Swiften/Serializer/StreamFeaturesSerializer.cpp b/Swiften/Serializer/StreamFeaturesSerializer.cpp index 820b96c..2534db0 100644 --- a/Swiften/Serializer/StreamFeaturesSerializer.cpp +++ b/Swiften/Serializer/StreamFeaturesSerializer.cpp @@ -8,7 +8,6 @@ #include <memory> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLTextNode.h> @@ -26,7 +25,7 @@ SafeByteArray StreamFeaturesSerializer::serialize(std::shared_ptr<ToplevelElemen } if (!streamFeatures->getCompressionMethods().empty()) { std::shared_ptr<XMLElement> compressionElement(new XMLElement("compression", "http://jabber.org/features/compress")); - foreach(const std::string& method, streamFeatures->getCompressionMethods()) { + for (const auto& method : streamFeatures->getCompressionMethods()) { std::shared_ptr<XMLElement> methodElement(new XMLElement("method")); methodElement->addNode(std::make_shared<XMLTextNode>(method)); compressionElement->addNode(methodElement); @@ -35,7 +34,7 @@ SafeByteArray StreamFeaturesSerializer::serialize(std::shared_ptr<ToplevelElemen } if (!streamFeatures->getAuthenticationMechanisms().empty()) { std::shared_ptr<XMLElement> mechanismsElement(new XMLElement("mechanisms", "urn:ietf:params:xml:ns:xmpp-sasl")); - foreach(const std::string& mechanism, streamFeatures->getAuthenticationMechanisms()) { + for (const auto& mechanism : streamFeatures->getAuthenticationMechanisms()) { std::shared_ptr<XMLElement> mechanismElement(new XMLElement("mechanism")); mechanismElement->addNode(std::make_shared<XMLTextNode>(mechanism)); mechanismsElement->addNode(mechanismElement); diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp index 4a874ab..f2397ca 100644 --- a/Swiften/Serializer/XML/XMLElement.cpp +++ b/Swiften/Serializer/XML/XMLElement.cpp @@ -6,7 +6,6 @@ #include <Swiften/Serializer/XML/XMLElement.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Serializer/XML/XMLTextNode.h> namespace Swift { @@ -23,14 +22,13 @@ XMLElement::XMLElement(const std::string& tag, const std::string& xmlns, const s std::string XMLElement::serialize() { std::string result; result += "<" + tag_; - typedef std::pair<std::string,std::string> Pair; - foreach(const Pair& p, attributes_) { + for (const auto& p : attributes_) { result += " " + p.first + "=\"" + p.second + "\""; } if (!childNodes_.empty()) { result += ">"; - foreach (std::shared_ptr<XMLNode> node, childNodes_) { + for (auto& node : childNodes_) { result += node->serialize(); } result += "</" + tag_ + ">"; diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp index 08b5485..9cde777 100644 --- a/Swiften/Serializer/XMPPSerializer.cpp +++ b/Swiften/Serializer/XMPPSerializer.cpp @@ -12,7 +12,6 @@ #include <boost/bind.hpp> #include <Swiften/Base/Log.h> -#include <Swiften/Base/foreach.h> #include <Swiften/Elements/ProtocolHeader.h> #include <Swiften/Serializer/AuthChallengeSerializer.h> #include <Swiften/Serializer/AuthFailureSerializer.h> |