summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-11-23 07:09:39 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-23 11:30:02 (GMT)
commite405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch)
tree9118ef838ebfaec1df90ec24761944b5d833774c /Sluift
parent8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff)
downloadswift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.zip
swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.tar.bz2
Migrate remaining Swiften/Base/foreach.h use to range-based for loop
Test-Information: Build on macOS 10.12.1 and all tests pass. Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/ElementConvertors/CommandConvertor.cpp6
-rw-r--r--Sluift/ElementConvertors/DOMElementConvertor.cpp3
-rw-r--r--Sluift/ElementConvertors/FormConvertor.cpp14
-rw-r--r--Sluift/ElementConvertors/ForwardedConvertor.cpp1
-rw-r--r--Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubEventItemConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp6
-rw-r--r--Sluift/ElementConvertors/PubSubItemConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubItemsConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubPublishConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubRetractConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/SecurityLabelConvertor.cpp4
-rw-r--r--Sluift/ElementConvertors/StanzaConvertor.h3
-rw-r--r--Sluift/Lua/FunctionRegistry.cpp4
-rw-r--r--Sluift/Lua/Value.cpp4
-rw-r--r--Sluift/LuaElementConvertors.cpp6
-rw-r--r--Sluift/client.cpp3
-rw-r--r--Sluift/component.cpp1
-rw-r--r--Sluift/main.cpp21
-rw-r--r--Sluift/sluift.cpp9
23 files changed, 43 insertions, 78 deletions
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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Value.h>
#include <Sluift/LuaElementConvertors.h>
@@ -154,7 +152,7 @@ void CommandConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Command> pay
if (!payload->getNotes().empty()) {
std::vector<Lua::Value> 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<Command> pay
if (!payload->getAvailableActions().empty()) {
std::vector<Lua::Value> 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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/RawXMLPayload.h>
#include <Swiften/Parser/Attribute.h>
#include <Swiften/Parser/AttributeMap.h>
@@ -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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Value.h>
@@ -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<FormField> >& fieldList) {
Lua::Array fields;
- foreach(std::shared_ptr<FormField> 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> 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> 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<FormField> > fields(form->getFields());
form->clearFields();
- foreach (std::shared_ptr<FormField> 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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/Delay.h>
#include <Swiften/Elements/IQ.h>
#include <Swiften/Elements/Message.h>
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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
@@ -60,7 +58,7 @@ void PubSubAffiliationsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<P
if (!payload->getAffiliations().empty()) {
{
int i = 0;
- foreach(std::shared_ptr<PubSubAffiliation> item, payload->getAffiliations()) {
+ for (auto&& item : payload->getAffiliations()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
@@ -77,7 +75,7 @@ void PubSubEventItemConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubS
lua_createtable(L, boost::numeric_cast<int>(payload->getData().size()), 0);
{
int i = 0;
- foreach(std::shared_ptr<Payload> item, payload->getData()) {
+ for (auto&& item : payload->getData()) {
if (convertors->convertToLua(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
@@ -78,7 +76,7 @@ void PubSubEventItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Pub
lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
{
int i = 0;
- foreach(std::shared_ptr<PubSubEventItem> item, payload->getItems()) {
+ for (auto&& item : payload->getItems()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
++i;
@@ -91,7 +89,7 @@ void PubSubEventItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Pub
lua_createtable(L, boost::numeric_cast<int>(payload->getRetracts().size()), 0);
{
int i = 0;
- foreach(std::shared_ptr<PubSubEventRetract> item, payload->getRetracts()) {
+ for (auto&& item : payload->getRetracts()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
@@ -59,7 +57,7 @@ void PubSubItemConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubIte
lua_createtable(L, boost::numeric_cast<int>(payload->getData().size()), 0);
{
int i = 0;
- foreach(std::shared_ptr<Payload> item, payload->getData()) {
+ for (auto&& item : payload->getData()) {
if (convertors->convertToLua(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
@@ -68,7 +66,7 @@ void PubSubItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubIt
if (!payload->getItems().empty()) {
{
int i = 0;
- foreach(std::shared_ptr<PubSubItem> item, payload->getItems()) {
+ for (auto&& item : payload->getItems()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
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<PubSubOwnerAffiliation> item, payload->getAffiliations()) {
+ for (auto&& item : payload->getAffiliations()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
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<PubSubOwnerSubscription> item, payload->getSubscriptions()) {
+ for (auto&& item : payload->getSubscriptions()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
@@ -61,7 +59,7 @@ void PubSubPublishConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSub
lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
{
int i = 0;
- foreach(std::shared_ptr<PubSubItem> item, payload->getItems()) {
+ for (auto&& item : payload->getItems()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
@@ -66,7 +64,7 @@ void PubSubRetractConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSub
lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
{
int i = 0;
- foreach(std::shared_ptr<PubSubItem> item, payload->getItems()) {
+ for (auto&& item : payload->getItems()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/LuaElementConvertors.h>
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<PubSubSubscription> item, payload->getSubscriptions()) {
+ for (auto&& item : payload->getSubscriptions()) {
if (convertors->convertToLuaUntyped(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <lua.hpp>
-#include <Swiften/Base/foreach.h>
-
using namespace Swift;
SecurityLabelConvertor::SecurityLabelConvertor() :
@@ -69,7 +67,7 @@ void SecurityLabelConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Securi
lua_createtable(L, boost::numeric_cast<int>(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<int>(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 <boost/numeric/conversion/cast.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/IQ.h>
#include <Swiften/Elements/Message.h>
#include <Swiften/Elements/Payload.h>
@@ -75,7 +74,7 @@ namespace Swift {
lua_createtable(L, boost::numeric_cast<int>(stanza->getPayloads().size()), 0);
{
int i = 0;
- foreach(const std::shared_ptr<Payload> &item, stanza->getPayloads()) {
+ for (const auto& item : stanza->getPayloads()) {
if (convertors->convertToLua(L, item) > 0) {
lua_rawseti(L, -2, boost::numeric_cast<int>(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 <Sluift/Lua/FunctionRegistry.h>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/Lua/Exception.h>
#include <Sluift/Lua/LuaUtils.h>
#include <Sluift/globals.h>
@@ -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 <lualib.h>
}
-#include <Swiften/Base/foreach.h>
-
using namespace Swift;
using namespace Swift::Lua;
@@ -49,7 +47,7 @@ namespace {
void operator()(const std::map<std::string, std::shared_ptr<Value> >& table) const {
lua_createtable(state, 0, boost::numeric_cast<int>(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 <memory>
-#include <Swiften/Base/foreach.h>
-
#include <Sluift/ElementConvertors/BodyConvertor.h>
#include <Sluift/ElementConvertors/CarbonsReceivedConvertor.h>
#include <Sluift/ElementConvertors/CarbonsSentConvertor.h>
@@ -95,7 +93,7 @@ std::shared_ptr<Element> LuaElementConvertors::convertFromLua(lua_State* L, int
std::shared_ptr<Element> LuaElementConvertors::convertFromLuaUntyped(lua_State* L, int index, const std::string& type) {
index = Lua::absoluteOffset(L, index);
- foreach (std::shared_ptr<LuaElementConvertor> convertor, convertors) {
+ for (auto&& convertor : convertors) {
if (std::shared_ptr<Element> result = convertor->convertFromLua(L, index, type)) {
return result;
}
@@ -131,7 +129,7 @@ boost::optional<std::string> LuaElementConvertors::doConvertToLuaUntyped(
if (!payload) {
return LuaElementConvertor::NO_RESULT;
}
- foreach (std::shared_ptr<LuaElementConvertor> convertor, convertors) {
+ for (auto&& convertor : convertors) {
if (boost::optional<std::string> 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 <boost/lambda/lambda.hpp>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Disco/ClientDiscoManager.h>
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Elements/Message.h>
@@ -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 <boost/lambda/lambda.hpp>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Elements/MAMQuery.h>
#include <Swiften/Elements/Message.h>
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 <iostream>
#include <string>
#include <vector>
-#include <iostream>
-#include <lua.hpp>
-#include <Swiften/Base/foreach.h>
-#include <Swiften/Base/Platform.h>
+
+#include <boost/assign/list_of.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/program_options.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
-#include <boost/program_options.hpp>
#include <boost/version.hpp>
-#include <boost/numeric/conversion/cast.hpp>
-#include <boost/assign/list_of.hpp>
+
+#include <lua.hpp>
+
+#include <Swiften/Base/Platform.h>
+
#include <Sluift/globals.h>
#include <Sluift/Console.h>
#include <Sluift/StandardTerminal.h>
@@ -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<int>(scriptArguments.size()), false));
@@ -163,7 +166,7 @@ int main(int argc, char* argv[]) {
lua_getglobal(L, "sluift");
std::vector<std::string> 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 <lua.hpp>
#include <Swiften/Base/IDGenerator.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/sleep.h>
#include <Swiften/Crypto/CryptoProvider.h>
#include <Swiften/Crypto/PlatformCryptoProvider.h>
@@ -461,7 +460,7 @@ SLUIFT_API int luaopen_sluift(lua_State* L) {
lua_rawgeti(L, LUA_REGISTRYINDEX, Sluift::globals.coreLibIndex);
std::vector<std::string> 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<std::string> 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<std::string> 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<LuaElementConvertor> convertor, Sluift::globals.elementConvertor.getConvertors()) {
+ for (auto&& convertor : Sluift::globals.elementConvertor.getConvertors()) {
boost::optional<LuaElementConvertor::Documentation> documentation = convertor->getDocumentation();
if (documentation) {
Lua::registerClassHelp(L, documentation->className, documentation->description);