From e405ff3561be3d3c0bd79d7d5173923a8828cf02 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Wed, 23 Nov 2016 08:09:39 +0100 Subject: 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 diff --git a/3rdParty/Boost/src/boost/range/adaptor/reversed.hpp b/3rdParty/Boost/src/boost/range/adaptor/reversed.hpp new file mode 100644 index 0000000..944fbff --- /dev/null +++ b/3rdParty/Boost/src/boost/range/adaptor/reversed.hpp @@ -0,0 +1,103 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#ifndef BOOST_RANGE_ADAPTOR_REVERSED_HPP +#define BOOST_RANGE_ADAPTOR_REVERSED_HPP + +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< class R > + struct reversed_range : + public boost::iterator_range< + boost::reverse_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + { + private: + typedef boost::iterator_range< + boost::reverse_iterator< + BOOST_DEDUCED_TYPENAME range_iterator::type + > + > + base; + + public: + typedef boost::reverse_iterator::type> iterator; + + explicit reversed_range( R& r ) + : base( iterator(boost::end(r)), iterator(boost::begin(r)) ) + { } + }; + + struct reverse_forwarder {}; + + template< class BidirectionalRange > + inline reversed_range + operator|( BidirectionalRange& r, reverse_forwarder ) + { + BOOST_RANGE_CONCEPT_ASSERT(( + BidirectionalRangeConcept)); + + return reversed_range( r ); + } + + template< class BidirectionalRange > + inline reversed_range + operator|( const BidirectionalRange& r, reverse_forwarder ) + { + BOOST_RANGE_CONCEPT_ASSERT(( + BidirectionalRangeConcept)); + + return reversed_range( r ); + } + + } // 'range_detail' + + using range_detail::reversed_range; + + namespace adaptors + { + namespace + { + const range_detail::reverse_forwarder reversed = + range_detail::reverse_forwarder(); + } + + template + inline reversed_range + reverse(BidirectionalRange& rng) + { + BOOST_RANGE_CONCEPT_ASSERT(( + BidirectionalRangeConcept)); + + return reversed_range(rng); + } + + template + inline reversed_range + reverse(const BidirectionalRange& rng) + { + BOOST_RANGE_CONCEPT_ASSERT(( + BidirectionalRangeConcept)); + + return reversed_range(rng); + } + } // 'adaptors' + +} // 'boost' + +#endif diff --git a/3rdParty/Boost/update.sh b/3rdParty/Boost/update.sh index 44114ed..afa7722 100755 --- a/3rdParty/Boost/update.sh +++ b/3rdParty/Boost/update.sh @@ -25,7 +25,6 @@ fi date_time/local_time/local_time.hpp \ date_time/c_local_time_adjustor.hpp \ date_time/gregorian/gregorian_types.hpp \ - foreach.hpp \ filesystem.hpp \ filesystem/fstream.hpp \ format.hpp \ @@ -41,8 +40,6 @@ fi random/uniform_int.hpp \ regex.hpp \ scope_exit.hpp \ - shared_ptr.hpp \ - smart_ptr/make_shared.hpp \ serialization/serialization.hpp \ serialization/vector.hpp \ serialization/list.hpp \ @@ -66,6 +63,7 @@ fi system/src/error_code.cpp \ phoenix/support/detail/iterate.hpp \ type_traits.hpp \ + range/adaptor/reversed.hpp \ $TARGET_DIR cp $1/LICENSE_1_0.txt $TARGET_DIR diff --git a/Slimber/LinkLocalPresenceManager.cpp b/Slimber/LinkLocalPresenceManager.cpp index f166b38..ec5f2cd 100644 --- a/Slimber/LinkLocalPresenceManager.cpp +++ b/Slimber/LinkLocalPresenceManager.cpp @@ -8,7 +8,6 @@ #include -#include #include #include #include @@ -25,7 +24,7 @@ LinkLocalPresenceManager::LinkLocalPresenceManager(LinkLocalServiceBrowser* brow } boost::optional LinkLocalPresenceManager::getServiceForJID(const JID& j) const { - foreach(const LinkLocalService& service, browser->getServices()) { + for (const auto& service : browser->getServices()) { if (service.getJID() == j) { return service; } @@ -52,7 +51,7 @@ void LinkLocalPresenceManager::handleServiceRemoved(const LinkLocalService& serv std::shared_ptr LinkLocalPresenceManager::getRoster() const { std::shared_ptr roster(new RosterPayload()); - foreach(const LinkLocalService& service, browser->getServices()) { + for (const auto& service : browser->getServices()) { roster->addItem(getRosterItem(service)); } return roster; @@ -60,14 +59,14 @@ std::shared_ptr LinkLocalPresenceManager::getRoster() const { std::vector > LinkLocalPresenceManager::getAllPresence() const { std::vector > result; - foreach(const LinkLocalService& service, browser->getServices()) { + for (const auto& service : browser->getServices()) { result.push_back(getPresence(service)); } return result; } RosterItemPayload LinkLocalPresenceManager::getRosterItem(const LinkLocalService& service) const { - return RosterItemPayload(service.getJID(), getRosterName(service), RosterItemPayload::Both); + return RosterItemPayload(service.getJID(), getRosterName(service), RosterItemPayload::Both); } std::string LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const { diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp index dcec6d5..cd36132 100644 --- a/Slimber/MainController.cpp +++ b/Slimber/MainController.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -88,7 +87,7 @@ void MainController::handleSelfConnected(bool b) { void MainController::handleServicesChanged() { std::vector names; - foreach(const LinkLocalService& service, linkLocalServiceBrowser->getServices()) { + for (const auto& service : linkLocalServiceBrowser->getServices()) { std::string description = service.getDescription(); if (description != service.getName()) { description += " (" + service.getName() + ")"; diff --git a/Slimber/MenuletController.cpp b/Slimber/MenuletController.cpp index fdf2fc7..5ea5bc9 100644 --- a/Slimber/MenuletController.cpp +++ b/Slimber/MenuletController.cpp @@ -8,8 +8,6 @@ #include -#include - #include MenuletController::MenuletController(Menulet* menulet) : @@ -41,7 +39,7 @@ void MenuletController::update() { else { menulet->setIcon("UsersOnline"); menulet->addItem("Online users:"); - foreach(const std::string& user, linkLocalUsers) { + for (const auto& user : linkLocalUsers) { menulet->addItem(std::string(" ") + user); } } diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index 7e24abe..3bc3112 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -6,13 +6,13 @@ #include +#include #include #include #include #include -#include #include #include #include @@ -111,11 +111,11 @@ void Server::stop(boost::optional e) { serverFromClientSession->finishSession(); } serverFromClientSession.reset(); - foreach(std::shared_ptr session, linkLocalSessions) { + for (auto&& session : linkLocalSessions) { session->finishSession(); } linkLocalSessions.clear(); - foreach(std::shared_ptr connector, connectors) { + for (auto&& connector : connectors) { connector->cancel(); } connectors.clear(); @@ -123,7 +123,7 @@ void Server::stop(boost::optional e) { if (serverFromNetworkConnectionServer) { serverFromNetworkConnectionServer->stop(); - foreach(boost::signals2::connection& connection, serverFromNetworkConnectionServerSignalConnections) { + for (auto&& connection : serverFromNetworkConnectionServerSignalConnections) { connection.disconnect(); } serverFromNetworkConnectionServerSignalConnections.clear(); @@ -131,7 +131,7 @@ void Server::stop(boost::optional e) { } if (serverFromClientConnectionServer) { serverFromClientConnectionServer->stop(); - foreach(boost::signals2::connection& connection, serverFromClientConnectionServerSignalConnections) { + for (auto&& connection : serverFromClientConnectionServerSignalConnections) { connection.disconnect(); } serverFromClientConnectionServerSignalConnections.clear(); @@ -218,7 +218,7 @@ void Server::handleElementReceived(std::shared_ptr element, std if (iq->getType() == IQ::Get) { session->sendElement(IQ::createResult(iq->getFrom(), iq->getID(), presenceManager->getRoster())); rosterRequested = true; - foreach(const std::shared_ptr presence, presenceManager->getAllPresence()) { + for (const auto& presence : presenceManager->getAllPresence()) { session->sendElement(presence); } } @@ -314,7 +314,7 @@ void Server::handleConnectFinished(std::shared_ptr connector new OutgoingLinkLocalSession( selfJID, connector->getService().getJID(), connector->getConnection(), &payloadParserFactories, &payloadSerializers, &xmlParserFactory)); - foreach(const std::shared_ptr element, connector->getQueuedElements()) { + for (const auto& element : connector->getQueuedElements()) { outgoingSession->queueElement(element); } registerLinkLocalSession(outgoingSession); @@ -333,7 +333,7 @@ void Server::registerLinkLocalSession(std::shared_ptr session) { } std::shared_ptr Server::getLinkLocalSessionForJID(const JID& jid) { - foreach(const std::shared_ptr session, linkLocalSessions) { + for (const auto& session : linkLocalSessions) { if (session->getRemoteJID() == jid) { return session; } @@ -342,7 +342,7 @@ std::shared_ptr Server::getLinkLocalSessionForJID(const JID& jid) { } std::shared_ptr Server::getLinkLocalConnectorForJID(const JID& jid) { - foreach(const std::shared_ptr connector, connectors) { + for (const auto& connector : connectors) { if (connector->getService().getJID() == jid) { return connector; } diff --git a/Sluift/ElementConvertors/CommandConvertor.cpp b/Sluift/ElementConvertors/CommandConvertor.cpp index 1e2f8e3..de7a439 100644 --- a/Sluift/ElementConvertors/CommandConvertor.cpp +++ b/Sluift/ElementConvertors/CommandConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include #include #include @@ -154,7 +152,7 @@ void CommandConvertor::doConvertToLua(lua_State* L, std::shared_ptr pay if (!payload->getNotes().empty()) { std::vector notes; - foreach (const Command::Note& note, payload->getNotes()) { + for (const auto& note : payload->getNotes()) { Lua::Table noteTable; if (!note.note.empty()) { noteTable["note"] = Lua::valueRef(note.note); @@ -179,7 +177,7 @@ void CommandConvertor::doConvertToLua(lua_State* L, std::shared_ptr pay if (!payload->getAvailableActions().empty()) { std::vector availableActions; - foreach (const Command::Action& action, payload->getAvailableActions()) { + for (const auto& action : payload->getAvailableActions()) { if (action != Command::NoAction) { availableActions.push_back(convertActionToString(action)); } diff --git a/Sluift/ElementConvertors/DOMElementConvertor.cpp b/Sluift/ElementConvertors/DOMElementConvertor.cpp index c03eb8c..b957686 100644 --- a/Sluift/ElementConvertors/DOMElementConvertor.cpp +++ b/Sluift/ElementConvertors/DOMElementConvertor.cpp @@ -10,7 +10,6 @@ #include -#include #include #include #include @@ -48,7 +47,7 @@ namespace { if (!attributes.getEntries().empty()) { lua_newtable(L); int i = 1; - foreach(const AttributeMap::Entry& entry, attributes.getEntries()) { + for (const auto& entry : attributes.getEntries()) { lua_pushnumber(L, i); lua_newtable(L); lua_pushstring(L, entry.getAttribute().getName().c_str()); diff --git a/Sluift/ElementConvertors/FormConvertor.cpp b/Sluift/ElementConvertors/FormConvertor.cpp index 85f40a1..90fd9fe 100644 --- a/Sluift/ElementConvertors/FormConvertor.cpp +++ b/Sluift/ElementConvertors/FormConvertor.cpp @@ -14,8 +14,6 @@ #include -#include - #include #include @@ -105,7 +103,7 @@ namespace { } if (!field->getOptions().empty()) { Lua::Array options; - foreach(const FormField::Option& option, field->getOptions()) { + for (const auto& option : field->getOptions()) { Lua::Table luaOption = boost::assign::map_list_of ("label", Lua::valueRef(option.label)) ("value", Lua::valueRef(option.value)); @@ -118,7 +116,7 @@ namespace { Lua::Array convertFieldListToLua(const std::vector< std::shared_ptr >& fieldList) { Lua::Array fields; - foreach(std::shared_ptr field, fieldList) { + for (auto&& field : fieldList) { fields.push_back(convertFieldToLua(field)); } return fields; @@ -245,7 +243,7 @@ namespace { lua_getfield(L, -1, "fields"); if (lua_istable(L, -1)) { - foreach (std::shared_ptr formField, convertFieldListFromLua(L)) { + for (auto&& formField : convertFieldListFromLua(L)) { result->addField(formField); } } @@ -253,7 +251,7 @@ namespace { lua_getfield(L, -1, "reported_fields"); if (lua_istable(L, -1)) { - foreach (std::shared_ptr formField, convertFieldListFromLua(L)) { + for (auto&& formField : convertFieldListFromLua(L)) { result->addReportedField(formField); } } @@ -294,7 +292,7 @@ namespace { if (!payload->getItems().empty()) { Lua::Array luaItems; - foreach(const Form::FormItem& item, payload->getItems()) { + for (const auto& item : payload->getItems()) { if (!item.empty()) { luaItems.push_back(convertFieldListToLua(item)); } @@ -322,7 +320,7 @@ namespace { form->clearReportedFields(); std::vector< std::shared_ptr > fields(form->getFields()); form->clearFields(); - foreach (std::shared_ptr field, fields) { + for (auto&& field : fields) { if (field->getType() == FormField::FixedType) { continue; } diff --git a/Sluift/ElementConvertors/ForwardedConvertor.cpp b/Sluift/ElementConvertors/ForwardedConvertor.cpp index 8474252..b353eea 100644 --- a/Sluift/ElementConvertors/ForwardedConvertor.cpp +++ b/Sluift/ElementConvertors/ForwardedConvertor.cpp @@ -12,7 +12,6 @@ #include -#include #include #include #include diff --git a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp index 8eae795..c6ba09e 100644 --- a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -60,7 +58,7 @@ void PubSubAffiliationsConvertor::doConvertToLua(lua_State* L, std::shared_ptr

getAffiliations().empty()) { { int i = 0; - foreach(std::shared_ptr item, payload->getAffiliations()) { + for (auto&& item : payload->getAffiliations()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp b/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp index e8ba5b5..ac86024 100644 --- a/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -77,7 +75,7 @@ void PubSubEventItemConvertor::doConvertToLua(lua_State* L, std::shared_ptr(payload->getData().size()), 0); { int i = 0; - foreach(std::shared_ptr item, payload->getData()) { + for (auto&& item : payload->getData()) { if (convertors->convertToLua(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp b/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp index c89c4a6..7a3cde1 100644 --- a/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -78,7 +76,7 @@ void PubSubEventItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr(payload->getItems().size()), 0); { int i = 0; - foreach(std::shared_ptr item, payload->getItems()) { + for (auto&& item : payload->getItems()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; @@ -91,7 +89,7 @@ void PubSubEventItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr(payload->getRetracts().size()), 0); { int i = 0; - foreach(std::shared_ptr item, payload->getRetracts()) { + for (auto&& item : payload->getRetracts()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubItemConvertor.cpp b/Sluift/ElementConvertors/PubSubItemConvertor.cpp index 99802bf..27fd4a3 100644 --- a/Sluift/ElementConvertors/PubSubItemConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubItemConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -59,7 +57,7 @@ void PubSubItemConvertor::doConvertToLua(lua_State* L, std::shared_ptr(payload->getData().size()), 0); { int i = 0; - foreach(std::shared_ptr item, payload->getData()) { + for (auto&& item : payload->getData()) { if (convertors->convertToLua(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubItemsConvertor.cpp b/Sluift/ElementConvertors/PubSubItemsConvertor.cpp index 8e1f08d..5fa1bd3 100644 --- a/Sluift/ElementConvertors/PubSubItemsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubItemsConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -68,7 +66,7 @@ void PubSubItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptrgetItems().empty()) { { int i = 0; - foreach(std::shared_ptr item, payload->getItems()) { + for (auto&& item : payload->getItems()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp index b66443f..ee8a8cb 100644 --- a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -58,7 +56,7 @@ void PubSubOwnerAffiliationsConvertor::doConvertToLua(lua_State* L, std::shared_ if (!payload->getAffiliations().empty()) { { int i = 0; - foreach(std::shared_ptr item, payload->getAffiliations()) { + for (auto&& item : payload->getAffiliations()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp index 50cfb9b..88085b5 100644 --- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -58,7 +56,7 @@ void PubSubOwnerSubscriptionsConvertor::doConvertToLua(lua_State* L, std::shared if (!payload->getSubscriptions().empty()) { { int i = 0; - foreach(std::shared_ptr item, payload->getSubscriptions()) { + for (auto&& item : payload->getSubscriptions()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubPublishConvertor.cpp b/Sluift/ElementConvertors/PubSubPublishConvertor.cpp index 38aca0a..63c97bc 100644 --- a/Sluift/ElementConvertors/PubSubPublishConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubPublishConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -61,7 +59,7 @@ void PubSubPublishConvertor::doConvertToLua(lua_State* L, std::shared_ptr(payload->getItems().size()), 0); { int i = 0; - foreach(std::shared_ptr item, payload->getItems()) { + for (auto&& item : payload->getItems()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubRetractConvertor.cpp b/Sluift/ElementConvertors/PubSubRetractConvertor.cpp index 38e15a1..c070ad6 100644 --- a/Sluift/ElementConvertors/PubSubRetractConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubRetractConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -66,7 +64,7 @@ void PubSubRetractConvertor::doConvertToLua(lua_State* L, std::shared_ptr(payload->getItems().size()), 0); { int i = 0; - foreach(std::shared_ptr item, payload->getItems()) { + for (auto&& item : payload->getItems()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp index 4cc5686..3712192 100644 --- a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp +++ b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - #include using namespace Swift; @@ -60,7 +58,7 @@ void PubSubSubscriptionsConvertor::doConvertToLua(lua_State* L, std::shared_ptr< if (!payload->getSubscriptions().empty()) { { int i = 0; - foreach(std::shared_ptr item, payload->getSubscriptions()) { + for (auto&& item : payload->getSubscriptions()) { if (convertors->convertToLuaUntyped(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/SecurityLabelConvertor.cpp b/Sluift/ElementConvertors/SecurityLabelConvertor.cpp index 133b123..21d9a8f 100644 --- a/Sluift/ElementConvertors/SecurityLabelConvertor.cpp +++ b/Sluift/ElementConvertors/SecurityLabelConvertor.cpp @@ -12,8 +12,6 @@ #include -#include - using namespace Swift; SecurityLabelConvertor::SecurityLabelConvertor() : @@ -69,7 +67,7 @@ void SecurityLabelConvertor::doConvertToLua(lua_State* L, std::shared_ptr(payload->getEquivalentLabels().size()), 0); { int i = 0; - foreach(const std::string& item, payload->getEquivalentLabels()) { + for (const auto& item : payload->getEquivalentLabels()) { lua_pushstring(L, item.c_str()); lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/ElementConvertors/StanzaConvertor.h b/Sluift/ElementConvertors/StanzaConvertor.h index e1d0cb3..bdaaad3 100644 --- a/Sluift/ElementConvertors/StanzaConvertor.h +++ b/Sluift/ElementConvertors/StanzaConvertor.h @@ -8,7 +8,6 @@ #include -#include #include #include #include @@ -75,7 +74,7 @@ namespace Swift { lua_createtable(L, boost::numeric_cast(stanza->getPayloads().size()), 0); { int i = 0; - foreach(const std::shared_ptr &item, stanza->getPayloads()) { + for (const auto& item : stanza->getPayloads()) { if (convertors->convertToLua(L, item) > 0) { lua_rawseti(L, -2, boost::numeric_cast(i+1)); ++i; diff --git a/Sluift/Lua/FunctionRegistry.cpp b/Sluift/Lua/FunctionRegistry.cpp index ebbd087..46c6d18 100644 --- a/Sluift/Lua/FunctionRegistry.cpp +++ b/Sluift/Lua/FunctionRegistry.cpp @@ -6,8 +6,6 @@ #include -#include - #include #include #include @@ -44,7 +42,7 @@ void FunctionRegistry::createFunctionTable(lua_State* L, const std::string& type } void FunctionRegistry::addFunctionsToTable(lua_State* L, const std::string& type) { - foreach(const Registration& registration, registrations) { + for (const auto& registration : registrations) { if (registration.type == type) { lua_pushcclosure(L, registration.function, 0); if (!registration.helpDescription.empty()) { diff --git a/Sluift/Lua/Value.cpp b/Sluift/Lua/Value.cpp index 70fbb89..96d954c 100644 --- a/Sluift/Lua/Value.cpp +++ b/Sluift/Lua/Value.cpp @@ -13,8 +13,6 @@ extern "C" { #include } -#include - using namespace Swift; using namespace Swift::Lua; @@ -49,7 +47,7 @@ namespace { void operator()(const std::map >& table) const { lua_createtable(state, 0, boost::numeric_cast(table.size())); - for(const auto& i : table) { + for (const auto& i : table) { boost::apply_visitor(PushVisitor(state), *i.second); lua_setfield(state, -2, i.first.c_str()); } diff --git a/Sluift/LuaElementConvertors.cpp b/Sluift/LuaElementConvertors.cpp index 38926e9..aac4d93 100644 --- a/Sluift/LuaElementConvertors.cpp +++ b/Sluift/LuaElementConvertors.cpp @@ -8,8 +8,6 @@ #include -#include - #include #include #include @@ -95,7 +93,7 @@ std::shared_ptr LuaElementConvertors::convertFromLua(lua_State* L, int std::shared_ptr LuaElementConvertors::convertFromLuaUntyped(lua_State* L, int index, const std::string& type) { index = Lua::absoluteOffset(L, index); - foreach (std::shared_ptr convertor, convertors) { + for (auto&& convertor : convertors) { if (std::shared_ptr result = convertor->convertFromLua(L, index, type)) { return result; } @@ -131,7 +129,7 @@ boost::optional LuaElementConvertors::doConvertToLuaUntyped( if (!payload) { return LuaElementConvertor::NO_RESULT; } - foreach (std::shared_ptr convertor, convertors) { + for (auto&& convertor : convertors) { if (boost::optional type = convertor->convertToLua(L, payload)) { return *type; } diff --git a/Sluift/client.cpp b/Sluift/client.cpp index 6376e9d..186effc 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -185,7 +184,7 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( SluiftClient* client = getClient(L); Lua::Table contactsTable; - foreach(const XMPPRosterItem& item, client->getRoster(getGlobalTimeout(L))) { + for (const auto& item : client->getRoster(getGlobalTimeout(L))) { std::string subscription; switch(item.getSubscription()) { case RosterItemPayload::None: subscription = "none"; break; diff --git a/Sluift/component.cpp b/Sluift/component.cpp index 9c2bc3a..df96d43 100644 --- a/Sluift/component.cpp +++ b/Sluift/component.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/Sluift/main.cpp b/Sluift/main.cpp index 05c7179..65d6d60 100644 --- a/Sluift/main.cpp +++ b/Sluift/main.cpp @@ -4,18 +4,21 @@ * See the COPYING file for more information. */ +#include #include #include -#include -#include -#include -#include + +#include +#include +#include #include #include -#include #include -#include -#include + +#include + +#include + #include #include #include @@ -87,7 +90,7 @@ static void runScript(lua_State* L, const std::string& script, const std::vector // Load file checkResult(L, luaL_loadfile(L, script.c_str())); - foreach (const std::string& scriptArgument, scriptArguments) { + for (const auto& scriptArgument : scriptArguments) { lua_pushstring(L, scriptArgument.c_str()); } checkResult(L, Console::call(L, boost::numeric_cast(scriptArguments.size()), false)); @@ -163,7 +166,7 @@ int main(int argc, char* argv[]) { lua_getglobal(L, "sluift"); std::vector globalImports = boost::assign::list_of ("help")("with"); - foreach (const std::string& globalImport, globalImports) { + for (const auto& globalImport : globalImports) { lua_getfield(L, -1, globalImport.c_str()); lua_setglobal(L, globalImport.c_str()); } diff --git a/Sluift/sluift.cpp b/Sluift/sluift.cpp index d92f0db..561f404 100644 --- a/Sluift/sluift.cpp +++ b/Sluift/sluift.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -461,7 +460,7 @@ SLUIFT_API int luaopen_sluift(lua_State* L) { lua_rawgeti(L, LUA_REGISTRYINDEX, Sluift::globals.coreLibIndex); std::vector coreLibExports = boost::assign::list_of ("tprint")("disco")("help")("get_help")("copy")("with")("read_file")("create_form"); - foreach (const std::string& coreLibExport, coreLibExports) { + for (const auto& coreLibExport : coreLibExports) { lua_getfield(L, -1, coreLibExport.c_str()); lua_setfield(L, -3, coreLibExport.c_str()); } @@ -470,7 +469,7 @@ SLUIFT_API int luaopen_sluift(lua_State* L) { // Load client metatable lua_rawgeti(L, LUA_REGISTRYINDEX, Sluift::globals.coreLibIndex); std::vector tables = boost::assign::list_of("Client"); - foreach(const std::string& table, tables) { + for (const auto& table : tables) { lua_getfield(L, -1, table.c_str()); Lua::FunctionRegistry::getInstance().addFunctionsToTable(L, table); lua_pop(L, 1); @@ -480,7 +479,7 @@ SLUIFT_API int luaopen_sluift(lua_State* L) { // Load component metatable lua_rawgeti(L, LUA_REGISTRYINDEX, Sluift::globals.coreLibIndex); std::vector comp_tables = boost::assign::list_of("Component"); - foreach(const std::string& table, comp_tables) { + for (const auto& table : comp_tables) { lua_getfield(L, -1, table.c_str()); Lua::FunctionRegistry::getInstance().addFunctionsToTable(L, table); lua_pop(L, 1); @@ -488,7 +487,7 @@ SLUIFT_API int luaopen_sluift(lua_State* L) { lua_pop(L, 1); // Register documentation for all elements - foreach (std::shared_ptr convertor, Sluift::globals.elementConvertor.getConvertors()) { + for (auto&& convertor : Sluift::globals.elementConvertor.getConvertors()) { boost::optional documentation = convertor->getDocumentation(); if (documentation) { Lua::registerClassHelp(L, documentation->className, documentation->description); diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp index a5080f9..8b952bb 100644 --- a/SwifTools/Application/ApplicationPathProvider.cpp +++ b/SwifTools/Application/ApplicationPathProvider.cpp @@ -10,7 +10,6 @@ #include #include -#include namespace Swift { @@ -33,7 +32,7 @@ boost::filesystem::path ApplicationPathProvider::getProfileDir(const std::string boost::filesystem::path ApplicationPathProvider::getResourcePath(const std::string& resource) const { std::vector resourcePaths = getResourceDirs(); - foreach(const boost::filesystem::path& resourcePath, resourcePaths) { + for (const auto& resourcePath : resourcePaths) { boost::filesystem::path r(resourcePath / resource); if (boost::filesystem::exists(r)) { return r; diff --git a/SwifTools/Application/UnixApplicationPathProvider.cpp b/SwifTools/Application/UnixApplicationPathProvider.cpp index c561d72..e455d23 100644 --- a/SwifTools/Application/UnixApplicationPathProvider.cpp +++ b/SwifTools/Application/UnixApplicationPathProvider.cpp @@ -8,14 +8,12 @@ #include -#include - #include #include +#include #include -#include namespace Swift { @@ -26,7 +24,7 @@ UnixApplicationPathProvider::UnixApplicationPathProvider(const std::string& name if (xdgDataDirs) { std::vector dataDirs = String::split(xdgDataDirs, ':'); if (!dataDirs.empty()) { - foreach(const std::string& dir, dataDirs) { + for (const auto& dir : dataDirs) { resourceDirs.push_back(boost::filesystem::path(dir) / "swift"); } return; @@ -56,7 +54,7 @@ boost::filesystem::path UnixApplicationPathProvider::getDataDir() const { boost::filesystem::create_directories(dataPath); } catch (const boost::filesystem::filesystem_error& e) { - std::cerr << "ERROR: " << e.what() << std::endl; + SWIFT_LOG(error) << "file system error: " << e.what() << std::endl; } return dataPath; } diff --git a/SwifTools/Notifier/GNTPNotifier.cpp b/SwifTools/Notifier/GNTPNotifier.cpp index 62203b4..89025af 100644 --- a/SwifTools/Notifier/GNTPNotifier.cpp +++ b/SwifTools/Notifier/GNTPNotifier.cpp @@ -15,7 +15,6 @@ #include #include -#include #include namespace Swift { @@ -29,7 +28,7 @@ GNTPNotifier::GNTPNotifier(const std::string& name, const boost::filesystem::pat message << "Notifications-Count: " << getAllTypes().size() << "\r\n"; std::vector defaultTypes = getDefaultTypes(); std::vector allTypes = getAllTypes(); - foreach(Notifier::Type type, allTypes) { + for (const auto& type : allTypes) { message << "\r\n"; message << "Notification-Name: " << typeToString(type) << "\r\n"; message << "Notification-Enabled: " << (std::find(defaultTypes.begin(), defaultTypes.end(), type) == defaultTypes.end() ? "false" : "true") << "\r\n"; diff --git a/SwifTools/TabComplete.cpp b/SwifTools/TabComplete.cpp index f158ffa..39a70cc 100644 --- a/SwifTools/TabComplete.cpp +++ b/SwifTools/TabComplete.cpp @@ -10,8 +10,6 @@ #include -#include - namespace Swift { void TabComplete::addWord(const std::string& word) { @@ -43,7 +41,7 @@ std::string TabComplete::completeWord(const std::string& word) { } else { lastShort_ = boost::to_lower_copy(word); lastCompletionCandidates_.clear(); - foreach (std::string candidate, words_) { + for (auto&& candidate : words_) { if (boost::starts_with(boost::to_lower_copy(candidate), boost::to_lower_copy(word))) { lastCompletionCandidates_.push_back(candidate); } diff --git a/Swift/Controllers/AdHocManager.cpp b/Swift/Controllers/AdHocManager.cpp index 81f80e2..717f083 100644 --- a/Swift/Controllers/AdHocManager.cpp +++ b/Swift/Controllers/AdHocManager.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -58,7 +57,7 @@ void AdHocManager::setServerDiscoInfo(std::shared_ptr info) { } void AdHocManager::setOnline(bool online) { - foreach (std::shared_ptr controller, controllers_) { + for (auto&& controller : controllers_) { controller->setOnline(online); } } @@ -66,7 +65,7 @@ void AdHocManager::setOnline(bool online) { void AdHocManager::handleServerDiscoItemsResponse(std::shared_ptr items, ErrorPayload::ref error) { std::vector commands; if (!error) { - foreach (DiscoItems::Item item, items->getItems()) { + for (const auto& item : items->getItems()) { if (item.getNode() != "http://isode.com/xmpp/commands#test") { commands.push_back(item); } diff --git a/Swift/Controllers/AdHocManager.h b/Swift/Controllers/AdHocManager.h index 20e5db7..0786370 100644 --- a/Swift/Controllers/AdHocManager.h +++ b/Swift/Controllers/AdHocManager.h @@ -10,7 +10,6 @@ #include -#include #include #include #include @@ -25,6 +24,7 @@ class IQRouter; class MainWindow; class UIEventStream; class AdHocCommandWindowFactory; + class AdHocManager { public: AdHocManager(const JID& jid, AdHocCommandWindowFactory* factory, IQRouter* iqRouter, UIEventStream* uiEventStream, MainWindow* mainWindow); @@ -32,10 +32,13 @@ public: void removeController(std::shared_ptr contoller); void setServerDiscoInfo(std::shared_ptr info); void setOnline(bool online); + private: void handleServerDiscoItemsResponse(std::shared_ptr, ErrorPayload::ref error); void handleUIEvent(std::shared_ptr event); boost::signals2::signal onControllerComplete; + +private: JID jid_; IQRouter* iqRouter_; UIEventStream* uiEventStream_; diff --git a/Swift/Controllers/BlockListController.cpp b/Swift/Controllers/BlockListController.cpp index 560a3f3..37c536b 100644 --- a/Swift/Controllers/BlockListController.cpp +++ b/Swift/Controllers/BlockListController.cpp @@ -14,7 +14,6 @@ #include -#include #include #include @@ -40,13 +39,13 @@ BlockListController::~BlockListController() { } void BlockListController::blockListDifferences(const std::vector &newBlockList, std::vector &jidsToUnblock, std::vector &jidsToBlock) const { - foreach (const JID& jid, blockListBeforeEdit) { + for (const auto& jid : blockListBeforeEdit) { if (std::find(newBlockList.begin(), newBlockList.end(), jid) == newBlockList.end()) { jidsToUnblock.push_back(jid); } } - foreach (const JID& jid, newBlockList) { + for (const auto& jid : newBlockList) { if (std::find(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid) == blockListBeforeEdit.end()) { jidsToBlock.push_back(jid); } @@ -169,13 +168,13 @@ void BlockListController::handleBlockListChanged() { blockListDifferences(blockListEditorWidget_->getCurrentBlockList(), jidsToUnblock, jidsToBlock); blockListBeforeEdit = blockListManager_->getBlockList()->getItems(); - foreach (const JID& jid, jidsToBlock) { + for (const auto& jid : jidsToBlock) { if (std::find(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid) == blockListBeforeEdit.end()) { blockListBeforeEdit.push_back(jid); } } - foreach (const JID& jid, jidsToUnblock) { + for (const auto& jid : jidsToUnblock) { blockListBeforeEdit.erase(std::remove(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid), blockListBeforeEdit.end()); } diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 9ae3845..349bf8a 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -11,10 +11,10 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -238,7 +238,7 @@ void MUCController::handleActionRequestedOnOccupant(ChatWindow::OccupantAction a void MUCController::handleBareJIDCapsChanged(const JID& /*jid*/) { Tristate support = Yes; bool any = false; - foreach (const std::string& nick, currentOccupants_) { + for (const auto& nick : currentOccupants_) { DiscoInfo::ref disco = entityCapsProvider_->getCaps(toJID_.toBare().toString() + "/" + nick); if (disco && disco->hasFeature(DiscoInfo::MessageCorrectionFeature)) { any = true; @@ -295,9 +295,8 @@ bool MUCController::isImpromptu() const { std::map MUCController::getParticipantJIDs() const { std::map participants; - typedef std::pair MUCOccupantPair; std::map occupants = muc_->getOccupants(); - foreach(const MUCOccupantPair& occupant, occupants) { + for (const auto& occupant : occupants) { if (occupant.first != nick_) { participants[occupant.first] = occupant.second.getRealJID().is_initialized() ? occupant.second.getRealJID().get().toBare() : JID(); } @@ -306,7 +305,7 @@ std::map MUCController::getParticipantJIDs() const { } void MUCController::sendInvites(const std::vector& jids, const std::string& reason) const { - foreach (const JID& jid, jids) { + for (const auto& jid : jids) { muc_->invitePerson(jid, reason, isImpromptu_); } } @@ -859,7 +858,7 @@ std::string MUCController::concatenateListOfNames(const std::vector& joinParts, bool isImpromptu) { std::vector sorted[4]; std::string eventStrings[4]; - foreach (NickJoinPart event, joinParts) { + for (const auto& event : joinParts) { sorted[event.type].push_back(event); } std::string result; @@ -937,7 +936,7 @@ void MUCController::handleBookmarkRequest() { // Check for existing bookmark for this room and, if it exists, use it instead. std::vector bookmarks = mucBookmarkManager_->getBookmarks(); - foreach (const MUCBookmark& bookmark, bookmarks) { + for (const auto& bookmark : bookmarks) { if (bookmark.getRoom() == jid.toBare()) { roomBookmark = bookmark; break; @@ -1001,7 +1000,7 @@ void MUCController::handleInvitePersonToThisMUCRequest(const std::vector& j void MUCController::handleUIEvent(std::shared_ptr event) { std::shared_ptr inviteEvent = std::dynamic_pointer_cast(event); if (inviteEvent && inviteEvent->getRoom() == muc_->getJID()) { - foreach (const JID& jid, inviteEvent->getInvites()) { + for (const auto& jid : inviteEvent->getInvites()) { muc_->invitePerson(jid, inviteEvent->getReason(), isImpromptu_); } } @@ -1014,16 +1013,14 @@ void MUCController::handleGetAffiliationsRequest() { muc_->requestAffiliationList(MUCOccupant::Outcast); } -typedef std::pair AffiliationChangePair; - void MUCController::handleChangeAffiliationsRequest(const std::vector >& changes) { std::set addedJIDs; - foreach (const AffiliationChangePair& change, changes) { + for (const auto& change : changes) { if (change.first != MUCOccupant::NoAffiliation) { addedJIDs.insert(change.second); } } - foreach (const AffiliationChangePair& change, changes) { + for (const auto& change : changes) { if (change.first != MUCOccupant::NoAffiliation || addedJIDs.find(change.second) == addedJIDs.end()) { muc_->changeAffiliation(change.second, change.first); } @@ -1070,7 +1067,7 @@ void MUCController::addRecentLogs() { joinContext_ = historyController_->getMUCContext(selfJID_, toJID_, lastActivity_); - foreach (const HistoryMessage& message, joinContext_) { + for (const auto& message : joinContext_) { bool senderIsSelf = nick_ == message.getFromJID().getResource(); // the chatWindow uses utc timestamps @@ -1083,7 +1080,7 @@ void MUCController::checkDuplicates(std::shared_ptr newMessage) { JID jid = newMessage->getFrom(); boost::optional time = newMessage->getTimestamp(); - reverse_foreach (const HistoryMessage& message, joinContext_) { + for (const auto& message : boost::adaptors::reverse(joinContext_)) { boost::posix_time::ptime messageTime = message.getTime() - boost::posix_time::hours(message.getOffset()); if (time && time < messageTime) { break; @@ -1112,7 +1109,7 @@ Form::ref MUCController::buildImpromptuRoomConfiguration(Form::ref roomConfigura Form::ref result = std::make_shared

(Form::SubmitType); std::string impromptuConfigs[] = { "muc#roomconfig_enablelogging", "muc#roomconfig_persistentroom", "muc#roomconfig_publicroom", "muc#roomconfig_whois"}; std::set impromptuConfigsMissing(impromptuConfigs, impromptuConfigs + 4); - foreach (std::shared_ptr field, roomConfigurationForm->getFields()) { + for (const auto& field : roomConfigurationForm->getFields()) { std::shared_ptr resultField; if (field->getName() == "muc#roomconfig_enablelogging") { resultField = std::make_shared(FormField::BooleanType, "0"); @@ -1138,7 +1135,7 @@ Form::ref MUCController::buildImpromptuRoomConfiguration(Form::ref roomConfigura } } - foreach (const std::string& config, impromptuConfigsMissing) { + for (const auto& config : impromptuConfigsMissing) { if (config == "muc#roomconfig_publicroom") { chatWindow_->addSystemMessage(chatMessageParser_->parseMessageBody(QT_TRANSLATE_NOOP("", "This server doesn't support hiding your chat from other users.")), ChatWindow::DefaultDirection); } else if (config == "muc#roomconfig_whois") { @@ -1151,12 +1148,11 @@ Form::ref MUCController::buildImpromptuRoomConfiguration(Form::ref roomConfigura void MUCController::setImpromptuWindowTitle() { std::string title; - typedef std::pair StringMUCOccupantPair; std::map occupants = muc_->getOccupants(); if (occupants.size() <= 1) { title = QT_TRANSLATE_NOOP("", "Empty Chat"); } else { - foreach (StringMUCOccupantPair pair, occupants) { + for (const auto& pair : occupants) { if (pair.first != nick_) { title += (title.empty() ? "" : ", ") + pair.first; } diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index 31c9be9..a5e68cf 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -89,7 +89,7 @@ class ChatsManagerTest : public CppUnit::TestFixture { CPPUNIT_TEST(testChatControllerHighlightingNotificationTesting); CPPUNIT_TEST(testChatControllerHighlightingNotificationDeduplicateSounds); CPPUNIT_TEST(testChatControllerMeMessageHandling); - CPPUNIT_TEST(testRestartingMUCComponentCrash); + CPPUNIT_TEST(testRestartingMUCComponentCrash); CPPUNIT_TEST(testChatControllerMeMessageHandlingInMUC); // Carbons tests @@ -455,7 +455,7 @@ public: uiEventStream_->send(std::make_shared(sender)); - foreach(const JID& senderJID, senderResource) { + for (const auto& senderJID : senderResource) { // The sender supports delivery receipts. DiscoInfo::ref disco = std::make_shared(); disco->addFeature(DiscoInfo::MessageDeliveryReceiptsFeature); @@ -478,7 +478,7 @@ public: CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex(1)->getPayload()); // Two resources respond with message receipts. - foreach(const JID& senderJID, senderResource) { + for (const auto& senderJID : senderResource) { Message::ref receiptReply = std::make_shared(); receiptReply->setFrom(senderJID); receiptReply->setTo(ownJID); @@ -497,7 +497,7 @@ public: CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex(1)->getPayload()); // Two resources respond with message receipts. - foreach(const JID& senderJID, senderResource) { + for (const auto& senderJID : senderResource) { Message::ref receiptReply = std::make_shared(); receiptReply->setFrom(senderJID); receiptReply->setTo(ownJID); @@ -570,7 +570,7 @@ public: uiEventStream_->send(std::make_shared(sender)); - foreach(const JID& senderJID, senderResource) { + for (const auto& senderJID : senderResource) { // The sender supports delivery receipts. DiscoInfo::ref disco = std::make_shared(); disco->addFeature(DiscoInfo::MessageDeliveryReceiptsFeature); @@ -593,7 +593,7 @@ public: CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex(1)->getPayload()); // Two resources respond with message receipts. - foreach(const JID& senderJID, senderResource) { + for (const auto& senderJID : senderResource) { Message::ref reply = std::make_shared(); reply->setFrom(senderJID); reply->setTo(ownJID); @@ -612,7 +612,7 @@ public: CPPUNIT_ASSERT(stanzaChannel_->getStanzaAtIndex(1)->getPayload()); // Two resources respond with message receipts. - foreach(const JID& senderJID, senderResource) { + for (const auto& senderJID : senderResource) { Message::ref receiptReply = std::make_shared(); receiptReply->setFrom(senderJID); receiptReply->setTo(ownJID); diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index 1142c98..32639f6 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -371,8 +370,7 @@ public: occupants.insert(occupant_map::value_type("Ernie", MUCOccupant("Ernie", MUCOccupant::Participant, MUCOccupant::Owner))); /* populate the MUC with fake users */ - typedef const std::pair occupantIterator; - foreach(occupantIterator &occupant, occupants) { + for (auto&& occupant : occupants) { muc_->insertOccupant(occupant.second); } @@ -387,7 +385,7 @@ public: alterations.push_back(MUCOccupant("Remko", MUCOccupant::NoRole, MUCOccupant::NoAffiliation)); alterations.push_back(MUCOccupant("Ernie", MUCOccupant::Visitor, MUCOccupant::Outcast)); - foreach(const MUCOccupant& alteration, alterations) { + for (const auto& alteration : alterations) { /* perform an alteration to a user's role and affiliation */ occupant_map::iterator occupant = occupants.find(alteration.getNick()); CPPUNIT_ASSERT(occupant != occupants.end()); @@ -506,10 +504,10 @@ public: void testRoleAffiliationStatesVerify(const std::map &occupants) { /* verify that the roster is in sync */ GroupRosterItem* group = window_->getRosterModel()->getRoot(); - foreach(RosterItem* rosterItem, group->getChildren()) { + for (auto rosterItem : group->getChildren()) { GroupRosterItem* child = dynamic_cast(rosterItem); CPPUNIT_ASSERT(child); - foreach(RosterItem* childItem, child->getChildren()) { + for (auto childItem : child->getChildren()) { ContactRosterItem* item = dynamic_cast(childItem); CPPUNIT_ASSERT(item); std::map::const_iterator occupant = occupants.find(item->getJID().getResource()); diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index 305049f..91e0dea 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -143,7 +142,8 @@ void UserSearchController::endDiscoWalker() { void UserSearchController::handleDiscoServiceFound(const JID& jid, std::shared_ptr info) { //bool isUserDirectory = false; bool supports55 = false; - foreach (DiscoInfo::Identity identity, info->getIdentities()) { + // TODO: Cleanup code + for (const auto& identity : info->getIdentities()) { if ((identity.getCategory() == "directory" && identity.getType() == "user")) { //isUserDirectory = true; @@ -186,7 +186,7 @@ void UserSearchController::handleSearchResponse(std::shared_ptr r if (resultsPayload->getForm()) { window_->setResultsForm(resultsPayload->getForm()); } else { - foreach (SearchPayload::Item item, resultsPayload->getItems()) { + for (auto&& item : resultsPayload->getItems()) { JID jid(item.jid); std::map fields; fields["first"] = item.first; @@ -232,7 +232,7 @@ void UserSearchController::handleContactSuggestionsRequested(std::string text) { std::vector::iterator i = suggestions.begin(); while (i != suggestions.end()) { bool found = false; - foreach (const JID& jid, existingJIDs) { + for (const auto& jid : existingJIDs) { if ((*i)->jid == jid) { found = true; break; @@ -274,7 +274,7 @@ void UserSearchController::handlePresenceChanged(Presence::ref presence) { void UserSearchController::handleJIDUpdateRequested(const std::vector& jids) { if (window_) { std::vector updates; - foreach(const JID& jid, jids) { + for (const auto& jid : jids) { updates.push_back(convertJIDtoContact(jid)); } window_->updateContacts(updates); @@ -283,7 +283,7 @@ void UserSearchController::handleJIDUpdateRequested(const std::vector& jids void UserSearchController::handleJIDAddRequested(const std::vector& jids) { std::vector contacts; - foreach(const JID& jid, jids) { + for (const auto& jid : jids) { contacts.push_back(convertJIDtoContact(jid)); } window_->addContacts(contacts); @@ -358,7 +358,7 @@ void UserSearchController::initializeUserWindow() { void UserSearchController::loadSavedDirectories() { savedDirectories_.clear(); - foreach (std::string stringItem, String::split(settings_->getStringSetting(SEARCHED_DIRECTORIES), '\n')) { + for (auto&& stringItem : String::split(settings_->getStringSetting(SEARCHED_DIRECTORIES), '\n')) { if(!stringItem.empty()) { savedDirectories_.push_back(JID(stringItem)); } @@ -375,7 +375,7 @@ void UserSearchController::addToSavedDirectories(const JID& jid) { std::string collapsed; int i = 0; - foreach (JID jidItem, savedDirectories_) { + for (const auto& jidItem : savedDirectories_) { if (i >= 15) { break; } diff --git a/Swift/Controllers/ChatMessageSummarizer.cpp b/Swift/Controllers/ChatMessageSummarizer.cpp index 6b630e7..ac3d896 100644 --- a/Swift/Controllers/ChatMessageSummarizer.cpp +++ b/Swift/Controllers/ChatMessageSummarizer.cpp @@ -6,7 +6,6 @@ #include -#include #include #include @@ -18,7 +17,7 @@ string ChatMessageSummarizer::getSummary(const string& current, const vector others; int currentUnread = 0; int otherCount = 0; - foreach (UnreadPair unread, unreads) { + for (const auto& unread : unreads) { if (unread.first == current) { currentUnread += unread.second; } else { diff --git a/Swift/Controllers/ContactSuggester.cpp b/Swift/Controllers/ContactSuggester.cpp index 8a3a6fa..eb27ed4 100644 --- a/Swift/Controllers/ContactSuggester.cpp +++ b/Swift/Controllers/ContactSuggester.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -55,7 +54,7 @@ bool ContactSuggester::matchContact(const std::string& search, const Contact::re std::vector ContactSuggester::getSuggestions(const std::string& search, bool withMUCNicks) const { std::vector results; - foreach(ContactProvider* provider, contactProviders_) { + for (auto provider : contactProviders_) { append(results, provider->getContacts(withMUCNicks)); } diff --git a/Swift/Controllers/ContactsFromXMPPRoster.cpp b/Swift/Controllers/ContactsFromXMPPRoster.cpp index e3c5d97..1d1ccd4 100644 --- a/Swift/Controllers/ContactsFromXMPPRoster.cpp +++ b/Swift/Controllers/ContactsFromXMPPRoster.cpp @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -29,7 +28,7 @@ ContactsFromXMPPRoster::~ContactsFromXMPPRoster() { std::vector ContactsFromXMPPRoster::getContacts(bool /*withMUCNicks*/) { std::vector results; std::vector rosterItems = roster_->getItems(); - foreach(const XMPPRosterItem& rosterItem, rosterItems) { + for (const auto& rosterItem : rosterItems) { Contact::ref contact = std::make_shared(rosterItem.getName().empty() ? rosterItem.getJID().toString() : rosterItem.getName(), rosterItem.getJID(), StatusShow::None,""); contact->statusType = presenceOracle_->getAccountPresence(contact->jid) ? presenceOracle_->getAccountPresence(contact->jid)->getShow() : StatusShow::None; contact->avatarPath = avatarManager_->getAvatarPath(contact->jid); diff --git a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp index af2831c..fcc35e4 100644 --- a/Swift/Controllers/FileTransfer/FileTransferOverview.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferOverview.cpp @@ -17,7 +17,6 @@ #include #include -#include #include namespace Swift { @@ -30,7 +29,7 @@ FileTransferOverview::FileTransferOverview(FileTransferManager* ftm) : fileTrans FileTransferOverview::~FileTransferOverview() { onNewFileTransferController.disconnect(boost::bind(&FileTransferOverview::handleNewFileTransferController, this, _1)); fileTransferManager->onIncomingFileTransfer.disconnect(boost::bind(&FileTransferOverview::handleIncomingFileTransfer, this, _1)); - foreach(FileTransferController* controller, fileTransfers) { + for (auto controller : fileTransfers) { controller->onStateChanged.disconnect(boost::bind(&FileTransferOverview::handleFileTransferStateChanged, this)); } } @@ -78,7 +77,7 @@ void FileTransferOverview::clearFinished() { bool FileTransferOverview::isClearable() const { bool isClearable = false; - foreach (FileTransferController* controller, fileTransfers) { + for (auto controller : fileTransfers) { if(controller->getState().type == FileTransfer::State::Finished || controller->getState().type == FileTransfer::State::Failed || controller->getState().type == FileTransfer::State::Canceled) { diff --git a/Swift/Controllers/HighlightManager.cpp b/Swift/Controllers/HighlightManager.cpp index 2afaf49..9176301 100644 --- a/Swift/Controllers/HighlightManager.cpp +++ b/Swift/Controllers/HighlightManager.cpp @@ -23,8 +23,6 @@ #include #include -#include - #include #include #include diff --git a/Swift/Controllers/HighlightRule.cpp b/Swift/Controllers/HighlightRule.cpp index 86ac5f7..a8cb7e4 100644 --- a/Swift/Controllers/HighlightRule.cpp +++ b/Swift/Controllers/HighlightRule.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014-2015 Isode Limited. + * Copyright (c) 2014-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -18,7 +18,6 @@ #include #include -#include namespace Swift { @@ -45,11 +44,11 @@ boost::regex HighlightRule::regexFromString(const std::string & s) const void HighlightRule::updateRegex() const { keywordRegex_.clear(); - foreach (const std::string & k, keywords_) { + for (const auto& k : keywords_) { keywordRegex_.push_back(regexFromString(k)); } senderRegex_.clear(); - foreach (const std::string & s, senders_) { + for (const auto& s : senders_) { senderRegex_.push_back(regexFromString(s)); } } @@ -79,7 +78,7 @@ bool HighlightRule::isMatch(const std::string& body, const std::string& sender, // check if a keyword matches if (!matchesKeyword && !keywords_.empty()) { - foreach (const boost::regex &keyword, keywordRegex_) { + for (const auto& keyword : keywordRegex_) { if (boost::regex_search(body, keyword)) { matchesKeyword = true; break; @@ -88,7 +87,7 @@ bool HighlightRule::isMatch(const std::string& body, const std::string& sender, } } - foreach (const boost::regex & rx, senderRegex_) { + for (const auto& rx : senderRegex_) { if (boost::regex_search(sender, rx)) { matchesSender = true; break; diff --git a/Swift/Controllers/Highlighter.cpp b/Swift/Controllers/Highlighter.cpp index 3499217..cea077e 100644 --- a/Swift/Controllers/Highlighter.cpp +++ b/Swift/Controllers/Highlighter.cpp @@ -12,8 +12,6 @@ #include -#include - #include namespace Swift { diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp index d66b2b2..669b002 100644 --- a/Swift/Controllers/HistoryViewController.cpp +++ b/Swift/Controllers/HistoryViewController.cpp @@ -12,9 +12,10 @@ #include +#include + #include #include -#include #include #include @@ -124,7 +125,7 @@ void HistoryViewController::handleSelectedContactChanged(RosterItem* newContact) historyWindow_->setDate(currentResultDate_); - foreach (const HistoryMessage& message, messages) { + for (const auto& message : messages) { addNewMessage(message, false); } } @@ -203,7 +204,7 @@ void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date& std::vector messages = historyController_->getMessagesFromPreviousDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date); - foreach (const HistoryMessage& message, messages) { + for (const auto& message : messages) { addNewMessage(message, true); } historyWindow_->resetConversationViewTopInsertPoint(); @@ -216,7 +217,7 @@ void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::da std::vector messages = historyController_->getMessagesFromNextDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date); - foreach (const HistoryMessage& message, messages) { + for (const auto& message : messages) { addNewMessage(message, false); } } @@ -237,7 +238,7 @@ void HistoryViewController::handleNextButtonClicked() { std::vector messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_); historyWindow_->setDate(currentResultDate_); - foreach (const HistoryMessage& message, messages) { + for (const auto& message : messages) { addNewMessage(message, false); } } @@ -258,7 +259,7 @@ void HistoryViewController::handlePreviousButtonClicked() { std::vector messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_); historyWindow_->setDate(currentResultDate_); - foreach (const HistoryMessage& message, messages) { + for (const auto& message : messages) { addNewMessage(message, false); } } @@ -280,7 +281,7 @@ void HistoryViewController::handleCalendarClicked(const boost::gregorian::date& newDate = date; } else if (date < currentResultDate_) { - foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) { + for (const auto& current : contacts_[selectedItemType_][selectedItem_->getJID()]) { if (current > date) { newDate = current; break; @@ -288,7 +289,7 @@ void HistoryViewController::handleCalendarClicked(const boost::gregorian::date& } } else { - reverse_foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) { + for (const auto& current : boost::adaptors::reverse(contacts_[selectedItemType_][selectedItem_->getJID()])) { if (current < date) { newDate = current; break; @@ -306,7 +307,7 @@ void HistoryViewController::handleCalendarClicked(const boost::gregorian::date& std::vector messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_); historyWindow_->setDate(currentResultDate_); - foreach (const HistoryMessage& message, messages) { + for (const auto& message : messages) { addNewMessage(message, false); } } @@ -347,7 +348,7 @@ Presence::ref HistoryViewController::getPresence(const JID& jid, bool isMUC) { return presence; } - foreach (Presence::ref presence, mucPresence) { + for (auto&& presence : mucPresence) { if (presence.get() && presence->getFrom() == jid) { return presence; } diff --git a/Swift/Controllers/PreviousStatusStore.cpp b/Swift/Controllers/PreviousStatusStore.cpp index 4806f9c..0b2d437 100644 --- a/Swift/Controllers/PreviousStatusStore.cpp +++ b/Swift/Controllers/PreviousStatusStore.cpp @@ -6,8 +6,6 @@ #include -#include - namespace Swift { PreviousStatusStore::PreviousStatusStore() { @@ -31,7 +29,7 @@ std::vector PreviousStatusStore::exactMatchSuggestions(StatusSho std::vector PreviousStatusStore::getSuggestions(const std::string& message) { std::vector suggestions; - foreach (TypeStringPair status, store_) { + for (auto&& status : store_) { if (status.second == message) { suggestions.clear(); suggestions.push_back(status); diff --git a/Swift/Controllers/PreviousStatusStore.h b/Swift/Controllers/PreviousStatusStore.h index eb1fb59..b106445 100644 --- a/Swift/Controllers/PreviousStatusStore.h +++ b/Swift/Controllers/PreviousStatusStore.h @@ -14,6 +14,7 @@ namespace Swift { typedef std::pair TypeStringPair; + class PreviousStatusStore { public: PreviousStatusStore(); diff --git a/Swift/Controllers/ProfileSettingsProvider.cpp b/Swift/Controllers/ProfileSettingsProvider.cpp index bb186fc..b979555 100644 --- a/Swift/Controllers/ProfileSettingsProvider.cpp +++ b/Swift/Controllers/ProfileSettingsProvider.cpp @@ -6,13 +6,15 @@ #include +#include + namespace Swift { ProfileSettingsProvider::ProfileSettingsProvider(const std::string& profile, SettingsProvider* provider) : profile_(profile) { provider_ = provider; bool found = false; - foreach (std::string existingProfile, provider->getAvailableProfiles()) { + for (const auto& existingProfile : provider->getAvailableProfiles()) { if (existingProfile == profile) { found = true; } diff --git a/Swift/Controllers/ProfileSettingsProvider.h b/Swift/Controllers/ProfileSettingsProvider.h index f3c3156..e309c11 100644 --- a/Swift/Controllers/ProfileSettingsProvider.h +++ b/Swift/Controllers/ProfileSettingsProvider.h @@ -1,17 +1,17 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include - -#include +#include namespace Swift { +class SettingsProvider; + class ProfileSettingsProvider { public: ProfileSettingsProvider(const std::string& profile, SettingsProvider* provider); @@ -25,6 +25,8 @@ class ProfileSettingsProvider { private: std::string profileSettingPath(const std::string &settingPath); + + private: SettingsProvider* provider_; std::string profile_; }; diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp index 71c5f8e..8fdf183 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.cpp +++ b/Swift/Controllers/Roster/ContactRosterItem.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp index af89b54..0f07c0b 100644 --- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp +++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -45,7 +44,7 @@ void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* gro void RosterGroupExpandinessPersister::save() { std::string setting; - foreach (const std::string& group, collapsed_) { + for (const auto& group : collapsed_) { if (!setting.empty()) { setting += "\n"; } diff --git a/Swift/Controllers/Roster/TableRoster.cpp b/Swift/Controllers/Roster/TableRoster.cpp index f164a4d..713f390 100644 --- a/Swift/Controllers/Roster/TableRoster.cpp +++ b/Swift/Controllers/Roster/TableRoster.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -104,11 +103,11 @@ void TableRoster::handleUpdateTimerTick() { // Get a model for the new roster std::vector
newSections; if (model) { - foreach(RosterItem* item, model->getRoot()->getDisplayedChildren()) { + for (auto item : model->getRoot()->getDisplayedChildren()) { if (GroupRosterItem* groupItem = boost::polymorphic_downcast(item)) { //std::cerr << "* " << groupItem->getDisplayName() << std::endl; Section section(groupItem->getDisplayName()); - foreach(RosterItem* groupChildItem, groupItem->getDisplayedChildren()) { + for (auto groupChildItem : groupItem->getDisplayedChildren()) { if (ContactRosterItem* contact = boost::polymorphic_downcast(groupChildItem)) { //std::cerr << " - " << contact->getDisplayJID() << std::endl; section.items.push_back(Item(contact->getDisplayName(), contact->getStatusText(), contact->getDisplayJID(), contact->getStatusShow(), contact->getAvatarPath())); diff --git a/Swift/Controllers/Settings/SettingsProviderHierachy.cpp b/Swift/Controllers/Settings/SettingsProviderHierachy.cpp index 5156d14..a05fabc 100644 --- a/Swift/Controllers/Settings/SettingsProviderHierachy.cpp +++ b/Swift/Controllers/Settings/SettingsProviderHierachy.cpp @@ -1,20 +1,20 @@ /* - * Copyright (c) 2012 Isode Limited. + * Copyright (c) 2012-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include -#include #include + namespace Swift { SettingsProviderHierachy::~SettingsProviderHierachy() { } bool SettingsProviderHierachy::hasSetting(const std::string& key) { - foreach (SettingsProvider* provider, providers_) { + for (auto provider : providers_) { if (provider->hasSetting(key)) { return true; } @@ -24,7 +24,7 @@ bool SettingsProviderHierachy::hasSetting(const std::string& key) { std::string SettingsProviderHierachy::getSetting(const Setting& setting) { std::string value = setting.getDefaultValue(); - foreach (SettingsProvider* provider, providers_) { + for (auto provider : providers_) { std::string providerSetting = provider->getSetting(setting); if (provider->hasSetting(setting.getKey())) { value = providerSetting; @@ -44,7 +44,7 @@ void SettingsProviderHierachy::storeSetting(const Setting& setting, bool SettingsProviderHierachy::getSetting(const Setting& setting) { bool value = setting.getDefaultValue(); - foreach (SettingsProvider* provider, providers_) { + for (auto provider : providers_) { bool providerSetting = provider->getSetting(setting); if (provider->hasSetting(setting.getKey())) { value = providerSetting; @@ -64,7 +64,7 @@ void SettingsProviderHierachy::storeSetting(const Setting& setting, const int SettingsProviderHierachy::getSetting(const Setting& setting) { int value = setting.getDefaultValue(); - foreach (SettingsProvider* provider, providers_) { + for (auto provider : providers_) { int providerSetting = provider->getSetting(setting); if (provider->hasSetting(setting.getKey())) { value = providerSetting; @@ -97,7 +97,7 @@ void SettingsProviderHierachy::removeProfile(const std::string& profile) { bool SettingsProviderHierachy::getIsSettingFinal(const std::string& settingPath) { bool isFinal = false; - foreach (SettingsProvider* provider, providers_) { + for (auto provider : providers_) { isFinal |= provider->getIsSettingFinal(settingPath); } return isFinal; diff --git a/Swift/Controllers/ShowProfileController.cpp b/Swift/Controllers/ShowProfileController.cpp index add6e73..b379141 100644 --- a/Swift/Controllers/ShowProfileController.cpp +++ b/Swift/Controllers/ShowProfileController.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -30,8 +29,7 @@ ShowProfileController::ShowProfileController(VCardManager* vcardManager, Profile } ShowProfileController::~ShowProfileController() { - typedef std::pair JIDProfileWindowPair; - foreach(const JIDProfileWindowPair& jidWndPair, openedProfileWindows) { + for (const auto& jidWndPair : openedProfileWindows) { jidWndPair.second->onWindowAboutToBeClosed.disconnect(boost::bind(&ShowProfileController::handleProfileWindowAboutToBeClosed, this, _1)); delete jidWndPair.second; } diff --git a/Swift/Controllers/Storages/AvatarFileStorage.cpp b/Swift/Controllers/Storages/AvatarFileStorage.cpp index cded945..a103920 100644 --- a/Swift/Controllers/Storages/AvatarFileStorage.cpp +++ b/Swift/Controllers/Storages/AvatarFileStorage.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/Swift/Controllers/Storages/CertificateMemoryStorage.cpp b/Swift/Controllers/Storages/CertificateMemoryStorage.cpp index 08c6ee7..545ca65 100644 --- a/Swift/Controllers/Storages/CertificateMemoryStorage.cpp +++ b/Swift/Controllers/Storages/CertificateMemoryStorage.cpp @@ -1,20 +1,18 @@ /* - * Copyright (c) 2011 Isode Limited. + * Copyright (c) 2011-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include -#include - using namespace Swift; CertificateMemoryStorage::CertificateMemoryStorage() { } bool CertificateMemoryStorage::hasCertificate(Certificate::ref certificate) const { - foreach(Certificate::ref storedCert, certificates) { + for (auto&& storedCert : certificates) { if (storedCert->toDER() == certificate->toDER()) { return true; } diff --git a/Swift/Controllers/Storages/VCardFileStorage.cpp b/Swift/Controllers/Storages/VCardFileStorage.cpp index dbb6799..2fdadf6 100644 --- a/Swift/Controllers/Storages/VCardFileStorage.cpp +++ b/Swift/Controllers/Storages/VCardFileStorage.cpp @@ -13,7 +13,6 @@ #include #include -#include #include #include #include diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h index c84d130..dde596e 100644 --- a/Swift/Controllers/UIInterfaces/ChatListWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -31,11 +30,11 @@ namespace Swift { if (impromptuJIDs.empty()) { return jid.toBare() == other.jid.toBare() && isMUC == other.isMUC; - } else { /* compare the chat occupant lists */ - typedef std::map JIDMap; - foreach (const JIDMap::value_type& jid, impromptuJIDs) { + } + else { /* compare the chat occupant lists */ + for (const auto& jid : impromptuJIDs) { bool found = false; - foreach (const JIDMap::value_type& otherJID, other.impromptuJIDs) { + for (const auto& otherJID : other.impromptuJIDs) { if (jid.second.toBare() == otherJID.second.toBare()) { found = true; break; @@ -58,9 +57,8 @@ namespace Swift { avatarPath = path; } std::string getImpromptuTitle() const { - typedef std::pair StringJIDPair; std::string title; - foreach(StringJIDPair pair, impromptuJIDs) { + for (auto& pair : impromptuJIDs) { if (title.empty()) { title += pair.first; } else { diff --git a/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp b/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp index 217a2f0..6ac51b2 100644 --- a/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp +++ b/Swift/Controllers/UnitTest/ContactSuggesterTest.cpp @@ -12,8 +12,6 @@ #include #include -#include - #include using namespace Swift; @@ -55,9 +53,9 @@ public: std::vector contacts; std::vector words = wordList(); std::vector statuses = statusList(); - foreach (const std::string& name, words) { - foreach (const std::string& jid, words) { - foreach (const StatusShow::Type& status, statuses) { + for (const auto& name : words) { + for (const auto& jid : words) { + for (const auto& status : statuses) { contacts.push_back(std::make_shared(name, jid, status, "")); } } @@ -68,7 +66,7 @@ public: /* a = a */ bool isReflexive(const boost::function& comparitor) { std::vector contacts = contactList(); - foreach (const Contact::ref& a, contacts) { + for (const auto& a : contacts) { if (!comparitor(a, a)) { return false; } @@ -79,8 +77,8 @@ public: /* a = b -> b = a */ bool isSymmetric(const boost::function& comparitor) { std::vector contacts = contactList(); - foreach (const Contact::ref& a, contacts) { - foreach (const Contact::ref& b, contacts) { + for (const auto& a : contacts) { + for (const auto& b : contacts) { if (comparitor(a, b)) { if (!comparitor(b, a)) { return false; @@ -94,9 +92,9 @@ public: /* a = b && b = c -> a = c */ bool isTransitive(const boost::function& comparitor) { std::vector contacts = contactList(); - foreach (const Contact::ref& a, contacts) { - foreach (const Contact::ref& b, contacts) { - foreach (const Contact::ref& c, contacts) { + for (const auto& a : contacts) { + for (const auto& b : contacts) { + for (const auto& c : contacts) { if (comparitor(a, b) && comparitor(b, c)) { if (!comparitor(a, c)) { return false; @@ -120,7 +118,7 @@ public: void sortTest() { std::vector words = wordList(); - foreach (const std::string& word, words) { + for (const auto& word : words) { CPPUNIT_ASSERT(isTransitive(boost::bind(Contact::sortPredicate, _1, _2, word))); } } diff --git a/Swift/Controllers/WhiteboardManager.cpp b/Swift/Controllers/WhiteboardManager.cpp index fab5380..37fe8e3 100644 --- a/Swift/Controllers/WhiteboardManager.cpp +++ b/Swift/Controllers/WhiteboardManager.cpp @@ -14,7 +14,6 @@ #include -#include #include #include #include @@ -25,8 +24,6 @@ #include namespace Swift { - typedef std::pair JIDWhiteboardWindowPair; - WhiteboardManager::WhiteboardManager(WhiteboardWindowFactory* whiteboardWindowFactory, UIEventStream* uiEventStream, NickResolver* nickResolver, WhiteboardSessionManager* whiteboardSessionManager) : whiteboardWindowFactory_(whiteboardWindowFactory), uiEventStream_(uiEventStream), nickResolver_(nickResolver), whiteboardSessionManager_(whiteboardSessionManager) { #ifdef SWIFT_EXPERIMENTAL_WB @@ -36,7 +33,7 @@ namespace Swift { } WhiteboardManager::~WhiteboardManager() { - foreach (JIDWhiteboardWindowPair whiteboardWindowPair, whiteboardWindows_) { + for (auto&& whiteboardWindowPair : whiteboardWindows_) { delete whiteboardWindowPair.second; } } diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp index f0debb9..f8fb192 100644 --- a/Swift/Controllers/XMPPEvents/EventController.cpp +++ b/Swift/Controllers/XMPPEvents/EventController.cpp @@ -11,8 +11,6 @@ #include #include -#include - #include #include #include @@ -25,7 +23,7 @@ EventController::EventController() { } EventController::~EventController() { - foreach(std::shared_ptr event, events_) { + for (auto&& event : events_) { event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event)); } } @@ -40,7 +38,7 @@ void EventController::handleIncomingEvent(std::shared_ptr sourceEve /* If it's a duplicate subscription request, remove the previous request first */ if (subscriptionEvent) { EventList existingEvents(events_); - foreach(std::shared_ptr existingEvent, existingEvents) { + for (auto&& existingEvent : existingEvents) { std::shared_ptr existingSubscriptionEvent = std::dynamic_pointer_cast(existingEvent); if (existingSubscriptionEvent) { if (existingSubscriptionEvent->getJID() == subscriptionEvent->getJID()) { diff --git a/Swift/QtUI/ChatList/ChatListGroupItem.h b/Swift/QtUI/ChatList/ChatListGroupItem.h index 427f00b..a9bb9b1 100644 --- a/Swift/QtUI/ChatList/ChatListGroupItem.h +++ b/Swift/QtUI/ChatList/ChatListGroupItem.h @@ -8,8 +8,6 @@ #include -#include - #include namespace Swift { @@ -24,13 +22,12 @@ namespace Swift { int row(ChatListItem* item) {return items_.indexOf(item);} QVariant data(int role) const {return (role == Qt::DisplayRole) ? name_ : QVariant();} void clear() { - foreach (ChatListItem* item, items_) { + for (auto item : items_) { delete item; } items_.clear(); } - private: static bool pointerItemLessThan(const ChatListItem* first, const ChatListItem* second) { QString myName = first->data(Qt::DisplayRole).toString().toLower(); diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp index e5e8963..416b786 100644 --- a/Swift/QtUI/ChatList/ChatListModel.cpp +++ b/Swift/QtUI/ChatList/ChatListModel.cpp @@ -96,7 +96,7 @@ void ChatListModel::setRecents(const std::list& recents) { recents_->clear(); endRemoveRows(); beginInsertRows(recentsIndex_, 0, recents.size()); - foreach (const ChatListWindow::Chat chat, recents) { + for (const auto& chat : recents) { recents_->addItem(new ChatListRecentItem(chat, recents_)); //whiteboards_->addItem(new ChatListRecentItem(chat, whiteboards_)); } @@ -121,8 +121,7 @@ QMimeData* ChatListModel::mimeData(const QModelIndexList& indexes) const { } dataStream << P2QSTRING(chat.jid.toString()); } else { - typedef std::map JIDMap; - foreach (const JIDMap::value_type& jid, chat.impromptuJIDs) { + for (const auto& jid : chat.impromptuJIDs) { dataStream << P2QSTRING(jid.second.toString()); } } diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp index 3fe462a..3caed57 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.cpp +++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp @@ -180,7 +180,7 @@ void QtChatListWindow::contextMenuEvent(QContextMenuEvent* event) { ChatListItem* baseItem = index.isValid() ? static_cast(index.internalPointer()) : nullptr; contextMenuItem_ = baseItem; - foreach(QAction* action, onlineOnlyActions_) { + for (auto action : onlineOnlyActions_) { action->setEnabled(isOnline_); } diff --git a/Swift/QtUI/ChatSnippet.cpp b/Swift/QtUI/ChatSnippet.cpp index 0369d0a..87dfac2 100644 --- a/Swift/QtUI/ChatSnippet.cpp +++ b/Swift/QtUI/ChatSnippet.cpp @@ -48,7 +48,7 @@ QString ChatSnippet::directionToCSS(Direction direction) { ChatSnippet::Direction ChatSnippet::getDirection(const ChatWindow::ChatMessage& message) { std::shared_ptr textPart; std::string text = ""; - foreach (std::shared_ptr part, message.getParts()) { + for (auto&& part : message.getParts()) { if ((textPart = std::dynamic_pointer_cast(part))) { text = textPart->text; break; diff --git a/Swift/QtUI/ChatSnippet.h b/Swift/QtUI/ChatSnippet.h index f715cbf..d8bc209 100644 --- a/Swift/QtUI/ChatSnippet.h +++ b/Swift/QtUI/ChatSnippet.h @@ -11,8 +11,6 @@ #include #include -#include - #include #include diff --git a/Swift/QtUI/CocoaUIHelpers.mm b/Swift/QtUI/CocoaUIHelpers.mm index 3ffa72c..1f4ffc1 100644 --- a/Swift/QtUI/CocoaUIHelpers.mm +++ b/Swift/QtUI/CocoaUIHelpers.mm @@ -13,6 +13,7 @@ #include "CocoaUIHelpers.h" #include + #include #include @@ -20,8 +21,6 @@ #include #include -#include - #pragma GCC diagnostic ignored "-Wold-style-cast" namespace Swift { @@ -29,7 +28,7 @@ namespace Swift { void CocoaUIHelpers::displayCertificateChainAsSheet(QWidget* parent, const std::vector& chain) { NSWindow* parentWindow = [((NSView*)parent->winId()) window]; NSMutableArray* certificates = [[NSMutableArray alloc] init]; - foreach(Certificate::ref cert, chain) { + for (auto&& cert : chain) { // convert chain to SecCertificateRef ByteArray certAsDER = cert->toDER(); std::shared_ptr::type> certData(CFDataCreate(nullptr, certAsDER.data(), certAsDER.size()), CFRelease); @@ -39,7 +38,6 @@ void CocoaUIHelpers::displayCertificateChainAsSheet(QWidget* parent, const std:: [certificates addObject: (id)macCert.get()]; } - SFCertificatePanel* panel = [[SFCertificatePanel alloc] init]; //[panel setPolicies:(id)policies.get()]; [panel beginSheetForWindow:parentWindow modalDelegate:nil didEndSelector:nullptr contextInfo:nullptr certificates:certificates showGroup:YES]; diff --git a/Swift/QtUI/EventViewer/EventModel.cpp b/Swift/QtUI/EventViewer/EventModel.cpp index e242003..5b97b3e 100644 --- a/Swift/QtUI/EventViewer/EventModel.cpp +++ b/Swift/QtUI/EventViewer/EventModel.cpp @@ -19,10 +19,10 @@ EventModel::EventModel() { } EventModel::~EventModel() { - foreach (QtEvent* event, activeEvents_) { + for (auto event : activeEvents_) { delete event; } - foreach (QtEvent* event, inactiveEvents_) { + for (auto event : inactiveEvents_) { delete event; } } diff --git a/Swift/QtUI/QtAdHocCommandWindow.cpp b/Swift/QtUI/QtAdHocCommandWindow.cpp index 6b982b1..65dac91 100644 --- a/Swift/QtUI/QtAdHocCommandWindow.cpp +++ b/Swift/QtUI/QtAdHocCommandWindow.cpp @@ -104,7 +104,7 @@ void QtAdHocCommandWindow::handleCompleteClicked() { void QtAdHocCommandWindow::handleNextStageReceived(Command::ref command) { QString notes; - foreach (Command::Note note, command->getNotes()) { + for (const auto& note : command->getNotes()) { if (!notes.isEmpty()) { notes += "\n"; } @@ -152,7 +152,7 @@ typedef std::pair ActionButton; void QtAdHocCommandWindow::setAvailableActions(Command::ref /*commandResult*/) { okButton_->show(); okButton_->setEnabled(true); - foreach (ActionButton pair, actions_) { + for (auto&& pair : actions_) { OutgoingAdHocCommandSession::ActionState state = command_->getActionState(pair.first); if (state & OutgoingAdHocCommandSession::Present) { okButton_->hide(); diff --git a/Swift/QtUI/QtAffiliationEditor.cpp b/Swift/QtUI/QtAffiliationEditor.cpp index 980b26a..92b6aff 100644 --- a/Swift/QtUI/QtAffiliationEditor.cpp +++ b/Swift/QtUI/QtAffiliationEditor.cpp @@ -37,7 +37,7 @@ const std::vector >& QtAffiliationEdito void QtAffiliationEditor::handleCurrentIndexChanged(int index) { ui_.list->clear(); - foreach (const JID& jid, affiliations_[affiliationFromIndex(index)]) { + for (const auto& jid : affiliations_[affiliationFromIndex(index)]) { ui_.list->addItem(P2QSTRING(jid.toString())); } } diff --git a/Swift/QtUI/QtBlockListEditorWindow.cpp b/Swift/QtUI/QtBlockListEditorWindow.cpp index 9e13943..30c939f 100644 --- a/Swift/QtUI/QtBlockListEditorWindow.cpp +++ b/Swift/QtUI/QtBlockListEditorWindow.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -158,7 +157,7 @@ void QtBlockListEditorWindow::applyChanges() { void QtBlockListEditorWindow::setCurrentBlockList(const std::vector &blockedJIDs) { ui->blockListTreeWidget->clear(); - foreach(const JID& jid, blockedJIDs) { + for (const auto& jid : blockedJIDs) { QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(P2QSTRING(jid.toString())) << ""); item->setFlags(item->flags() | Qt::ItemIsEditable); ui->blockListTreeWidget->addTopLevelItem(item); diff --git a/Swift/QtUI/QtCertificateViewerDialog.cpp b/Swift/QtUI/QtCertificateViewerDialog.cpp index a99c29a..6454d82 100644 --- a/Swift/QtUI/QtCertificateViewerDialog.cpp +++ b/Swift/QtUI/QtCertificateViewerDialog.cpp @@ -18,8 +18,6 @@ #include #include -#include - #include namespace Swift { @@ -43,7 +41,7 @@ void QtCertificateViewerDialog::setCertificateChain(const std::vectortoDER(); QByteArray dataArray(reinterpret_cast(certAsDer.data()), certAsDer.size()); currentChain.push_front(QSslCertificate(dataArray, QSsl::Der)); @@ -125,8 +123,8 @@ void QtCertificateViewerDialog::setCertificateDetails(const QSslCertificate& cer #endif if (!altNames.empty()) { ADD_SECTION(tr("Alternate Subject Names")); - foreach (const SANTYPE &type, altNames.uniqueKeys()) { - foreach (QString name, altNames.values(type)) { + for (const auto& type : altNames.uniqueKeys()) { + for (auto&& name : altNames.values(type)) { if (type == QSsl::EmailEntry) { ADD_FIELD(tr("E-mail Address"), name); } else { diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index bb9c005..3241858 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -80,7 +80,7 @@ QtChatTabs::QtChatTabs(bool singleWindow, SettingsProvider* settingsProvider, bo } QtChatTabs::~QtChatTabs() { - foreach (QShortcut* shortcut, shortcuts_) { + for (auto shortcut : shortcuts_) { delete shortcut; } diff --git a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp b/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp index fb41446..40ab17f 100644 --- a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp +++ b/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp @@ -12,7 +12,6 @@ #include #include -#include #include @@ -95,7 +94,7 @@ QList QtChatTabsShortcutOnlySubstitute::tabbableWindows() const { QList windows = qApp->topLevelWidgets(); QList tabbables; - foreach(QWidget* topLevelWidget, windows) { + for (auto topLevelWidget : windows) { QtTabbable* tabbable = dynamic_cast(topLevelWidget); if (tabbable) { tabbables << tabbable; diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index bda6b3e..d799e19 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -386,7 +386,7 @@ void QtChatWindow::setAvailableSecurityLabels(const std::vectorsetModel(labelModel_); - foreach (SecurityLabelsCatalog::Item label, labels) { + for (const auto& label : labels) { if (label.getIsDefault()) { defaultIndex = i; break; @@ -712,8 +712,7 @@ void QtChatWindow::handleActionButtonClicked() { } else { - foreach(ChatWindow::RoomAction availableAction, availableRoomActions_) - { + for (auto&& availableAction : availableRoomActions_) { if (impromptu_) { // hide options we don't need in impromptu chats if (availableAction == ChatWindow::ChangeSubject || diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index 4e9a7fe..17f5ccf 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -51,7 +51,7 @@ QtContactEditWidget::QtContactEditWidget(const std::set& allGroups, groupsArea->setWidget(groups); QVBoxLayout* scrollLayout = new QVBoxLayout(groups); - foreach (std::string group, allGroups) { + for (const auto& group : allGroups) { QString groupName = doubleAmpersand(group); QCheckBox* check = new QCheckBox(groups); check->setText(groupName); @@ -79,7 +79,7 @@ void QtContactEditWidget::setName(const std::string& name) { std::string QtContactEditWidget::getName() const { std::string name = Q2PSTRING(name_->text()); QList buttons = findChildren(); - foreach(const QRadioButton* button, buttons) { + for (const auto button : buttons) { if (button->isChecked()) { if (button == nameRadioButton_) { name = Q2PSTRING(name_->text()); @@ -93,14 +93,14 @@ std::string QtContactEditWidget::getName() const { } void QtContactEditWidget::setSelectedGroups(const std::vector& groups) { - foreach (std::string group, groups) { + for (auto&& group : groups) { checkBoxes_[group]->setCheckState(Qt::Checked); } } std::set QtContactEditWidget::getSelectedGroups() const { std::set groups; - foreach(const CheckBoxMap::value_type& group, checkBoxes_) { + for (const auto& group : checkBoxes_) { if (group.second->checkState() == Qt::Checked) { groups.insert(group.first); } @@ -124,7 +124,7 @@ void QtContactEditWidget::setNameSuggestions(const std::vector& sug } // populate new suggestions - foreach(const std::string& name, suggestions) { + for (const auto& name : suggestions) { suggestionsLayout_->insertWidget(nameLayout_->count() - 2, new QRadioButton(doubleAmpersand(name), this)); } @@ -133,7 +133,7 @@ void QtContactEditWidget::setNameSuggestions(const std::vector& sug QRadioButton* suggestedRadioButton = nullptr; QList radioButtons = findChildren(); - foreach (QRadioButton* candidate, radioButtons) { + for (auto candidate : radioButtons) { if (candidate->text() == name_->text()) { suggestedRadioButton = candidate; break; diff --git a/Swift/QtUI/QtContactEditWidget.h b/Swift/QtUI/QtContactEditWidget.h index d4ea609..0718fee 100644 --- a/Swift/QtUI/QtContactEditWidget.h +++ b/Swift/QtUI/QtContactEditWidget.h @@ -41,9 +41,9 @@ namespace Swift { private: QString doubleAmpersand(const std::string& name) const; std::string singleAmpersand(const QString& name) const; + private: - typedef std::map CheckBoxMap; - CheckBoxMap checkBoxes_; + std::map checkBoxes_; QHBoxLayout* nameLayout_; QHBoxLayout* suggestionsLayout_; QRadioButton* nameRadioButton_; diff --git a/Swift/QtUI/QtEmoticonsGrid.cpp b/Swift/QtUI/QtEmoticonsGrid.cpp index a81f516..4c8c024 100644 --- a/Swift/QtUI/QtEmoticonsGrid.cpp +++ b/Swift/QtUI/QtEmoticonsGrid.cpp @@ -14,16 +14,14 @@ #include -#include +#include -#include +#include #include namespace Swift { -typedef std::map EmoticonsMap; // Without this typedef compiler complains when using foreach - QtEmoticonsGrid::QtEmoticonsGrid(const std::map& emoticons, QWidget* parent) : QGridLayout(parent) { makeUniqueEmoticonsMap(emoticons); @@ -31,7 +29,7 @@ QtEmoticonsGrid::QtEmoticonsGrid(const std::map& emoti int row = 0; int column = 0; - foreach(EmoticonsMap::value_type emoticon, uniqueEmoticons_) { + for (auto&& emoticon : uniqueEmoticons_) { QtEmoticonCell* newCell = new QtEmoticonCell(P2QSTRING(emoticon.first), P2QSTRING(emoticon.second)); addWidget(newCell, row, column); connect(newCell, SIGNAL(emoticonClicked(QString)), this, SLOT(emoticonClickedSlot(QString))); @@ -50,7 +48,7 @@ QtEmoticonsGrid::~QtEmoticonsGrid() { void QtEmoticonsGrid::makeUniqueEmoticonsMap(const std::map& emoticons) { std::set paths; - reverse_foreach(EmoticonsMap::value_type emoticon, emoticons) { + for (auto&& emoticon : boost::adaptors::reverse(emoticons)) { if (paths.find(emoticon.second) == paths.end()) { uniqueEmoticons_.insert(emoticon); paths.insert(emoticon.second); diff --git a/Swift/QtUI/QtFormResultItemModel.cpp b/Swift/QtUI/QtFormResultItemModel.cpp index 60cf0c0..b35bb4f 100644 --- a/Swift/QtUI/QtFormResultItemModel.cpp +++ b/Swift/QtUI/QtFormResultItemModel.cpp @@ -14,8 +14,6 @@ #include -#include - #include namespace Swift { @@ -73,7 +71,7 @@ const std::string QtFormResultItemModel::getFieldValue(const Form::FormItem& ite // determine field name std::string name = formResult_->getReportedFields().at(column)->getName(); - foreach(FormField::ref field, item) { + for (auto&& field : item) { if (field->getName() == name) { std::string delimiter = ""; if (field->getType() == FormField::TextMultiType) { diff --git a/Swift/QtUI/QtFormWidget.cpp b/Swift/QtUI/QtFormWidget.cpp index 1d26815..96c2da0 100644 --- a/Swift/QtUI/QtFormWidget.cpp +++ b/Swift/QtUI/QtFormWidget.cpp @@ -20,8 +20,6 @@ #include -#include - #include namespace Swift { @@ -43,7 +41,7 @@ QtFormWidget::QtFormWidget(Form::ref form, QWidget* parent) : QWidget(parent), f QGridLayout* layout = new QGridLayout(scroll); const std::vector items = form->getItems(); if (items.empty()) { /* single item forms */ - foreach (FormField::ref field, form->getFields()) { + for (auto&& field : form->getFields()) { QWidget* widget = createWidget(field, field->getType(), 0); if (widget) { layout->addWidget(new QLabel(field->getLabel().c_str(), this), row, 0); @@ -80,12 +78,12 @@ QListWidget* QtFormWidget::createList(FormField::ref field) { std::vector selected; /* if this is an editable form, use the 'options' list, otherwise use the 'values' list */ if (form_->getType() != Form::FormType) { - foreach (const std::string& value, field->getValues()) { + for (const auto& value : field->getValues()) { listWidget->addItem(P2QSTRING(value)); selected.push_back(false); } } else { - foreach (FormField::Option option, field->getOptions()) { + for (auto&& option : field->getOptions()) { listWidget->addItem(option.label.c_str()); if (field->getType() == FormField::ListSingleType) { selected.push_back(!field->getValues().empty() && option.value == field->getValues()[0]); @@ -157,7 +155,7 @@ QWidget* QtFormWidget::createWidget(FormField::ref field, const FormField::Type Form::ref QtFormWidget::getCompletedForm() { Form::ref result(new Form(Form::SubmitType)); - foreach (std::shared_ptr field, form_->getFields()) { + for (auto&& field : form_->getFields()) { std::shared_ptr resultField = std::make_shared(field->getType()); if (field->getType() == FormField::BooleanType) { resultField->setBoolValue(qobject_cast(fields_[field->getName()])->checkState() == Qt::Checked); @@ -191,14 +189,14 @@ Form::ref QtFormWidget::getCompletedForm() { QString string = widget->toPlainText(); if (!string.isEmpty()) { QStringList lines = string.split("\n"); - foreach (QString line, lines) { + for (auto&& line : lines) { resultField->addValue(Q2PSTRING(line)); } } } if (field->getType() == FormField::ListMultiType) { QListWidget* listWidget = qobject_cast(fields_[field->getName()]); - foreach (QListWidgetItem* item, listWidget->selectedItems()) { + for (auto item : listWidget->selectedItems()) { resultField->addValue(field->getOptions()[listWidget->row(item)].value); } } @@ -226,7 +224,7 @@ void QtFormWidget::setEditable(bool editable) { if (!form_) { return; } - foreach (std::shared_ptr field, form_->getFields()) { + for (auto&& field : form_->getFields()) { QWidget* widget = nullptr; if (field) { widget = fields_[field->getName()]; diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index 53e7ffe..77a7f12 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -176,7 +176,7 @@ void QtHistoryWindow::handleScrollRequested(int pos) { } QDate currentDate; - foreach (const QDate& date, dates_) { + for (const auto& date : dates_) { int snippetPosition = conversation_->getSnippetPositionByDate(date); if (snippetPosition <= pos) { currentDate = date; diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index d91f694..865d8b5 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -499,7 +499,7 @@ void QtLoginWindow::morphInto(MainWindow *mainWindow) { setInitialMenus(); std::vector mainWindowMenus = qtMainWindow->getMenus(); viewMenu_ = mainWindowMenus[0]; - foreach (QMenu* menu, mainWindowMenus) { + for (auto menu : mainWindowMenus) { menuBar_->addMenu(menu); } setFocus(); diff --git a/Swift/QtUI/QtPlainChatView.cpp b/Swift/QtUI/QtPlainChatView.cpp index d682cfa..05a2eb0 100644 --- a/Swift/QtUI/QtPlainChatView.cpp +++ b/Swift/QtUI/QtPlainChatView.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -45,7 +44,7 @@ QtPlainChatView::~QtPlainChatView() { QString chatMessageToString(const ChatWindow::ChatMessage& message) { QString result; - foreach (std::shared_ptr part, message.getParts()) { + for (auto&& part : message.getParts()) { std::shared_ptr textPart; std::shared_ptr uriPart; std::shared_ptr emoticonPart; diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp index 461ea38..80e275b 100644 --- a/Swift/QtUI/QtProfileWindow.cpp +++ b/Swift/QtUI/QtProfileWindow.cpp @@ -156,7 +156,7 @@ void QtProfileWindow::handleAdjustSizeTimeout() { // Force recaluclation of all layout geometry in children widgets. // This is required on Windows to have the correct size even on first show. QList children = findChildren(); - foreach(QWidget* child, children) { + for (auto child : children) { child->updateGeometry(); } diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp index 3c32dc8..42ac22d 100644 --- a/Swift/QtUI/QtSettingsProvider.cpp +++ b/Swift/QtUI/QtSettingsProvider.cpp @@ -77,7 +77,7 @@ void QtSettingsProvider::storeSetting(const Setting& setting, const int& se std::vector QtSettingsProvider::getAvailableProfiles() { std::vector profiles; QVariant profilesVariant = settings_.value("profileList"); - foreach(QString profileQString, profilesVariant.toStringList()) { + for (const auto& profileQString : profilesVariant.toStringList()) { profiles.push_back(std::string(profileQString.toUtf8())); } return profiles; @@ -92,7 +92,7 @@ void QtSettingsProvider::createProfile(const std::string& profile) { void QtSettingsProvider::removeProfile(const std::string& profile) { QString profileStart(QString(profile.c_str()) + ":"); - foreach (QString key, settings_.allKeys()) { + for (auto&& key : settings_.allKeys()) { if (key.startsWith(profileStart)) { settings_.remove(key); } diff --git a/Swift/QtUI/QtSingleWindow.cpp b/Swift/QtUI/QtSingleWindow.cpp index ab7e81e..1fba497 100644 --- a/Swift/QtUI/QtSingleWindow.cpp +++ b/Swift/QtUI/QtSingleWindow.cpp @@ -6,8 +6,6 @@ #include -#include - #include #include @@ -45,7 +43,7 @@ void QtSingleWindow::handleTabsTitleChanged(const QString& title) { void QtSingleWindow::handleSplitterMoved(int, int) { QList variantValues; QList intValues = sizes(); - foreach (int value, intValues) { + for (const auto& value : intValues) { variantValues.append(QVariant(value)); } settings_->getQSettings()->setValue(SINGLE_WINDOW_SPLITS, QVariant(variantValues)); @@ -54,7 +52,7 @@ void QtSingleWindow::handleSplitterMoved(int, int) { void QtSingleWindow::restoreSplitters() { QList variantValues = settings_->getQSettings()->value(SINGLE_WINDOW_SPLITS).toList(); QList intValues; - foreach (QVariant value, variantValues) { + for (auto&& value : variantValues) { intValues.append(value.toInt()); } setSizes(intValues); diff --git a/Swift/QtUI/QtSpellCheckHighlighter.cpp b/Swift/QtUI/QtSpellCheckHighlighter.cpp index 6565b06..cb467e2 100644 --- a/Swift/QtUI/QtSpellCheckHighlighter.cpp +++ b/Swift/QtUI/QtSpellCheckHighlighter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -29,7 +29,7 @@ void QtSpellCheckHighlighter::highlightBlock(const QString& text) { spellingErrorFormat.setUnderlineColor(QColor(Qt::red)); spellingErrorFormat.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline); - foreach (PositionPair position, misspelledPositions_) { + for (auto&& position : misspelledPositions_) { setFormat(boost::get<0>(position), boost::get<1>(position) - boost::get<0>(position), spellingErrorFormat); }; } diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp index 2e9e4cc..b175e5c 100644 --- a/Swift/QtUI/QtStatusWidget.cpp +++ b/Swift/QtUI/QtStatusWidget.cpp @@ -144,7 +144,7 @@ void QtStatusWidget::generateList() { QString text = statusEdit_->text(); newStatusText_ = text; menu_->clear(); - foreach (StatusShow::Type type, icons_.keys()) { + for (const auto& type : icons_.keys()) { QListWidgetItem* item = new QListWidgetItem(text == "" ? getNoMessage() : text, menu_); item->setIcon(icons_[type]); item->setToolTip(P2QSTRING(statusShowTypeToFriendlyName(type)) + ": " + item->text()); @@ -152,7 +152,7 @@ void QtStatusWidget::generateList() { item->setData(Qt::UserRole, QVariant(type)); } std::vector previousStatuses = statusCache_->getMatches(Q2PSTRING(text), 8); - foreach (StatusCache::PreviousStatus savedStatus, previousStatuses) { + for (const auto& savedStatus : previousStatuses) { if (savedStatus.first.empty() || std::find_if(allTypes_.begin(), allTypes_.end(), savedStatus.second == lambda::_1 && savedStatus.first == lambda::bind(&statusShowTypeToFriendlyName, lambda::_1)) != allTypes_.end()) { continue; @@ -163,7 +163,7 @@ void QtStatusWidget::generateList() { item->setStatusTip(item->toolTip()); item->setData(Qt::UserRole, QVariant(savedStatus.second)); } - foreach (StatusShow::Type type, icons_.keys()) { + for (const auto& type : icons_.keys()) { if (Q2PSTRING(text) == statusShowTypeToFriendlyName(type)) { continue; } @@ -203,7 +203,7 @@ void QtStatusWidget::handleClicked() { if (x + width > screenWidth) { x = screenWidth - width; } - //foreach (StatusShow::Type type, allTypes_) { + //for (StatusShow::Type type : allTypes_) { // if (statusEdit_->text() == P2QSTRING(statusShowTypeToFriendlyName(type))) { statusEdit_->setText(""); // } diff --git a/Swift/QtUI/QtSubscriptionRequestWindow.cpp b/Swift/QtUI/QtSubscriptionRequestWindow.cpp index eea13f2..c8c4178 100644 --- a/Swift/QtUI/QtSubscriptionRequestWindow.cpp +++ b/Swift/QtUI/QtSubscriptionRequestWindow.cpp @@ -73,7 +73,7 @@ QtSubscriptionRequestWindow::~QtSubscriptionRequestWindow() { } QtSubscriptionRequestWindow* QtSubscriptionRequestWindow::getWindow(std::shared_ptr event, QWidget* parent) { - foreach (QtSubscriptionRequestWindow* window, windows_) { + for (auto window : windows_) { if (window->getEvent() == event) { return window; } diff --git a/Swift/QtUI/QtTabbable.cpp b/Swift/QtUI/QtTabbable.cpp index bad6315..ed0963b 100644 --- a/Swift/QtUI/QtTabbable.cpp +++ b/Swift/QtUI/QtTabbable.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp b/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp index ed36580..02ceb0a 100644 --- a/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp +++ b/Swift/QtUI/QtVCardWidget/QtTagComboBox.cpp @@ -50,7 +50,7 @@ void QtTagComboBox::addTag(const QString &id, const QString &label) { void QtTagComboBox::setTag(const QString &id, bool value) { QList tagActions = editMenu->actions(); - foreach(QAction* action, tagActions) { + for (auto action : tagActions) { if (action->data() == id) { action->setChecked(value); updateDisplayItem(); @@ -61,7 +61,7 @@ void QtTagComboBox::setTag(const QString &id, bool value) { bool QtTagComboBox::isTagSet(const QString &id) const { QList tagActions = editMenu->actions(); - foreach(QAction* action, tagActions) { + for (auto action : tagActions) { if (action->data() == id) { return action->isChecked(); } @@ -94,7 +94,7 @@ bool QtTagComboBox::event(QEvent* event) { void QtTagComboBox::updateDisplayItem() { QList tagActions = editMenu->actions(); QString text = ""; - foreach(QAction* action, tagActions) { + for (auto action : tagActions) { if (action->isChecked()) { if (text != "") { text += ", "; diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp index 4043dbc..596006a 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp @@ -90,7 +90,7 @@ void QtVCardAddressField::setupContentWidgets() { } void QtVCardAddressField::customCleanup() { - foreach(QWidget* widget, textFields) { + for (auto widget : textFields) { widget->hide(); textFieldGridLayout->removeWidget(widget); } @@ -170,7 +170,7 @@ void QtVCardAddressField::handleEditibleChanged(bool isEditable) { domesticRadioButton->setVisible(isEditable); internationalRadioButton->setVisible(isEditable); - foreach (QWidget* widget, textFields) { + for (auto widget : textFields) { QtResizableLineEdit* lineEdit; if ((lineEdit = dynamic_cast(widget))) { lineEdit->setVisible(isEditable ? true : !lineEdit->text().isEmpty()); diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp index ab69cba..9bb6a35 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp @@ -121,7 +121,7 @@ QGridLayout* QtVCardGeneralField::getGridLayout() const { void QtVCardGeneralField::handleCloseButtonClicked() { customCleanup(); - foreach(QWidget* widget, childWidgets) { + for (auto widget : childWidgets) { widget->hide(); layout->removeWidget(widget); } diff --git a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp index 9e303b7..5162c73 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp @@ -78,7 +78,7 @@ bool QtVCardOrganizationField::isEmpty() const { void QtVCardOrganizationField::setOrganization(const VCard::Organization& organization) { organizationLineEdit->setText(P2QSTRING(organization.name)); unitsTreeWidget->clear(); - foreach(std::string unit, organization.units) { + for (const auto& unit : organization.units) { QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(P2QSTRING(unit)) << ""); item->setFlags(item->flags() | Qt::ItemIsEditable); unitsTreeWidget->addTopLevelItem(item); @@ -134,7 +134,7 @@ void QtVCardOrganizationField::handleRowsRemoved(const QModelIndex&, int, int) { void QtVCardOrganizationField::guaranteeEmptyRow() { bool hasEmptyRow = false; QList rows = unitsTreeWidget->findItems("", Qt::MatchFixedString); - foreach(QTreeWidgetItem* row, rows) { + for (auto row : rows) { if (row->text(0).isEmpty()) { hasEmptyRow = true; } diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index c0ce3dc..6fe9397 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -499,7 +499,7 @@ QString QtWebKitChatView::getHighlightSpanStart(const HighlightAction& highlight QString QtWebKitChatView::chatMessageToHTML(const ChatWindow::ChatMessage& message) { QString result; - foreach (std::shared_ptr part, message.getParts()) { + for (const auto& part : message.getParts()) { std::shared_ptr textPart; std::shared_ptr uriPart; std::shared_ptr emoticonPart; diff --git a/Swift/QtUI/Roster/QtFilterWidget.cpp b/Swift/QtUI/Roster/QtFilterWidget.cpp index d2e4d09..2e1ead9 100644 --- a/Swift/QtUI/Roster/QtFilterWidget.cpp +++ b/Swift/QtUI/Roster/QtFilterWidget.cpp @@ -100,7 +100,7 @@ bool QtFilterWidget::eventFilter(QObject*, QEvent* event) { void QtFilterWidget::popAllFilters() { std::vector filters = treeView_->getRoster()->getFilters(); - foreach(RosterFilter* filter, filters) { + for (auto filter : filters) { filters_.push_back(filter); treeView_->getRoster()->removeFilter(filter); } @@ -111,7 +111,7 @@ void QtFilterWidget::popAllFilters() { void QtFilterWidget::pushAllFilters() { treeView_->getRoster()->onFilterAdded.disconnect(boost::bind(&QtFilterWidget::handleFilterAdded, this, _1)); treeView_->getRoster()->onFilterRemoved.disconnect(boost::bind(&QtFilterWidget::handleFilterRemoved, this, _1)); - foreach(RosterFilter* filter, filters_) { + for (auto filter : filters_) { treeView_->getRoster()->addFilter(filter); } filters_.clear(); diff --git a/Swift/QtUI/Roster/QtOccupantListWidget.cpp b/Swift/QtUI/Roster/QtOccupantListWidget.cpp index 03c14fd..a12863d 100644 --- a/Swift/QtUI/Roster/QtOccupantListWidget.cpp +++ b/Swift/QtUI/Roster/QtOccupantListWidget.cpp @@ -50,7 +50,7 @@ void QtOccupantListWidget::contextMenuEvent(QContextMenuEvent* event) { } else { std::map actions; - foreach (ChatWindow::OccupantAction availableAction, availableOccupantActions_) { + for (const auto& availableAction : availableOccupantActions_) { QString text = "Error: missing string"; switch (availableAction) { case ChatWindow::Kick: text = tr("Kick user"); break; diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp index 3f77c86..ef4d778 100644 --- a/Swift/QtUI/Roster/RosterModel.cpp +++ b/Swift/QtUI/Roster/RosterModel.cpp @@ -53,7 +53,7 @@ void RosterModel::reLayout() { if (!roster_) { return; } - foreach (RosterItem* item, roster_->getRoot()->getDisplayedChildren()) { + for (auto item : roster_->getRoot()->getDisplayedChildren()) { GroupRosterItem* child = dynamic_cast(item); if (!child) continue; emit itemExpanded(index(child), child->isExpanded()); diff --git a/Swift/QtUI/Roster/RosterTooltip.cpp b/Swift/QtUI/Roster/RosterTooltip.cpp index 8d467fd..ea4c9cd 100644 --- a/Swift/QtUI/Roster/RosterTooltip.cpp +++ b/Swift/QtUI/Roster/RosterTooltip.cpp @@ -122,7 +122,7 @@ QString RosterTooltip::buildVCardSummary(VCard::ref vcard) { // star | name | content QString currentBlock; - foreach (const VCard::Telephone& tel, vcard->getTelephones()) { + for (const auto& tel : vcard->getTelephones()) { QString type = tel.isFax ? QObject::tr("Fax") : QObject::tr("Telephone"); QString field = buildVCardField(tel.isPreferred, type, htmlEscape(P2QSTRING(tel.number))); if (tel.isPreferred) { @@ -134,7 +134,7 @@ QString RosterTooltip::buildVCardSummary(VCard::ref vcard) { summary += currentBlock; currentBlock = ""; - foreach (const VCard::EMailAddress& mail, vcard->getEMailAddresses()) { + for (const auto& mail : vcard->getEMailAddresses()) { QString field = buildVCardField(mail.isPreferred, QObject::tr("E-Mail"), htmlEscape(P2QSTRING(mail.address))); if (mail.isPreferred) { currentBlock = field; @@ -145,14 +145,14 @@ QString RosterTooltip::buildVCardSummary(VCard::ref vcard) { summary += currentBlock; currentBlock = ""; - foreach (const VCard::Organization& org, vcard->getOrganizations()) { + for (const auto& org : vcard->getOrganizations()) { QString field = buildVCardField(false, QObject::tr("Organization"), htmlEscape(P2QSTRING(org.name))); currentBlock += field; } summary += currentBlock; currentBlock = ""; - foreach(const std::string& title, vcard->getTitles()) { + for (const auto& title : vcard->getTitles()) { QString field = buildVCardField(false, QObject::tr("Title"), htmlEscape(P2QSTRING(title))); currentBlock += field; } diff --git a/Swift/QtUI/UserSearch/ContactListModel.cpp b/Swift/QtUI/UserSearch/ContactListModel.cpp index 376d3b1..6ef85d7 100644 --- a/Swift/QtUI/UserSearch/ContactListModel.cpp +++ b/Swift/QtUI/UserSearch/ContactListModel.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include diff --git a/Swift/QtUI/UserSearch/QtContactListWidget.cpp b/Swift/QtUI/UserSearch/QtContactListWidget.cpp index 1dbfc1f..73a8482 100644 --- a/Swift/QtUI/UserSearch/QtContactListWidget.cpp +++ b/Swift/QtUI/UserSearch/QtContactListWidget.cpp @@ -85,8 +85,8 @@ bool QtContactListWidget::isFull() const { void QtContactListWidget::updateContacts(const std::vector& contactUpdates) { std::vector contacts = contactListModel_->getList(); - foreach(const Contact::ref& contactUpdate, contactUpdates) { - for(auto& contact : contacts) { + for (const auto& contactUpdate : contactUpdates) { + for (auto&& contact : contacts) { if (contactUpdate->jid == contact->jid) { contact = contactUpdate; break; diff --git a/Swift/QtUI/WinUIHelpers.cpp b/Swift/QtUI/WinUIHelpers.cpp index 4898916..ec39c38 100644 --- a/Swift/QtUI/WinUIHelpers.cpp +++ b/Swift/QtUI/WinUIHelpers.cpp @@ -19,8 +19,6 @@ #include -#include - namespace Swift { void WinUIHelpers::displayCertificateChainAsSheet(QWidget* parent, const std::vector& chain) { diff --git a/Swiften/Base/foreach.h b/Swiften/Base/foreach.h deleted file mode 100644 index 3e8ec43..0000000 --- a/Swiften/Base/foreach.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Isode Limited. - * All rights reserved. - * See the COPYING file for more information. - */ - -#pragma once - -#include - -#undef foreach -#define foreach BOOST_FOREACH -#define reverse_foreach BOOST_REVERSE_FOREACH diff --git a/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp b/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp index 278068a..7eeb531 100644 --- a/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp +++ b/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -142,7 +141,7 @@ public: int getComposingCount() const { int result = 0; - foreach(std::shared_ptr stanza, stanzaChannel->sentStanzas) { + for (auto&& stanza : stanzaChannel->sentStanzas) { if (stanza->getPayload() && stanza->getPayload()->getChatState() == ChatState::Composing) { result++; } @@ -152,7 +151,7 @@ public: int getActiveCount() const { int result = 0; - foreach(std::shared_ptr stanza, stanzaChannel->sentStanzas) { + for (auto&& stanza : stanzaChannel->sentStanzas) { if (stanza->getPayload() && stanza->getPayload()->getChatState() == ChatState::Active) { result++; } diff --git a/Swiften/Client/BlockListImpl.cpp b/Swiften/Client/BlockListImpl.cpp index ebffff8..54dcdf5 100644 --- a/Swiften/Client/BlockListImpl.cpp +++ b/Swiften/Client/BlockListImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 Isode Limited. + * Copyright (c) 2011-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -8,8 +8,6 @@ #include -#include - using namespace Swift; BlockListImpl::BlockListImpl() : state(Init) { @@ -18,14 +16,14 @@ BlockListImpl::BlockListImpl() : state(Init) { void BlockListImpl::setItems(const std::vector& newItems) { // JIDs which are in the current list but not in the new list, are removed. - foreach (const JID& jid, items) { + for (const auto& jid : items) { if (std::find(newItems.begin(), newItems.end(), jid) == newItems.end()) { onItemRemoved(jid); } } // JIDs which are in the new list but not in the current list, are added. - foreach (const JID& jid, newItems) { + for (const auto& jid : newItems) { if (std::find(items.begin(), items.end(), jid) == items.end()) { onItemAdded(jid); } @@ -56,14 +54,14 @@ void BlockListImpl::setState(State state) { } void BlockListImpl::addItems(const std::vector& items) { - foreach (const JID& item, items) { + for (const auto& item : items) { addItem(item); } } void BlockListImpl::removeItems(const std::vector& items) { std::vector itemsToRemove = items; - foreach (const JID& item, itemsToRemove) { + for (const auto& item : itemsToRemove) { removeItem(item); } } diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index c2f8fd7..3d75d8b 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -443,7 +442,7 @@ void CoreClient::purgePassword() { void CoreClient::resetConnector() { connector_->onConnectFinished.disconnect(boost::bind(&CoreClient::handleConnectorFinished, this, _1, _2)); connector_.reset(); - foreach(ConnectionFactory* f, proxyConnectionFactories) { + for (auto f : proxyConnectionFactories) { delete f; } proxyConnectionFactories.clear(); diff --git a/Swiften/Client/UnitTest/ClientBlockListManagerTest.cpp b/Swiften/Client/UnitTest/ClientBlockListManagerTest.cpp index aaf99e0..5d22cac 100644 --- a/Swiften/Client/UnitTest/ClientBlockListManagerTest.cpp +++ b/Swiften/Client/UnitTest/ClientBlockListManagerTest.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -171,7 +170,7 @@ class ClientBlockListManagerTest : public CppUnit::TestFixture { // build IQ response std::shared_ptr responsePayload = std::make_shared(); - foreach(const JID& jid, blockedJids) { + for (const auto& jid : blockedJids) { responsePayload->addItem(jid); } diff --git a/Swiften/Client/XMLBeautifier.cpp b/Swiften/Client/XMLBeautifier.cpp index 9e9c4c5..e2cd58e 100644 --- a/Swiften/Client/XMLBeautifier.cpp +++ b/Swiften/Client/XMLBeautifier.cpp @@ -16,7 +16,6 @@ #include #include -#include #include namespace Swift { @@ -99,7 +98,7 @@ void XMLBeautifier::handleStartElement(const std::string& element, const std::st buffer << "\"" << (doColoring ? styleNamespace(ns) : ns) << "\""; } if (!attributes.getEntries().empty()) { - foreach(AttributeMap::Entry entry, attributes.getEntries()) { + for (const auto& entry : attributes.getEntries()) { buffer << " "; buffer << (doColoring ? styleAttribute(entry.getAttribute().getName()) : entry.getAttribute().getName()); buffer << "="; 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 -#include #include #include #include @@ -30,28 +29,28 @@ CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const { std::vector 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 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 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 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 #include -#include 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 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 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. diff --git a/Swiften/Elements/Form.cpp b/Swiften/Elements/Form.cpp index f8414b2..dc4bd72 100644 --- a/Swiften/Elements/Form.cpp +++ b/Swiften/Elements/Form.cpp @@ -6,8 +6,6 @@ #include -#include - namespace Swift { std::string Form::getFormType() const { @@ -19,7 +17,7 @@ std::string Form::getFormType() const { } FormField::ref Form::getField(const std::string& name) const { - foreach(FormField::ref field, fields_) { + for (const auto& field : fields_) { if (field->getName() == name) { return field; } @@ -45,7 +43,7 @@ const std::vector& Form::getItems() const { void Form::clearEmptyTextFields() { std::vector populatedFields; - foreach (FormField::ref field, fields_) { + for (const auto& field : fields_) { if (field->getType() == FormField::TextSingleType) { if (!field->getTextSingleValue().empty()) { populatedFields.push_back(field); diff --git a/Swiften/Elements/RosterItemExchangePayload.cpp b/Swiften/Elements/RosterItemExchangePayload.cpp index 1890811..79d0371 100644 --- a/Swiften/Elements/RosterItemExchangePayload.cpp +++ b/Swiften/Elements/RosterItemExchangePayload.cpp @@ -12,8 +12,6 @@ #include -#include - namespace Swift { RosterItemExchangePayload::Item::Item(Action action) : action(action) { diff --git a/Swiften/Elements/RosterPayload.cpp b/Swiften/Elements/RosterPayload.cpp index b4be7d1..d745357 100644 --- a/Swiften/Elements/RosterPayload.cpp +++ b/Swiften/Elements/RosterPayload.cpp @@ -6,12 +6,10 @@ #include -#include - namespace Swift { boost::optional RosterPayload::getItem(const JID& jid) const { - foreach(const RosterItemPayload& item, items_) { + for (const auto& item : items_) { // FIXME: MSVC rejects this. Find out why. //if (item.getJID() == jid) { if (item.getJID().equals(jid, JID::WithResource)) { diff --git a/Swiften/Elements/Stanza.cpp b/Swiften/Elements/Stanza.cpp index f5a1b58..0ff6b3c 100644 --- a/Swiften/Elements/Stanza.cpp +++ b/Swiften/Elements/Stanza.cpp @@ -10,7 +10,6 @@ #include -#include #include namespace Swift { @@ -23,7 +22,7 @@ Stanza::~Stanza() { } void Stanza::updatePayload(std::shared_ptr payload) { - foreach (std::shared_ptr& i, payloads_) { + for (auto&& i : payloads_) { if (typeid(*i.get()) == typeid(*payload.get())) { i = payload; return; @@ -43,7 +42,7 @@ void Stanza::removePayloadOfSameType(std::shared_ptr payload) { } std::shared_ptr Stanza::getPayloadOfSameType(std::shared_ptr payload) const { - foreach (const std::shared_ptr& i, payloads_) { + for (const auto& i : payloads_) { if (typeid(*i.get()) == typeid(*payload.get())) { return i; } diff --git a/Swiften/Elements/VCard.cpp b/Swiften/Elements/VCard.cpp index f541d06..571ead4 100644 --- a/Swiften/Elements/VCard.cpp +++ b/Swiften/Elements/VCard.cpp @@ -1,17 +1,15 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include -#include - namespace Swift { VCard::EMailAddress VCard::getPreferredEMailAddress() const { - foreach(const EMailAddress& address, emailAddresses_) { + for (const auto& address : emailAddresses_) { if (address.isPreferred) { return address; } diff --git a/Swiften/EventLoop/EventLoop.cpp b/Swiften/EventLoop/EventLoop.cpp index eefbf65..186616f 100644 --- a/Swiften/EventLoop/EventLoop.cpp +++ b/Swiften/EventLoop/EventLoop.cpp @@ -16,7 +16,6 @@ #include #include -#include namespace lambda = boost::lambda; @@ -61,7 +60,7 @@ void EventLoop::handleNextEvents() { callEventPosted = !events_.empty(); } if (!nextEvents.empty()) { - foreach (const Event& event, nextEvents) { + for (const auto& event : nextEvents) { invokeCallback(event); } } diff --git a/Swiften/EventLoop/SimpleEventLoop.cpp b/Swiften/EventLoop/SimpleEventLoop.cpp index 2397016..cac04e4 100644 --- a/Swiften/EventLoop/SimpleEventLoop.cpp +++ b/Swiften/EventLoop/SimpleEventLoop.cpp @@ -8,8 +8,6 @@ #include -#include - namespace Swift { SimpleEventLoop::SimpleEventLoop() : isRunning_(true), eventAvailable_(false) { diff --git a/Swiften/EventLoop/SingleThreadedEventLoop.cpp b/Swiften/EventLoop/SingleThreadedEventLoop.cpp index acb6e4d..0542f37 100644 --- a/Swiften/EventLoop/SingleThreadedEventLoop.cpp +++ b/Swiften/EventLoop/SingleThreadedEventLoop.cpp @@ -16,8 +16,6 @@ #include -#include - namespace Swift { SingleThreadedEventLoop::SingleThreadedEventLoop() @@ -35,8 +33,9 @@ void SingleThreadedEventLoop::waitForEvents() { eventAvailableCondition_.wait(lock); } - if (shouldShutDown_) + if (shouldShutDown_) { throw EventLoopCanceledException(); + } } void SingleThreadedEventLoop::handleEvents() { diff --git a/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp b/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp index c3983f1..10b0b40 100644 --- a/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp +++ b/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp @@ -9,7 +9,6 @@ #include -#include #include #include #include @@ -47,7 +46,7 @@ static void handleRoomsItemsResponse(std::shared_ptr items, ErrorPay int roomCount = 0; cout << "List of rooms at " << mucJID.toString() << endl; - foreach (DiscoItems::Item item, items->getItems()) { + for (auto&& item : items->getItems()) { roomCount++; cout << "\t" << roomCount << ". " << item.getJID().getNode() << " - " << item.getName() << std::endl; if (roomCount == 1) { diff --git a/Swiften/Examples/SendFile/ReceiveFile.cpp b/Swiften/Examples/SendFile/ReceiveFile.cpp index 0b61987..193c1b7 100644 --- a/Swiften/Examples/SendFile/ReceiveFile.cpp +++ b/Swiften/Examples/SendFile/ReceiveFile.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -56,7 +55,8 @@ class FileReceiver { } void stop() { - foreach(const IncomingFileTransfer::ref transfer, incomingFileTransfers) { + for (const auto& transfer : incomingFileTransfers) { + (void)transfer; //transfer->stop(); } client->disconnect(); diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp index aefafd9..c6987c0 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -295,7 +294,7 @@ void DefaultFileTransferTransporter::closeLocalSession() { s5bRegistry->setHasBytestream(getSOCKS5DstAddr(), false); if (s5bServerManager->getServer()) { std::vector > serverSessions = s5bServerManager->getServer()->getSessions(getSOCKS5DstAddr()); - foreach(std::shared_ptr session, serverSessions) { + for (auto&& session : serverSessions) { session->stop(); } } diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp index f73cd38..d5de5e4 100644 --- a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -130,7 +129,7 @@ void IncomingJingleFileTransfer::handleLocalTransportCandidatesGenerated( transport->setSessionID(s5bSessionID); transport->setMode(JingleS5BTransportPayload::TCPMode); transport->setDstAddr(dstAddr); - foreach(JingleS5BTransportPayload::Candidate candidate, candidates) { + for (auto&& candidate : candidates) { transport->addCandidate(candidate); } session->sendAccept(getContentID(), initialContent->getDescriptions()[0], transport); @@ -197,7 +196,7 @@ void IncomingJingleFileTransfer::checkIfAllDataReceived() { if (receivedBytes == getFileSizeInBytes()) { SWIFT_LOG(debug) << "All data received." << std::endl; bool hashInfoAvailable = false; - foreach(const JingleFileTransferFileInfo::HashElementMap::value_type& hashElement, hashes) { + for (const auto& hashElement : hashes) { hashInfoAvailable |= !hashElement.second.empty(); } diff --git a/Swiften/FileTransfer/JingleFileTransfer.cpp b/Swiften/FileTransfer/JingleFileTransfer.cpp index 36725de..62c3a53 100644 --- a/Swiften/FileTransfer/JingleFileTransfer.cpp +++ b/Swiften/FileTransfer/JingleFileTransfer.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -39,7 +38,7 @@ JingleFileTransfer::~JingleFileTransfer() { void JingleFileTransfer::fillCandidateMap(CandidateMap& map, const std::vector& candidates) { map.clear(); - foreach (JingleS5BTransportPayload::Candidate candidate, candidates) { + for (auto&& candidate : candidates) { map[candidate.cid] = candidate; } } diff --git a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp index fcc160a..367fc97 100644 --- a/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingJingleFileTransfer.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -215,7 +214,7 @@ void OutgoingJingleFileTransfer::handleLocalTransportCandidatesGenerated( s5bTransport->setSessionID(s5bSessionID); s5bTransport->setMode(JingleS5BTransportPayload::TCPMode); s5bTransport->setDstAddr(dstAddr); - foreach(JingleS5BTransportPayload::Candidate candidate, candidates) { + for (auto&& candidate : candidates) { s5bTransport->addCandidate(candidate); SWIFT_LOG(debug) << "\t" << "S5B candidate: " << candidate.hostPort.toString() << std::endl; } diff --git a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp index a0e7a6f..56013ca 100644 --- a/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp +++ b/Swiften/FileTransfer/RemoteJingleTransportCandidateSelector.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -39,7 +38,7 @@ RemoteJingleTransportCandidateSelector::~RemoteJingleTransportCandidateSelector( void RemoteJingleTransportCandidateSelector::addCandidates( const std::vector& candidates) { - foreach(JingleS5BTransportPayload::Candidate c, candidates) { + for (auto&& c : candidates) { this->candidates.push(c); } } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp index 9624d4c..90c42dd 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -38,8 +37,7 @@ void SOCKS5BytestreamProxyFinder::start() { } void SOCKS5BytestreamProxyFinder::stop() { - typedef std::shared_ptr > S5BProxyRequestGenericRequest; - foreach (S5BProxyRequestGenericRequest requester, pendingRequests) { + for (auto&& requester : pendingRequests) { requester->onResponse.disconnect(boost::bind(&SOCKS5BytestreamProxyFinder::handleProxyResponse, this, requester, _1, _2)); } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp index 1591e24..9e214fc 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp @@ -10,7 +10,6 @@ #include #include -#include namespace Swift { diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp index b68bd58..483ea18 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -30,7 +29,7 @@ void SOCKS5BytestreamServer::start() { void SOCKS5BytestreamServer::stop() { connectionServer->onNewConnection.disconnect(boost::bind(&SOCKS5BytestreamServer::handleNewConnection, this, _1)); - foreach (std::shared_ptr session, sessions) { + for (auto&& session : sessions) { session->onFinished.disconnect(boost::bind(&SOCKS5BytestreamServer::handleSessionFinished, this, session)); session->stop(); } @@ -52,7 +51,7 @@ HostAddressPort SOCKS5BytestreamServer::getAddressPort() const { std::vector< std::shared_ptr > SOCKS5BytestreamServer::getSessions( const std::string& streamID) const { std::vector< std::shared_ptr > result; - foreach (std::shared_ptr session, sessions) { + for (auto&& session : sessions) { if (session->getStreamID() == streamID) { result.push_back(session); } diff --git a/Swiften/Jingle/JingleSession.cpp b/Swiften/Jingle/JingleSession.cpp index 778ee1d..b5cfbef 100644 --- a/Swiften/Jingle/JingleSession.cpp +++ b/Swiften/Jingle/JingleSession.cpp @@ -7,12 +7,11 @@ #include #include +#include #include #include -#include - using namespace Swift; JingleSession::JingleSession(const JID& initiator, const std::string& id) : initiator(initiator), id(id) { diff --git a/Swiften/Jingle/JingleSessionManager.cpp b/Swiften/Jingle/JingleSessionManager.cpp index ca6cebb..f7ed58e 100644 --- a/Swiften/Jingle/JingleSessionManager.cpp +++ b/Swiften/Jingle/JingleSessionManager.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include @@ -44,7 +43,7 @@ void JingleSessionManager::registerOutgoingSession(const JID& initiator, JingleS void JingleSessionManager::handleIncomingSession(const JID& initiator, const JID& recipient, JingleSessionImpl::ref session, const std::vector& contents) { sessions.insert(std::make_pair(JIDSession(initiator, session->getID()), session)); - foreach (IncomingJingleSessionHandler* handler, incomingSessionHandlers) { + for (auto handler : incomingSessionHandlers) { if (handler->handleIncomingJingleSession(session, contents, recipient)) { return; } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp index 9cfe3cd..0906ffc 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -106,7 +105,7 @@ void BonjourQuerier::run() { maxSocket = interruptSelectReadSocket; FD_SET(interruptSelectReadSocket, &fdSet); - foreach(const std::shared_ptr& query, runningQueries) { + for (const auto& query : runningQueries) { int socketID = query->getSocketID(); maxSocket = std::max(maxSocket, socketID); FD_SET(socketID, &fdSet); @@ -124,7 +123,7 @@ void BonjourQuerier::run() { { std::lock_guard lock(runningQueriesMutex); - foreach(std::shared_ptr query, runningQueries) { + for (auto&& query : runningQueries) { if (FD_ISSET(query->getSocketID(), &fdSet)) { query->processResult(); } diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp index 63ad3b8..c17f8b2 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -49,14 +48,14 @@ void FakeDNSSDQuerier::addRunningQuery(std::shared_ptr query) { runningQueries.push_back(query); allQueriesEverRun.push_back(query); if (std::shared_ptr browseQuery = std::dynamic_pointer_cast(query)) { - foreach(const DNSSDServiceID& service, services) { + for (const auto& service : services) { eventLoop->postEvent(boost::bind(boost::ref(browseQuery->onServiceAdded), service), shared_from_this()); } } else if (std::shared_ptr resolveQuery = std::dynamic_pointer_cast(query)) { - for(ServiceInfoMap::const_iterator i = serviceInfo.begin(); i != serviceInfo.end(); ++i) { - if (i->first == resolveQuery->service) { - eventLoop->postEvent(boost::bind(boost::ref(resolveQuery->onServiceResolved), i->second), shared_from_this()); + for (const auto& i : serviceInfo) { + if (i.first == resolveQuery->service) { + eventLoop->postEvent(boost::bind(boost::ref(resolveQuery->onServiceResolved), i.second), shared_from_this()); } } } @@ -81,7 +80,7 @@ void FakeDNSSDQuerier::removeRunningQuery(std::shared_ptr query) void FakeDNSSDQuerier::addService(const DNSSDServiceID& id) { services.insert(id); - foreach(const std::shared_ptr& query, getQueries()) { + for (const auto& query : getQueries()) { eventLoop->postEvent(boost::bind(boost::ref(query->onServiceAdded), id), shared_from_this()); } } @@ -89,7 +88,7 @@ void FakeDNSSDQuerier::addService(const DNSSDServiceID& id) { void FakeDNSSDQuerier::removeService(const DNSSDServiceID& id) { services.erase(id); serviceInfo.erase(id); - foreach(const std::shared_ptr& query, getQueries()) { + for (const auto& query : getQueries()) { eventLoop->postEvent(boost::bind(boost::ref(query->onServiceRemoved), id), shared_from_this()); } } @@ -99,7 +98,7 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol if (!r.second) { r.first->second = info; } - foreach(const std::shared_ptr& query, getQueries()) { + for (const auto& query : getQueries()) { if (query->service == id) { eventLoop->postEvent(boost::bind(boost::ref(query->onServiceResolved), info), shared_from_this()); } @@ -107,7 +106,7 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol } bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, int port, const ByteArray& info) { - foreach(const std::shared_ptr& query, getQueries()) { + for (const auto& query : getQueries()) { if (query->name == name && query->port == port && query->info == info) { return true; } @@ -116,20 +115,20 @@ bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, int port, co } void FakeDNSSDQuerier::setBrowseError() { - foreach(const std::shared_ptr& query, getQueries()) { + for (const auto& query : getQueries()) { eventLoop->postEvent(boost::ref(query->onError), shared_from_this()); } } void FakeDNSSDQuerier::setRegisterError() { - foreach(const std::shared_ptr& query, getQueries()) { + for (const auto& query : getQueries()) { eventLoop->postEvent(boost::bind(boost::ref(query->onRegisterFinished), boost::optional()), shared_from_this()); } } void FakeDNSSDQuerier::setAddress(const std::string& hostname, boost::optional address) { addresses[hostname] = address; - foreach(const std::shared_ptr& query, getQueries()) { + for (const auto& query : getQueries()) { if (query->hostname == hostname) { eventLoop->postEvent(boost::bind( boost::ref(query->onHostnameResolved), address), shared_from_this()); diff --git a/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp b/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp index f97d9a1..a639ec5 100644 --- a/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp +++ b/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp @@ -8,7 +8,6 @@ #include -#include #include #include #include @@ -35,7 +34,7 @@ void OutgoingLinkLocalSession::handleSessionStarted() { } void OutgoingLinkLocalSession::handleStreamStart(const ProtocolHeader&) { - foreach(const std::shared_ptr& stanza, queuedElements_) { + for (const auto& stanza : queuedElements_) { sendElement(stanza); } queuedElements_.clear(); diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp index a06a0a2..9f8ae77 100644 --- a/Swiften/MUC/MUCBookmarkManager.cpp +++ b/Swiften/MUC/MUCBookmarkManager.cpp @@ -10,7 +10,6 @@ #include -#include #include #include #include @@ -36,12 +35,12 @@ void MUCBookmarkManager::handleBookmarksReceived(std::shared_ptr payloa storage = payload; std::vector receivedBookmarks; - foreach (Storage::Room room, payload->getRooms()) { + for (const auto& room : payload->getRooms()) { receivedBookmarks.push_back(MUCBookmark(room)); } std::vector newBookmarks; - foreach (const MUCBookmark& oldBookmark, bookmarks_) { + for (const auto& oldBookmark : bookmarks_) { if (containsEquivalent(receivedBookmarks, oldBookmark)) { newBookmarks.push_back(oldBookmark); } else { @@ -49,7 +48,7 @@ void MUCBookmarkManager::handleBookmarksReceived(std::shared_ptr payloa } } - foreach (const MUCBookmark& newBookmark, receivedBookmarks) { + for (const auto& newBookmark : receivedBookmarks) { if (!containsEquivalent(bookmarks_, newBookmark)) { newBookmarks.push_back(newBookmark); onBookmarkAdded(newBookmark); @@ -102,7 +101,7 @@ void MUCBookmarkManager::flush() { } // Update the storage element storage->clearRooms(); - foreach(const MUCBookmark& bookmark, bookmarks_) { + for (const auto& bookmark : bookmarks_) { storage->addRoom(bookmark.toStorage()); } 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 #include -#include #include #include @@ -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 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 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 #include -#include #include #include 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 -#include #include namespace Swift { @@ -49,7 +48,7 @@ std::shared_ptr DummyTimerFactory::createTimer(int milliseconds) { void DummyTimerFactory::setTime(int time) { assert(time > currentTime); - foreach(std::shared_ptr 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 #include #include -#include #include #include #include @@ -68,8 +67,7 @@ void HTTPConnectProxiedConnection::initializeProxy() { append(data, createSafeByteArray("\r\n")); } else if (!nextHTTPRequestHeaders_.empty()) { - typedef std::pair 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 >& headerFields) { - typedef std::pair 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 -#include #include #include @@ -17,9 +16,9 @@ NetworkEnvironment::~NetworkEnvironment() { HostAddress NetworkEnvironment::getLocalAddress() const { std::vector 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 #include -#include #include #include #include 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 -#include #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 #include -#include #include #include @@ -65,8 +64,8 @@ std::vector WindowsNetworkEnvironment::getNetworkInterfaces() } } - for (std::map::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; } 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 -#include - 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 -#include - 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 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 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 -#include #include #include #include @@ -167,7 +166,7 @@ FullPayloadParserFactoryCollection::FullPayloadParserFactoryCollection() { factories_.push_back(std::make_shared >("sent", "urn:xmpp:carbons:2", this)); factories_.push_back(std::make_shared >("private", "urn:xmpp:carbons:2")); - foreach(std::shared_ptr 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 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 -#include #include 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 -#include #include 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 -#include - 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 -#include #include #include #include @@ -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 #include -#include - #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(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 #include -#include #include #include #include @@ -36,7 +35,7 @@ class MUCUserPayloadParserTest : public CppUnit::TestFixture MUCUserPayload::ref payload = std::dynamic_pointer_cast(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 #include -#include #include #include @@ -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; diff --git a/Swiften/Parser/SerializingParser.cpp b/Swiften/Parser/SerializingParser.cpp index ad794aa..85b0dd4 100644 --- a/Swiften/Parser/SerializingParser.cpp +++ b/Swiften/Parser/SerializingParser.cpp @@ -9,7 +9,6 @@ #include #include -#include #include namespace Swift { @@ -20,7 +19,7 @@ SerializingParser::SerializingParser() { void SerializingParser::handleStartElement(const std::string& tag, const std::string& ns, const AttributeMap& attributes) { std::shared_ptr element = std::make_shared(tag, ns); // FIXME: Ignoring attribute namespace - foreach (const AttributeMap::Entry& e, attributes.getEntries()) { + for (const auto& e : attributes.getEntries()) { element->setAttribute(e.getAttribute().getName(), e.getValue()); } diff --git a/Swiften/Parser/Tree/TreeReparser.cpp b/Swiften/Parser/Tree/TreeReparser.cpp index 7fc74cf..6993d73 100644 --- a/Swiften/Parser/Tree/TreeReparser.cpp +++ b/Swiften/Parser/Tree/TreeReparser.cpp @@ -11,7 +11,6 @@ #include -#include #include #include #include @@ -31,7 +30,7 @@ std::shared_ptr TreeReparser::parseTree(ParserElement::ref root, Payloa if (current.second) { stack.push_back(ElementState(current.first, false)); parser->handleStartElement(current.first->getName(), current.first->getNamespace(), current.first->getAttributes()); - foreach(ParserElement::ref child, current.first->getAllChildren()) { + for (const auto& child : current.first->getAllChildren()) { stack.push_back(ElementState(child, true)); } } else { diff --git a/Swiften/Presence/DirectedPresenceSender.cpp b/Swiften/Presence/DirectedPresenceSender.cpp index c1ce3a0..c1134c7 100644 --- a/Swiften/Presence/DirectedPresenceSender.cpp +++ b/Swiften/Presence/DirectedPresenceSender.cpp @@ -6,8 +6,6 @@ #include -#include - namespace Swift { DirectedPresenceSender::DirectedPresenceSender(PresenceSender* sender) : sender(sender) { @@ -22,7 +20,7 @@ void DirectedPresenceSender::sendPresence(std::shared_ptr presence) { if (!presence->getTo().isValid()) { std::shared_ptr presenceCopy(new Presence(*presence)); - foreach(const JID& jid, directedPresenceReceivers) { + for (const auto& jid : directedPresenceReceivers) { presenceCopy->setTo(jid); sender->sendPresence(presenceCopy); } diff --git a/Swiften/Presence/SubscriptionManager.cpp b/Swiften/Presence/SubscriptionManager.cpp index 8de152c..83009e9 100644 --- a/Swiften/Presence/SubscriptionManager.cpp +++ b/Swiften/Presence/SubscriptionManager.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,7 +8,6 @@ #include -#include #include namespace Swift { diff --git a/Swiften/QA/ConcurrentFileTransferTest/ConcurrentFileTransferTest.cpp b/Swiften/QA/ConcurrentFileTransferTest/ConcurrentFileTransferTest.cpp index 8122c63..664a87b 100644 --- a/Swiften/QA/ConcurrentFileTransferTest/ConcurrentFileTransferTest.cpp +++ b/Swiften/QA/ConcurrentFileTransferTest/ConcurrentFileTransferTest.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/Swiften/QA/FileTransferTest/FileTransferTest.cpp b/Swiften/QA/FileTransferTest/FileTransferTest.cpp index 4cf4048..b627b30 100644 --- a/Swiften/QA/FileTransferTest/FileTransferTest.cpp +++ b/Swiften/QA/FileTransferTest/FileTransferTest.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -346,7 +345,7 @@ int main(int argc, char** argv) { std::vector configurations; std::string configs_env = std::string(getenv("SWIFT_FILETRANSFERTEST_CONFIG")); boost::split(configurations, configs_env, boost::is_any_of("|")); - foreach(const std::string& config, configurations) { + for (const auto& config : configurations) { std::vector split_config; boost::split(split_config, config, boost::is_any_of(":")); assert(split_config.size() == 2); @@ -360,8 +359,7 @@ int main(int argc, char** argv) { } } - typedef std::pair IntPair; - foreach(IntPair failedTest, failedTestPairs) { + for (auto&& failedTest : failedTestPairs) { std::cout << "Failed test: " << "( " << failedTest.first << ", " << failedTest.second << ") " << std::endl; } } @@ -377,8 +375,7 @@ int main(int argc, char** argv) { } } - typedef std::pair IntPair; - foreach(IntPair failedTest, failedTestPairs) { + for (auto&& failedTest : failedTestPairs) { std::cout << "Failed test: " << "( " << failedTest.first << ", " << failedTest.second << ") " << std::endl; } } diff --git a/Swiften/QA/ProxyProviderTest/ProxyProviderTest.cpp b/Swiften/QA/ProxyProviderTest/ProxyProviderTest.cpp index 2b6bfa8..53f9e60 100644 --- a/Swiften/QA/ProxyProviderTest/ProxyProviderTest.cpp +++ b/Swiften/QA/ProxyProviderTest/ProxyProviderTest.cpp @@ -12,7 +12,6 @@ #include -#include #include using namespace Swift; diff --git a/Swiften/Queries/IQRouter.cpp b/Swiften/Queries/IQRouter.cpp index e28c2f4..286b65f 100644 --- a/Swiften/Queries/IQRouter.cpp +++ b/Swiften/Queries/IQRouter.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -53,7 +52,7 @@ void IQRouter::handleIQ(std::shared_ptr iq) { } void IQRouter::processPendingRemoves() { - foreach(std::shared_ptr handler, queuedRemoves_) { + for (auto&& handler : queuedRemoves_) { erase(handlers_, handler); } queuedRemoves_.clear(); diff --git a/Swiften/Roster/XMPPRosterController.cpp b/Swiften/Roster/XMPPRosterController.cpp index 57b0645..8ee9755 100644 --- a/Swiften/Roster/XMPPRosterController.cpp +++ b/Swiften/Roster/XMPPRosterController.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -51,7 +50,7 @@ void XMPPRosterController::requestRoster() { void XMPPRosterController::handleRosterReceived(std::shared_ptr rosterPayload, bool initial, std::shared_ptr previousRoster) { if (rosterPayload) { - foreach(const RosterItemPayload& item, rosterPayload->getItems()) { + for (const auto& item : rosterPayload->getItems()) { //Don't worry about the updated case, the XMPPRoster sorts that out. if (item.getSubscription() == RosterItemPayload::Remove) { xmppRoster_->removeContact(item.getJID()); @@ -62,7 +61,7 @@ void XMPPRosterController::handleRosterReceived(std::shared_ptr r } else if (previousRoster) { // The cached version hasn't changed; emit all items - foreach(const RosterItemPayload& item, previousRoster->getItems()) { + for (const auto& item : previousRoster->getItems()) { if (item.getSubscription() != RosterItemPayload::Remove) { xmppRoster_->addContact(item.getJID(), item.getName(), item.getGroups(), item.getSubscription()); } @@ -83,7 +82,7 @@ void XMPPRosterController::saveRoster(const std::string& version) { std::vector items = xmppRoster_->getItems(); std::shared_ptr roster(new RosterPayload()); roster->setVersion(version); - foreach(const XMPPRosterItem& item, items) { + for (const auto& item : items) { roster->addItem(RosterItemPayload(item.getJID(), item.getName(), item.getSubscription(), item.getGroups())); } rosterStorage_->setRoster(roster); diff --git a/Swiften/Roster/XMPPRosterImpl.cpp b/Swiften/Roster/XMPPRosterImpl.cpp index 9a2ea7a..74f634f 100644 --- a/Swiften/Roster/XMPPRosterImpl.cpp +++ b/Swiften/Roster/XMPPRosterImpl.cpp @@ -1,13 +1,11 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include -#include - namespace Swift { XMPPRosterImpl::XMPPRosterImpl() { @@ -78,7 +76,7 @@ RosterItemPayload::Subscription XMPPRosterImpl::getSubscriptionStateForJID(const std::vector XMPPRosterImpl::getItems() const { std::vector result; - foreach(const RosterMap::value_type& entry, entries_) { + for (const auto& entry : entries_) { result.push_back(entry.second); } return result; @@ -96,7 +94,7 @@ boost::optional XMPPRosterImpl::getItem(const JID& jid) const { std::set XMPPRosterImpl::getGroups() const { std::set result; - foreach(const RosterMap::value_type& entry, entries_) { + for (const auto& entry : entries_) { std::vector groups = entry.second.getGroups(); result.insert(groups.begin(), groups.end()); } 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 -#include #include #include @@ -22,7 +21,7 @@ BytestreamsSerializer::BytestreamsSerializer() { std::string BytestreamsSerializer::serializePayload(std::shared_ptr 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 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 -#include #include #include #include @@ -50,14 +49,14 @@ std::string CommandSerializer::serializePayload(std::shared_ptr command actions += " execute='" + executeAction + "'"; } actions += ">"; - foreach (Command::Action action, command->getAvailableActions()) { + for (const auto& action : command->getAvailableActions()) { actions += "<" + actionToString(action) + "/>"; } actions += ""; commandElement.addNode(std::make_shared(actions)); } - foreach (Command::Note note, command->getNotes()) { + for (const auto& note : command->getNotes()) { std::shared_ptr 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 -#include #include #include #include @@ -23,7 +22,7 @@ std::string DiscoInfoSerializer::serializePayload(std::shared_ptr 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 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 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 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(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 -#include #include namespace Swift { @@ -21,7 +20,7 @@ std::string DiscoItemsSerializer::serializePayload(std::shared_ptr 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 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 #include -#include #include #include @@ -52,33 +51,33 @@ std::string FormSerializer::serializePayload(std::shared_ptr form) const if (!form->getInstructions().empty()) { multiLineify(form->getInstructions(), "instructions", formElement); } - foreach(std::shared_ptr page, form->getPages()) { + for (const auto& page : form->getPages()) { formElement->addNode(pageToXML(page)); } - foreach(std::shared_ptr field, form->getFields()) { + for (const auto& field : form->getFields()) { formElement->addNode(fieldToXML(field, true)); } if (!form->getReportedFields().empty()) { std::shared_ptr 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 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 field, fields_) { + for (const auto& field : fields_) { formElement->addNode(fieldToXML(field,true)); } @@ -103,17 +102,18 @@ std::shared_ptr FormSerializer::pageToXML(std::shared_ptr 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 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("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 FormSerializer::sectionToXML(std::shared_ptrgetLabel().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 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("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 FormSerializer::fieldToXML(std::shared_ptrsetAttribute("type", fieldType); } - foreach (const std::string& value, field->getValues()) { + for (const auto& value : field->getValues()) { std::shared_ptr valueElement = std::make_shared("value"); valueElement->addNode(std::make_shared(value)); fieldElement->addNode(valueElement); } - foreach (const FormField::Option& option, field->getOptions()) { + for (const auto& option : field->getOptions()) { std::shared_ptr 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 lines = String::split(unRdText, '\n'); - foreach (std::string line, lines) { + for (const auto& line : lines) { std::shared_ptr lineElement(new XMLElement(elementName)); lineElement->addNode(std::make_shared(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 -#include #include #include #include @@ -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 -#include #include #include #include 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 -#include #include #include #include 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 #include -#include #include #include #include @@ -38,7 +37,7 @@ std::string JingleContentPayloadSerializer::serializePayload(std::shared_ptrgetDescriptions()) { + for (auto&& desc : payload->getDescriptions()) { if ((filetransfer = std::dynamic_pointer_cast(desc))) { payloadXML.addNode(std::make_shared(ftSerializer.serializePayload(filetransfer))); } @@ -54,7 +53,7 @@ std::string JingleContentPayloadSerializer::serializePayload(std::shared_ptrgetTransports()) { + for (auto&& transport : payload->getTransports()) { if ((ibb = std::dynamic_pointer_cast(transport))) { payloadXML.addNode(std::make_shared(ibbSerializer.serializePayload(ibb))); } else if ((s5b = std::dynamic_pointer_cast(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 #include -#include #include #include #include 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 #include -#include #include #include #include @@ -54,7 +53,7 @@ std::string JingleFileTransferFileInfoSerializer::serializePayload(std::shared_p fileElement.addNode(std::make_shared("size", "", boost::lexical_cast(fileInfo->getSize()))); } - foreach (JingleFileTransferFileInfo::HashElementMap::value_type hashElement, fileInfo->getHashes()) { + for (const auto& hashElement : fileInfo->getHashes()) { std::shared_ptr hash = std::make_shared("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 #include -#include #include #include #include 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 -#include #include #include #include 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 #include -#include #include #include #include @@ -41,7 +40,7 @@ std::string JinglePayloadSerializer::serializePayload(std::shared_ptr > payloads = payload->getPayloads(); if (!payloads.empty()) { - foreach(std::shared_ptr subPayload, payloads) { + for (auto&& subPayload : payloads) { PayloadSerializer* serializer = serializers->getPayloadSerializer(subPayload); if (serializer) { jinglePayload.addNode(std::make_shared(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 #include -#include #include #include #include @@ -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 candidateXML = std::make_shared("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 #include -#include #include #include #include @@ -21,7 +20,7 @@ MUCAdminPayloadSerializer::MUCAdminPayloadSerializer() : GenericPayloadSerialize std::string MUCAdminPayloadSerializer::serializePayload(std::shared_ptr 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 -#include #include #include 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 -#include #include #include #include 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 #include -#include #include #include #include @@ -23,14 +22,14 @@ MUCUserPayloadSerializer::MUCUserPayloadSerializer(PayloadSerializerCollection* std::string MUCUserPayloadSerializer::serializePayload(std::shared_ptr 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 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 -#include #include #include #include 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 #include -#include #include #include #include @@ -32,7 +29,7 @@ std::string PubSubAffiliationsSerializer::serializePayload(std::shared_ptrgetNode()) { element.setAttribute("node", *payload->getNode()); } - foreach(std::shared_ptr item, payload->getAffiliations()) { + for (const auto& item : payload->getAffiliations()) { element.addNode(std::make_shared(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 #include -#include #include #include #include @@ -34,7 +31,7 @@ std::string PubSubEventItemSerializer::serializePayload(std::shared_ptrgetPublisher()) { element.setAttribute("publisher", *payload->getPublisher()); } - foreach(std::shared_ptr item, payload->getData()) { + for (const auto& item : payload->getData()) { element.addNode(std::make_shared(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 #include -#include #include #include #include @@ -31,10 +28,10 @@ std::string PubSubEventItemsSerializer::serializePayload(std::shared_ptrgetNode()); - foreach(std::shared_ptr item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared(PubSubEventItemSerializer(serializers).serialize(item))); } - foreach(std::shared_ptr item, payload->getRetracts()) { + for (const auto& item : payload->getRetracts()) { element.addNode(std::make_shared(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 -#include #include #include #include @@ -38,7 +37,7 @@ std::string PubSubEventSerializer::serializePayload(std::shared_ptr } XMLElement element("event", "http://jabber.org/protocol/pubsub#event"); std::shared_ptr p = payload->getPayload(); - foreach(std::shared_ptr serializer, pubsubSerializers) { + for (const auto& serializer : pubsubSerializers) { if (serializer->canSerialize(p)) { element.addNode(std::make_shared(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 #include -#include #include #include #include @@ -28,7 +25,7 @@ std::string PubSubItemSerializer::serializePayload(std::shared_ptr p return ""; } XMLElement element("item", "http://jabber.org/protocol/pubsub"); - foreach(std::shared_ptr item, payload->getData()) { + for (const auto& item : payload->getData()) { element.addNode(std::make_shared(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 #include @@ -13,7 +11,6 @@ #include #include -#include #include #include #include @@ -36,7 +33,7 @@ std::string PubSubItemsSerializer::serializePayload(std::shared_ptr SWIFT_LOG(warning) << "Serializing PubSubItems with empty node attribute"; } element.setAttribute("node", payload->getNode()); - foreach(std::shared_ptr item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared(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 -#include #include -#include #include #include #include @@ -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 item, payload->getAffiliations()) { + for (const auto& item : payload->getAffiliations()) { element.addNode(std::make_shared(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 -#include #include #include #include @@ -38,7 +37,7 @@ std::string PubSubOwnerPubSubSerializer::serializePayload(std::shared_ptr p = payload->getPayload(); - foreach(std::shared_ptr serializer, pubsubSerializers) { + for (const auto& serializer : pubsubSerializers) { if (serializer->canSerialize(p)) { element.addNode(std::make_shared(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 -#include #include -#include #include #include #include @@ -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 item, payload->getSubscriptions()) { + for (const auto& item : payload->getSubscriptions()) { element.addNode(std::make_shared(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 #include -#include #include #include #include @@ -30,7 +27,7 @@ std::string PubSubPublishSerializer::serializePayload(std::shared_ptrgetNode()); - foreach(std::shared_ptr item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared(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 -#include #include #include #include @@ -28,7 +27,7 @@ std::string PubSubRetractSerializer::serializePayload(std::shared_ptrgetNode()); - foreach(std::shared_ptr item, payload->getItems()) { + for (const auto& item : payload->getItems()) { element.addNode(std::make_shared(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 #include -#include #include #include #include @@ -52,7 +49,7 @@ std::string PubSubSerializer::serializePayload(std::shared_ptr payload) } XMLElement element("pubsub", "http://jabber.org/protocol/pubsub"); std::shared_ptr p = payload->getPayload(); - foreach(std::shared_ptr serializer, pubsubSerializers) { + for (const auto& serializer : pubsubSerializers) { if (serializer->canSerialize(p)) { element.addNode(std::make_shared(serializer->serialize(p))); if (std::shared_ptr create = std::dynamic_pointer_cast(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 -#include #include #include #include @@ -30,7 +29,7 @@ std::string PubSubSubscriptionsSerializer::serializePayload(std::shared_ptrgetNode()) { element.setAttribute("node", *payload->getNode()); } - foreach(std::shared_ptr item, payload->getSubscriptions()) { + for (const auto& item : payload->getSubscriptions()) { element.addNode(std::make_shared(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 -#include #include #include #include @@ -26,7 +25,7 @@ RosterItemExchangeSerializer::RosterItemExchangeSerializer() : GenericPayloadSer std::string RosterItemExchangeSerializer::serializePayload(std::shared_ptr 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 itemElement(new XMLElement("item")); itemElement->setAttribute("jid", item.getJID()); itemElement->setAttribute("name", item.getName()); @@ -37,7 +36,7 @@ std::string RosterItemExchangeSerializer::serializePayload(std::shared_ptrsetAttribute("action", "delete"); break; } - foreach(const std::string& group, item.getGroups()) { + for (const auto& group : item.getGroups()) { std::shared_ptr groupElement(new XMLElement("group")); groupElement->addNode(std::make_shared(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 -#include #include #include #include @@ -23,7 +22,7 @@ std::string RosterSerializer::serializePayload(std::shared_ptr ro if (roster->getVersion()) { queryElement.setAttribute("ver", *roster->getVersion()); } - foreach(const RosterItemPayload& item, roster->getItems()) { + for (const auto& item : roster->getItems()) { std::shared_ptr 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 ro itemElement->setAttribute("ask", "subscribe"); } - foreach(const std::string& group, item.getGroups()) { + for (const auto& group : item.getGroups()) { std::shared_ptr groupElement(new XMLElement("group")); groupElement->addNode(std::make_shared(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 -#include #include #include #include @@ -41,7 +40,7 @@ std::string SearchPayloadSerializer::serializePayload(std::shared_ptrgetEMail()))); } - 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 -#include #include #include #include @@ -36,7 +35,7 @@ std::string SecurityLabelSerializer::serializePayload(std::shared_ptraddNode(std::make_shared(label->getLabel())); element.addNode(labelElement); - foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) { + for (const auto& equivalentLabel : label->getEquivalentLabels()) { std::shared_ptr equivalentLabelElement(new XMLElement("equivalentlabel")); equivalentLabelElement->addNode(std::make_shared(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 -#include #include #include #include @@ -29,7 +28,7 @@ std::string SecurityLabelsCatalogSerializer::serializePayload(std::shared_ptrgetDescription().empty()) { element.setAttribute("desc", catalog->getDescription()); } - foreach (const SecurityLabelsCatalog::Item& item, catalog->getItems()) { + for (const auto& item : catalog->getItems()) { std::shared_ptr 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 -#include #include #include @@ -20,7 +19,7 @@ StorageSerializer::StorageSerializer() : GenericPayloadSerializer() { std::string StorageSerializer::serializePayload(std::shared_ptr storage) const { XMLElement storageElement("storage", "storage:bookmarks"); - foreach(const Storage::Room& room, storage->getRooms()) { + for (const auto& room : storage->getRooms()) { std::shared_ptr 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 storageElement.addNode(conferenceElement); } - foreach(const Storage::URL& url, storage->getURLs()) { + for (const auto& url : storage->getURLs()) { std::shared_ptr 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 #include -#include #include #include #include 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 #include -#include #include #include #include @@ -54,7 +53,7 @@ std::string StreamInitiationSerializer::serializePayload(std::shared_ptr(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 #include -#include #include #include #include @@ -47,7 +46,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr vcard) con } queryElement.addNode(nameElement); } - foreach(const VCard::EMailAddress& emailAddress, vcard->getEMailAddresses()) { + for (const auto& emailAddress : vcard->getEMailAddresses()) { std::shared_ptr emailElement(new XMLElement("EMAIL")); emailElement->addNode(std::make_shared("USERID", "", emailAddress.address)); if (emailAddress.isHome) { @@ -84,7 +83,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr vcard) con queryElement.addNode(std::make_shared("BDAY", "", dateTimeToString(vcard->getBirthday()))); } - foreach(const VCard::Telephone& telephone, vcard->getTelephones()) { + for (const auto& telephone : vcard->getTelephones()) { std::shared_ptr telElement(new XMLElement("TEL")); telElement->addNode(std::make_shared("NUMBER", "", telephone.number)); if (telephone.isHome) { @@ -129,7 +128,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr vcard) con queryElement.addNode(telElement); } - foreach(const VCard::Address& address, vcard->getAddresses()) { + for (const auto& address : vcard->getAddresses()) { std::shared_ptr adrElement = std::make_shared("ADR"); if (!address.poBox.empty()) { adrElement->addNode(std::make_shared("POBOX", "", address.poBox)); @@ -177,10 +176,10 @@ std::string VCardSerializer::serializePayload(std::shared_ptr vcard) con queryElement.addNode(adrElement); } - foreach(const VCard::AddressLabel& addressLabel, vcard->getAddressLabels()) { + for (const auto& addressLabel : vcard->getAddressLabels()) { std::shared_ptr labelElement = std::make_shared("LABEL"); - foreach(const std::string& line, addressLabel.lines) { + for (const auto& line : addressLabel.lines) { labelElement->addNode(std::make_shared("LINE", "", line)); } @@ -208,7 +207,7 @@ std::string VCardSerializer::serializePayload(std::shared_ptr vcard) con queryElement.addNode(labelElement); } - foreach(const JID& jid, vcard->getJIDs()) { + for (const auto& jid : vcard->getJIDs()) { queryElement.addNode(std::make_shared("JID", "", jid.toString())); } @@ -216,28 +215,28 @@ std::string VCardSerializer::serializePayload(std::shared_ptr vcard) con queryElement.addNode(std::make_shared("DESC", "", vcard->getDescription())); } - foreach(const VCard::Organization& org, vcard->getOrganizations()) { + for (const auto& org : vcard->getOrganizations()) { std::shared_ptr orgElement = std::make_shared("ORG"); if (!org.name.empty()) { orgElement->addNode(std::make_shared("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("ORGUNIT", "", unit)); } } queryElement.addNode(orgElement); } - foreach(const std::string& title, vcard->getTitles()) { + for (const auto& title : vcard->getTitles()) { queryElement.addNode(std::make_shared("TITLE", "", title)); } - foreach(const std::string& role, vcard->getRoles()) { + for (const auto& role : vcard->getRoles()) { queryElement.addNode(std::make_shared("ROLE", "", role)); } - foreach(const std::string& url, vcard->getURLs()) { + for (const auto& url : vcard->getURLs()) { queryElement.addNode(std::make_shared("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 #include -#include #include #include #include @@ -47,7 +46,7 @@ SafeByteArray StanzaSerializer::serialize(std::shared_ptr eleme setStanzaSpecificAttributes(stanza, stanzaElement); std::string serializedPayloads; - foreach (const std::shared_ptr& 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 -#include #include #include @@ -26,7 +25,7 @@ SafeByteArray StreamFeaturesSerializer::serialize(std::shared_ptrgetCompressionMethods().empty()) { std::shared_ptr 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 methodElement(new XMLElement("method")); methodElement->addNode(std::make_shared(method)); compressionElement->addNode(methodElement); @@ -35,7 +34,7 @@ SafeByteArray StreamFeaturesSerializer::serialize(std::shared_ptrgetAuthenticationMechanisms().empty()) { std::shared_ptr 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 mechanismElement(new XMLElement("mechanism")); mechanismElement->addNode(std::make_shared(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 -#include #include 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 Pair; - foreach(const Pair& p, attributes_) { + for (const auto& p : attributes_) { result += " " + p.first + "=\"" + p.second + "\""; } if (!childNodes_.empty()) { result += ">"; - foreach (std::shared_ptr node, childNodes_) { + for (auto& node : childNodes_) { result += node->serialize(); } result += ""; 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 #include -#include #include #include #include diff --git a/Swiften/Session/BOSHSessionStream.cpp b/Swiften/Session/BOSHSessionStream.cpp index 635fd69..4c7bdee 100644 --- a/Swiften/Session/BOSHSessionStream.cpp +++ b/Swiften/Session/BOSHSessionStream.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/Swiften/StreamStack/StreamStack.cpp b/Swiften/StreamStack/StreamStack.cpp index 0bcd1b3..44a018d 100644 --- a/Swiften/StreamStack/StreamStack.cpp +++ b/Swiften/StreamStack/StreamStack.cpp @@ -8,7 +8,6 @@ #include -#include #include #include #include diff --git a/Swiften/TLS/ServerIdentityVerifier.cpp b/Swiften/TLS/ServerIdentityVerifier.cpp index 872717b..226e94b 100644 --- a/Swiften/TLS/ServerIdentityVerifier.cpp +++ b/Swiften/TLS/ServerIdentityVerifier.cpp @@ -8,7 +8,6 @@ #include -#include #include namespace Swift { @@ -30,7 +29,7 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { } // DNS names std::vector dnsNames = certificate->getDNSNames(); - foreach (const std::string& dnsName, dnsNames) { + for (const auto& dnsName : dnsNames) { if (matchesDomain(dnsName)) { return true; } @@ -39,7 +38,7 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { // SRV names std::vector srvNames = certificate->getSRVNames(); - foreach (const std::string& srvName, srvNames) { + for (const auto& srvName : srvNames) { // Only match SRV names that begin with the service; this isn't required per // spec, but we're being purist about this. if (boost::starts_with(srvName, "_xmpp-client.") && matchesDomain(srvName.substr(std::string("_xmpp-client.").size(), srvName.npos))) { @@ -50,7 +49,7 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { // XmppAddr std::vector xmppAddresses = certificate->getXMPPAddresses(); - foreach (const std::string& xmppAddress, xmppAddresses) { + for (const auto& xmppAddress : xmppAddresses) { if (matchesAddress(xmppAddress)) { return true; } @@ -60,7 +59,7 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { // CommonNames. Only check this if there was no SAN (according to spec). if (!hasSAN) { std::vector commonNames = certificate->getCommonNames(); - foreach (const std::string& commonName, commonNames) { + for (const auto& commonName : commonNames) { if (matchesDomain(commonName)) { return true; } diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.cpp b/Swiften/Whiteboard/WhiteboardSessionManager.cpp index 66b5ef8..59f6c47 100644 --- a/Swiften/Whiteboard/WhiteboardSessionManager.cpp +++ b/Swiften/Whiteboard/WhiteboardSessionManager.cpp @@ -17,7 +17,6 @@ #include -#include #include #include #include @@ -80,7 +79,7 @@ namespace Swift { std::vector presences = presenceOracle_->getAllPresence(bareJID); //iterate over them - foreach(Presence::ref pres, presences) { + for (const auto& pres : presences) { if (pres->getPriority() > priority) { // look up caps from the jid DiscoInfo::ref info = capsProvider_->getCaps(pres->getFrom()); -- cgit v0.10.2-6-g49f6