summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift/ElementConvertors')
-rw-r--r--Sluift/ElementConvertors/BodyConvertor.cpp30
-rw-r--r--Sluift/ElementConvertors/BodyConvertor.h20
-rw-r--r--Sluift/ElementConvertors/CarbonsReceivedConvertor.cpp53
-rw-r--r--Sluift/ElementConvertors/CarbonsReceivedConvertor.h30
-rw-r--r--Sluift/ElementConvertors/CarbonsSentConvertor.cpp52
-rw-r--r--Sluift/ElementConvertors/CarbonsSentConvertor.h30
-rw-r--r--Sluift/ElementConvertors/CommandConvertor.cpp333
-rw-r--r--Sluift/ElementConvertors/CommandConvertor.h24
-rw-r--r--Sluift/ElementConvertors/DOMElementConvertor.cpp342
-rw-r--r--Sluift/ElementConvertors/DOMElementConvertor.h26
-rw-r--r--Sluift/ElementConvertors/DefaultElementConvertor.cpp21
-rw-r--r--Sluift/ElementConvertors/DefaultElementConvertor.h16
-rw-r--r--Sluift/ElementConvertors/DelayConvertor.cpp56
-rw-r--r--Sluift/ElementConvertors/DelayConvertor.h18
-rw-r--r--Sluift/ElementConvertors/DiscoInfoConvertor.cpp187
-rw-r--r--Sluift/ElementConvertors/DiscoInfoConvertor.h20
-rw-r--r--Sluift/ElementConvertors/DiscoItemsConvertor.cpp97
-rw-r--r--Sluift/ElementConvertors/DiscoItemsConvertor.h18
-rw-r--r--Sluift/ElementConvertors/ElementConvertors.ipp136
-rw-r--r--Sluift/ElementConvertors/FormConvertor.cpp666
-rw-r--r--Sluift/ElementConvertors/FormConvertor.h18
-rw-r--r--Sluift/ElementConvertors/ForwardedConvertor.cpp96
-rw-r--r--Sluift/ElementConvertors/ForwardedConvertor.h29
-rw-r--r--Sluift/ElementConvertors/IQConvertor.cpp95
-rw-r--r--Sluift/ElementConvertors/IQConvertor.h31
-rw-r--r--Sluift/ElementConvertors/IsodeIQDelegationConvertor.cpp54
-rw-r--r--Sluift/ElementConvertors/IsodeIQDelegationConvertor.h26
-rw-r--r--Sluift/ElementConvertors/MAMFinConvertor.cpp113
-rw-r--r--Sluift/ElementConvertors/MAMFinConvertor.h27
-rw-r--r--Sluift/ElementConvertors/MAMQueryConvertor.cpp125
-rw-r--r--Sluift/ElementConvertors/MAMQueryConvertor.h27
-rw-r--r--Sluift/ElementConvertors/MAMResultConvertor.cpp98
-rw-r--r--Sluift/ElementConvertors/MAMResultConvertor.h27
-rw-r--r--Sluift/ElementConvertors/MessageConvertor.cpp115
-rw-r--r--Sluift/ElementConvertors/MessageConvertor.h31
-rw-r--r--Sluift/ElementConvertors/PresenceConvertor.cpp139
-rw-r--r--Sluift/ElementConvertors/PresenceConvertor.h31
-rw-r--r--Sluift/ElementConvertors/PubSubAffiliationConvertor.cpp137
-rw-r--r--Sluift/ElementConvertors/PubSubAffiliationConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp107
-rw-r--r--Sluift/ElementConvertors/PubSubAffiliationsConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubConfigureConvertor.cpp54
-rw-r--r--Sluift/ElementConvertors/PubSubConfigureConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubCreateConvertor.cpp70
-rw-r--r--Sluift/ElementConvertors/PubSubCreateConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubDefaultConvertor.cpp105
-rw-r--r--Sluift/ElementConvertors/PubSubDefaultConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubEventAssociateConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubEventAssociateConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubEventCollectionConvertor.cpp96
-rw-r--r--Sluift/ElementConvertors/PubSubEventCollectionConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubEventConfigurationConvertor.cpp70
-rw-r--r--Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubEventConvertor.cpp30
-rw-r--r--Sluift/ElementConvertors/PubSubEventConvertor.h24
-rw-r--r--Sluift/ElementConvertors/PubSubEventDeleteConvertor.cpp70
-rw-r--r--Sluift/ElementConvertors/PubSubEventDeleteConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubEventDisassociateConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubEventItemConvertor.cpp155
-rw-r--r--Sluift/ElementConvertors/PubSubEventItemConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp171
-rw-r--r--Sluift/ElementConvertors/PubSubEventItemsConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubEventPurgeConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubEventPurgeConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubEventRedirectConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubEventRedirectConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubEventRetractConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubEventRetractConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.cpp163
-rw-r--r--Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubItemConvertor.cpp111
-rw-r--r--Sluift/ElementConvertors/PubSubItemConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubItemsConvertor.cpp143
-rw-r--r--Sluift/ElementConvertors/PubSubItemsConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubOptionsConvertor.cpp106
-rw-r--r--Sluift/ElementConvertors/PubSubOptionsConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.cpp137
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp103
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.cpp74
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.cpp54
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.cpp70
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.cpp113
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp103
-rw-r--r--Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubPublishConvertor.cpp111
-rw-r--r--Sluift/ElementConvertors/PubSubPublishConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubRetractConvertor.cpp129
-rw-r--r--Sluift/ElementConvertors/PubSubRetractConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubSubscribeConvertor.cpp90
-rw-r--r--Sluift/ElementConvertors/PubSubSubscribeConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.cpp49
-rw-r--r--Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h25
-rw-r--r--Sluift/ElementConvertors/PubSubSubscriptionConvertor.cpp174
-rw-r--r--Sluift/ElementConvertors/PubSubSubscriptionConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp107
-rw-r--r--Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h26
-rw-r--r--Sluift/ElementConvertors/PubSubUnsubscribeConvertor.cpp89
-rw-r--r--Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h25
-rw-r--r--Sluift/ElementConvertors/RawXMLElementConvertor.cpp35
-rw-r--r--Sluift/ElementConvertors/RawXMLElementConvertor.h22
-rw-r--r--Sluift/ElementConvertors/ResultSetConvertor.cpp190
-rw-r--r--Sluift/ElementConvertors/ResultSetConvertor.h26
-rw-r--r--Sluift/ElementConvertors/SConscript98
-rw-r--r--Sluift/ElementConvertors/SecurityLabelConvertor.cpp151
-rw-r--r--Sluift/ElementConvertors/SecurityLabelConvertor.h25
-rw-r--r--Sluift/ElementConvertors/SoftwareVersionConvertor.cpp61
-rw-r--r--Sluift/ElementConvertors/SoftwareVersionConvertor.h18
-rw-r--r--Sluift/ElementConvertors/StanzaConvertor.h142
-rw-r--r--Sluift/ElementConvertors/StatusConvertor.cpp33
-rw-r--r--Sluift/ElementConvertors/StatusConvertor.h18
-rw-r--r--Sluift/ElementConvertors/StatusShowConvertor.cpp95
-rw-r--r--Sluift/ElementConvertors/StatusShowConvertor.h22
-rw-r--r--Sluift/ElementConvertors/SubjectConvertor.cpp30
-rw-r--r--Sluift/ElementConvertors/SubjectConvertor.h20
-rw-r--r--Sluift/ElementConvertors/UserLocationConvertor.cpp471
-rw-r--r--Sluift/ElementConvertors/UserLocationConvertor.h25
-rw-r--r--Sluift/ElementConvertors/UserTuneConvertor.cpp173
-rw-r--r--Sluift/ElementConvertors/UserTuneConvertor.h25
-rw-r--r--Sluift/ElementConvertors/VCardConvertor.cpp1218
-rw-r--r--Sluift/ElementConvertors/VCardConvertor.h18
-rw-r--r--Sluift/ElementConvertors/VCardUpdateConvertor.cpp33
-rw-r--r--Sluift/ElementConvertors/VCardUpdateConvertor.h18
133 files changed, 5266 insertions, 5212 deletions
diff --git a/Sluift/ElementConvertors/BodyConvertor.cpp b/Sluift/ElementConvertors/BodyConvertor.cpp
index 35f1a72..f6797b0 100644
--- a/Sluift/ElementConvertors/BodyConvertor.cpp
+++ b/Sluift/ElementConvertors/BodyConvertor.cpp
@@ -1,13 +1,15 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/BodyConvertor.h>
+#include <memory>
+
#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+
#include <Sluift/Lua/LuaUtils.h>
using namespace Swift;
@@ -18,18 +20,18 @@ BodyConvertor::BodyConvertor() : GenericLuaElementConvertor<Body>("body") {
BodyConvertor::~BodyConvertor() {
}
-boost::shared_ptr<Body> BodyConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Body> result = boost::make_shared<Body>();
- if (boost::optional<std::string> value = Lua::getStringField(L, -1, "text")) {
- result->setText(*value);
- }
- return result;
+std::shared_ptr<Body> BodyConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Body> result = std::make_shared<Body>();
+ if (boost::optional<std::string> value = Lua::getStringField(L, -1, "text")) {
+ result->setText(*value);
+ }
+ return result;
}
-void BodyConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Body> payload) {
- lua_createtable(L, 0, 0);
- if (!payload->getText().empty()) {
- lua_pushstring(L, payload->getText().c_str());
- lua_setfield(L, -2, "text");
- }
+void BodyConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Body> payload) {
+ lua_createtable(L, 0, 0);
+ if (!payload->getText().empty()) {
+ lua_pushstring(L, payload->getText().c_str());
+ lua_setfield(L, -2, "text");
+ }
}
diff --git a/Sluift/ElementConvertors/BodyConvertor.h b/Sluift/ElementConvertors/BodyConvertor.h
index c9d922b..64ff4d0 100644
--- a/Sluift/ElementConvertors/BodyConvertor.h
+++ b/Sluift/ElementConvertors/BodyConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,19 +7,19 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/Body.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/Body.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class BodyConvertor : public GenericLuaElementConvertor<Body> {
- public:
- BodyConvertor();
- virtual ~BodyConvertor();
+ class BodyConvertor : public GenericLuaElementConvertor<Body> {
+ public:
+ BodyConvertor();
+ virtual ~BodyConvertor();
- virtual boost::shared_ptr<Body> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Body>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<Body> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Body>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/CarbonsReceivedConvertor.cpp b/Sluift/ElementConvertors/CarbonsReceivedConvertor.cpp
new file mode 100644
index 0000000..cfd55f3
--- /dev/null
+++ b/Sluift/ElementConvertors/CarbonsReceivedConvertor.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Sluift/ElementConvertors/CarbonsReceivedConvertor.h>
+
+#include <memory>
+#include <lua.hpp>
+
+#include <Swiften/Elements/Forwarded.h>
+
+#include <Sluift/LuaElementConvertors.h>
+
+using namespace Swift;
+
+CarbonsReceivedConvertor::CarbonsReceivedConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<CarbonsReceived>("carbons_received"),
+ convertors(convertors) {
+}
+
+CarbonsReceivedConvertor::~CarbonsReceivedConvertor() {
+}
+
+std::shared_ptr<CarbonsReceived> CarbonsReceivedConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<CarbonsReceived> result = std::make_shared<CarbonsReceived>();
+ lua_getfield(L, -1, "payload");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<Forwarded> payload = std::dynamic_pointer_cast<Forwarded>(convertors->convertFromLuaUntyped(L, -1, "payload"));
+ if (!!payload) {
+ result->setForwarded(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
+}
+
+void CarbonsReceivedConvertor::doConvertToLua(lua_State* L, std::shared_ptr<CarbonsReceived> payload) {
+ lua_createtable(L, 0, 0);
+ if (convertors->convertToLuaUntyped(L, payload->getForwarded()) > 0) {
+ lua_setfield(L, -2, "payload");
+
+ }
+}
+
+boost::optional<LuaElementConvertor::Documentation> CarbonsReceivedConvertor::getDocumentation() const {
+ return Documentation(
+ "CarbonsReceived",
+ "This table has the following fields:\n\n"
+ "- `payload`: @{Forwarded}\n"
+ );
+}
diff --git a/Sluift/ElementConvertors/CarbonsReceivedConvertor.h b/Sluift/ElementConvertors/CarbonsReceivedConvertor.h
new file mode 100644
index 0000000..f18f699
--- /dev/null
+++ b/Sluift/ElementConvertors/CarbonsReceivedConvertor.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/CarbonsReceived.h>
+
+#include <Sluift/GenericLuaElementConvertor.h>
+
+namespace Swift {
+ class LuaElementConvertors;
+
+ class CarbonsReceivedConvertor : public GenericLuaElementConvertor<CarbonsReceived> {
+ public:
+ CarbonsReceivedConvertor(LuaElementConvertors* convertors);
+ virtual ~CarbonsReceivedConvertor();
+
+ virtual std::shared_ptr<CarbonsReceived> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<CarbonsReceived>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+
+ private:
+ LuaElementConvertors* convertors;
+ };
+}
+
diff --git a/Sluift/ElementConvertors/CarbonsSentConvertor.cpp b/Sluift/ElementConvertors/CarbonsSentConvertor.cpp
new file mode 100644
index 0000000..45851d2
--- /dev/null
+++ b/Sluift/ElementConvertors/CarbonsSentConvertor.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2016 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Sluift/ElementConvertors/CarbonsSentConvertor.h>
+
+#include <memory>
+#include <lua.hpp>
+
+#include <Swiften/Elements/Forwarded.h>
+
+#include <Sluift/LuaElementConvertors.h>
+
+using namespace Swift;
+
+CarbonsSentConvertor::CarbonsSentConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<CarbonsSent>("carbons_sent"),
+ convertors(convertors) {
+}
+
+CarbonsSentConvertor::~CarbonsSentConvertor() {
+}
+
+std::shared_ptr<CarbonsSent> CarbonsSentConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<CarbonsSent> result = std::make_shared<CarbonsSent>();
+ lua_getfield(L, -1, "payload");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<Forwarded> payload = std::dynamic_pointer_cast<Forwarded>(convertors->convertFromLuaUntyped(L, -1, "payload"));
+ if (!!payload) {
+ result->setForwarded(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
+}
+
+void CarbonsSentConvertor::doConvertToLua(lua_State* L, std::shared_ptr<CarbonsSent> payload) {
+ lua_createtable(L, 0, 0);
+ if (convertors->convertToLuaUntyped(L, payload->getForwarded()) > 0) {
+ lua_setfield(L, -2, "payload");
+ }
+}
+
+boost::optional<LuaElementConvertor::Documentation> CarbonsSentConvertor::getDocumentation() const {
+ return Documentation(
+ "CarbonsSent",
+ "This table has the following fields:\n\n"
+ "- `payload`: @{Forwarded}\n"
+ );
+}
diff --git a/Sluift/ElementConvertors/CarbonsSentConvertor.h b/Sluift/ElementConvertors/CarbonsSentConvertor.h
new file mode 100644
index 0000000..a36a6a8
--- /dev/null
+++ b/Sluift/ElementConvertors/CarbonsSentConvertor.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/CarbonsSent.h>
+
+#include <Sluift/GenericLuaElementConvertor.h>
+
+namespace Swift {
+ class LuaElementConvertors;
+
+ class CarbonsSentConvertor : public GenericLuaElementConvertor<CarbonsSent> {
+ public:
+ CarbonsSentConvertor(LuaElementConvertors* convertors);
+ virtual ~CarbonsSentConvertor();
+
+ virtual std::shared_ptr<CarbonsSent> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<CarbonsSent>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+
+ private:
+ LuaElementConvertors* convertors;
+ };
+}
+
diff --git a/Sluift/ElementConvertors/CommandConvertor.cpp b/Sluift/ElementConvertors/CommandConvertor.cpp
index c9fc952..de7a439 100644
--- a/Sluift/ElementConvertors/CommandConvertor.cpp
+++ b/Sluift/ElementConvertors/CommandConvertor.cpp
@@ -1,16 +1,17 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/CommandConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
+
#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Value.h>
#include <Sluift/LuaElementConvertors.h>
@@ -18,179 +19,177 @@
using namespace Swift;
static Command::Action convertActionFromString(const std::string& action) {
- if (action == "cancel") { return Command::Cancel; }
- else if (action == "execute") { return Command::Execute; }
- else if (action == "complete") { return Command::Complete; }
- else if (action == "prev") { return Command::Prev; }
- else if (action == "next") { return Command::Next; }
- return Command::NoAction;
+ if (action == "cancel") { return Command::Cancel; }
+ else if (action == "execute") { return Command::Execute; }
+ else if (action == "complete") { return Command::Complete; }
+ else if (action == "prev") { return Command::Prev; }
+ else if (action == "next") { return Command::Next; }
+ return Command::NoAction;
}
static std::string convertActionToString(Command::Action action) {
- switch (action) {
- case Command::Cancel: return "cancel";
- case Command::Execute: return "execute";
- case Command::Complete: return "complete";
- case Command::Prev: return "prev";
- case Command::Next: return "next";
- case Command::NoAction: assert(false); return "";
- }
- assert(false);
- return "";
+ switch (action) {
+ case Command::Cancel: return "cancel";
+ case Command::Execute: return "execute";
+ case Command::Complete: return "complete";
+ case Command::Prev: return "prev";
+ case Command::Next: return "next";
+ case Command::NoAction: assert(false); return "";
+ }
+ assert(false);
+ return "";
}
-CommandConvertor::CommandConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<Command>("command"),
- convertors(convertors) {
+CommandConvertor::CommandConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<Command>("command"),
+ convertors(convertors) {
}
CommandConvertor::~CommandConvertor() {
}
-boost::shared_ptr<Command> CommandConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Command> result = boost::make_shared<Command>();
-
- lua_getfield(L, -1, "node");
- if (!lua_isnil(L, -1)) {
- result->setNode(std::string(Lua::checkString(L, -1)));
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "session_id");
- if (!lua_isnil(L, -1)) {
- result->setSessionID(std::string(Lua::checkString(L, -1)));
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "status");
- if (!lua_isnil(L, -1)) {
- std::string statusText = Lua::checkString(L, -1);
- Command::Status status = Command::NoStatus;
- if (statusText == "executing") { status = Command::Executing; }
- else if (statusText == "completed") { status = Command::Completed; }
- else if (statusText == "canceled") { status = Command::Canceled; }
- result->setStatus(status);
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "action");
- if (!lua_isnil(L, -1)) {
- result->setAction(convertActionFromString(Lua::checkString(L, -1)));
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "execute_action");
- if (!lua_isnil(L, -1)) {
- result->setExecuteAction(convertActionFromString(Lua::checkString(L, -1)));
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "available_actions");
- if (!lua_isnil(L, -1)) {
- Lua::checkType(L, -1, LUA_TTABLE);
- lua_pushnil(L);
- for (lua_pushnil(L); lua_next(L, -2) != 0; ) {
- result->addAvailableAction(convertActionFromString(Lua::checkString(L, -1)));
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "notes");
- if (!lua_isnil(L, -1)) {
- Lua::checkType(L, -1, LUA_TTABLE);
- lua_pushnil(L);
- for (lua_pushnil(L); lua_next(L, -2) != 0; ) {
- Lua::checkType(L, -1, LUA_TTABLE);
- std::string note;
- lua_getfield(L, -1, "note");
- if (!lua_isnil(L, -1)) {
- note = Lua::checkString(L, -1);
- }
- lua_pop(L, 1);
-
- Command::Note::Type noteType = Command::Note::Info;
- lua_getfield(L, -1, "type");
- if (!lua_isnil(L, -1)) {
- std::string type = Lua::checkString(L, -1);
- if (type == "info") { noteType = Command::Note::Info; }
- else if (type == "warn") { noteType = Command::Note::Warn; }
- else if (type == "error") { noteType = Command::Note::Error; }
- }
- lua_pop(L, 1);
-
- result->addNote(Command::Note(note, noteType));
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "form");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Form> form = boost::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
- result->setForm(form);
- }
- }
- lua_pop(L, 1);
-
- return result;
+std::shared_ptr<Command> CommandConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Command> result = std::make_shared<Command>();
+
+ lua_getfield(L, -1, "node");
+ if (!lua_isnil(L, -1)) {
+ result->setNode(std::string(Lua::checkString(L, -1)));
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "session_id");
+ if (!lua_isnil(L, -1)) {
+ result->setSessionID(std::string(Lua::checkString(L, -1)));
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "status");
+ if (!lua_isnil(L, -1)) {
+ std::string statusText = Lua::checkString(L, -1);
+ Command::Status status = Command::NoStatus;
+ if (statusText == "executing") { status = Command::Executing; }
+ else if (statusText == "completed") { status = Command::Completed; }
+ else if (statusText == "canceled") { status = Command::Canceled; }
+ result->setStatus(status);
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "action");
+ if (!lua_isnil(L, -1)) {
+ result->setAction(convertActionFromString(Lua::checkString(L, -1)));
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "execute_action");
+ if (!lua_isnil(L, -1)) {
+ result->setExecuteAction(convertActionFromString(Lua::checkString(L, -1)));
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "available_actions");
+ if (!lua_isnil(L, -1)) {
+ Lua::checkType(L, -1, LUA_TTABLE);
+ for (lua_pushnil(L); lua_next(L, -2) != 0; ) {
+ result->addAvailableAction(convertActionFromString(Lua::checkString(L, -1)));
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "notes");
+ if (!lua_isnil(L, -1)) {
+ Lua::checkType(L, -1, LUA_TTABLE);
+ for (lua_pushnil(L); lua_next(L, -2) != 0; ) {
+ Lua::checkType(L, -1, LUA_TTABLE);
+ std::string note;
+ lua_getfield(L, -1, "note");
+ if (!lua_isnil(L, -1)) {
+ note = Lua::checkString(L, -1);
+ }
+ lua_pop(L, 1);
+
+ Command::Note::Type noteType = Command::Note::Info;
+ lua_getfield(L, -1, "type");
+ if (!lua_isnil(L, -1)) {
+ std::string type = Lua::checkString(L, -1);
+ if (type == "info") { noteType = Command::Note::Info; }
+ else if (type == "warn") { noteType = Command::Note::Warn; }
+ else if (type == "error") { noteType = Command::Note::Error; }
+ }
+ lua_pop(L, 1);
+
+ result->addNote(Command::Note(note, noteType));
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "form");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Form> form = std::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
+ result->setForm(form);
+ }
+ }
+ lua_pop(L, 1);
+
+ return result;
}
-void CommandConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Command> payload) {
- Lua::Table result;
- if (!payload->getNode().empty()) {
- result["node"] = Lua::valueRef(payload->getNode());
- }
- if (!payload->getSessionID().empty()) {
- result["session_id"] = Lua::valueRef(payload->getSessionID());
- }
- switch (payload->getStatus()) {
- case Command::Executing: result["status"] = Lua::valueRef("executing"); break;
- case Command::Completed: result["status"] = Lua::valueRef("completed"); break;
- case Command::Canceled: result["status"] = Lua::valueRef("canceled"); break;
- case Command::NoStatus: break;
- }
-
- if (!payload->getNotes().empty()) {
- std::vector<Lua::Value> notes;
- foreach (const Command::Note& note, payload->getNotes()) {
- Lua::Table noteTable;
- if (!note.note.empty()) {
- noteTable["note"] = Lua::valueRef(note.note);
- }
- switch (note.type) {
- case Command::Note::Info: noteTable["type"] = Lua::valueRef("info"); break;
- case Command::Note::Warn: noteTable["type"] = Lua::valueRef("warn"); break;
- case Command::Note::Error: noteTable["type"] = Lua::valueRef("error"); break;
- }
- notes.push_back(noteTable);
- }
- result["notes"] = Lua::valueRef(notes);
- }
-
- if (payload->getAction() != Command::NoAction) {
- result["action"] = Lua::valueRef(convertActionToString(payload->getAction()));
- }
-
- if (payload->getExecuteAction() != Command::NoAction) {
- result["execute_action"] = Lua::valueRef(convertActionToString(payload->getAction()));
- }
-
- if (!payload->getAvailableActions().empty()) {
- std::vector<Lua::Value> availableActions;
- foreach (const Command::Action& action, payload->getAvailableActions()) {
- if (action != Command::NoAction) {
- availableActions.push_back(convertActionToString(action));
- }
- }
- result["available_actions"] = Lua::valueRef(availableActions);
- }
-
- Lua::pushValue(L, result);
-
- if (payload->getForm()) {
- bool result = convertors->convertToLuaUntyped(L, payload->getForm());
- assert(result);
- lua_setfield(L, -2, "form");
- }
+void CommandConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Command> payload) {
+ Lua::Table result;
+ if (!payload->getNode().empty()) {
+ result["node"] = Lua::valueRef(payload->getNode());
+ }
+ if (!payload->getSessionID().empty()) {
+ result["session_id"] = Lua::valueRef(payload->getSessionID());
+ }
+ switch (payload->getStatus()) {
+ case Command::Executing: result["status"] = Lua::valueRef("executing"); break;
+ case Command::Completed: result["status"] = Lua::valueRef("completed"); break;
+ case Command::Canceled: result["status"] = Lua::valueRef("canceled"); break;
+ case Command::NoStatus: break;
+ }
+
+ if (!payload->getNotes().empty()) {
+ std::vector<Lua::Value> notes;
+ for (const auto& note : payload->getNotes()) {
+ Lua::Table noteTable;
+ if (!note.note.empty()) {
+ noteTable["note"] = Lua::valueRef(note.note);
+ }
+ switch (note.type) {
+ case Command::Note::Info: noteTable["type"] = Lua::valueRef("info"); break;
+ case Command::Note::Warn: noteTable["type"] = Lua::valueRef("warn"); break;
+ case Command::Note::Error: noteTable["type"] = Lua::valueRef("error"); break;
+ }
+ notes.push_back(noteTable);
+ }
+ result["notes"] = Lua::valueRef(notes);
+ }
+
+ if (payload->getAction() != Command::NoAction) {
+ result["action"] = Lua::valueRef(convertActionToString(payload->getAction()));
+ }
+
+ if (payload->getExecuteAction() != Command::NoAction) {
+ result["execute_action"] = Lua::valueRef(convertActionToString(payload->getAction()));
+ }
+
+ if (!payload->getAvailableActions().empty()) {
+ std::vector<Lua::Value> availableActions;
+ for (const auto& action : payload->getAvailableActions()) {
+ if (action != Command::NoAction) {
+ availableActions.push_back(convertActionToString(action));
+ }
+ }
+ result["available_actions"] = Lua::valueRef(availableActions);
+ }
+
+ Lua::pushValue(L, result);
+
+ if (payload->getForm()) {
+ bool result = convertors->convertToLuaUntyped(L, payload->getForm());
+ assert(result);
+ lua_setfield(L, -2, "form");
+ }
}
diff --git a/Sluift/ElementConvertors/CommandConvertor.h b/Sluift/ElementConvertors/CommandConvertor.h
index 868fe5e..1b0d481 100644
--- a/Sluift/ElementConvertors/CommandConvertor.h
+++ b/Sluift/ElementConvertors/CommandConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,22 +7,22 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/Command.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/Command.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class CommandConvertor : public GenericLuaElementConvertor<Command> {
- public:
- CommandConvertor(LuaElementConvertors* convertors);
- virtual ~CommandConvertor();
+ class CommandConvertor : public GenericLuaElementConvertor<Command> {
+ public:
+ CommandConvertor(LuaElementConvertors* convertors);
+ virtual ~CommandConvertor();
- virtual boost::shared_ptr<Command> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Command>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<Command> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Command>) SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/DOMElementConvertor.cpp b/Sluift/ElementConvertors/DOMElementConvertor.cpp
index 6ed214d..b957686 100644
--- a/Sluift/ElementConvertors/DOMElementConvertor.cpp
+++ b/Sluift/ElementConvertors/DOMElementConvertor.cpp
@@ -1,159 +1,159 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/DOMElementConvertor.h>
-#include <iostream>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <lua.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/RawXMLPayload.h>
-#include <Swiften/Serializer/PayloadSerializer.h>
-#include <Sluift/Lua/Check.h>
-#include <Sluift/Lua/LuaUtils.h>
-#include <Swiften/Parser/XMLParserClient.h>
-#include <Swiften/Parser/XMLParser.h>
-#include <Swiften/Parser/AttributeMap.h>
#include <Swiften/Parser/Attribute.h>
+#include <Swiften/Parser/AttributeMap.h>
+#include <Swiften/Parser/XMLParser.h>
+#include <Swiften/Parser/XMLParserClient.h>
+#include <Swiften/Serializer/PayloadSerializer.h>
#include <Swiften/Serializer/XML/XMLElement.h>
-#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
+#include <Swiften/Serializer/XML/XMLTextNode.h>
+
+#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Debug.h>
+#include <Sluift/Lua/LuaUtils.h>
using namespace Swift;
namespace {
- class ParserClient : public XMLParserClient {
- public:
- ParserClient(lua_State* L) : L(L), currentIndex(1) {
- }
-
- virtual void handleStartElement(
- const std::string& element, const std::string& ns,
- const AttributeMap& attributes) SWIFTEN_OVERRIDE {
- lua_checkstack(L, 6);
- lua_pushnumber(L, currentIndex);
- lua_newtable(L);
- lua_pushstring(L, element.c_str());
- lua_setfield(L, -2, "tag");
- if (!ns.empty()) {
- lua_pushstring(L, ns.c_str());
- lua_setfield(L, -2, "ns");
- }
- if (!attributes.getEntries().empty()) {
- lua_newtable(L);
- int i = 1;
- foreach(const AttributeMap::Entry& entry, attributes.getEntries()) {
- lua_pushnumber(L, i);
- lua_newtable(L);
- lua_pushstring(L, entry.getAttribute().getName().c_str());
- lua_setfield(L, -2, "name");
- if (!entry.getAttribute().getNamespace().empty()) {
- lua_pushstring(L, entry.getAttribute().getNamespace().c_str());
- lua_setfield(L, -2, "ns");
- }
- lua_pushstring(L, entry.getValue().c_str());
- lua_setfield(L, -2, "value");
- lua_settable(L, -3);
- ++i;
- }
- lua_setfield(L, -2, "attributes");
- }
-
- indexStack.push_back(currentIndex);
- currentIndex = 1;
- lua_newtable(L);
- }
-
- virtual void handleEndElement(
- const std::string&, const std::string&) SWIFTEN_OVERRIDE {
- lua_setfield(L, -2, "children");
- lua_settable(L, -3);
- currentIndex = indexStack.back();
- indexStack.pop_back();
- currentIndex++;
- }
-
- virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE {
- lua_checkstack(L, 2);
- lua_pushnumber(L, currentIndex);
- lua_pushstring(L, data.c_str());
- lua_settable(L, -3);
- currentIndex++;
- }
-
- private:
- lua_State* L;
- std::vector<int> indexStack;
- int currentIndex;
- };
-
- std::string serializeElement(lua_State* L) {
- std::string tag;
- lua_getfield(L, -1, "tag");
- if (lua_isstring(L, -1)) {
- tag = lua_tostring(L, -1);
- }
- lua_pop(L, 1);
-
- std::string ns;
- lua_getfield(L, -1, "ns");
- if (lua_isstring(L, -1)) {
- ns = lua_tostring(L, -1);
- }
- lua_pop(L, 1);
-
- XMLElement element(tag, ns);
-
- lua_getfield(L, -1, "attributes");
- if (lua_istable(L, -1)) {
- int index = Lua::absoluteOffset(L, -1);
- for (lua_pushnil(L); lua_next(L, index) != 0; ) {
- if (lua_istable(L, -1)) {
- std::string attributeName;
- lua_getfield(L, -1, "name");
- if (lua_isstring(L, -1)) {
- attributeName = lua_tostring(L, -1);
- }
- lua_pop(L, 1);
-
- std::string attributeValue;
- lua_getfield(L, -1, "value");
- if (lua_isstring(L, -1)) {
- attributeValue = lua_tostring(L, -1);
- }
- lua_pop(L, 1);
-
- if (!attributeName.empty()) {
- element.setAttribute(attributeName, attributeValue);
- }
- }
- lua_pop(L, 1); // value
- }
- }
- lua_pop(L, 1); // children
-
- lua_getfield(L, -1, "children");
- if (lua_istable(L, -1)) {
- int index = Lua::absoluteOffset(L, -1);
- for (lua_pushnil(L); lua_next(L, index) != 0; ) {
- if (lua_isstring(L, -1)) {
- element.addNode(boost::make_shared<XMLTextNode>(lua_tostring(L, -1)));
- }
- else if (lua_istable(L, -1)) {
- element.addNode(boost::make_shared<XMLRawTextNode>(serializeElement(L)));
- }
- lua_pop(L, 1); // value
- }
- }
- lua_pop(L, 1); // children
-
- return element.serialize();
- }
+ class ParserClient : public XMLParserClient {
+ public:
+ ParserClient(lua_State* L) : L(L), currentIndex(1) {
+ }
+
+ virtual void handleStartElement(
+ const std::string& element, const std::string& ns,
+ const AttributeMap& attributes) SWIFTEN_OVERRIDE {
+ lua_checkstack(L, 6);
+ lua_pushnumber(L, currentIndex);
+ lua_newtable(L);
+ lua_pushstring(L, element.c_str());
+ lua_setfield(L, -2, "tag");
+ if (!ns.empty()) {
+ lua_pushstring(L, ns.c_str());
+ lua_setfield(L, -2, "ns");
+ }
+ if (!attributes.getEntries().empty()) {
+ lua_newtable(L);
+ int i = 1;
+ for (const auto& entry : attributes.getEntries()) {
+ lua_pushnumber(L, i);
+ lua_newtable(L);
+ lua_pushstring(L, entry.getAttribute().getName().c_str());
+ lua_setfield(L, -2, "name");
+ if (!entry.getAttribute().getNamespace().empty()) {
+ lua_pushstring(L, entry.getAttribute().getNamespace().c_str());
+ lua_setfield(L, -2, "ns");
+ }
+ lua_pushstring(L, entry.getValue().c_str());
+ lua_setfield(L, -2, "value");
+ lua_settable(L, -3);
+ ++i;
+ }
+ lua_setfield(L, -2, "attributes");
+ }
+
+ indexStack.push_back(currentIndex);
+ currentIndex = 1;
+ lua_newtable(L);
+ }
+
+ virtual void handleEndElement(
+ const std::string&, const std::string&) SWIFTEN_OVERRIDE {
+ lua_setfield(L, -2, "children");
+ lua_settable(L, -3);
+ currentIndex = indexStack.back();
+ indexStack.pop_back();
+ currentIndex++;
+ }
+
+ virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE {
+ lua_checkstack(L, 2);
+ lua_pushnumber(L, currentIndex);
+ lua_pushstring(L, data.c_str());
+ lua_settable(L, -3);
+ currentIndex++;
+ }
+
+ private:
+ lua_State* L;
+ std::vector<int> indexStack;
+ int currentIndex;
+ };
+
+ std::string serializeElement(lua_State* L) {
+ std::string tag;
+ lua_getfield(L, -1, "tag");
+ if (lua_isstring(L, -1)) {
+ tag = lua_tostring(L, -1);
+ }
+ lua_pop(L, 1);
+
+ std::string ns;
+ lua_getfield(L, -1, "ns");
+ if (lua_isstring(L, -1)) {
+ ns = lua_tostring(L, -1);
+ }
+ lua_pop(L, 1);
+
+ XMLElement element(tag, ns);
+
+ lua_getfield(L, -1, "attributes");
+ if (lua_istable(L, -1)) {
+ int index = Lua::absoluteOffset(L, -1);
+ for (lua_pushnil(L); lua_next(L, index) != 0; ) {
+ if (lua_istable(L, -1)) {
+ std::string attributeName;
+ lua_getfield(L, -1, "name");
+ if (lua_isstring(L, -1)) {
+ attributeName = lua_tostring(L, -1);
+ }
+ lua_pop(L, 1);
+
+ std::string attributeValue;
+ lua_getfield(L, -1, "value");
+ if (lua_isstring(L, -1)) {
+ attributeValue = lua_tostring(L, -1);
+ }
+ lua_pop(L, 1);
+
+ if (!attributeName.empty()) {
+ element.setAttribute(attributeName, attributeValue);
+ }
+ }
+ lua_pop(L, 1); // value
+ }
+ }
+ lua_pop(L, 1); // children
+
+ lua_getfield(L, -1, "children");
+ if (lua_istable(L, -1)) {
+ int index = Lua::absoluteOffset(L, -1);
+ for (lua_pushnil(L); lua_next(L, index) != 0; ) {
+ if (lua_isstring(L, -1)) {
+ element.addNode(std::make_shared<XMLTextNode>(lua_tostring(L, -1)));
+ }
+ else if (lua_istable(L, -1)) {
+ element.addNode(std::make_shared<XMLRawTextNode>(serializeElement(L)));
+ }
+ lua_pop(L, 1); // value
+ }
+ }
+ lua_pop(L, 1); // children
+
+ return element.serialize();
+ }
}
DOMElementConvertor::DOMElementConvertor() {
@@ -162,40 +162,40 @@ DOMElementConvertor::DOMElementConvertor() {
DOMElementConvertor::~DOMElementConvertor() {
}
-boost::shared_ptr<Element> DOMElementConvertor::convertFromLua(lua_State* L, int index, const std::string& type) {
- if (!lua_istable(L, index) || type != "dom") {
- return boost::shared_ptr<Payload>();
- }
- return boost::make_shared<RawXMLPayload>(serializeElement(L).c_str());
+std::shared_ptr<Element> DOMElementConvertor::convertFromLua(lua_State* L, int index, const std::string& type) {
+ if (!lua_istable(L, index) || type != "dom") {
+ return std::shared_ptr<Payload>();
+ }
+ return std::make_shared<RawXMLPayload>(serializeElement(L).c_str());
}
boost::optional<std::string> DOMElementConvertor::convertToLua(
- lua_State* L, boost::shared_ptr<Element> element) {
- // Serialize payload to XML
- boost::shared_ptr<Payload> payload = boost::dynamic_pointer_cast<Payload>(element);
- if (!payload) {
- return boost::optional<std::string>();
- }
-
- PayloadSerializer* serializer = serializers.getPayloadSerializer(payload);
- assert(serializer);
- std::string serializedPayload = serializer->serialize(payload);
-
- lua_newtable(L);
-
- // Parse the payload again
- ParserClient parserClient(L);
- boost::shared_ptr<XMLParser> parser(parsers.createXMLParser(&parserClient));
- bool result = parser->parse(serializedPayload);
- assert(result);
-
- // There can only be one element, so stripping the list
- lua_pushnil(L);
- lua_next(L, -2);
- Lua::registerTableToString(L, -1);
-
- lua_replace(L, -3);
- lua_settop(L, -2);
-
- return std::string("dom");
+ lua_State* L, std::shared_ptr<Element> element) {
+ // Serialize payload to XML
+ std::shared_ptr<Payload> payload = std::dynamic_pointer_cast<Payload>(element);
+ if (!payload) {
+ return boost::optional<std::string>();
+ }
+
+ PayloadSerializer* serializer = serializers.getPayloadSerializer(payload);
+ assert(serializer);
+ std::string serializedPayload = serializer->serialize(payload);
+
+ lua_newtable(L);
+
+ // Parse the payload again
+ ParserClient parserClient(L);
+ std::shared_ptr<XMLParser> parser(parsers.createXMLParser(&parserClient));
+ bool result = parser->parse(serializedPayload);
+ assert(result);
+
+ // There can only be one element, so stripping the list
+ lua_pushnil(L);
+ lua_next(L, -2);
+ Lua::registerTableToString(L, -1);
+
+ lua_replace(L, -3);
+ lua_settop(L, -2);
+
+ return std::string("dom");
}
diff --git a/Sluift/ElementConvertors/DOMElementConvertor.h b/Sluift/ElementConvertors/DOMElementConvertor.h
index 610dbff..7b1ba58 100644
--- a/Sluift/ElementConvertors/DOMElementConvertor.h
+++ b/Sluift/ElementConvertors/DOMElementConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,22 +7,22 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Parser/PlatformXMLParserFactory.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
#include <Sluift/LuaElementConvertor.h>
-#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
-#include <Swiften/Parser/PlatformXMLParserFactory.h>
namespace Swift {
- class DOMElementConvertor : public LuaElementConvertor {
- public:
- DOMElementConvertor();
- virtual ~DOMElementConvertor();
+ class DOMElementConvertor : public LuaElementConvertor {
+ public:
+ DOMElementConvertor();
+ virtual ~DOMElementConvertor();
- virtual boost::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE;
- virtual boost::optional<std::string> convertToLua(lua_State*, boost::shared_ptr<Element>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE;
+ virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) SWIFTEN_OVERRIDE;
- private:
- PlatformXMLParserFactory parsers;
- FullPayloadSerializerCollection serializers;
- };
+ private:
+ PlatformXMLParserFactory parsers;
+ FullPayloadSerializerCollection serializers;
+ };
}
diff --git a/Sluift/ElementConvertors/DefaultElementConvertor.cpp b/Sluift/ElementConvertors/DefaultElementConvertor.cpp
index c95da93..75e6706 100644
--- a/Sluift/ElementConvertors/DefaultElementConvertor.cpp
+++ b/Sluift/ElementConvertors/DefaultElementConvertor.cpp
@@ -1,14 +1,15 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/DefaultElementConvertor.h>
-#include <iostream>
-#include <typeinfo>
#include <string>
+#include <typeinfo>
+
+#include <Swiften/Base/Log.h>
using namespace Swift;
@@ -18,13 +19,13 @@ DefaultElementConvertor::DefaultElementConvertor() {
DefaultElementConvertor::~DefaultElementConvertor() {
}
-boost::shared_ptr<Element> DefaultElementConvertor::convertFromLua(lua_State*, int, const std::string& type) {
- std::cerr << "Warning: Unable to convert type '" << type << "'" << std::endl;
- return boost::shared_ptr<Element>();
+std::shared_ptr<Element> DefaultElementConvertor::convertFromLua(lua_State*, int, const std::string& type) {
+ SWIFT_LOG(warning) << "Unable to convert type '" << type << "'" << std::endl;
+ return std::shared_ptr<Element>();
}
-boost::optional<std::string> DefaultElementConvertor::convertToLua(lua_State*, boost::shared_ptr<Element>) {
- // Should have been handled by the raw XML convertor
- assert(false);
- return NO_RESULT;
+boost::optional<std::string> DefaultElementConvertor::convertToLua(lua_State*, std::shared_ptr<Element>) {
+ // Should have been handled by the raw XML convertor
+ assert(false);
+ return NO_RESULT;
}
diff --git a/Sluift/ElementConvertors/DefaultElementConvertor.h b/Sluift/ElementConvertors/DefaultElementConvertor.h
index e08bb98..4aec300 100644
--- a/Sluift/ElementConvertors/DefaultElementConvertor.h
+++ b/Sluift/ElementConvertors/DefaultElementConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,12 +11,12 @@
#include <Sluift/LuaElementConvertor.h>
namespace Swift {
- class DefaultElementConvertor : public LuaElementConvertor {
- public:
- DefaultElementConvertor();
- virtual ~DefaultElementConvertor();
+ class DefaultElementConvertor : public LuaElementConvertor {
+ public:
+ DefaultElementConvertor();
+ virtual ~DefaultElementConvertor();
- virtual boost::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE;
- virtual boost::optional<std::string> convertToLua(lua_State*, boost::shared_ptr<Element>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE;
+ virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/DelayConvertor.cpp b/Sluift/ElementConvertors/DelayConvertor.cpp
index a17e114..f23e137 100644
--- a/Sluift/ElementConvertors/DelayConvertor.cpp
+++ b/Sluift/ElementConvertors/DelayConvertor.cpp
@@ -1,17 +1,21 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/DelayConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/Lua/Check.h>
+
+#include <lua.hpp>
+
#include <Swiften/Base/DateTime.h>
+#include <Sluift/Lua/Check.h>
+
using namespace Swift;
DelayConvertor::DelayConvertor() : GenericLuaElementConvertor<Delay>("delay") {
@@ -20,28 +24,28 @@ DelayConvertor::DelayConvertor() : GenericLuaElementConvertor<Delay>("delay") {
DelayConvertor::~DelayConvertor() {
}
-boost::shared_ptr<Delay> DelayConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Delay> result = boost::make_shared<Delay>();
- lua_getfield(L, -1, "stamp");
- if (lua_isstring(L, -1)) {
- result->setStamp(stringToDateTime(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "from");
- if (lua_isstring(L, -1)) {
- result->setFrom(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<Delay> DelayConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Delay> result = std::make_shared<Delay>();
+ lua_getfield(L, -1, "stamp");
+ if (lua_isstring(L, -1)) {
+ result->setStamp(stringToDateTime(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "from");
+ if (lua_isstring(L, -1)) {
+ result->setFrom(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void DelayConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Delay> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getFrom()) {
- lua_pushstring(L, (*payload->getFrom()).toString().c_str());
- lua_setfield(L, -2, "from");
- }
- lua_pushstring(L, dateTimeToString(payload->getStamp()).c_str());
- lua_setfield(L, -2, "stamp");
+void DelayConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Delay> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getFrom()) {
+ lua_pushstring(L, (*payload->getFrom()).toString().c_str());
+ lua_setfield(L, -2, "from");
+ }
+ lua_pushstring(L, dateTimeToString(payload->getStamp()).c_str());
+ lua_setfield(L, -2, "stamp");
}
diff --git a/Sluift/ElementConvertors/DelayConvertor.h b/Sluift/ElementConvertors/DelayConvertor.h
index 6cee7de..b9f72f2 100644
--- a/Sluift/ElementConvertors/DelayConvertor.h
+++ b/Sluift/ElementConvertors/DelayConvertor.h
@@ -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.
*/
@@ -7,17 +7,17 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/Delay.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/Delay.h>
namespace Swift {
- class DelayConvertor : public GenericLuaElementConvertor<Delay> {
- public:
- DelayConvertor();
- virtual ~DelayConvertor();
+ class DelayConvertor : public GenericLuaElementConvertor<Delay> {
+ public:
+ DelayConvertor();
+ virtual ~DelayConvertor();
- virtual boost::shared_ptr<Delay> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Delay>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<Delay> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Delay>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/DiscoInfoConvertor.cpp b/Sluift/ElementConvertors/DiscoInfoConvertor.cpp
index d9a408e..2aa4a77 100644
--- a/Sluift/ElementConvertors/DiscoInfoConvertor.cpp
+++ b/Sluift/ElementConvertors/DiscoInfoConvertor.cpp
@@ -1,14 +1,17 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/DiscoInfoConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
+
#include <Sluift/Lua/LuaUtils.h>
using namespace Swift;
@@ -19,98 +22,98 @@ DiscoInfoConvertor::DiscoInfoConvertor() : GenericLuaElementConvertor<DiscoInfo>
DiscoInfoConvertor::~DiscoInfoConvertor() {
}
-boost::shared_ptr<DiscoInfo> DiscoInfoConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<DiscoInfo> result = boost::make_shared<DiscoInfo>();
- if (boost::optional<std::string> value = Lua::getStringField(L, -1, "node")) {
- result->setNode(*value);
- }
-
- lua_getfield(L, -1, "identities");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- result->addIdentity(DiscoInfo::Identity(
- Lua::getStringField(L, -1, "name").get_value_or(""),
- Lua::getStringField(L, -1, "category").get_value_or("client"),
- Lua::getStringField(L, -1, "type").get_value_or("pc"),
- Lua::getStringField(L, -1, "language").get_value_or("")));
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "features");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- result->addFeature(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
-
- // TODO: Extension
-
- return result;
+std::shared_ptr<DiscoInfo> DiscoInfoConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<DiscoInfo> result = std::make_shared<DiscoInfo>();
+ if (boost::optional<std::string> value = Lua::getStringField(L, -1, "node")) {
+ result->setNode(*value);
+ }
+
+ lua_getfield(L, -1, "identities");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ result->addIdentity(DiscoInfo::Identity(
+ Lua::getStringField(L, -1, "name").get_value_or(""),
+ Lua::getStringField(L, -1, "category").get_value_or("client"),
+ Lua::getStringField(L, -1, "type").get_value_or("pc"),
+ Lua::getStringField(L, -1, "language").get_value_or("")));
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "features");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ result->addFeature(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+
+ // TODO: Extension
+
+ return result;
}
-void DiscoInfoConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<DiscoInfo> payload) {
- lua_newtable(L);
- if (!payload->getNode().empty()) {
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- }
-
- const std::vector<DiscoInfo::Identity>& identities = payload->getIdentities();
- if (!identities.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(identities.size()), 0);
- for (size_t i = 0; i < identities.size(); ++i) {
- lua_createtable(L, 0, 0);
- if (!identities[i].getName().empty()) {
- lua_pushstring(L, identities[i].getName().c_str());
- lua_setfield(L, -2, "name");
- }
- if (!identities[i].getCategory().empty()) {
- lua_pushstring(L, identities[i].getCategory().c_str());
- lua_setfield(L, -2, "category");
- }
- if (!identities[i].getType().empty()) {
- lua_pushstring(L, identities[i].getType().c_str());
- lua_setfield(L, -2, "type");
- }
- if (!identities[i].getLanguage().empty()) {
- lua_pushstring(L, identities[i].getLanguage().c_str());
- lua_setfield(L, -2, "language");
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "identities");
- }
-
- const std::vector<std::string>& features = payload->getFeatures();
- if (!features.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(features.size()), 0);
- for (size_t i = 0; i < features.size(); ++i) {
- lua_pushstring(L, features[i].c_str());
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "features");
- }
-
- // TODO: Extension
+void DiscoInfoConvertor::doConvertToLua(lua_State* L, std::shared_ptr<DiscoInfo> payload) {
+ lua_newtable(L);
+ if (!payload->getNode().empty()) {
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ }
+
+ const std::vector<DiscoInfo::Identity>& identities = payload->getIdentities();
+ if (!identities.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(identities.size()), 0);
+ for (size_t i = 0; i < identities.size(); ++i) {
+ lua_createtable(L, 0, 0);
+ if (!identities[i].getName().empty()) {
+ lua_pushstring(L, identities[i].getName().c_str());
+ lua_setfield(L, -2, "name");
+ }
+ if (!identities[i].getCategory().empty()) {
+ lua_pushstring(L, identities[i].getCategory().c_str());
+ lua_setfield(L, -2, "category");
+ }
+ if (!identities[i].getType().empty()) {
+ lua_pushstring(L, identities[i].getType().c_str());
+ lua_setfield(L, -2, "type");
+ }
+ if (!identities[i].getLanguage().empty()) {
+ lua_pushstring(L, identities[i].getLanguage().c_str());
+ lua_setfield(L, -2, "language");
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "identities");
+ }
+
+ const std::vector<std::string>& features = payload->getFeatures();
+ if (!features.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(features.size()), 0);
+ for (size_t i = 0; i < features.size(); ++i) {
+ lua_pushstring(L, features[i].c_str());
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "features");
+ }
+
+ // TODO: Extension
}
boost::optional<LuaElementConvertor::Documentation> DiscoInfoConvertor::getDocumentation() const {
- return Documentation(
- "DiscoInfo",
- "Represents `disco#info` service discovery data.\n\n"
- "This table has the following structure:\n\n"
- "- `node`: string\n"
- "- `identities`: array(table)\n"
- " - `name`: string\n"
- " - `category`: string\n"
- " - `type`: string\n"
- " - `language`: string\n"
- "- `features`: array(string)\n"
- );
+ return Documentation(
+ "DiscoInfo",
+ "Represents `disco#info` service discovery data.\n\n"
+ "This table has the following structure:\n\n"
+ "- `node`: string\n"
+ "- `identities`: array(table)\n"
+ " - `name`: string\n"
+ " - `category`: string\n"
+ " - `type`: string\n"
+ " - `language`: string\n"
+ "- `features`: array(string)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/DiscoInfoConvertor.h b/Sluift/ElementConvertors/DiscoInfoConvertor.h
index 7c5009f..34f8237 100644
--- a/Sluift/ElementConvertors/DiscoInfoConvertor.h
+++ b/Sluift/ElementConvertors/DiscoInfoConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,18 +7,18 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/DiscoInfo.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/DiscoInfo.h>
namespace Swift {
- class DiscoInfoConvertor : public GenericLuaElementConvertor<DiscoInfo> {
- public:
- DiscoInfoConvertor();
- virtual ~DiscoInfoConvertor();
+ class DiscoInfoConvertor : public GenericLuaElementConvertor<DiscoInfo> {
+ public:
+ DiscoInfoConvertor();
+ virtual ~DiscoInfoConvertor();
- virtual boost::shared_ptr<DiscoInfo> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<DiscoInfo>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<DiscoInfo> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<DiscoInfo>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/DiscoItemsConvertor.cpp b/Sluift/ElementConvertors/DiscoItemsConvertor.cpp
index 6ec944a..c15a0f8 100644
--- a/Sluift/ElementConvertors/DiscoItemsConvertor.cpp
+++ b/Sluift/ElementConvertors/DiscoItemsConvertor.cpp
@@ -1,14 +1,17 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/DiscoItemsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
+
#include <Sluift/Lua/LuaUtils.h>
using namespace Swift;
@@ -19,50 +22,50 @@ DiscoItemsConvertor::DiscoItemsConvertor() : GenericLuaElementConvertor<DiscoIte
DiscoItemsConvertor::~DiscoItemsConvertor() {
}
-boost::shared_ptr<DiscoItems> DiscoItemsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<DiscoItems> result = boost::make_shared<DiscoItems>();
- if (boost::optional<std::string> value = Lua::getStringField(L, -1, "node")) {
- result->setNode(*value);
- }
- lua_getfield(L, -1, "items");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- result->addItem(DiscoItems::Item(
- Lua::getStringField(L, -1, "name").get_value_or(""),
- JID(Lua::getStringField(L, -1, "jid").get_value_or("")),
- Lua::getStringField(L, -1, "node").get_value_or("")));
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<DiscoItems> DiscoItemsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<DiscoItems> result = std::make_shared<DiscoItems>();
+ if (boost::optional<std::string> value = Lua::getStringField(L, -1, "node")) {
+ result->setNode(*value);
+ }
+ lua_getfield(L, -1, "items");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ result->addItem(DiscoItems::Item(
+ Lua::getStringField(L, -1, "name").get_value_or(""),
+ JID(Lua::getStringField(L, -1, "jid").get_value_or("")),
+ Lua::getStringField(L, -1, "node").get_value_or("")));
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void DiscoItemsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<DiscoItems> payload) {
- lua_newtable(L);
- if (!payload->getNode().empty()) {
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- }
- const std::vector<DiscoItems::Item>& items = payload->getItems();
- if (!items.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(items.size()), 0);
- for (size_t i = 0; i < items.size(); ++i) {
- lua_createtable(L, 0, 0);
- if (!items[i].getName().empty()) {
- lua_pushstring(L, items[i].getName().c_str());
- lua_setfield(L, -2, "name");
- }
- if (!items[i].getNode().empty()) {
- lua_pushstring(L, items[i].getNode().c_str());
- lua_setfield(L, -2, "node");
- }
- if (items[i].getJID().isValid()) {
- lua_pushstring(L, items[i].getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "items");
- }
+void DiscoItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<DiscoItems> payload) {
+ lua_newtable(L);
+ if (!payload->getNode().empty()) {
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ }
+ const std::vector<DiscoItems::Item>& items = payload->getItems();
+ if (!items.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(items.size()), 0);
+ for (size_t i = 0; i < items.size(); ++i) {
+ lua_createtable(L, 0, 0);
+ if (!items[i].getName().empty()) {
+ lua_pushstring(L, items[i].getName().c_str());
+ lua_setfield(L, -2, "name");
+ }
+ if (!items[i].getNode().empty()) {
+ lua_pushstring(L, items[i].getNode().c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (items[i].getJID().isValid()) {
+ lua_pushstring(L, items[i].getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "items");
+ }
}
diff --git a/Sluift/ElementConvertors/DiscoItemsConvertor.h b/Sluift/ElementConvertors/DiscoItemsConvertor.h
index 5e3a86c..a77b948 100644
--- a/Sluift/ElementConvertors/DiscoItemsConvertor.h
+++ b/Sluift/ElementConvertors/DiscoItemsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,17 +7,17 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/DiscoItems.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/DiscoItems.h>
namespace Swift {
- class DiscoItemsConvertor : public GenericLuaElementConvertor<DiscoItems> {
- public:
- DiscoItemsConvertor();
- virtual ~DiscoItemsConvertor();
+ class DiscoItemsConvertor : public GenericLuaElementConvertor<DiscoItems> {
+ public:
+ DiscoItemsConvertor();
+ virtual ~DiscoItemsConvertor();
- virtual boost::shared_ptr<DiscoItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<DiscoItems>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<DiscoItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<DiscoItems>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/ElementConvertors.ipp b/Sluift/ElementConvertors/ElementConvertors.ipp
index 7d25e86..a81c9cf 100644
--- a/Sluift/ElementConvertors/ElementConvertors.ipp
+++ b/Sluift/ElementConvertors/ElementConvertors.ipp
@@ -1,87 +1,87 @@
/*
- * Copyright (c) 2013-2014 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#include <Sluift/ElementConvertors/PubSubRetractConvertor.h>
+#include <Sluift/ElementConvertors/IsodeIQDelegationConvertor.h>
+#include <Sluift/ElementConvertors/PubSubAffiliationConvertor.h>
#include <Sluift/ElementConvertors/PubSubAffiliationsConvertor.h>
-#include <Sluift/ElementConvertors/PubSubPublishConvertor.h>
-#include <Sluift/ElementConvertors/PubSubItemsConvertor.h>
-#include <Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventRedirectConvertor.h>
-#include <Sluift/ElementConvertors/UserTuneConvertor.h>
#include <Sluift/ElementConvertors/PubSubConfigureConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h>
-#include <Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h>
-#include <Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h>
-#include <Sluift/ElementConvertors/UserLocationConvertor.h>
-#include <Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h>
-#include <Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h>
+#include <Sluift/ElementConvertors/PubSubCreateConvertor.h>
#include <Sluift/ElementConvertors/PubSubDefaultConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventAssociateConvertor.h>
#include <Sluift/ElementConvertors/PubSubEventCollectionConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventRetractConvertor.h>
-#include <Sluift/ElementConvertors/PubSubItemConvertor.h>
-#include <Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h>
#include <Sluift/ElementConvertors/PubSubEventDeleteConvertor.h>
-#include <Sluift/ElementConvertors/PubSubCreateConvertor.h>
-#include <Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventItemConvertor.h>
#include <Sluift/ElementConvertors/PubSubEventItemsConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventPurgeConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventRedirectConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventRetractConvertor.h>
+#include <Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h>
+#include <Sluift/ElementConvertors/PubSubItemConvertor.h>
+#include <Sluift/ElementConvertors/PubSubItemsConvertor.h>
#include <Sluift/ElementConvertors/PubSubOptionsConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventItemConvertor.h>
-#include <Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h>
-#include <Sluift/ElementConvertors/IsodeIQDelegationConvertor.h>
#include <Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventPurgeConvertor.h>
-#include <Sluift/ElementConvertors/PubSubAffiliationConvertor.h>
-#include <Sluift/ElementConvertors/PubSubSubscribeConvertor.h>
-#include <Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h>
+#include <Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h>
+#include <Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h>
#include <Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h>
-#include <Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventAssociateConvertor.h>
+#include <Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h>
+#include <Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h>
+#include <Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h>
+#include <Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h>
+#include <Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h>
+#include <Sluift/ElementConvertors/PubSubPublishConvertor.h>
+#include <Sluift/ElementConvertors/PubSubRetractConvertor.h>
+#include <Sluift/ElementConvertors/PubSubSubscribeConvertor.h>
+#include <Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h>
#include <Sluift/ElementConvertors/PubSubSubscriptionConvertor.h>
+#include <Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h>
+#include <Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h>
#include <Sluift/ElementConvertors/SecurityLabelConvertor.h>
-#include <Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h>
+#include <Sluift/ElementConvertors/UserLocationConvertor.h>
+#include <Sluift/ElementConvertors/UserTuneConvertor.h>
void LuaElementConvertors::registerConvertors() {
- convertors.push_back(boost::make_shared<PubSubRetractConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubAffiliationsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubPublishConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubItemsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerRedirectConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventRedirectConvertor>(this));
- convertors.push_back(boost::make_shared<UserTuneConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubConfigureConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventDisassociateConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerAffiliationsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerConfigureConvertor>(this));
- convertors.push_back(boost::make_shared<UserLocationConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubSubscribeOptionsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerSubscriptionsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubDefaultConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventCollectionConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventSubscriptionConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventRetractConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubItemConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubUnsubscribeConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventDeleteConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubCreateConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerPurgeConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventItemsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOptionsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventItemConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerSubscriptionConvertor>(this));
- convertors.push_back(boost::make_shared<IsodeIQDelegationConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerAffiliationConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventPurgeConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubAffiliationConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubSubscribeConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerDeleteConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubOwnerDefaultConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubSubscriptionsConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventAssociateConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubSubscriptionConvertor>(this));
- convertors.push_back(boost::make_shared<SecurityLabelConvertor>(this));
- convertors.push_back(boost::make_shared<PubSubEventConfigurationConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubRetractConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubAffiliationsConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubPublishConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubItemsConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOwnerRedirectConvertor>());
+ convertors.push_back(std::make_shared<PubSubEventRedirectConvertor>());
+ convertors.push_back(std::make_shared<UserTuneConvertor>());
+ convertors.push_back(std::make_shared<PubSubConfigureConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubEventDisassociateConvertor>());
+ convertors.push_back(std::make_shared<PubSubOwnerAffiliationsConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOwnerConfigureConvertor>(this));
+ convertors.push_back(std::make_shared<UserLocationConvertor>());
+ convertors.push_back(std::make_shared<PubSubSubscribeOptionsConvertor>());
+ convertors.push_back(std::make_shared<PubSubOwnerSubscriptionsConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubDefaultConvertor>());
+ convertors.push_back(std::make_shared<PubSubEventCollectionConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubEventSubscriptionConvertor>());
+ convertors.push_back(std::make_shared<PubSubEventRetractConvertor>());
+ convertors.push_back(std::make_shared<PubSubItemConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubUnsubscribeConvertor>());
+ convertors.push_back(std::make_shared<PubSubEventDeleteConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubCreateConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOwnerPurgeConvertor>());
+ convertors.push_back(std::make_shared<PubSubEventItemsConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOptionsConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubEventItemConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOwnerSubscriptionConvertor>());
+ convertors.push_back(std::make_shared<IsodeIQDelegationConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOwnerAffiliationConvertor>());
+ convertors.push_back(std::make_shared<PubSubEventPurgeConvertor>());
+ convertors.push_back(std::make_shared<PubSubAffiliationConvertor>());
+ convertors.push_back(std::make_shared<PubSubSubscribeConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOwnerDeleteConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubOwnerDefaultConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubSubscriptionsConvertor>(this));
+ convertors.push_back(std::make_shared<PubSubEventAssociateConvertor>());
+ convertors.push_back(std::make_shared<PubSubSubscriptionConvertor>(this));
+ convertors.push_back(std::make_shared<SecurityLabelConvertor>());
+ convertors.push_back(std::make_shared<PubSubEventConfigurationConvertor>(this));
}
diff --git a/Sluift/ElementConvertors/FormConvertor.cpp b/Sluift/ElementConvertors/FormConvertor.cpp
index be1015c..90fd9fe 100644
--- a/Sluift/ElementConvertors/FormConvertor.cpp
+++ b/Sluift/ElementConvertors/FormConvertor.cpp
@@ -1,343 +1,343 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/FormConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <sstream>
+
+#include <boost/assign/list_of.hpp>
#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
+
#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Value.h>
-#include <Swiften/Base/foreach.h>
-#include <boost/assign/list_of.hpp>
-#include <sstream>
using namespace Swift;
namespace {
- int formIndex(lua_State* L) {
- lua_getfield(L, 1, "fields");
- if (lua_type(L, -1) != LUA_TTABLE) {
- return 0;
- }
- int index = Lua::absoluteOffset(L, -1);
- lua_pushnil(L);
- for (lua_pushnil(L); lua_next(L, index) != 0; ) {
- lua_getfield(L, -1, "name");
- if (lua_equal(L, -1, 2)) {
- lua_pop(L, 1);
- return 1;
- }
- lua_pop(L, 2);
- }
- return 0;
- }
-
- int formNewIndex(lua_State* L) {
- lua_getfield(L, 1, "fields");
- bool foundField = false;
- if (lua_type(L, -1) == LUA_TTABLE) {
- for (lua_pushnil(L); lua_next(L, -2) != 0; ) {
- lua_getfield(L, -1, "name");
- if (lua_equal(L, -1, 2)) {
- lua_pushvalue(L, 3);
- lua_setfield(L, -3, "value");
- foundField = true;
- lua_pop(L, 3);
- break;
- }
- lua_pop(L, 2);
- }
- }
- lua_pop(L, 1);
-
- if (!foundField) {
- lua_pushvalue(L, 2);
- lua_pushvalue(L, 3);
- lua_rawset(L, 1);
- }
- return 0;
- }
-
- Lua::Table convertFieldToLua(boost::shared_ptr<FormField> field) {
- Lua::Table luaField = boost::assign::map_list_of("name", Lua::valueRef(field->getName()));
- std::string type;
- switch (field->getType()) {
- case FormField::UnknownType: type = ""; break;
- case FormField::BooleanType: type = "boolean"; break;
- case FormField::FixedType: type = "fixed"; break;
- case FormField::HiddenType: type = "hidden"; break;
- case FormField::ListSingleType: type = "list-single"; break;
- case FormField::TextMultiType: type = "text-multi"; break;
- case FormField::TextPrivateType: type = "text-private"; break;
- case FormField::TextSingleType: type = "text-single"; break;
- case FormField::JIDSingleType: type = "jid-single"; break;
- case FormField::JIDMultiType: type = "jid-multi"; break;
- case FormField::ListMultiType: type = "list-multi"; break;
- }
- if (!type.empty()) {
- luaField["type"] = Lua::valueRef(type);
- }
- if (!field->getLabel().empty()) {
- luaField["label"] = Lua::valueRef(field->getLabel());
- }
- if (field->getRequired()) {
- luaField["required"] = Lua::boolRef(field->getRequired());
- }
- if (!field->getDescription().empty()) {
- luaField["description"] = Lua::valueRef(field->getDescription());
- }
- if (field->getType() == FormField::BooleanType) {
- luaField["value"] = Lua::boolRef(field->getBoolValue());
- }
- else if (field->getValues().size() > 1) {
- luaField["value"] = Lua::valueRef(Lua::Array(field->getValues().begin(), field->getValues().end()));
- }
- else if (field->getValues().size() == 1) {
- luaField["value"] = Lua::valueRef(field->getValues()[0]);
- }
- if (!field->getOptions().empty()) {
- Lua::Array options;
- foreach(const FormField::Option& option, field->getOptions()) {
- Lua::Table luaOption = boost::assign::map_list_of
- ("label", Lua::valueRef(option.label))
- ("value", Lua::valueRef(option.value));
- options.push_back(luaOption);
- }
- luaField["options"] = valueRef(options);
- }
- return luaField;
- }
-
- Lua::Array convertFieldListToLua(const std::vector< boost::shared_ptr<FormField> >& fieldList) {
- Lua::Array fields;
- foreach(boost::shared_ptr<FormField> field, fieldList) {
- fields.push_back(convertFieldToLua(field));
- }
- return fields;
- }
-
-
- boost::shared_ptr<FormField> convertFieldFromLua(lua_State* L) {
- boost::shared_ptr<FormField> result = boost::make_shared<FormField>();
- FormField::Type fieldType = FormField::UnknownType;
- boost::optional<std::string> type = Lua::getStringField(L, -1, "type");
- if (type) {
- if (*type == "boolean") {
- fieldType = FormField::BooleanType;
- }
- if (*type == "fixed") {
- fieldType = FormField::FixedType;
- }
- if (*type == "hidden") {
- fieldType = FormField::HiddenType;
- }
- if (*type == "list-single") {
- fieldType = FormField::ListSingleType;
- }
- if (*type == "text-multi") {
- fieldType = FormField::TextMultiType;
- }
- if (*type == "text-private") {
- fieldType = FormField::TextPrivateType;
- }
- if (*type == "text-single") {
- fieldType = FormField::TextSingleType;
- }
- if (*type == "jid-single") {
- fieldType = FormField::JIDSingleType;
- }
- if (*type == "jid-multi") {
- fieldType = FormField::JIDMultiType;
- }
- if (*type == "list-multi") {
- fieldType = FormField::ListMultiType;
- }
- }
- result->setType(fieldType);
- if (boost::optional<std::string> name = Lua::getStringField(L, -1, "name")) {
- result->setName(*name);
- }
- if (boost::optional<std::string> description = Lua::getStringField(L, -1, "description")) {
- result->setDescription(*description);
- }
- if (boost::optional<std::string> label = Lua::getStringField(L, -1, "label")) {
- result->setLabel(*label);
- }
- if (boost::optional<bool> required = Lua::getBooleanField(L, -1, "required")) {
- result->setRequired(*required);
- }
- if (boost::optional<std::string> value = Lua::getStringField(L, -1, "value")) {
- result->addValue(*value);
- }
- else if (boost::optional<bool> value = Lua::getBooleanField(L, -1, "value")) {
- result->setBoolValue(*value);
- }
- else {
- lua_getfield(L, -1, "value");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- result->addValue(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- }
- lua_getfield(L, -1, "options");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_istable(L, -1)) {
- FormField::Option option("", "");
- if (boost::optional<std::string> value = Lua::getStringField(L, -1, "value")) {
- option.value = *value;
- }
- if (boost::optional<std::string> label = Lua::getStringField(L, -1, "label")) {
- option.label = *label;
- }
- result->addOption(option);
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- return result;
- }
-
- std::vector< boost::shared_ptr<FormField> > convertFieldListFromLua(lua_State* L) {
- std::vector< boost::shared_ptr<FormField> > result;
- for (lua_pushnil(L); lua_next(L, -2);) {
- result.push_back(convertFieldFromLua(L));
- lua_pop(L, 1);
- }
- return result;
- }
-
- boost::shared_ptr<Form> convertFormFromLua(lua_State* L) {
- boost::shared_ptr<Form> result = boost::make_shared<Form>();
- if (boost::optional<std::string> title = Lua::getStringField(L, -1, "title")) {
- result->setTitle(*title);
- }
- if (boost::optional<std::string> instructions = Lua::getStringField(L, -1, "instructions")) {
- result->setInstructions(*instructions);
- }
- if (boost::optional<std::string> type = Lua::getStringField(L, -1, "type")) {
- Form::Type formType = Form::FormType;
- if (*type == "submit") {
- formType = Form::SubmitType;
- }
- else if (*type == "cancel") {
- formType = Form::CancelType;
- }
- else if (*type == "result") {
- formType = Form::ResultType;
- }
- result->setType(formType);
- }
-
- lua_getfield(L, -1, "fields");
- if (lua_istable(L, -1)) {
- foreach (boost::shared_ptr<FormField> formField, convertFieldListFromLua(L)) {
- result->addField(formField);
- }
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "reported_fields");
- if (lua_istable(L, -1)) {
- foreach (boost::shared_ptr<FormField> formField, convertFieldListFromLua(L)) {
- result->addReportedField(formField);
- }
- }
- lua_pop(L, 1);
-
- lua_getfield(L, -1, "items");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2);) {
- result->addItem(convertFieldListFromLua(L));
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
-
- return result;
- }
-
- void convertFormToLua(lua_State* L, boost::shared_ptr<Form> payload) {
- std::string type;
- switch (payload->getType()) {
- case Form::FormType: type = "form"; break;
- case Form::SubmitType: type = "submit"; break;
- case Form::CancelType: type = "cancel"; break;
- case Form::ResultType: type = "result"; break;
- }
-
- Lua::Table result = boost::assign::map_list_of("type", Lua::valueRef(type));
- if (!payload->getTitle().empty()) {
- result["title"] = Lua::valueRef(payload->getTitle());
- }
- if (!payload->getInstructions().empty()) {
- result["instructions"] = Lua::valueRef(payload->getInstructions());
- }
- if (!payload->getFields().empty()) {
- result["fields"] = valueRef(convertFieldListToLua(payload->getFields()));
- }
- if (!payload->getReportedFields().empty()) {
- result["reported_fields"] = valueRef(convertFieldListToLua(payload->getReportedFields()));
- }
-
- if (!payload->getItems().empty()) {
- Lua::Array luaItems;
- foreach(const Form::FormItem& item, payload->getItems()) {
- if (!item.empty()) {
- luaItems.push_back(convertFieldListToLua(item));
- }
- }
- result["items"] = valueRef(luaItems);
- }
-
- Lua::pushValue(L, result);
-
- lua_newtable(L);
- lua_pushcfunction(L, formIndex);
- lua_setfield(L, -2, "__index");
- lua_pushcfunction(L, formNewIndex);
- lua_setfield(L, -2, "__newindex");
- lua_setmetatable(L, -2);
- }
-
- int createSubmission(lua_State* L) {
- boost::shared_ptr<Form> form = convertFormFromLua(L);
-
- // Remove all redundant elements
- form->setInstructions("");
- form->setTitle("");
- form->clearItems();
- form->clearReportedFields();
- std::vector< boost::shared_ptr<FormField> > fields(form->getFields());
- form->clearFields();
- foreach (boost::shared_ptr<FormField> field, fields) {
- if (field->getType() == FormField::FixedType) {
- continue;
- }
- field->clearOptions();
- field->setLabel("");
- field->setType(FormField::UnknownType);
- field->setDescription("");
- form->addField(field);
- }
- form->setType(Form::SubmitType);
-
- // Convert back
- convertFormToLua(L, form);
- Lua::registerTableToString(L, -1);
-
- return 1;
- }
+ int formIndex(lua_State* L) {
+ lua_getfield(L, 1, "fields");
+ if (lua_type(L, -1) != LUA_TTABLE) {
+ return 0;
+ }
+ int index = Lua::absoluteOffset(L, -1);
+ lua_pushnil(L);
+ for (lua_pushnil(L); lua_next(L, index) != 0; ) {
+ lua_getfield(L, -1, "name");
+ if (lua_equal(L, -1, 2)) {
+ lua_pop(L, 1);
+ return 1;
+ }
+ lua_pop(L, 2);
+ }
+ return 0;
+ }
+
+ int formNewIndex(lua_State* L) {
+ lua_getfield(L, 1, "fields");
+ bool foundField = false;
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ for (lua_pushnil(L); lua_next(L, -2) != 0; ) {
+ lua_getfield(L, -1, "name");
+ if (lua_equal(L, -1, 2)) {
+ lua_pushvalue(L, 3);
+ lua_setfield(L, -3, "value");
+ foundField = true;
+ lua_pop(L, 3);
+ break;
+ }
+ lua_pop(L, 2);
+ }
+ }
+ lua_pop(L, 1);
+
+ if (!foundField) {
+ lua_pushvalue(L, 2);
+ lua_pushvalue(L, 3);
+ lua_rawset(L, 1);
+ }
+ return 0;
+ }
+
+ Lua::Table convertFieldToLua(std::shared_ptr<FormField> field) {
+ Lua::Table luaField = boost::assign::map_list_of("name", Lua::valueRef(field->getName()));
+ std::string type;
+ switch (field->getType()) {
+ case FormField::UnknownType: type = ""; break;
+ case FormField::BooleanType: type = "boolean"; break;
+ case FormField::FixedType: type = "fixed"; break;
+ case FormField::HiddenType: type = "hidden"; break;
+ case FormField::ListSingleType: type = "list-single"; break;
+ case FormField::TextMultiType: type = "text-multi"; break;
+ case FormField::TextPrivateType: type = "text-private"; break;
+ case FormField::TextSingleType: type = "text-single"; break;
+ case FormField::JIDSingleType: type = "jid-single"; break;
+ case FormField::JIDMultiType: type = "jid-multi"; break;
+ case FormField::ListMultiType: type = "list-multi"; break;
+ }
+ if (!type.empty()) {
+ luaField["type"] = Lua::valueRef(type);
+ }
+ if (!field->getLabel().empty()) {
+ luaField["label"] = Lua::valueRef(field->getLabel());
+ }
+ if (field->getRequired()) {
+ luaField["required"] = Lua::boolRef(field->getRequired());
+ }
+ if (!field->getDescription().empty()) {
+ luaField["description"] = Lua::valueRef(field->getDescription());
+ }
+ if (field->getType() == FormField::BooleanType) {
+ luaField["value"] = Lua::boolRef(field->getBoolValue());
+ }
+ else if (field->getValues().size() > 1) {
+ luaField["value"] = Lua::valueRef(Lua::Array(field->getValues().begin(), field->getValues().end()));
+ }
+ else if (field->getValues().size() == 1) {
+ luaField["value"] = Lua::valueRef(field->getValues()[0]);
+ }
+ if (!field->getOptions().empty()) {
+ Lua::Array options;
+ for (const auto& option : field->getOptions()) {
+ Lua::Table luaOption = boost::assign::map_list_of
+ ("label", Lua::valueRef(option.label))
+ ("value", Lua::valueRef(option.value));
+ options.push_back(luaOption);
+ }
+ luaField["options"] = valueRef(options);
+ }
+ return luaField;
+ }
+
+ Lua::Array convertFieldListToLua(const std::vector< std::shared_ptr<FormField> >& fieldList) {
+ Lua::Array fields;
+ for (auto&& field : fieldList) {
+ fields.push_back(convertFieldToLua(field));
+ }
+ return fields;
+ }
+
+
+ std::shared_ptr<FormField> convertFieldFromLua(lua_State* L) {
+ std::shared_ptr<FormField> result = std::make_shared<FormField>();
+ FormField::Type fieldType = FormField::UnknownType;
+ boost::optional<std::string> type = Lua::getStringField(L, -1, "type");
+ if (type) {
+ if (*type == "boolean") {
+ fieldType = FormField::BooleanType;
+ }
+ if (*type == "fixed") {
+ fieldType = FormField::FixedType;
+ }
+ if (*type == "hidden") {
+ fieldType = FormField::HiddenType;
+ }
+ if (*type == "list-single") {
+ fieldType = FormField::ListSingleType;
+ }
+ if (*type == "text-multi") {
+ fieldType = FormField::TextMultiType;
+ }
+ if (*type == "text-private") {
+ fieldType = FormField::TextPrivateType;
+ }
+ if (*type == "text-single") {
+ fieldType = FormField::TextSingleType;
+ }
+ if (*type == "jid-single") {
+ fieldType = FormField::JIDSingleType;
+ }
+ if (*type == "jid-multi") {
+ fieldType = FormField::JIDMultiType;
+ }
+ if (*type == "list-multi") {
+ fieldType = FormField::ListMultiType;
+ }
+ }
+ result->setType(fieldType);
+ if (boost::optional<std::string> name = Lua::getStringField(L, -1, "name")) {
+ result->setName(*name);
+ }
+ if (boost::optional<std::string> description = Lua::getStringField(L, -1, "description")) {
+ result->setDescription(*description);
+ }
+ if (boost::optional<std::string> label = Lua::getStringField(L, -1, "label")) {
+ result->setLabel(*label);
+ }
+ if (boost::optional<bool> required = Lua::getBooleanField(L, -1, "required")) {
+ result->setRequired(*required);
+ }
+ if (boost::optional<std::string> value = Lua::getStringField(L, -1, "value")) {
+ result->addValue(*value);
+ }
+ else if (boost::optional<bool> value = Lua::getBooleanField(L, -1, "value")) {
+ result->setBoolValue(*value);
+ }
+ else {
+ lua_getfield(L, -1, "value");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ result->addValue(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ }
+ lua_getfield(L, -1, "options");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_istable(L, -1)) {
+ FormField::Option option("", "");
+ if (boost::optional<std::string> value = Lua::getStringField(L, -1, "value")) {
+ option.value = *value;
+ }
+ if (boost::optional<std::string> label = Lua::getStringField(L, -1, "label")) {
+ option.label = *label;
+ }
+ result->addOption(option);
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
+ }
+
+ std::vector< std::shared_ptr<FormField> > convertFieldListFromLua(lua_State* L) {
+ std::vector< std::shared_ptr<FormField> > result;
+ for (lua_pushnil(L); lua_next(L, -2);) {
+ result.push_back(convertFieldFromLua(L));
+ lua_pop(L, 1);
+ }
+ return result;
+ }
+
+ std::shared_ptr<Form> convertFormFromLua(lua_State* L) {
+ std::shared_ptr<Form> result = std::make_shared<Form>();
+ if (boost::optional<std::string> title = Lua::getStringField(L, -1, "title")) {
+ result->setTitle(*title);
+ }
+ if (boost::optional<std::string> instructions = Lua::getStringField(L, -1, "instructions")) {
+ result->setInstructions(*instructions);
+ }
+ if (boost::optional<std::string> type = Lua::getStringField(L, -1, "type")) {
+ Form::Type formType = Form::FormType;
+ if (*type == "submit") {
+ formType = Form::SubmitType;
+ }
+ else if (*type == "cancel") {
+ formType = Form::CancelType;
+ }
+ else if (*type == "result") {
+ formType = Form::ResultType;
+ }
+ result->setType(formType);
+ }
+
+ lua_getfield(L, -1, "fields");
+ if (lua_istable(L, -1)) {
+ for (auto&& formField : convertFieldListFromLua(L)) {
+ result->addField(formField);
+ }
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "reported_fields");
+ if (lua_istable(L, -1)) {
+ for (auto&& formField : convertFieldListFromLua(L)) {
+ result->addReportedField(formField);
+ }
+ }
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "items");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2);) {
+ result->addItem(convertFieldListFromLua(L));
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+
+ return result;
+ }
+
+ void convertFormToLua(lua_State* L, std::shared_ptr<Form> payload) {
+ std::string type;
+ switch (payload->getType()) {
+ case Form::FormType: type = "form"; break;
+ case Form::SubmitType: type = "submit"; break;
+ case Form::CancelType: type = "cancel"; break;
+ case Form::ResultType: type = "result"; break;
+ }
+
+ Lua::Table result = boost::assign::map_list_of("type", Lua::valueRef(type));
+ if (!payload->getTitle().empty()) {
+ result["title"] = Lua::valueRef(payload->getTitle());
+ }
+ if (!payload->getInstructions().empty()) {
+ result["instructions"] = Lua::valueRef(payload->getInstructions());
+ }
+ result["fields"] = valueRef(convertFieldListToLua(payload->getFields()));
+ if (!payload->getReportedFields().empty()) {
+ result["reported_fields"] = valueRef(convertFieldListToLua(payload->getReportedFields()));
+ }
+
+ if (!payload->getItems().empty()) {
+ Lua::Array luaItems;
+ for (const auto& item : payload->getItems()) {
+ if (!item.empty()) {
+ luaItems.push_back(convertFieldListToLua(item));
+ }
+ }
+ result["items"] = valueRef(luaItems);
+ }
+
+ Lua::pushValue(L, result);
+
+ lua_newtable(L);
+ lua_pushcfunction(L, formIndex);
+ lua_setfield(L, -2, "__index");
+ lua_pushcfunction(L, formNewIndex);
+ lua_setfield(L, -2, "__newindex");
+ lua_setmetatable(L, -2);
+ }
+
+ int createSubmission(lua_State* L) {
+ std::shared_ptr<Form> form = convertFormFromLua(L);
+
+ // Remove all redundant elements
+ form->setInstructions("");
+ form->setTitle("");
+ form->clearItems();
+ form->clearReportedFields();
+ std::vector< std::shared_ptr<FormField> > fields(form->getFields());
+ form->clearFields();
+ for (auto&& field : fields) {
+ if (field->getType() == FormField::FixedType) {
+ continue;
+ }
+ field->clearOptions();
+ field->setLabel("");
+ field->setType(FormField::UnknownType);
+ field->setDescription("");
+ form->addField(field);
+ }
+ form->setType(Form::SubmitType);
+
+ // Convert back
+ convertFormToLua(L, form);
+ Lua::registerTableToString(L, -1);
+
+ return 1;
+ }
}
FormConvertor::FormConvertor() : GenericLuaElementConvertor<Form>("form") {
@@ -346,14 +346,14 @@ FormConvertor::FormConvertor() : GenericLuaElementConvertor<Form>("form") {
FormConvertor::~FormConvertor() {
}
-boost::shared_ptr<Form> FormConvertor::doConvertFromLua(lua_State* L) {
- return convertFormFromLua(L);
+std::shared_ptr<Form> FormConvertor::doConvertFromLua(lua_State* L) {
+ return convertFormFromLua(L);
}
-void FormConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Form> payload) {
- convertFormToLua(L, payload);
+void FormConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Form> payload) {
+ convertFormToLua(L, payload);
- lua_pushstring(L, "create_submission");
- lua_pushcfunction(L, createSubmission);
- lua_rawset(L, -3);
+ lua_pushstring(L, "create_submission");
+ lua_pushcfunction(L, createSubmission);
+ lua_rawset(L, -3);
}
diff --git a/Sluift/ElementConvertors/FormConvertor.h b/Sluift/ElementConvertors/FormConvertor.h
index 3c1542f..b32a940 100644
--- a/Sluift/ElementConvertors/FormConvertor.h
+++ b/Sluift/ElementConvertors/FormConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,17 +7,17 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/Form.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/Form.h>
namespace Swift {
- class FormConvertor : public GenericLuaElementConvertor<Form> {
- public:
- FormConvertor();
- virtual ~FormConvertor();
+ class FormConvertor : public GenericLuaElementConvertor<Form> {
+ public:
+ FormConvertor();
+ virtual ~FormConvertor();
- virtual boost::shared_ptr<Form> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Form>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<Form> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Form>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/ForwardedConvertor.cpp b/Sluift/ElementConvertors/ForwardedConvertor.cpp
index a6ec79c..b353eea 100644
--- a/Sluift/ElementConvertors/ForwardedConvertor.cpp
+++ b/Sluift/ElementConvertors/ForwardedConvertor.cpp
@@ -1,72 +1,74 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
+#include <Sluift/ElementConvertors/ForwardedConvertor.h>
+
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+
#include <lua.hpp>
-#include <Swiften/Base/foreach.h>
-#include <Sluift/ElementConvertors/ForwardedConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
+
#include <Swiften/Elements/Delay.h>
#include <Swiften/Elements/IQ.h>
-#include <Swiften/Elements/Presence.h>
#include <Swiften/Elements/Message.h>
+#include <Swiften/Elements/Presence.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-ForwardedConvertor::ForwardedConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<Forwarded>("forwarded"),
- convertors(convertors) {
+ForwardedConvertor::ForwardedConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<Forwarded>("forwarded"),
+ convertors(convertors) {
}
ForwardedConvertor::~ForwardedConvertor() {
}
-boost::shared_ptr<Forwarded> ForwardedConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Forwarded> result = boost::make_shared<Forwarded>();
- lua_getfield(L, -1, "delay");
- if (!lua_isnil(L, -1)) {
- boost::shared_ptr<Delay> delay = boost::dynamic_pointer_cast<Delay>(convertors->convertFromLuaUntyped(L, -1, "delay"));
- if (!!delay) {
- result->setDelay(delay);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "stanza");
- if (!lua_isnil(L, -1)) {
- boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(convertors->convertFromLua(L, -1));
- if (!!stanza) {
- result->setStanza(stanza);
- }
- lua_pop(L, 1);
- return result;
- }
- return result;
+std::shared_ptr<Forwarded> ForwardedConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Forwarded> result = std::make_shared<Forwarded>();
+ lua_getfield(L, -1, "delay");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<Delay> delay = std::dynamic_pointer_cast<Delay>(convertors->convertFromLuaUntyped(L, -1, "delay"));
+ if (!!delay) {
+ result->setDelay(delay);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "stanza");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<Stanza> stanza = std::dynamic_pointer_cast<Stanza>(convertors->convertFromLua(L, -1));
+ if (!!stanza) {
+ result->setStanza(stanza);
+ }
+ lua_pop(L, 1);
+ return result;
+ }
+ return result;
}
-void ForwardedConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Forwarded> payload) {
- lua_createtable(L, 0, 0);
- if (convertors->convertToLuaUntyped(L, payload->getDelay()) > 0) {
- lua_setfield(L, -2, "delay");
- }
- boost::shared_ptr<Stanza> stanza = payload->getStanza();
- if (!!stanza) {
- if (convertors->convertToLua(L, stanza) > 0) {
- lua_setfield(L, -2, "stanza");
- }
- }
+void ForwardedConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Forwarded> payload) {
+ lua_createtable(L, 0, 0);
+ if (convertors->convertToLuaUntyped(L, payload->getDelay()) > 0) {
+ lua_setfield(L, -2, "delay");
+ }
+ std::shared_ptr<Stanza> stanza = payload->getStanza();
+ if (!!stanza) {
+ if (convertors->convertToLua(L, stanza) > 0) {
+ lua_setfield(L, -2, "stanza");
+ }
+ }
}
boost::optional<LuaElementConvertor::Documentation> ForwardedConvertor::getDocumentation() const {
- return Documentation(
- "Forwarded",
- "This table has the following fields:\n\n"
- "- `delay`: @{Delay} (Optional)\n"
- "- `stanza`: @{Stanza} (Optional)\n"
- );
+ return Documentation(
+ "Forwarded",
+ "This table has the following fields:\n\n"
+ "- `delay`: @{Delay} (Optional)\n"
+ "- `stanza`: @{Stanza} (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/ForwardedConvertor.h b/Sluift/ElementConvertors/ForwardedConvertor.h
index a7d2586..a83b5f4 100644
--- a/Sluift/ElementConvertors/ForwardedConvertor.h
+++ b/Sluift/ElementConvertors/ForwardedConvertor.h
@@ -1,30 +1,31 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/GenericLuaElementConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Forwarded.h>
+#include <Sluift/GenericLuaElementConvertor.h>
+
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class ForwardedConvertor : public GenericLuaElementConvertor<Forwarded> {
- public:
- ForwardedConvertor(LuaElementConvertors* convertors);
- virtual ~ForwardedConvertor();
+ class ForwardedConvertor : public GenericLuaElementConvertor<Forwarded> {
+ public:
+ ForwardedConvertor(LuaElementConvertors* convertors);
+ virtual ~ForwardedConvertor();
- virtual boost::shared_ptr<Forwarded> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Forwarded>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<Forwarded> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Forwarded>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/IQConvertor.cpp b/Sluift/ElementConvertors/IQConvertor.cpp
index e9119cb..67a4a2a 100644
--- a/Sluift/ElementConvertors/IQConvertor.cpp
+++ b/Sluift/ElementConvertors/IQConvertor.cpp
@@ -1,74 +1,75 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#include <boost/smart_ptr/make_shared.hpp>
-#include <lua.hpp>
#include <Sluift/ElementConvertors/IQConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <memory>
+
+#include <lua.hpp>
+
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-IQConvertor::IQConvertor(LuaElementConvertors* convertors) :
- StanzaConvertor<IQ>("iq"),
- convertors(convertors) {
+IQConvertor::IQConvertor(LuaElementConvertors* convertors) :
+ StanzaConvertor<IQ>("iq"),
+ convertors(convertors) {
}
IQConvertor::~IQConvertor() {
}
-boost::shared_ptr<IQ> IQConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<IQ> result = getStanza(L, convertors);
- lua_getfield(L, -1, "type");
- if (lua_isstring(L, -1)) {
- result->setType(IQConvertor::convertIQTypeFromString(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<IQ> IQConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<IQ> result = getStanza(L, convertors);
+ lua_getfield(L, -1, "type");
+ if (lua_isstring(L, -1)) {
+ result->setType(IQConvertor::convertIQTypeFromString(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void IQConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<IQ> stanza) {
- pushStanza(L, stanza, convertors);
- const std::string type = IQConvertor::convertIQTypeToString(stanza->getType());
- lua_pushstring(L, type.c_str());
- lua_setfield(L, -2, "type");
+void IQConvertor::doConvertToLua(lua_State* L, std::shared_ptr<IQ> stanza) {
+ pushStanza(L, stanza, convertors);
+ const std::string type = IQConvertor::convertIQTypeToString(stanza->getType());
+ lua_pushstring(L, type.c_str());
+ lua_setfield(L, -2, "type");
}
boost::optional<LuaElementConvertor::Documentation> IQConvertor::getDocumentation() const {
- return Documentation(
- "IQ",
- "This table has the following fields:\n\n"
- "- `type`: string\n"
- "- `id`: string\n"
- "- `from`: string\n"
- "- `to`: string\n"
- "- `payloads`: array<@{Payload}>\n"
- );
+ return Documentation(
+ "IQ",
+ "This table has the following fields:\n\n"
+ "- `type`: string\n"
+ "- `id`: string\n"
+ "- `from`: string\n"
+ "- `to`: string\n"
+ "- `payloads`: array<@{Payload}>\n"
+ );
}
std::string IQConvertor::convertIQTypeToString(IQ::Type type) {
- switch (type) {
- case IQ::Get: return "get";
- case IQ::Set: return "set";
- case IQ::Result: return "result";
- case IQ::Error: return "error";
- }
- assert(false);
- return "";
+ switch (type) {
+ case IQ::Get: return "get";
+ case IQ::Set: return "set";
+ case IQ::Result: return "result";
+ case IQ::Error: return "error";
+ }
+ assert(false);
+ return "";
}
IQ::Type IQConvertor::convertIQTypeFromString(const std::string& type) {
- if (type == "get") {
- return IQ::Get;
- }
- else if (type == "set") {
- return IQ::Set;
- }
- else {
- throw Lua::Exception("Illegal query type: '" + type + "'");
- }
+ if (type == "get") {
+ return IQ::Get;
+ }
+ else if (type == "set") {
+ return IQ::Set;
+ }
+ else {
+ throw Lua::Exception("Illegal query type: '" + type + "'");
+ }
}
diff --git a/Sluift/ElementConvertors/IQConvertor.h b/Sluift/ElementConvertors/IQConvertor.h
index b5351b7..859900a 100644
--- a/Sluift/ElementConvertors/IQConvertor.h
+++ b/Sluift/ElementConvertors/IQConvertor.h
@@ -1,33 +1,34 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/ElementConvertors/StanzaConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/IQ.h>
+#include <Sluift/ElementConvertors/StanzaConvertor.h>
+
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class IQConvertor : public StanzaConvertor<IQ> {
- public:
- IQConvertor(LuaElementConvertors* convertors);
- virtual ~IQConvertor();
+ class IQConvertor : public StanzaConvertor<IQ> {
+ public:
+ IQConvertor(LuaElementConvertors* convertors);
+ virtual ~IQConvertor();
- virtual boost::shared_ptr<IQ> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<IQ>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<IQ> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<IQ>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- static std::string convertIQTypeToString(IQ::Type type);
- static IQ::Type convertIQTypeFromString(const std::string& type);
+ static std::string convertIQTypeToString(IQ::Type type);
+ static IQ::Type convertIQTypeFromString(const std::string& type);
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/IsodeIQDelegationConvertor.cpp b/Sluift/ElementConvertors/IsodeIQDelegationConvertor.cpp
index c60a7aa..56b4a80 100644
--- a/Sluift/ElementConvertors/IsodeIQDelegationConvertor.cpp
+++ b/Sluift/ElementConvertors/IsodeIQDelegationConvertor.cpp
@@ -1,52 +1,50 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/IsodeIQDelegationConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-IsodeIQDelegationConvertor::IsodeIQDelegationConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<IsodeIQDelegation>("isode_iq_delegation"),
- convertors(convertors) {
+IsodeIQDelegationConvertor::IsodeIQDelegationConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<IsodeIQDelegation>("isode_iq_delegation"),
+ convertors(convertors) {
}
IsodeIQDelegationConvertor::~IsodeIQDelegationConvertor() {
}
-boost::shared_ptr<IsodeIQDelegation> IsodeIQDelegationConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<IsodeIQDelegation> result = boost::make_shared<IsodeIQDelegation>();
- lua_getfield(L, -1, "forward");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Forwarded> payload = boost::dynamic_pointer_cast<Forwarded>(convertors->convertFromLuaUntyped(L, -1, "forwarded"))) {
- result->setForward(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<IsodeIQDelegation> IsodeIQDelegationConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<IsodeIQDelegation> result = std::make_shared<IsodeIQDelegation>();
+ lua_getfield(L, -1, "forward");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Forwarded> payload = std::dynamic_pointer_cast<Forwarded>(convertors->convertFromLuaUntyped(L, -1, "forwarded"))) {
+ result->setForward(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void IsodeIQDelegationConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<IsodeIQDelegation> payload) {
- lua_createtable(L, 0, 0);
- if (convertors->convertToLuaUntyped(L, payload->getForward()) > 0) {
- lua_setfield(L, -2, "forward");
- }
+void IsodeIQDelegationConvertor::doConvertToLua(lua_State* L, std::shared_ptr<IsodeIQDelegation> payload) {
+ lua_createtable(L, 0, 0);
+ if (convertors->convertToLuaUntyped(L, payload->getForward()) > 0) {
+ lua_setfield(L, -2, "forward");
+ }
}
boost::optional<LuaElementConvertor::Documentation> IsodeIQDelegationConvertor::getDocumentation() const {
- return Documentation(
- "IsodeIQDelegation",
- "This table has the following fields:\n\n"
- "- `forward`: @{Forwarded}\n"
- );
+ return Documentation(
+ "IsodeIQDelegation",
+ "This table has the following fields:\n\n"
+ "- `forward`: @{Forwarded}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h b/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h
index 5af4944..f8b8c4a 100644
--- a/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h
+++ b/Sluift/ElementConvertors/IsodeIQDelegationConvertor.h
@@ -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.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/IsodeIQDelegation.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/IsodeIQDelegation.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class IsodeIQDelegationConvertor : public GenericLuaElementConvertor<IsodeIQDelegation> {
- public:
- IsodeIQDelegationConvertor(LuaElementConvertors* convertors);
- virtual ~IsodeIQDelegationConvertor();
+ class IsodeIQDelegationConvertor : public GenericLuaElementConvertor<IsodeIQDelegation> {
+ public:
+ IsodeIQDelegationConvertor(LuaElementConvertors* convertors);
+ virtual ~IsodeIQDelegationConvertor();
- virtual boost::shared_ptr<IsodeIQDelegation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<IsodeIQDelegation>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<IsodeIQDelegation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<IsodeIQDelegation>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/MAMFinConvertor.cpp b/Sluift/ElementConvertors/MAMFinConvertor.cpp
index 25e4406..4fb8201 100644
--- a/Sluift/ElementConvertors/MAMFinConvertor.cpp
+++ b/Sluift/ElementConvertors/MAMFinConvertor.cpp
@@ -1,78 +1,81 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
+#include <Sluift/ElementConvertors/MAMFinConvertor.h>
+
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+
#include <lua.hpp>
-#include <Sluift/ElementConvertors/MAMFinConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
+
#include <Swiften/Elements/ResultSet.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-MAMFinConvertor::MAMFinConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<MAMFin>("mam_fin"),
- convertors(convertors) {
+MAMFinConvertor::MAMFinConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<MAMFin>("mam_fin"),
+ convertors(convertors) {
}
MAMFinConvertor::~MAMFinConvertor() {
}
-boost::shared_ptr<MAMFin> MAMFinConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<MAMFin> result = boost::make_shared<MAMFin>();
- lua_getfield(L, -1, "query_id");
- if (lua_isstring(L, -1)) {
- result->setQueryID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "complete");
- if (lua_isboolean(L, -1)) {
- result->setComplete(lua_toboolean(L, -1) != 0);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "stable");
- if (!lua_isnil(L, -1)) {
- result->setStable(lua_toboolean(L, -1) != 0);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "result_set");
- if (!lua_isnil(L, -1)) {
- boost::shared_ptr<ResultSet> resultSet = boost::dynamic_pointer_cast<ResultSet>(convertors->convertFromLuaUntyped(L, -1, "result_set"));
- if (!!resultSet) {
- result->setResultSet(resultSet);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<MAMFin> MAMFinConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<MAMFin> result = std::make_shared<MAMFin>();
+ lua_getfield(L, -1, "query_id");
+ if (lua_isstring(L, -1)) {
+ result->setQueryID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "complete");
+ if (lua_isboolean(L, -1)) {
+ result->setComplete(lua_toboolean(L, -1) != 0);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "stable");
+ if (!lua_isnil(L, -1)) {
+ result->setStable(lua_toboolean(L, -1) != 0);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "result_set");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<ResultSet> resultSet = std::dynamic_pointer_cast<ResultSet>(convertors->convertFromLuaUntyped(L, -1, "result_set"));
+ if (!!resultSet) {
+ result->setResultSet(resultSet);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void MAMFinConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<MAMFin> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getQueryID()) {
- lua_pushstring(L, (*payload->getQueryID()).c_str());
- lua_setfield(L, -2, "query_id");
- }
- lua_pushboolean(L, payload->isComplete());
- lua_setfield(L, -2, "complete");
- lua_pushboolean(L, payload->isStable());
- lua_setfield(L, -2, "stable");
- if (convertors->convertToLuaUntyped(L, payload->getResultSet()) > 0) {
- lua_setfield(L, -2, "result_set");
- }
+void MAMFinConvertor::doConvertToLua(lua_State* L, std::shared_ptr<MAMFin> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getQueryID()) {
+ lua_pushstring(L, (*payload->getQueryID()).c_str());
+ lua_setfield(L, -2, "query_id");
+ }
+ lua_pushboolean(L, payload->isComplete());
+ lua_setfield(L, -2, "complete");
+ lua_pushboolean(L, payload->isStable());
+ lua_setfield(L, -2, "stable");
+ if (convertors->convertToLuaUntyped(L, payload->getResultSet()) > 0) {
+ lua_setfield(L, -2, "result_set");
+ }
}
boost::optional<LuaElementConvertor::Documentation> MAMFinConvertor::getDocumentation() const {
- return Documentation(
- "MAMFin",
- "This table has the following fields:\n\n"
- "- `query_id`: string (Optional)\n"
- "- `complete`: boolean (Optional)\n"
- "- `stable`: boolean (Optional)\n"
- "- `result_set`: @{ResultSet} (Optional)\n"
- );
+ return Documentation(
+ "MAMFin",
+ "This table has the following fields:\n\n"
+ "- `query_id`: string (Optional)\n"
+ "- `complete`: boolean (Optional)\n"
+ "- `stable`: boolean (Optional)\n"
+ "- `result_set`: @{ResultSet} (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/MAMFinConvertor.h b/Sluift/ElementConvertors/MAMFinConvertor.h
index 4021c00..371076a 100644
--- a/Sluift/ElementConvertors/MAMFinConvertor.h
+++ b/Sluift/ElementConvertors/MAMFinConvertor.h
@@ -1,29 +1,30 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/GenericLuaElementConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MAMFin.h>
+#include <Sluift/GenericLuaElementConvertor.h>
+
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class MAMFinConvertor : public GenericLuaElementConvertor<MAMFin> {
- public:
- MAMFinConvertor(LuaElementConvertors* convertors);
- virtual ~MAMFinConvertor();
+ class MAMFinConvertor : public GenericLuaElementConvertor<MAMFin> {
+ public:
+ MAMFinConvertor(LuaElementConvertors* convertors);
+ virtual ~MAMFinConvertor();
- virtual boost::shared_ptr<MAMFin> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<MAMFin>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<MAMFin> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMFin>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/MAMQueryConvertor.cpp b/Sluift/ElementConvertors/MAMQueryConvertor.cpp
index d53fd9b..52337ce 100644
--- a/Sluift/ElementConvertors/MAMQueryConvertor.cpp
+++ b/Sluift/ElementConvertors/MAMQueryConvertor.cpp
@@ -1,85 +1,88 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
+#include <Sluift/ElementConvertors/MAMQueryConvertor.h>
+
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+
#include <lua.hpp>
-#include <Sluift/ElementConvertors/MAMQueryConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
+
#include <Swiften/Elements/Form.h>
#include <Swiften/Elements/ResultSet.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-MAMQueryConvertor::MAMQueryConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<MAMQuery>("mam"),
- convertors(convertors) {
+MAMQueryConvertor::MAMQueryConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<MAMQuery>("mam"),
+ convertors(convertors) {
}
MAMQueryConvertor::~MAMQueryConvertor() {
}
-boost::shared_ptr<MAMQuery> MAMQueryConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<MAMQuery> result = boost::make_shared<MAMQuery>();
- lua_getfield(L, -1, "query_id");
- if (lua_isstring(L, -1)) {
- result->setQueryID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "form");
- if (!lua_isnil(L, -1)) {
- boost::shared_ptr<Form> form = boost::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"));
- if (!!form) {
- result->setForm(form);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "result_set");
- if (!lua_isnil(L, -1)) {
- boost::shared_ptr<ResultSet> resultSet = boost::dynamic_pointer_cast<ResultSet>(convertors->convertFromLuaUntyped(L, -1, "result_set"));
- if (!!resultSet) {
- result->setResultSet(resultSet);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<MAMQuery> MAMQueryConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<MAMQuery> result = std::make_shared<MAMQuery>();
+ lua_getfield(L, -1, "query_id");
+ if (lua_isstring(L, -1)) {
+ result->setQueryID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "form");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<Form> form = std::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"));
+ if (!!form) {
+ result->setForm(form);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "result_set");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<ResultSet> resultSet = std::dynamic_pointer_cast<ResultSet>(convertors->convertFromLuaUntyped(L, -1, "result_set"));
+ if (!!resultSet) {
+ result->setResultSet(resultSet);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void MAMQueryConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<MAMQuery> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getQueryID()) {
- lua_pushstring(L, (*payload->getQueryID()).c_str());
- lua_setfield(L, -2, "query_id");
- }
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- if (convertors->convertToLuaUntyped(L, payload->getForm()) > 0) {
- lua_setfield(L, -2, "form");
- }
- if (convertors->convertToLuaUntyped(L, payload->getResultSet()) > 0) {
- lua_setfield(L, -2, "result_set");
- }
+void MAMQueryConvertor::doConvertToLua(lua_State* L, std::shared_ptr<MAMQuery> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getQueryID()) {
+ lua_pushstring(L, (*payload->getQueryID()).c_str());
+ lua_setfield(L, -2, "query_id");
+ }
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (convertors->convertToLuaUntyped(L, payload->getForm()) > 0) {
+ lua_setfield(L, -2, "form");
+ }
+ if (convertors->convertToLuaUntyped(L, payload->getResultSet()) > 0) {
+ lua_setfield(L, -2, "result_set");
+ }
}
boost::optional<LuaElementConvertor::Documentation> MAMQueryConvertor::getDocumentation() const {
- return Documentation(
- "MAMQuery",
- "This table has the following fields:\n\n"
- "- `query_id`: string (Optional)\n"
- "- `node`: string (Optional)\n"
- "- `form`: string @{Form} (Optional)\n"
- "- `result_set`: @{ResultSet} (Optional)\n"
- );
+ return Documentation(
+ "MAMQuery",
+ "This table has the following fields:\n\n"
+ "- `query_id`: string (Optional)\n"
+ "- `node`: string (Optional)\n"
+ "- `form`: string @{Form} (Optional)\n"
+ "- `result_set`: @{ResultSet} (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/MAMQueryConvertor.h b/Sluift/ElementConvertors/MAMQueryConvertor.h
index 5169607..4ee119e 100644
--- a/Sluift/ElementConvertors/MAMQueryConvertor.h
+++ b/Sluift/ElementConvertors/MAMQueryConvertor.h
@@ -1,29 +1,30 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/GenericLuaElementConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MAMQuery.h>
+#include <Sluift/GenericLuaElementConvertor.h>
+
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class MAMQueryConvertor : public GenericLuaElementConvertor<MAMQuery> {
- public:
- MAMQueryConvertor(LuaElementConvertors* convertors);
- virtual ~MAMQueryConvertor();
+ class MAMQueryConvertor : public GenericLuaElementConvertor<MAMQuery> {
+ public:
+ MAMQueryConvertor(LuaElementConvertors* convertors);
+ virtual ~MAMQueryConvertor();
- virtual boost::shared_ptr<MAMQuery> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<MAMQuery>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<MAMQuery> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMQuery>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/MAMResultConvertor.cpp b/Sluift/ElementConvertors/MAMResultConvertor.cpp
index c163201..25b4c39 100644
--- a/Sluift/ElementConvertors/MAMResultConvertor.cpp
+++ b/Sluift/ElementConvertors/MAMResultConvertor.cpp
@@ -1,71 +1,73 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
+#include <Sluift/ElementConvertors/MAMResultConvertor.h>
+
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+
#include <lua.hpp>
-#include <Sluift/ElementConvertors/MAMResultConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Elements/Forwarded.h>
+#include <Swiften/Elements/Forwarded.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-MAMResultConvertor::MAMResultConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<MAMResult>("mam_result"),
- convertors(convertors) {
+MAMResultConvertor::MAMResultConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<MAMResult>("mam_result"),
+ convertors(convertors) {
}
MAMResultConvertor::~MAMResultConvertor() {
}
-boost::shared_ptr<MAMResult> MAMResultConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<MAMResult> result = boost::make_shared<MAMResult>();
- lua_getfield(L, -1, "payload");
- if (!lua_isnil(L, -1)) {
- boost::shared_ptr<Forwarded> payload = boost::dynamic_pointer_cast<Forwarded>(convertors->convertFromLuaUntyped(L, -1, "payload"));
- if (!!payload) {
- result->setPayload(payload);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "id");
- if (lua_isstring(L, -1)) {
- result->setID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "query_id");
- if (lua_isstring(L, -1)) {
- result->setQueryID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<MAMResult> MAMResultConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<MAMResult> result = std::make_shared<MAMResult>();
+ lua_getfield(L, -1, "payload");
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<Forwarded> payload = std::dynamic_pointer_cast<Forwarded>(convertors->convertFromLuaUntyped(L, -1, "payload"));
+ if (!!payload) {
+ result->setPayload(payload);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "id");
+ if (lua_isstring(L, -1)) {
+ result->setID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "query_id");
+ if (lua_isstring(L, -1)) {
+ result->setQueryID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void MAMResultConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<MAMResult> payload) {
- lua_createtable(L, 0, 0);
- if (convertors->convertToLuaUntyped(L, payload->getPayload()) > 0) {
- lua_setfield(L, -2, "payload");
- }
- lua_pushstring(L, payload->getID().c_str());
- lua_setfield(L, -2, "id");
- if (payload->getQueryID()) {
- lua_pushstring(L, (*payload->getQueryID()).c_str());
- lua_setfield(L, -2, "query_id");
- }
+void MAMResultConvertor::doConvertToLua(lua_State* L, std::shared_ptr<MAMResult> payload) {
+ lua_createtable(L, 0, 0);
+ if (convertors->convertToLuaUntyped(L, payload->getPayload()) > 0) {
+ lua_setfield(L, -2, "payload");
+ }
+ lua_pushstring(L, payload->getID().c_str());
+ lua_setfield(L, -2, "id");
+ if (payload->getQueryID()) {
+ lua_pushstring(L, (*payload->getQueryID()).c_str());
+ lua_setfield(L, -2, "query_id");
+ }
}
boost::optional<LuaElementConvertor::Documentation> MAMResultConvertor::getDocumentation() const {
- return Documentation(
- "MAMResult",
- "This table has the following fields:\n\n"
- "- `payload`: @{Forwarded}\n"
- "- `id`: string\n"
- "- `query_id`: string (Optional)\n"
- );
+ return Documentation(
+ "MAMResult",
+ "This table has the following fields:\n\n"
+ "- `payload`: @{Forwarded}\n"
+ "- `id`: string\n"
+ "- `query_id`: string (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/MAMResultConvertor.h b/Sluift/ElementConvertors/MAMResultConvertor.h
index 65d430a..a1b2564 100644
--- a/Sluift/ElementConvertors/MAMResultConvertor.h
+++ b/Sluift/ElementConvertors/MAMResultConvertor.h
@@ -1,29 +1,30 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/GenericLuaElementConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/MAMResult.h>
+#include <Sluift/GenericLuaElementConvertor.h>
+
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class MAMResultConvertor : public GenericLuaElementConvertor<MAMResult> {
- public:
- MAMResultConvertor(LuaElementConvertors* convertors);
- virtual ~MAMResultConvertor();
+ class MAMResultConvertor : public GenericLuaElementConvertor<MAMResult> {
+ public:
+ MAMResultConvertor(LuaElementConvertors* convertors);
+ virtual ~MAMResultConvertor();
- virtual boost::shared_ptr<MAMResult> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<MAMResult>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<MAMResult> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<MAMResult>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/MessageConvertor.cpp b/Sluift/ElementConvertors/MessageConvertor.cpp
index d56e680..b7bf286 100644
--- a/Sluift/ElementConvertors/MessageConvertor.cpp
+++ b/Sluift/ElementConvertors/MessageConvertor.cpp
@@ -1,84 +1,85 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#include <boost/smart_ptr/make_shared.hpp>
-#include <lua.hpp>
#include <Sluift/ElementConvertors/MessageConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <memory>
+
+#include <lua.hpp>
+
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-MessageConvertor::MessageConvertor(LuaElementConvertors* convertors) :
- StanzaConvertor<Message>("message"),
- convertors(convertors) {
+MessageConvertor::MessageConvertor(LuaElementConvertors* convertors) :
+ StanzaConvertor<Message>("message"),
+ convertors(convertors) {
}
MessageConvertor::~MessageConvertor() {
}
-boost::shared_ptr<Message> MessageConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Message> result = getStanza(L, convertors);
- lua_getfield(L, -1, "type");
- if (lua_isstring(L, -1)) {
- result->setType(convertMessageTypeFromString(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<Message> MessageConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Message> result = getStanza(L, convertors);
+ lua_getfield(L, -1, "type");
+ if (lua_isstring(L, -1)) {
+ result->setType(convertMessageTypeFromString(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void MessageConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Message> stanza) {
- pushStanza(L, stanza, convertors);
- const std::string type = convertMessageTypeToString(stanza->getType());
- lua_pushstring(L, type.c_str());
- lua_setfield(L, -2, "type");
+void MessageConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Message> stanza) {
+ pushStanza(L, stanza, convertors);
+ const std::string type = convertMessageTypeToString(stanza->getType());
+ lua_pushstring(L, type.c_str());
+ lua_setfield(L, -2, "type");
}
boost::optional<LuaElementConvertor::Documentation> MessageConvertor::getDocumentation() const {
- return Documentation(
- "Message",
- "This table has the following fields:\n\n"
- "- `type`: string\n"
- "- `id`: string\n"
- "- `from`: string\n"
- "- `to`: string\n"
- "- `payloads`: array<@{Payload}>\n"
- );
+ return Documentation(
+ "Message",
+ "This table has the following fields:\n\n"
+ "- `type`: string\n"
+ "- `id`: string\n"
+ "- `from`: string\n"
+ "- `to`: string\n"
+ "- `payloads`: array<@{Payload}>\n"
+ );
}
std::string MessageConvertor::convertMessageTypeToString(Message::Type type) {
- switch (type) {
- case Message::Normal: return "normal";
- case Message::Chat: return "chat";
- case Message::Error: return "error";
- case Message::Groupchat: return "groupchat";
- case Message::Headline: return "headline";
- }
- assert(false);
- return "";
+ switch (type) {
+ case Message::Normal: return "normal";
+ case Message::Chat: return "chat";
+ case Message::Error: return "error";
+ case Message::Groupchat: return "groupchat";
+ case Message::Headline: return "headline";
+ }
+ assert(false);
+ return "";
}
Message::Type MessageConvertor::convertMessageTypeFromString(const std::string& type) {
- if (type == "normal") {
- return Message::Normal;
- }
- else if (type == "chat") {
- return Message::Chat;
- }
- else if (type == "error") {
- return Message::Error;
- }
- else if (type == "groupchat") {
- return Message::Groupchat;
- }
- else if (type == "headline") {
- return Message::Headline;
- }
- else {
- throw Lua::Exception("Illegal message type: '" + type + "'");
- }
+ if (type == "normal") {
+ return Message::Normal;
+ }
+ else if (type == "chat") {
+ return Message::Chat;
+ }
+ else if (type == "error") {
+ return Message::Error;
+ }
+ else if (type == "groupchat") {
+ return Message::Groupchat;
+ }
+ else if (type == "headline") {
+ return Message::Headline;
+ }
+ else {
+ throw Lua::Exception("Illegal message type: '" + type + "'");
+ }
}
diff --git a/Sluift/ElementConvertors/MessageConvertor.h b/Sluift/ElementConvertors/MessageConvertor.h
index f0da885..2031552 100644
--- a/Sluift/ElementConvertors/MessageConvertor.h
+++ b/Sluift/ElementConvertors/MessageConvertor.h
@@ -1,33 +1,34 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/ElementConvertors/StanzaConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Message.h>
+#include <Sluift/ElementConvertors/StanzaConvertor.h>
+
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class MessageConvertor : public StanzaConvertor<Message> {
- public:
- MessageConvertor(LuaElementConvertors* convertors);
- virtual ~MessageConvertor();
+ class MessageConvertor : public StanzaConvertor<Message> {
+ public:
+ MessageConvertor(LuaElementConvertors* convertors);
+ virtual ~MessageConvertor();
- virtual boost::shared_ptr<Message> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Message>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<Message> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Message>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- static std::string convertMessageTypeToString(Message::Type type);
- static Message::Type convertMessageTypeFromString(const std::string& type);
+ static std::string convertMessageTypeToString(Message::Type type);
+ static Message::Type convertMessageTypeFromString(const std::string& type);
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PresenceConvertor.cpp b/Sluift/ElementConvertors/PresenceConvertor.cpp
index 4ab178c..abfac77 100644
--- a/Sluift/ElementConvertors/PresenceConvertor.cpp
+++ b/Sluift/ElementConvertors/PresenceConvertor.cpp
@@ -1,96 +1,97 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#include <boost/smart_ptr/make_shared.hpp>
-#include <lua.hpp>
#include <Sluift/ElementConvertors/PresenceConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <memory>
+
+#include <lua.hpp>
+
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PresenceConvertor::PresenceConvertor(LuaElementConvertors* convertors) :
- StanzaConvertor<Presence>("presence"),
- convertors(convertors) {
+PresenceConvertor::PresenceConvertor(LuaElementConvertors* convertors) :
+ StanzaConvertor<Presence>("presence"),
+ convertors(convertors) {
}
PresenceConvertor::~PresenceConvertor() {
}
-boost::shared_ptr<Presence> PresenceConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Presence> result = getStanza(L, convertors);
- lua_getfield(L, -1, "type");
- if (lua_isstring(L, -1)) {
- result->setType(convertPresenceTypeFromString(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<Presence> PresenceConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Presence> result = getStanza(L, convertors);
+ lua_getfield(L, -1, "type");
+ if (lua_isstring(L, -1)) {
+ result->setType(convertPresenceTypeFromString(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PresenceConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Presence> stanza) {
- pushStanza(L, stanza, convertors);
- const std::string type = convertPresenceTypeToString(stanza->getType());
- lua_pushstring(L, type.c_str());
- lua_setfield(L, -2, "type");
+void PresenceConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Presence> stanza) {
+ pushStanza(L, stanza, convertors);
+ const std::string type = convertPresenceTypeToString(stanza->getType());
+ lua_pushstring(L, type.c_str());
+ lua_setfield(L, -2, "type");
}
boost::optional<LuaElementConvertor::Documentation> PresenceConvertor::getDocumentation() const {
- return Documentation(
- "Presence",
- "This table has the following fields:\n\n"
- "- `type`: string\n"
- "- `id`: string\n"
- "- `from`: string\n"
- "- `to`: string\n"
- "- `payloads`: array<@{Payload}>\n"
- );
+ return Documentation(
+ "Presence",
+ "This table has the following fields:\n\n"
+ "- `type`: string\n"
+ "- `id`: string\n"
+ "- `from`: string\n"
+ "- `to`: string\n"
+ "- `payloads`: array<@{Payload}>\n"
+ );
}
std::string PresenceConvertor::convertPresenceTypeToString(Presence::Type type) {
- switch (type) {
- case Presence::Available: return "available";
- case Presence::Error: return "error";
- case Presence::Probe: return "probe";
- case Presence::Subscribe: return "subscribe";
- case Presence::Subscribed: return "subscribed";
- case Presence::Unavailable: return "unavailable";
- case Presence::Unsubscribe: return "unsubscribe";
- case Presence::Unsubscribed: return "unsubscribed";
- }
- assert(false);
- return "";
+ switch (type) {
+ case Presence::Available: return "available";
+ case Presence::Error: return "error";
+ case Presence::Probe: return "probe";
+ case Presence::Subscribe: return "subscribe";
+ case Presence::Subscribed: return "subscribed";
+ case Presence::Unavailable: return "unavailable";
+ case Presence::Unsubscribe: return "unsubscribe";
+ case Presence::Unsubscribed: return "unsubscribed";
+ }
+ assert(false);
+ return "";
}
Presence::Type PresenceConvertor::convertPresenceTypeFromString(const std::string& type) {
- if (type == "available") {
- return Presence::Available;
- }
- else if (type == "error") {
- return Presence::Error;
- }
- else if (type == "probe") {
- return Presence::Probe;
- }
- else if (type == "subscribe") {
- return Presence::Subscribe;
- }
- else if (type == "subscribed") {
- return Presence::Subscribed;
- }
- else if (type == "unavailable") {
- return Presence::Unavailable;
- }
- else if (type == "unsubscribe") {
- return Presence::Unsubscribe;
- }
- else if (type == "unsubscribed") {
- return Presence::Unsubscribed;
- }
- else {
- throw Lua::Exception("Illegal presence type: '" + type + "'");
- }
+ if (type == "available") {
+ return Presence::Available;
+ }
+ else if (type == "error") {
+ return Presence::Error;
+ }
+ else if (type == "probe") {
+ return Presence::Probe;
+ }
+ else if (type == "subscribe") {
+ return Presence::Subscribe;
+ }
+ else if (type == "subscribed") {
+ return Presence::Subscribed;
+ }
+ else if (type == "unavailable") {
+ return Presence::Unavailable;
+ }
+ else if (type == "unsubscribe") {
+ return Presence::Unsubscribe;
+ }
+ else if (type == "unsubscribed") {
+ return Presence::Unsubscribed;
+ }
+ else {
+ throw Lua::Exception("Illegal presence type: '" + type + "'");
+ }
}
diff --git a/Sluift/ElementConvertors/PresenceConvertor.h b/Sluift/ElementConvertors/PresenceConvertor.h
index fc4326e..11ec547 100644
--- a/Sluift/ElementConvertors/PresenceConvertor.h
+++ b/Sluift/ElementConvertors/PresenceConvertor.h
@@ -1,33 +1,34 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/ElementConvertors/StanzaConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/Presence.h>
+#include <Sluift/ElementConvertors/StanzaConvertor.h>
+
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PresenceConvertor : public StanzaConvertor<Presence> {
- public:
- PresenceConvertor(LuaElementConvertors* convertors);
- virtual ~PresenceConvertor();
+ class PresenceConvertor : public StanzaConvertor<Presence> {
+ public:
+ PresenceConvertor(LuaElementConvertors* convertors);
+ virtual ~PresenceConvertor();
- virtual boost::shared_ptr<Presence> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Presence>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<Presence> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Presence>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- static std::string convertPresenceTypeToString(Presence::Type type);
- static Presence::Type convertPresenceTypeFromString(const std::string& type);
+ static std::string convertPresenceTypeToString(Presence::Type type);
+ static Presence::Type convertPresenceTypeFromString(const std::string& type);
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubAffiliationConvertor.cpp b/Sluift/ElementConvertors/PubSubAffiliationConvertor.cpp
index c35488d..62a2b60 100644
--- a/Sluift/ElementConvertors/PubSubAffiliationConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubAffiliationConvertor.cpp
@@ -1,93 +1,88 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubAffiliationConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubAffiliationConvertor::PubSubAffiliationConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubAffiliation>("pubsub_affiliation"),
- convertors(convertors) {
+PubSubAffiliationConvertor::PubSubAffiliationConvertor() :
+ GenericLuaElementConvertor<PubSubAffiliation>("pubsub_affiliation") {
}
PubSubAffiliationConvertor::~PubSubAffiliationConvertor() {
}
-boost::shared_ptr<PubSubAffiliation> PubSubAffiliationConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubAffiliation> result = boost::make_shared<PubSubAffiliation>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "type");
- if (lua_isstring(L, -1)) {
- if (std::string(lua_tostring(L, -1)) == "none") {
- result->setType(PubSubAffiliation::None);
- }
- if (std::string(lua_tostring(L, -1)) == "member") {
- result->setType(PubSubAffiliation::Member);
- }
- if (std::string(lua_tostring(L, -1)) == "outcast") {
- result->setType(PubSubAffiliation::Outcast);
- }
- if (std::string(lua_tostring(L, -1)) == "owner") {
- result->setType(PubSubAffiliation::Owner);
- }
- if (std::string(lua_tostring(L, -1)) == "publisher") {
- result->setType(PubSubAffiliation::Publisher);
- }
- if (std::string(lua_tostring(L, -1)) == "publish_only") {
- result->setType(PubSubAffiliation::PublishOnly);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubAffiliation> PubSubAffiliationConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubAffiliation> result = std::make_shared<PubSubAffiliation>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "type");
+ if (lua_isstring(L, -1)) {
+ if (std::string(lua_tostring(L, -1)) == "none") {
+ result->setType(PubSubAffiliation::None);
+ }
+ if (std::string(lua_tostring(L, -1)) == "member") {
+ result->setType(PubSubAffiliation::Member);
+ }
+ if (std::string(lua_tostring(L, -1)) == "outcast") {
+ result->setType(PubSubAffiliation::Outcast);
+ }
+ if (std::string(lua_tostring(L, -1)) == "owner") {
+ result->setType(PubSubAffiliation::Owner);
+ }
+ if (std::string(lua_tostring(L, -1)) == "publisher") {
+ result->setType(PubSubAffiliation::Publisher);
+ }
+ if (std::string(lua_tostring(L, -1)) == "publish_only") {
+ result->setType(PubSubAffiliation::PublishOnly);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubAffiliationConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubAffiliation> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- switch (payload->getType()) {
- case PubSubAffiliation::None:
- lua_pushstring(L, "none");
- break;
- case PubSubAffiliation::Member:
- lua_pushstring(L, "member");
- break;
- case PubSubAffiliation::Outcast:
- lua_pushstring(L, "outcast");
- break;
- case PubSubAffiliation::Owner:
- lua_pushstring(L, "owner");
- break;
- case PubSubAffiliation::Publisher:
- lua_pushstring(L, "publisher");
- break;
- case PubSubAffiliation::PublishOnly:
- lua_pushstring(L, "publish_only");
- break;
- }
- lua_setfield(L, -2, "type");
+void PubSubAffiliationConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubAffiliation> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ switch (payload->getType()) {
+ case PubSubAffiliation::None:
+ lua_pushstring(L, "none");
+ break;
+ case PubSubAffiliation::Member:
+ lua_pushstring(L, "member");
+ break;
+ case PubSubAffiliation::Outcast:
+ lua_pushstring(L, "outcast");
+ break;
+ case PubSubAffiliation::Owner:
+ lua_pushstring(L, "owner");
+ break;
+ case PubSubAffiliation::Publisher:
+ lua_pushstring(L, "publisher");
+ break;
+ case PubSubAffiliation::PublishOnly:
+ lua_pushstring(L, "publish_only");
+ break;
+ }
+ lua_setfield(L, -2, "type");
}
boost::optional<LuaElementConvertor::Documentation> PubSubAffiliationConvertor::getDocumentation() const {
- return Documentation(
- "PubSubAffiliation",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `type`: `\"none\"`, `\"member\"`, `\"outcast\"`, `\"owner\"`, `\"publisher\"`, or `\"publish_only\"`\n"
- );
+ return Documentation(
+ "PubSubAffiliation",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `type`: `\"none\"`, `\"member\"`, `\"outcast\"`, `\"owner\"`, `\"publisher\"`, or `\"publish_only\"`\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubAffiliationConvertor.h b/Sluift/ElementConvertors/PubSubAffiliationConvertor.h
index 846dc38..456ef4e 100644
--- a/Sluift/ElementConvertors/PubSubAffiliationConvertor.h
+++ b/Sluift/ElementConvertors/PubSubAffiliationConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubAffiliation.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubAffiliation.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubAffiliationConvertor : public GenericLuaElementConvertor<PubSubAffiliation> {
- public:
- PubSubAffiliationConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubAffiliationConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubAffiliation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubAffiliation>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubAffiliationConvertor : public GenericLuaElementConvertor<PubSubAffiliation> {
+ public:
+ PubSubAffiliationConvertor();
+ virtual ~PubSubAffiliationConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubAffiliation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubAffiliation>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp
index a338eda..c6ba09e 100644
--- a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.cpp
@@ -1,79 +1,78 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubAffiliationsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubAffiliationsConvertor::PubSubAffiliationsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubAffiliations>("pubsub_affiliations"),
- convertors(convertors) {
+PubSubAffiliationsConvertor::PubSubAffiliationsConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubAffiliations>("pubsub_affiliations"),
+ convertors(convertors) {
}
PubSubAffiliationsConvertor::~PubSubAffiliationsConvertor() {
}
-boost::shared_ptr<PubSubAffiliations> PubSubAffiliationsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubAffiliations> result = boost::make_shared<PubSubAffiliations>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubAffiliation> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubAffiliation> payload = boost::dynamic_pointer_cast<PubSubAffiliation>(convertors->convertFromLuaUntyped(L, -1, "pubsub_affiliation"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubAffiliations> PubSubAffiliationsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubAffiliations> result = std::make_shared<PubSubAffiliations>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubAffiliation> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubAffiliation> payload = std::dynamic_pointer_cast<PubSubAffiliation>(convertors->convertFromLuaUntyped(L, -1, "pubsub_affiliation"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setAffiliations(items);
- }
- return result;
+ result->setAffiliations(items);
+ }
+ return result;
}
-void PubSubAffiliationsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubAffiliations> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- if (!payload->getAffiliations().empty()) {
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubAffiliation> item, payload->getAffiliations()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- }
+void PubSubAffiliationsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubAffiliations> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (!payload->getAffiliations().empty()) {
+ {
+ int i = 0;
+ for (auto&& item : payload->getAffiliations()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubAffiliationsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubAffiliations",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `affiliations`: array<@{PubSubAffiliation}>\n"
- );
+ return Documentation(
+ "PubSubAffiliations",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `affiliations`: array<@{PubSubAffiliation}>\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h
index f398436..8ad38b2 100644
--- a/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubAffiliationsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubAffiliations.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubAffiliations.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubAffiliationsConvertor : public GenericLuaElementConvertor<PubSubAffiliations> {
- public:
- PubSubAffiliationsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubAffiliationsConvertor();
+ class PubSubAffiliationsConvertor : public GenericLuaElementConvertor<PubSubAffiliations> {
+ public:
+ PubSubAffiliationsConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubAffiliationsConvertor();
- virtual boost::shared_ptr<PubSubAffiliations> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubAffiliations>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubAffiliations> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubAffiliations>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubConfigureConvertor.cpp b/Sluift/ElementConvertors/PubSubConfigureConvertor.cpp
index be6b978..d8bf05d 100644
--- a/Sluift/ElementConvertors/PubSubConfigureConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubConfigureConvertor.cpp
@@ -1,52 +1,50 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubConfigureConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubConfigureConvertor::PubSubConfigureConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubConfigure>("pubsub_configure"),
- convertors(convertors) {
+PubSubConfigureConvertor::PubSubConfigureConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubConfigure>("pubsub_configure"),
+ convertors(convertors) {
}
PubSubConfigureConvertor::~PubSubConfigureConvertor() {
}
-boost::shared_ptr<PubSubConfigure> PubSubConfigureConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubConfigure> result = boost::make_shared<PubSubConfigure>();
- lua_getfield(L, -1, "data");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Form> payload = boost::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
- result->setData(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubConfigure> PubSubConfigureConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubConfigure> result = std::make_shared<PubSubConfigure>();
+ lua_getfield(L, -1, "data");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Form> payload = std::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
+ result->setData(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubConfigureConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubConfigure> payload) {
- lua_createtable(L, 0, 0);
- if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
- lua_setfield(L, -2, "data");
- }
+void PubSubConfigureConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubConfigure> payload) {
+ lua_createtable(L, 0, 0);
+ if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
+ lua_setfield(L, -2, "data");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubConfigureConvertor::getDocumentation() const {
- return Documentation(
- "PubSubConfigure",
- "This table has the following fields:\n\n"
- "- `data`: @{Form}\n"
- );
+ return Documentation(
+ "PubSubConfigure",
+ "This table has the following fields:\n\n"
+ "- `data`: @{Form}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubConfigureConvertor.h b/Sluift/ElementConvertors/PubSubConfigureConvertor.h
index 4fc57b2..e41bb68 100644
--- a/Sluift/ElementConvertors/PubSubConfigureConvertor.h
+++ b/Sluift/ElementConvertors/PubSubConfigureConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubConfigure.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubConfigure.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubConfigureConvertor : public GenericLuaElementConvertor<PubSubConfigure> {
- public:
- PubSubConfigureConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubConfigureConvertor();
+ class PubSubConfigureConvertor : public GenericLuaElementConvertor<PubSubConfigure> {
+ public:
+ PubSubConfigureConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubConfigureConvertor();
- virtual boost::shared_ptr<PubSubConfigure> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubConfigure>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubConfigure> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubConfigure>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubCreateConvertor.cpp b/Sluift/ElementConvertors/PubSubCreateConvertor.cpp
index ac601d9..80553d5 100644
--- a/Sluift/ElementConvertors/PubSubCreateConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubCreateConvertor.cpp
@@ -1,60 +1,58 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubCreateConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubCreateConvertor::PubSubCreateConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubCreate>("pubsub_create"),
- convertors(convertors) {
+PubSubCreateConvertor::PubSubCreateConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubCreate>("pubsub_create"),
+ convertors(convertors) {
}
PubSubCreateConvertor::~PubSubCreateConvertor() {
}
-boost::shared_ptr<PubSubCreate> PubSubCreateConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubCreate> result = boost::make_shared<PubSubCreate>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "configure");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubConfigure> payload = boost::dynamic_pointer_cast<PubSubConfigure>(convertors->convertFromLuaUntyped(L, -1, "pubsub_configure"))) {
- result->setConfigure(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubCreate> PubSubCreateConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubCreate> result = std::make_shared<PubSubCreate>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "configure");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubConfigure> payload = std::dynamic_pointer_cast<PubSubConfigure>(convertors->convertFromLuaUntyped(L, -1, "pubsub_configure"))) {
+ result->setConfigure(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubCreateConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubCreate> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (convertors->convertToLuaUntyped(L, payload->getConfigure()) > 0) {
- lua_setfield(L, -2, "configure");
- }
+void PubSubCreateConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubCreate> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (convertors->convertToLuaUntyped(L, payload->getConfigure()) > 0) {
+ lua_setfield(L, -2, "configure");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubCreateConvertor::getDocumentation() const {
- return Documentation(
- "PubSubCreate",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `configure`: @{PubSubConfigure}\n"
- );
+ return Documentation(
+ "PubSubCreate",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `configure`: @{PubSubConfigure}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubCreateConvertor.h b/Sluift/ElementConvertors/PubSubCreateConvertor.h
index a4bf149..12c47da 100644
--- a/Sluift/ElementConvertors/PubSubCreateConvertor.h
+++ b/Sluift/ElementConvertors/PubSubCreateConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubCreate.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubCreate.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubCreateConvertor : public GenericLuaElementConvertor<PubSubCreate> {
- public:
- PubSubCreateConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubCreateConvertor();
+ class PubSubCreateConvertor : public GenericLuaElementConvertor<PubSubCreate> {
+ public:
+ PubSubCreateConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubCreateConvertor();
- virtual boost::shared_ptr<PubSubCreate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubCreate>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubCreate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubCreate>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubDefaultConvertor.cpp b/Sluift/ElementConvertors/PubSubDefaultConvertor.cpp
index e0de984..8406913 100644
--- a/Sluift/ElementConvertors/PubSubDefaultConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubDefaultConvertor.cpp
@@ -1,77 +1,72 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubDefaultConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubDefaultConvertor::PubSubDefaultConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubDefault>("pubsub_default"),
- convertors(convertors) {
+PubSubDefaultConvertor::PubSubDefaultConvertor() :
+ GenericLuaElementConvertor<PubSubDefault>("pubsub_default") {
}
PubSubDefaultConvertor::~PubSubDefaultConvertor() {
}
-boost::shared_ptr<PubSubDefault> PubSubDefaultConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubDefault> result = boost::make_shared<PubSubDefault>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "type");
- if (lua_isstring(L, -1)) {
- if (std::string(lua_tostring(L, -1)) == "none") {
- result->setType(PubSubDefault::None);
- }
- if (std::string(lua_tostring(L, -1)) == "collection") {
- result->setType(PubSubDefault::Collection);
- }
- if (std::string(lua_tostring(L, -1)) == "leaf") {
- result->setType(PubSubDefault::Leaf);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubDefault> PubSubDefaultConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubDefault> result = std::make_shared<PubSubDefault>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "type");
+ if (lua_isstring(L, -1)) {
+ if (std::string(lua_tostring(L, -1)) == "none") {
+ result->setType(PubSubDefault::None);
+ }
+ if (std::string(lua_tostring(L, -1)) == "collection") {
+ result->setType(PubSubDefault::Collection);
+ }
+ if (std::string(lua_tostring(L, -1)) == "leaf") {
+ result->setType(PubSubDefault::Leaf);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubDefaultConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubDefault> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- switch (payload->getType()) {
- case PubSubDefault::None:
- lua_pushstring(L, "none");
- break;
- case PubSubDefault::Collection:
- lua_pushstring(L, "collection");
- break;
- case PubSubDefault::Leaf:
- lua_pushstring(L, "leaf");
- break;
- }
- lua_setfield(L, -2, "type");
+void PubSubDefaultConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubDefault> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ switch (payload->getType()) {
+ case PubSubDefault::None:
+ lua_pushstring(L, "none");
+ break;
+ case PubSubDefault::Collection:
+ lua_pushstring(L, "collection");
+ break;
+ case PubSubDefault::Leaf:
+ lua_pushstring(L, "leaf");
+ break;
+ }
+ lua_setfield(L, -2, "type");
}
boost::optional<LuaElementConvertor::Documentation> PubSubDefaultConvertor::getDocumentation() const {
- return Documentation(
- "PubSubDefault",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `type`: `\"none\"`, `\"collection\"`, or `\"leaf\"`\n"
- );
+ return Documentation(
+ "PubSubDefault",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `type`: `\"none\"`, `\"collection\"`, or `\"leaf\"`\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubDefaultConvertor.h b/Sluift/ElementConvertors/PubSubDefaultConvertor.h
index 9b6a01f..fbdbf95 100644
--- a/Sluift/ElementConvertors/PubSubDefaultConvertor.h
+++ b/Sluift/ElementConvertors/PubSubDefaultConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubDefault.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubDefault.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubDefaultConvertor : public GenericLuaElementConvertor<PubSubDefault> {
- public:
- PubSubDefaultConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubDefaultConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubDefault> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubDefault>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubDefaultConvertor : public GenericLuaElementConvertor<PubSubDefault> {
+ public:
+ PubSubDefaultConvertor();
+ virtual ~PubSubDefaultConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubDefault> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubDefault>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventAssociateConvertor.cpp b/Sluift/ElementConvertors/PubSubEventAssociateConvertor.cpp
index 623ddc4..eb025a5 100644
--- a/Sluift/ElementConvertors/PubSubEventAssociateConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventAssociateConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventAssociateConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubEventAssociateConvertor::PubSubEventAssociateConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventAssociate>("pubsub_event_associate"),
- convertors(convertors) {
+PubSubEventAssociateConvertor::PubSubEventAssociateConvertor() :
+ GenericLuaElementConvertor<PubSubEventAssociate>("pubsub_event_associate") {
}
PubSubEventAssociateConvertor::~PubSubEventAssociateConvertor() {
}
-boost::shared_ptr<PubSubEventAssociate> PubSubEventAssociateConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventAssociate> result = boost::make_shared<PubSubEventAssociate>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventAssociate> PubSubEventAssociateConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventAssociate> result = std::make_shared<PubSubEventAssociate>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventAssociateConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventAssociate> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
+void PubSubEventAssociateConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventAssociate> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventAssociateConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventAssociate",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- );
+ return Documentation(
+ "PubSubEventAssociate",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h b/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h
index 6f4f3d8..975aa60 100644
--- a/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventAssociateConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventAssociate.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventAssociate.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubEventAssociateConvertor : public GenericLuaElementConvertor<PubSubEventAssociate> {
- public:
- PubSubEventAssociateConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventAssociateConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubEventAssociate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventAssociate>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubEventAssociateConvertor : public GenericLuaElementConvertor<PubSubEventAssociate> {
+ public:
+ PubSubEventAssociateConvertor();
+ virtual ~PubSubEventAssociateConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubEventAssociate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventAssociate>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventCollectionConvertor.cpp b/Sluift/ElementConvertors/PubSubEventCollectionConvertor.cpp
index 8fdfefa..721b1b4 100644
--- a/Sluift/ElementConvertors/PubSubEventCollectionConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventCollectionConvertor.cpp
@@ -1,73 +1,71 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventCollectionConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubEventCollectionConvertor::PubSubEventCollectionConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventCollection>("pubsub_event_collection"),
- convertors(convertors) {
+PubSubEventCollectionConvertor::PubSubEventCollectionConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubEventCollection>("pubsub_event_collection"),
+ convertors(convertors) {
}
PubSubEventCollectionConvertor::~PubSubEventCollectionConvertor() {
}
-boost::shared_ptr<PubSubEventCollection> PubSubEventCollectionConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventCollection> result = boost::make_shared<PubSubEventCollection>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "disassociate");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubEventDisassociate> payload = boost::dynamic_pointer_cast<PubSubEventDisassociate>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_disassociate"))) {
- result->setDisassociate(payload);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "associate");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubEventAssociate> payload = boost::dynamic_pointer_cast<PubSubEventAssociate>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_associate"))) {
- result->setAssociate(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventCollection> PubSubEventCollectionConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventCollection> result = std::make_shared<PubSubEventCollection>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "disassociate");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubEventDisassociate> payload = std::dynamic_pointer_cast<PubSubEventDisassociate>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_disassociate"))) {
+ result->setDisassociate(payload);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "associate");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubEventAssociate> payload = std::dynamic_pointer_cast<PubSubEventAssociate>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_associate"))) {
+ result->setAssociate(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventCollectionConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventCollection> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- if (convertors->convertToLuaUntyped(L, payload->getDisassociate()) > 0) {
- lua_setfield(L, -2, "disassociate");
- }
- if (convertors->convertToLuaUntyped(L, payload->getAssociate()) > 0) {
- lua_setfield(L, -2, "associate");
- }
+void PubSubEventCollectionConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventCollection> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (convertors->convertToLuaUntyped(L, payload->getDisassociate()) > 0) {
+ lua_setfield(L, -2, "disassociate");
+ }
+ if (convertors->convertToLuaUntyped(L, payload->getAssociate()) > 0) {
+ lua_setfield(L, -2, "associate");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventCollectionConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventCollection",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `disassociate`: @{PubSubEventDisassociate}\n"
- "- `associate`: @{PubSubEventAssociate}\n"
- );
+ return Documentation(
+ "PubSubEventCollection",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `disassociate`: @{PubSubEventDisassociate}\n"
+ "- `associate`: @{PubSubEventAssociate}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h b/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h
index 4226619..e8feada 100644
--- a/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventCollectionConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventCollection.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventCollection.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubEventCollectionConvertor : public GenericLuaElementConvertor<PubSubEventCollection> {
- public:
- PubSubEventCollectionConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventCollectionConvertor();
+ class PubSubEventCollectionConvertor : public GenericLuaElementConvertor<PubSubEventCollection> {
+ public:
+ PubSubEventCollectionConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubEventCollectionConvertor();
- virtual boost::shared_ptr<PubSubEventCollection> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventCollection>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubEventCollection> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventCollection>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.cpp b/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.cpp
index 56f46ec..828a010 100644
--- a/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.cpp
@@ -1,60 +1,58 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubEventConfigurationConvertor::PubSubEventConfigurationConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventConfiguration>("pubsub_event_configuration"),
- convertors(convertors) {
+PubSubEventConfigurationConvertor::PubSubEventConfigurationConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubEventConfiguration>("pubsub_event_configuration"),
+ convertors(convertors) {
}
PubSubEventConfigurationConvertor::~PubSubEventConfigurationConvertor() {
}
-boost::shared_ptr<PubSubEventConfiguration> PubSubEventConfigurationConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventConfiguration> result = boost::make_shared<PubSubEventConfiguration>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "data");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Form> payload = boost::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
- result->setData(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventConfiguration> PubSubEventConfigurationConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventConfiguration> result = std::make_shared<PubSubEventConfiguration>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "data");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Form> payload = std::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
+ result->setData(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventConfigurationConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventConfiguration> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
- lua_setfield(L, -2, "data");
- }
+void PubSubEventConfigurationConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventConfiguration> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
+ lua_setfield(L, -2, "data");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventConfigurationConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventConfiguration",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `data`: @{Form}\n"
- );
+ return Documentation(
+ "PubSubEventConfiguration",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `data`: @{Form}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h b/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h
index ce76da4..dd327d4 100644
--- a/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventConfigurationConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventConfiguration.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventConfiguration.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubEventConfigurationConvertor : public GenericLuaElementConvertor<PubSubEventConfiguration> {
- public:
- PubSubEventConfigurationConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventConfigurationConvertor();
+ class PubSubEventConfigurationConvertor : public GenericLuaElementConvertor<PubSubEventConfiguration> {
+ public:
+ PubSubEventConfigurationConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubEventConfigurationConvertor();
- virtual boost::shared_ptr<PubSubEventConfiguration> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventConfiguration>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubEventConfiguration> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventConfiguration>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventConvertor.cpp b/Sluift/ElementConvertors/PubSubEventConvertor.cpp
index ae4374c..da7c849 100644
--- a/Sluift/ElementConvertors/PubSubEventConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventConvertor.cpp
@@ -1,37 +1,35 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubEventConvertor::PubSubEventConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEvent>("pubsub_event"),
- convertors(convertors) {
+PubSubEventConvertor::PubSubEventConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubEvent>("pubsub_event"),
+ convertors(convertors) {
}
PubSubEventConvertor::~PubSubEventConvertor() {
}
-boost::shared_ptr<PubSubEvent> PubSubEventConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEvent> result = boost::make_shared<PubSubEvent>();
- if (boost::shared_ptr<PubSubEventPayload> payload = boost::dynamic_pointer_cast<PubSubEventPayload>(convertors->convertFromLua(L, -1))) {
- result->setPayload(payload);
- }
- return result;
+std::shared_ptr<PubSubEvent> PubSubEventConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEvent> result = std::make_shared<PubSubEvent>();
+ if (std::shared_ptr<PubSubEventPayload> payload = std::dynamic_pointer_cast<PubSubEventPayload>(convertors->convertFromLua(L, -1))) {
+ result->setPayload(payload);
+ }
+ return result;
}
-void PubSubEventConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEvent> event) {
- convertors->convertToLua(L, event->getPayload());
+void PubSubEventConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEvent> event) {
+ convertors->convertToLua(L, event->getPayload());
}
diff --git a/Sluift/ElementConvertors/PubSubEventConvertor.h b/Sluift/ElementConvertors/PubSubEventConvertor.h
index 3bb4594..8b0cbec 100644
--- a/Sluift/ElementConvertors/PubSubEventConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,22 +7,22 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEvent.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEvent.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubEventConvertor : public GenericLuaElementConvertor<PubSubEvent> {
- public:
- PubSubEventConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventConvertor();
+ class PubSubEventConvertor : public GenericLuaElementConvertor<PubSubEvent> {
+ public:
+ PubSubEventConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubEventConvertor();
- virtual boost::shared_ptr<PubSubEvent> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEvent>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubEvent> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEvent>) SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventDeleteConvertor.cpp b/Sluift/ElementConvertors/PubSubEventDeleteConvertor.cpp
index 29ead48..06fb3a2 100644
--- a/Sluift/ElementConvertors/PubSubEventDeleteConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventDeleteConvertor.cpp
@@ -1,60 +1,58 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventDeleteConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubEventDeleteConvertor::PubSubEventDeleteConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventDelete>("pubsub_event_delete"),
- convertors(convertors) {
+PubSubEventDeleteConvertor::PubSubEventDeleteConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubEventDelete>("pubsub_event_delete"),
+ convertors(convertors) {
}
PubSubEventDeleteConvertor::~PubSubEventDeleteConvertor() {
}
-boost::shared_ptr<PubSubEventDelete> PubSubEventDeleteConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventDelete> result = boost::make_shared<PubSubEventDelete>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "redirects");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubEventRedirect> payload = boost::dynamic_pointer_cast<PubSubEventRedirect>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_redirect"))) {
- result->setRedirects(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventDelete> PubSubEventDeleteConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventDelete> result = std::make_shared<PubSubEventDelete>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "redirects");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubEventRedirect> payload = std::dynamic_pointer_cast<PubSubEventRedirect>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_redirect"))) {
+ result->setRedirects(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventDeleteConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventDelete> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (convertors->convertToLuaUntyped(L, payload->getRedirects()) > 0) {
- lua_setfield(L, -2, "redirects");
- }
+void PubSubEventDeleteConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventDelete> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (convertors->convertToLuaUntyped(L, payload->getRedirects()) > 0) {
+ lua_setfield(L, -2, "redirects");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventDeleteConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventDelete",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `redirects`: @{PubSubEventRedirect}\n"
- );
+ return Documentation(
+ "PubSubEventDelete",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `redirects`: @{PubSubEventRedirect}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h b/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h
index e229781..ba2b0b8 100644
--- a/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventDeleteConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventDelete.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventDelete.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubEventDeleteConvertor : public GenericLuaElementConvertor<PubSubEventDelete> {
- public:
- PubSubEventDeleteConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventDeleteConvertor();
+ class PubSubEventDeleteConvertor : public GenericLuaElementConvertor<PubSubEventDelete> {
+ public:
+ PubSubEventDeleteConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubEventDeleteConvertor();
- virtual boost::shared_ptr<PubSubEventDelete> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventDelete>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubEventDelete> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventDelete>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.cpp b/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.cpp
index 9ca8395..0ada5ce 100644
--- a/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubEventDisassociateConvertor::PubSubEventDisassociateConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventDisassociate>("pubsub_event_disassociate"),
- convertors(convertors) {
+PubSubEventDisassociateConvertor::PubSubEventDisassociateConvertor() :
+ GenericLuaElementConvertor<PubSubEventDisassociate>("pubsub_event_disassociate") {
}
PubSubEventDisassociateConvertor::~PubSubEventDisassociateConvertor() {
}
-boost::shared_ptr<PubSubEventDisassociate> PubSubEventDisassociateConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventDisassociate> result = boost::make_shared<PubSubEventDisassociate>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventDisassociate> PubSubEventDisassociateConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventDisassociate> result = std::make_shared<PubSubEventDisassociate>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventDisassociateConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventDisassociate> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
+void PubSubEventDisassociateConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventDisassociate> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventDisassociateConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventDisassociate",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- );
+ return Documentation(
+ "PubSubEventDisassociate",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h b/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h
index 25a3863..0a1d678 100644
--- a/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventDisassociateConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventDisassociate.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventDisassociate.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubEventDisassociateConvertor : public GenericLuaElementConvertor<PubSubEventDisassociate> {
- public:
- PubSubEventDisassociateConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventDisassociateConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubEventDisassociate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventDisassociate>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubEventDisassociateConvertor : public GenericLuaElementConvertor<PubSubEventDisassociate> {
+ public:
+ PubSubEventDisassociateConvertor();
+ virtual ~PubSubEventDisassociateConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubEventDisassociate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventDisassociate>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp b/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp
index 43a64ff..ac86024 100644
--- a/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventItemConvertor.cpp
@@ -1,103 +1,102 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventItemConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubEventItemConvertor::PubSubEventItemConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventItem>("pubsub_event_item"),
- convertors(convertors) {
+PubSubEventItemConvertor::PubSubEventItemConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubEventItem>("pubsub_event_item"),
+ convertors(convertors) {
}
PubSubEventItemConvertor::~PubSubEventItemConvertor() {
}
-boost::shared_ptr<PubSubEventItem> PubSubEventItemConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventItem> result = boost::make_shared<PubSubEventItem>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "publisher");
- if (lua_isstring(L, -1)) {
- result->setPublisher(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "data");
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<Payload> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Payload> payload = boost::dynamic_pointer_cast<Payload>(convertors->convertFromLua(L, -1))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubEventItem> PubSubEventItemConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventItem> result = std::make_shared<PubSubEventItem>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "publisher");
+ if (lua_isstring(L, -1)) {
+ result->setPublisher(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "data");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<Payload> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Payload> payload = std::dynamic_pointer_cast<Payload>(convertors->convertFromLua(L, -1))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setData(items);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "id");
- if (lua_isstring(L, -1)) {
- result->setID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+ result->setData(items);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "id");
+ if (lua_isstring(L, -1)) {
+ result->setID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventItemConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventItem> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- if (payload->getPublisher()) {
- lua_pushstring(L, (*payload->getPublisher()).c_str());
- lua_setfield(L, -2, "publisher");
- }
- if (!payload->getData().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(payload->getData().size()), 0);
- {
- int i = 0;
- foreach(boost::shared_ptr<Payload> item, payload->getData()) {
- if (convertors->convertToLua(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- lua_setfield(L, -2, "data");
- }
- if (payload->getID()) {
- lua_pushstring(L, (*payload->getID()).c_str());
- lua_setfield(L, -2, "id");
- }
+void PubSubEventItemConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventItem> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (payload->getPublisher()) {
+ lua_pushstring(L, (*payload->getPublisher()).c_str());
+ lua_setfield(L, -2, "publisher");
+ }
+ if (!payload->getData().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(payload->getData().size()), 0);
+ {
+ int i = 0;
+ for (auto&& item : payload->getData()) {
+ if (convertors->convertToLua(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ lua_setfield(L, -2, "data");
+ }
+ if (payload->getID()) {
+ lua_pushstring(L, (*payload->getID()).c_str());
+ lua_setfield(L, -2, "id");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventItemConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventItem",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `publisher`: string (Optional)\n"
- "- `data`: array<element (table)>\n"
- "- `id`: string (Optional)\n"
- );
+ return Documentation(
+ "PubSubEventItem",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `publisher`: string (Optional)\n"
+ "- `data`: array<element (table)>\n"
+ "- `id`: string (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventItemConvertor.h b/Sluift/ElementConvertors/PubSubEventItemConvertor.h
index c7dac83..6239b14 100644
--- a/Sluift/ElementConvertors/PubSubEventItemConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventItemConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventItem.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventItem.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubEventItemConvertor : public GenericLuaElementConvertor<PubSubEventItem> {
- public:
- PubSubEventItemConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventItemConvertor();
+ class PubSubEventItemConvertor : public GenericLuaElementConvertor<PubSubEventItem> {
+ public:
+ PubSubEventItemConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubEventItemConvertor();
- virtual boost::shared_ptr<PubSubEventItem> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventItem>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubEventItem> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventItem>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp b/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp
index 3287a6d..7a3cde1 100644
--- a/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventItemsConvertor.cpp
@@ -1,112 +1,111 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventItemsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubEventItemsConvertor::PubSubEventItemsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventItems>("pubsub_event_items"),
- convertors(convertors) {
+PubSubEventItemsConvertor::PubSubEventItemsConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubEventItems>("pubsub_event_items"),
+ convertors(convertors) {
}
PubSubEventItemsConvertor::~PubSubEventItemsConvertor() {
}
-boost::shared_ptr<PubSubEventItems> PubSubEventItemsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventItems> result = boost::make_shared<PubSubEventItems>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "items");
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubEventItem> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubEventItem> payload = boost::dynamic_pointer_cast<PubSubEventItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_item"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubEventItems> PubSubEventItemsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventItems> result = std::make_shared<PubSubEventItems>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "items");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubEventItem> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubEventItem> payload = std::dynamic_pointer_cast<PubSubEventItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_item"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setItems(items);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "retracts");
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubEventRetract> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubEventRetract> payload = boost::dynamic_pointer_cast<PubSubEventRetract>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_retract"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+ result->setItems(items);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "retracts");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubEventRetract> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubEventRetract> payload = std::dynamic_pointer_cast<PubSubEventRetract>(convertors->convertFromLuaUntyped(L, -1, "pubsub_event_retract"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setRetracts(items);
- }
- lua_pop(L, 1);
- return result;
+ result->setRetracts(items);
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventItemsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventItems> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (!payload->getItems().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubEventItem> item, payload->getItems()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- lua_setfield(L, -2, "items");
- }
- if (!payload->getRetracts().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(payload->getRetracts().size()), 0);
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubEventRetract> item, payload->getRetracts()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- lua_setfield(L, -2, "retracts");
- }
+void PubSubEventItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventItems> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (!payload->getItems().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
+ {
+ int i = 0;
+ for (auto&& item : payload->getItems()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ lua_setfield(L, -2, "items");
+ }
+ if (!payload->getRetracts().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(payload->getRetracts().size()), 0);
+ {
+ int i = 0;
+ for (auto&& item : payload->getRetracts()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ lua_setfield(L, -2, "retracts");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventItemsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventItems",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `items`: array<@{PubSubEventItem}>\n"
- "- `retracts`: array<@{PubSubEventRetract}>\n"
- );
+ return Documentation(
+ "PubSubEventItems",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `items`: array<@{PubSubEventItem}>\n"
+ "- `retracts`: array<@{PubSubEventRetract}>\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventItemsConvertor.h b/Sluift/ElementConvertors/PubSubEventItemsConvertor.h
index c409a3c..ea8942b 100644
--- a/Sluift/ElementConvertors/PubSubEventItemsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventItemsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventItems.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventItems.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubEventItemsConvertor : public GenericLuaElementConvertor<PubSubEventItems> {
- public:
- PubSubEventItemsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventItemsConvertor();
+ class PubSubEventItemsConvertor : public GenericLuaElementConvertor<PubSubEventItems> {
+ public:
+ PubSubEventItemsConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubEventItemsConvertor();
- virtual boost::shared_ptr<PubSubEventItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventItems>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubEventItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventItems>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventPurgeConvertor.cpp b/Sluift/ElementConvertors/PubSubEventPurgeConvertor.cpp
index e4604c0..223eedd 100644
--- a/Sluift/ElementConvertors/PubSubEventPurgeConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventPurgeConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventPurgeConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubEventPurgeConvertor::PubSubEventPurgeConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventPurge>("pubsub_event_purge"),
- convertors(convertors) {
+PubSubEventPurgeConvertor::PubSubEventPurgeConvertor() :
+ GenericLuaElementConvertor<PubSubEventPurge>("pubsub_event_purge") {
}
PubSubEventPurgeConvertor::~PubSubEventPurgeConvertor() {
}
-boost::shared_ptr<PubSubEventPurge> PubSubEventPurgeConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventPurge> result = boost::make_shared<PubSubEventPurge>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventPurge> PubSubEventPurgeConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventPurge> result = std::make_shared<PubSubEventPurge>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventPurgeConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventPurge> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
+void PubSubEventPurgeConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventPurge> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventPurgeConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventPurge",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- );
+ return Documentation(
+ "PubSubEventPurge",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h b/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h
index 39e571d..e3321b1 100644
--- a/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventPurgeConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventPurge.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventPurge.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubEventPurgeConvertor : public GenericLuaElementConvertor<PubSubEventPurge> {
- public:
- PubSubEventPurgeConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventPurgeConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubEventPurge> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventPurge>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubEventPurgeConvertor : public GenericLuaElementConvertor<PubSubEventPurge> {
+ public:
+ PubSubEventPurgeConvertor();
+ virtual ~PubSubEventPurgeConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubEventPurge> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventPurge>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventRedirectConvertor.cpp b/Sluift/ElementConvertors/PubSubEventRedirectConvertor.cpp
index 3c0555e..673b320 100644
--- a/Sluift/ElementConvertors/PubSubEventRedirectConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventRedirectConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventRedirectConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubEventRedirectConvertor::PubSubEventRedirectConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventRedirect>("pubsub_event_redirect"),
- convertors(convertors) {
+PubSubEventRedirectConvertor::PubSubEventRedirectConvertor() :
+ GenericLuaElementConvertor<PubSubEventRedirect>("pubsub_event_redirect") {
}
PubSubEventRedirectConvertor::~PubSubEventRedirectConvertor() {
}
-boost::shared_ptr<PubSubEventRedirect> PubSubEventRedirectConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventRedirect> result = boost::make_shared<PubSubEventRedirect>();
- lua_getfield(L, -1, "uri");
- if (lua_isstring(L, -1)) {
- result->setURI(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventRedirect> PubSubEventRedirectConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventRedirect> result = std::make_shared<PubSubEventRedirect>();
+ lua_getfield(L, -1, "uri");
+ if (lua_isstring(L, -1)) {
+ result->setURI(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventRedirectConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventRedirect> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getURI().c_str());
- lua_setfield(L, -2, "uri");
+void PubSubEventRedirectConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventRedirect> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getURI().c_str());
+ lua_setfield(L, -2, "uri");
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventRedirectConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventRedirect",
- "This table has the following fields:\n\n"
- "- `uri`: string\n"
- );
+ return Documentation(
+ "PubSubEventRedirect",
+ "This table has the following fields:\n\n"
+ "- `uri`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h b/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h
index 90b9d49..b1f33d2 100644
--- a/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventRedirectConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventRedirect.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventRedirect.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubEventRedirectConvertor : public GenericLuaElementConvertor<PubSubEventRedirect> {
- public:
- PubSubEventRedirectConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventRedirectConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubEventRedirect> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventRedirect>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubEventRedirectConvertor : public GenericLuaElementConvertor<PubSubEventRedirect> {
+ public:
+ PubSubEventRedirectConvertor();
+ virtual ~PubSubEventRedirectConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubEventRedirect> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventRedirect>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventRetractConvertor.cpp b/Sluift/ElementConvertors/PubSubEventRetractConvertor.cpp
index f4f1cfb..5981922 100644
--- a/Sluift/ElementConvertors/PubSubEventRetractConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventRetractConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventRetractConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubEventRetractConvertor::PubSubEventRetractConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventRetract>("pubsub_event_retract"),
- convertors(convertors) {
+PubSubEventRetractConvertor::PubSubEventRetractConvertor() :
+ GenericLuaElementConvertor<PubSubEventRetract>("pubsub_event_retract") {
}
PubSubEventRetractConvertor::~PubSubEventRetractConvertor() {
}
-boost::shared_ptr<PubSubEventRetract> PubSubEventRetractConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventRetract> result = boost::make_shared<PubSubEventRetract>();
- lua_getfield(L, -1, "id");
- if (lua_isstring(L, -1)) {
- result->setID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventRetract> PubSubEventRetractConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventRetract> result = std::make_shared<PubSubEventRetract>();
+ lua_getfield(L, -1, "id");
+ if (lua_isstring(L, -1)) {
+ result->setID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventRetractConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventRetract> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getID().c_str());
- lua_setfield(L, -2, "id");
+void PubSubEventRetractConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventRetract> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getID().c_str());
+ lua_setfield(L, -2, "id");
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventRetractConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventRetract",
- "This table has the following fields:\n\n"
- "- `id`: string\n"
- );
+ return Documentation(
+ "PubSubEventRetract",
+ "This table has the following fields:\n\n"
+ "- `id`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventRetractConvertor.h b/Sluift/ElementConvertors/PubSubEventRetractConvertor.h
index 0e3b303..65aac36 100644
--- a/Sluift/ElementConvertors/PubSubEventRetractConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventRetractConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventRetract.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventRetract.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubEventRetractConvertor : public GenericLuaElementConvertor<PubSubEventRetract> {
- public:
- PubSubEventRetractConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventRetractConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubEventRetract> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventRetract>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubEventRetractConvertor : public GenericLuaElementConvertor<PubSubEventRetract> {
+ public:
+ PubSubEventRetractConvertor();
+ virtual ~PubSubEventRetractConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubEventRetract> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventRetract>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.cpp b/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.cpp
index 7eec64d..cab78d4 100644
--- a/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.cpp
@@ -1,107 +1,104 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Swiften/Base/DateTime.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubEventSubscriptionConvertor::PubSubEventSubscriptionConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubEventSubscription>("pubsub_event_subscription"),
- convertors(convertors) {
+PubSubEventSubscriptionConvertor::PubSubEventSubscriptionConvertor() :
+ GenericLuaElementConvertor<PubSubEventSubscription>("pubsub_event_subscription") {
}
PubSubEventSubscriptionConvertor::~PubSubEventSubscriptionConvertor() {
}
-boost::shared_ptr<PubSubEventSubscription> PubSubEventSubscriptionConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubEventSubscription> result = boost::make_shared<PubSubEventSubscription>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "jid");
- if (lua_isstring(L, -1)) {
- result->setJID(JID(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription");
- if (lua_isstring(L, -1)) {
- if (std::string(lua_tostring(L, -1)) == "none") {
- result->setSubscription(PubSubEventSubscription::None);
- }
- if (std::string(lua_tostring(L, -1)) == "pending") {
- result->setSubscription(PubSubEventSubscription::Pending);
- }
- if (std::string(lua_tostring(L, -1)) == "subscribed") {
- result->setSubscription(PubSubEventSubscription::Subscribed);
- }
- if (std::string(lua_tostring(L, -1)) == "unconfigured") {
- result->setSubscription(PubSubEventSubscription::Unconfigured);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription_id");
- if (lua_isstring(L, -1)) {
- result->setSubscriptionID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "expiry");
- if (lua_isstring(L, -1)) {
- result->setExpiry(stringToDateTime(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubEventSubscription> PubSubEventSubscriptionConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubEventSubscription> result = std::make_shared<PubSubEventSubscription>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "jid");
+ if (lua_isstring(L, -1)) {
+ result->setJID(JID(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription");
+ if (lua_isstring(L, -1)) {
+ if (std::string(lua_tostring(L, -1)) == "none") {
+ result->setSubscription(PubSubEventSubscription::None);
+ }
+ if (std::string(lua_tostring(L, -1)) == "pending") {
+ result->setSubscription(PubSubEventSubscription::Pending);
+ }
+ if (std::string(lua_tostring(L, -1)) == "subscribed") {
+ result->setSubscription(PubSubEventSubscription::Subscribed);
+ }
+ if (std::string(lua_tostring(L, -1)) == "unconfigured") {
+ result->setSubscription(PubSubEventSubscription::Unconfigured);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription_id");
+ if (lua_isstring(L, -1)) {
+ result->setSubscriptionID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "expiry");
+ if (lua_isstring(L, -1)) {
+ result->setExpiry(stringToDateTime(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubEventSubscriptionConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubEventSubscription> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- lua_pushstring(L, payload->getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- switch (payload->getSubscription()) {
- case PubSubEventSubscription::None:
- lua_pushstring(L, "none");
- break;
- case PubSubEventSubscription::Pending:
- lua_pushstring(L, "pending");
- break;
- case PubSubEventSubscription::Subscribed:
- lua_pushstring(L, "subscribed");
- break;
- case PubSubEventSubscription::Unconfigured:
- lua_pushstring(L, "unconfigured");
- break;
- }
- lua_setfield(L, -2, "subscription");
- if (payload->getSubscriptionID()) {
- lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
- lua_setfield(L, -2, "subscription_id");
- }
- lua_pushstring(L, dateTimeToString(payload->getExpiry()).c_str());
- lua_setfield(L, -2, "expiry");
+void PubSubEventSubscriptionConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubEventSubscription> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ lua_pushstring(L, payload->getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ switch (payload->getSubscription()) {
+ case PubSubEventSubscription::None:
+ lua_pushstring(L, "none");
+ break;
+ case PubSubEventSubscription::Pending:
+ lua_pushstring(L, "pending");
+ break;
+ case PubSubEventSubscription::Subscribed:
+ lua_pushstring(L, "subscribed");
+ break;
+ case PubSubEventSubscription::Unconfigured:
+ lua_pushstring(L, "unconfigured");
+ break;
+ }
+ lua_setfield(L, -2, "subscription");
+ if (payload->getSubscriptionID()) {
+ lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
+ lua_setfield(L, -2, "subscription_id");
+ }
+ lua_pushstring(L, dateTimeToString(payload->getExpiry()).c_str());
+ lua_setfield(L, -2, "expiry");
}
boost::optional<LuaElementConvertor::Documentation> PubSubEventSubscriptionConvertor::getDocumentation() const {
- return Documentation(
- "PubSubEventSubscription",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `jid`: jid (string)\n"
- "- `subscription`: `\"none\"`, `\"pending\"`, `\"subscribed\"`, or `\"unconfigured\"`\n"
- "- `subscription_id`: string (Optional)\n"
- "- `expiry`: datetime (string)\n"
- );
+ return Documentation(
+ "PubSubEventSubscription",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `jid`: jid (string)\n"
+ "- `subscription`: `\"none\"`, `\"pending\"`, `\"subscribed\"`, or `\"unconfigured\"`\n"
+ "- `subscription_id`: string (Optional)\n"
+ "- `expiry`: datetime (string)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h b/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h
index c254e34..0b3181b 100644
--- a/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h
+++ b/Sluift/ElementConvertors/PubSubEventSubscriptionConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubEventSubscription.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubEventSubscription.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubEventSubscriptionConvertor : public GenericLuaElementConvertor<PubSubEventSubscription> {
- public:
- PubSubEventSubscriptionConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubEventSubscriptionConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubEventSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubEventSubscription>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubEventSubscriptionConvertor : public GenericLuaElementConvertor<PubSubEventSubscription> {
+ public:
+ PubSubEventSubscriptionConvertor();
+ virtual ~PubSubEventSubscriptionConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubEventSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubEventSubscription>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubItemConvertor.cpp b/Sluift/ElementConvertors/PubSubItemConvertor.cpp
index 61aa17c..27fd4a3 100644
--- a/Sluift/ElementConvertors/PubSubItemConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubItemConvertor.cpp
@@ -1,81 +1,80 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubItemConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubItemConvertor::PubSubItemConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubItem>("pubsub_item"),
- convertors(convertors) {
+PubSubItemConvertor::PubSubItemConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubItem>("pubsub_item"),
+ convertors(convertors) {
}
PubSubItemConvertor::~PubSubItemConvertor() {
}
-boost::shared_ptr<PubSubItem> PubSubItemConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubItem> result = boost::make_shared<PubSubItem>();
- lua_getfield(L, -1, "data");
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<Payload> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Payload> payload = boost::dynamic_pointer_cast<Payload>(convertors->convertFromLua(L, -1))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubItem> PubSubItemConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubItem> result = std::make_shared<PubSubItem>();
+ lua_getfield(L, -1, "data");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<Payload> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Payload> payload = std::dynamic_pointer_cast<Payload>(convertors->convertFromLua(L, -1))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setData(items);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "id");
- if (lua_isstring(L, -1)) {
- result->setID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+ result->setData(items);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "id");
+ if (lua_isstring(L, -1)) {
+ result->setID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubItemConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubItem> payload) {
- lua_createtable(L, 0, 0);
- if (!payload->getData().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(payload->getData().size()), 0);
- {
- int i = 0;
- foreach(boost::shared_ptr<Payload> item, payload->getData()) {
- if (convertors->convertToLua(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- lua_setfield(L, -2, "data");
- }
- lua_pushstring(L, payload->getID().c_str());
- lua_setfield(L, -2, "id");
+void PubSubItemConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubItem> payload) {
+ lua_createtable(L, 0, 0);
+ if (!payload->getData().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(payload->getData().size()), 0);
+ {
+ int i = 0;
+ for (auto&& item : payload->getData()) {
+ if (convertors->convertToLua(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ lua_setfield(L, -2, "data");
+ }
+ lua_pushstring(L, payload->getID().c_str());
+ lua_setfield(L, -2, "id");
}
boost::optional<LuaElementConvertor::Documentation> PubSubItemConvertor::getDocumentation() const {
- return Documentation(
- "PubSubItem",
- "This table has the following fields:\n\n"
- "- `data`: array<element (table)>\n"
- "- `id`: string\n"
- );
+ return Documentation(
+ "PubSubItem",
+ "This table has the following fields:\n\n"
+ "- `data`: array<element (table)>\n"
+ "- `id`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubItemConvertor.h b/Sluift/ElementConvertors/PubSubItemConvertor.h
index 334c15c..2772932 100644
--- a/Sluift/ElementConvertors/PubSubItemConvertor.h
+++ b/Sluift/ElementConvertors/PubSubItemConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubItem.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubItem.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubItemConvertor : public GenericLuaElementConvertor<PubSubItem> {
- public:
- PubSubItemConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubItemConvertor();
+ class PubSubItemConvertor : public GenericLuaElementConvertor<PubSubItem> {
+ public:
+ PubSubItemConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubItemConvertor();
- virtual boost::shared_ptr<PubSubItem> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubItem>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubItem> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubItem>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubItemsConvertor.cpp b/Sluift/ElementConvertors/PubSubItemsConvertor.cpp
index 8ce1884..5fa1bd3 100644
--- a/Sluift/ElementConvertors/PubSubItemsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubItemsConvertor.cpp
@@ -1,97 +1,96 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubItemsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubItemsConvertor::PubSubItemsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubItems>("pubsub_items"),
- convertors(convertors) {
+PubSubItemsConvertor::PubSubItemsConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubItems>("pubsub_items"),
+ convertors(convertors) {
}
PubSubItemsConvertor::~PubSubItemsConvertor() {
}
-boost::shared_ptr<PubSubItems> PubSubItemsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubItems> result = boost::make_shared<PubSubItems>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubItem> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubItem> payload = boost::dynamic_pointer_cast<PubSubItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_item"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubItems> PubSubItemsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubItems> result = std::make_shared<PubSubItems>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubItem> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubItem> payload = std::dynamic_pointer_cast<PubSubItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_item"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setItems(items);
- }
- lua_getfield(L, -1, "maximum_items");
- if (lua_isnumber(L, -1)) {
- result->setMaximumItems(boost::numeric_cast<unsigned int>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription_id");
- if (lua_isstring(L, -1)) {
- result->setSubscriptionID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+ result->setItems(items);
+ }
+ lua_getfield(L, -1, "maximum_items");
+ if (lua_isnumber(L, -1)) {
+ result->setMaximumItems(boost::numeric_cast<unsigned int>(lua_tonumber(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription_id");
+ if (lua_isstring(L, -1)) {
+ result->setSubscriptionID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubItemsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubItems> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (!payload->getItems().empty()) {
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- }
- if (payload->getMaximumItems()) {
- lua_pushnumber(L, (*payload->getMaximumItems()));
- lua_setfield(L, -2, "maximum_items");
- }
- if (payload->getSubscriptionID()) {
- lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
- lua_setfield(L, -2, "subscription_id");
- }
+void PubSubItemsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubItems> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (!payload->getItems().empty()) {
+ {
+ int i = 0;
+ for (auto&& item : payload->getItems()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ }
+ if (payload->getMaximumItems()) {
+ lua_pushnumber(L, (*payload->getMaximumItems()));
+ lua_setfield(L, -2, "maximum_items");
+ }
+ if (payload->getSubscriptionID()) {
+ lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
+ lua_setfield(L, -2, "subscription_id");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubItemsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubItems",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `items`: array<@{PubSubItem}>\n"
- "- `maximum_items`: number (Optional)\n"
- "- `subscription_id`: string (Optional)\n"
- );
+ return Documentation(
+ "PubSubItems",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `items`: array<@{PubSubItem}>\n"
+ "- `maximum_items`: number (Optional)\n"
+ "- `subscription_id`: string (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubItemsConvertor.h b/Sluift/ElementConvertors/PubSubItemsConvertor.h
index 801c2d8..56348b0 100644
--- a/Sluift/ElementConvertors/PubSubItemsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubItemsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubItems.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubItems.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubItemsConvertor : public GenericLuaElementConvertor<PubSubItems> {
- public:
- PubSubItemsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubItemsConvertor();
+ class PubSubItemsConvertor : public GenericLuaElementConvertor<PubSubItems> {
+ public:
+ PubSubItemsConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubItemsConvertor();
- virtual boost::shared_ptr<PubSubItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubItems>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubItems> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubItems>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubOptionsConvertor.cpp
index dcb37a5..3582c63 100644
--- a/Sluift/ElementConvertors/PubSubOptionsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOptionsConvertor.cpp
@@ -1,78 +1,76 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOptionsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubOptionsConvertor::PubSubOptionsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOptions>("pubsub_options"),
- convertors(convertors) {
+PubSubOptionsConvertor::PubSubOptionsConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubOptions>("pubsub_options"),
+ convertors(convertors) {
}
PubSubOptionsConvertor::~PubSubOptionsConvertor() {
}
-boost::shared_ptr<PubSubOptions> PubSubOptionsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOptions> result = boost::make_shared<PubSubOptions>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "jid");
- if (lua_isstring(L, -1)) {
- result->setJID(JID(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "data");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Form> payload = boost::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
- result->setData(payload);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription_id");
- if (lua_isstring(L, -1)) {
- result->setSubscriptionID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOptions> PubSubOptionsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOptions> result = std::make_shared<PubSubOptions>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "jid");
+ if (lua_isstring(L, -1)) {
+ result->setJID(JID(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "data");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Form> payload = std::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
+ result->setData(payload);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription_id");
+ if (lua_isstring(L, -1)) {
+ result->setSubscriptionID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOptionsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOptions> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- lua_pushstring(L, payload->getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
- lua_setfield(L, -2, "data");
- }
- if (payload->getSubscriptionID()) {
- lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
- lua_setfield(L, -2, "subscription_id");
- }
+void PubSubOptionsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOptions> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ lua_pushstring(L, payload->getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
+ lua_setfield(L, -2, "data");
+ }
+ if (payload->getSubscriptionID()) {
+ lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
+ lua_setfield(L, -2, "subscription_id");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubOptionsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOptions",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `jid`: jid (string)\n"
- "- `data`: @{Form}\n"
- "- `subscription_id`: string (Optional)\n"
- );
+ return Documentation(
+ "PubSubOptions",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `jid`: jid (string)\n"
+ "- `data`: @{Form}\n"
+ "- `subscription_id`: string (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOptionsConvertor.h b/Sluift/ElementConvertors/PubSubOptionsConvertor.h
index 8aacdbd..60d11cc 100644
--- a/Sluift/ElementConvertors/PubSubOptionsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOptionsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOptions.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOptions.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubOptionsConvertor : public GenericLuaElementConvertor<PubSubOptions> {
- public:
- PubSubOptionsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOptionsConvertor();
+ class PubSubOptionsConvertor : public GenericLuaElementConvertor<PubSubOptions> {
+ public:
+ PubSubOptionsConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubOptionsConvertor();
- virtual boost::shared_ptr<PubSubOptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOptions>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubOptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOptions>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.cpp
index bfcd4c4..15a800b 100644
--- a/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.cpp
@@ -1,93 +1,88 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubOwnerAffiliationConvertor::PubSubOwnerAffiliationConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerAffiliation>("pubsub_owner_affiliation"),
- convertors(convertors) {
+PubSubOwnerAffiliationConvertor::PubSubOwnerAffiliationConvertor() :
+ GenericLuaElementConvertor<PubSubOwnerAffiliation>("pubsub_owner_affiliation") {
}
PubSubOwnerAffiliationConvertor::~PubSubOwnerAffiliationConvertor() {
}
-boost::shared_ptr<PubSubOwnerAffiliation> PubSubOwnerAffiliationConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerAffiliation> result = boost::make_shared<PubSubOwnerAffiliation>();
- lua_getfield(L, -1, "jid");
- if (lua_isstring(L, -1)) {
- result->setJID(JID(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "type");
- if (lua_isstring(L, -1)) {
- if (std::string(lua_tostring(L, -1)) == "none") {
- result->setType(PubSubOwnerAffiliation::None);
- }
- if (std::string(lua_tostring(L, -1)) == "member") {
- result->setType(PubSubOwnerAffiliation::Member);
- }
- if (std::string(lua_tostring(L, -1)) == "outcast") {
- result->setType(PubSubOwnerAffiliation::Outcast);
- }
- if (std::string(lua_tostring(L, -1)) == "owner") {
- result->setType(PubSubOwnerAffiliation::Owner);
- }
- if (std::string(lua_tostring(L, -1)) == "publisher") {
- result->setType(PubSubOwnerAffiliation::Publisher);
- }
- if (std::string(lua_tostring(L, -1)) == "publish_only") {
- result->setType(PubSubOwnerAffiliation::PublishOnly);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOwnerAffiliation> PubSubOwnerAffiliationConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerAffiliation> result = std::make_shared<PubSubOwnerAffiliation>();
+ lua_getfield(L, -1, "jid");
+ if (lua_isstring(L, -1)) {
+ result->setJID(JID(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "type");
+ if (lua_isstring(L, -1)) {
+ if (std::string(lua_tostring(L, -1)) == "none") {
+ result->setType(PubSubOwnerAffiliation::None);
+ }
+ if (std::string(lua_tostring(L, -1)) == "member") {
+ result->setType(PubSubOwnerAffiliation::Member);
+ }
+ if (std::string(lua_tostring(L, -1)) == "outcast") {
+ result->setType(PubSubOwnerAffiliation::Outcast);
+ }
+ if (std::string(lua_tostring(L, -1)) == "owner") {
+ result->setType(PubSubOwnerAffiliation::Owner);
+ }
+ if (std::string(lua_tostring(L, -1)) == "publisher") {
+ result->setType(PubSubOwnerAffiliation::Publisher);
+ }
+ if (std::string(lua_tostring(L, -1)) == "publish_only") {
+ result->setType(PubSubOwnerAffiliation::PublishOnly);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOwnerAffiliationConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerAffiliation> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- switch (payload->getType()) {
- case PubSubOwnerAffiliation::None:
- lua_pushstring(L, "none");
- break;
- case PubSubOwnerAffiliation::Member:
- lua_pushstring(L, "member");
- break;
- case PubSubOwnerAffiliation::Outcast:
- lua_pushstring(L, "outcast");
- break;
- case PubSubOwnerAffiliation::Owner:
- lua_pushstring(L, "owner");
- break;
- case PubSubOwnerAffiliation::Publisher:
- lua_pushstring(L, "publisher");
- break;
- case PubSubOwnerAffiliation::PublishOnly:
- lua_pushstring(L, "publish_only");
- break;
- }
- lua_setfield(L, -2, "type");
+void PubSubOwnerAffiliationConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerAffiliation> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ switch (payload->getType()) {
+ case PubSubOwnerAffiliation::None:
+ lua_pushstring(L, "none");
+ break;
+ case PubSubOwnerAffiliation::Member:
+ lua_pushstring(L, "member");
+ break;
+ case PubSubOwnerAffiliation::Outcast:
+ lua_pushstring(L, "outcast");
+ break;
+ case PubSubOwnerAffiliation::Owner:
+ lua_pushstring(L, "owner");
+ break;
+ case PubSubOwnerAffiliation::Publisher:
+ lua_pushstring(L, "publisher");
+ break;
+ case PubSubOwnerAffiliation::PublishOnly:
+ lua_pushstring(L, "publish_only");
+ break;
+ }
+ lua_setfield(L, -2, "type");
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerAffiliationConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerAffiliation",
- "This table has the following fields:\n\n"
- "- `jid`: jid (string)\n"
- "- `type`: `\"none\"`, `\"member\"`, `\"outcast\"`, `\"owner\"`, `\"publisher\"`, or `\"publish_only\"`\n"
- );
+ return Documentation(
+ "PubSubOwnerAffiliation",
+ "This table has the following fields:\n\n"
+ "- `jid`: jid (string)\n"
+ "- `type`: `\"none\"`, `\"member\"`, `\"outcast\"`, `\"owner\"`, `\"publisher\"`, or `\"publish_only\"`\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h b/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h
index f16503f..9020482 100644
--- a/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerAffiliation.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerAffiliation.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubOwnerAffiliationConvertor : public GenericLuaElementConvertor<PubSubOwnerAffiliation> {
- public:
- PubSubOwnerAffiliationConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerAffiliationConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubOwnerAffiliation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerAffiliation>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubOwnerAffiliationConvertor : public GenericLuaElementConvertor<PubSubOwnerAffiliation> {
+ public:
+ PubSubOwnerAffiliationConvertor();
+ virtual ~PubSubOwnerAffiliationConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubOwnerAffiliation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerAffiliation>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp
index 85f9c3f..ee8a8cb 100644
--- a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.cpp
@@ -1,77 +1,76 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubOwnerAffiliationsConvertor::PubSubOwnerAffiliationsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerAffiliations>("pubsub_owner_affiliations"),
- convertors(convertors) {
+PubSubOwnerAffiliationsConvertor::PubSubOwnerAffiliationsConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubOwnerAffiliations>("pubsub_owner_affiliations"),
+ convertors(convertors) {
}
PubSubOwnerAffiliationsConvertor::~PubSubOwnerAffiliationsConvertor() {
}
-boost::shared_ptr<PubSubOwnerAffiliations> PubSubOwnerAffiliationsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerAffiliations> result = boost::make_shared<PubSubOwnerAffiliations>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubOwnerAffiliation> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubOwnerAffiliation> payload = boost::dynamic_pointer_cast<PubSubOwnerAffiliation>(convertors->convertFromLuaUntyped(L, -1, "pubsub_owner_affiliation"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubOwnerAffiliations> PubSubOwnerAffiliationsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerAffiliations> result = std::make_shared<PubSubOwnerAffiliations>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubOwnerAffiliation> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubOwnerAffiliation> payload = std::dynamic_pointer_cast<PubSubOwnerAffiliation>(convertors->convertFromLuaUntyped(L, -1, "pubsub_owner_affiliation"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setAffiliations(items);
- }
- return result;
+ result->setAffiliations(items);
+ }
+ return result;
}
-void PubSubOwnerAffiliationsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerAffiliations> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (!payload->getAffiliations().empty()) {
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubOwnerAffiliation> item, payload->getAffiliations()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- }
+void PubSubOwnerAffiliationsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerAffiliations> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (!payload->getAffiliations().empty()) {
+ {
+ int i = 0;
+ for (auto&& item : payload->getAffiliations()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerAffiliationsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerAffiliations",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `affiliations`: array<@{PubSubOwnerAffiliation}>\n"
- );
+ return Documentation(
+ "PubSubOwnerAffiliations",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `affiliations`: array<@{PubSubOwnerAffiliation}>\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h
index 63ed4a7..3026e2c 100644
--- a/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerAffiliationsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerAffiliations.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerAffiliations.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubOwnerAffiliationsConvertor : public GenericLuaElementConvertor<PubSubOwnerAffiliations> {
- public:
- PubSubOwnerAffiliationsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerAffiliationsConvertor();
+ class PubSubOwnerAffiliationsConvertor : public GenericLuaElementConvertor<PubSubOwnerAffiliations> {
+ public:
+ PubSubOwnerAffiliationsConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubOwnerAffiliationsConvertor();
- virtual boost::shared_ptr<PubSubOwnerAffiliations> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerAffiliations>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubOwnerAffiliations> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerAffiliations>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.cpp
index 1c8c0fb..d179152 100644
--- a/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.cpp
@@ -1,62 +1,60 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubOwnerConfigureConvertor::PubSubOwnerConfigureConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerConfigure>("pubsub_owner_configure"),
- convertors(convertors) {
+PubSubOwnerConfigureConvertor::PubSubOwnerConfigureConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubOwnerConfigure>("pubsub_owner_configure"),
+ convertors(convertors) {
}
PubSubOwnerConfigureConvertor::~PubSubOwnerConfigureConvertor() {
}
-boost::shared_ptr<PubSubOwnerConfigure> PubSubOwnerConfigureConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerConfigure> result = boost::make_shared<PubSubOwnerConfigure>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "data");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Form> payload = boost::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
- result->setData(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOwnerConfigure> PubSubOwnerConfigureConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerConfigure> result = std::make_shared<PubSubOwnerConfigure>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "data");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Form> payload = std::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
+ result->setData(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOwnerConfigureConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerConfigure> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
- lua_setfield(L, -2, "data");
- }
+void PubSubOwnerConfigureConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerConfigure> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
+ lua_setfield(L, -2, "data");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerConfigureConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerConfigure",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `data`: @{Form}\n"
- );
+ return Documentation(
+ "PubSubOwnerConfigure",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `data`: @{Form}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h b/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h
index d02336d..4b39fdf 100644
--- a/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerConfigureConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerConfigure.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerConfigure.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubOwnerConfigureConvertor : public GenericLuaElementConvertor<PubSubOwnerConfigure> {
- public:
- PubSubOwnerConfigureConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerConfigureConvertor();
+ class PubSubOwnerConfigureConvertor : public GenericLuaElementConvertor<PubSubOwnerConfigure> {
+ public:
+ PubSubOwnerConfigureConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubOwnerConfigureConvertor();
- virtual boost::shared_ptr<PubSubOwnerConfigure> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerConfigure>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubOwnerConfigure> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerConfigure>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.cpp
index 9879be2..b2ff3de 100644
--- a/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.cpp
@@ -1,52 +1,50 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubOwnerDefaultConvertor::PubSubOwnerDefaultConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerDefault>("pubsub_owner_default"),
- convertors(convertors) {
+PubSubOwnerDefaultConvertor::PubSubOwnerDefaultConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubOwnerDefault>("pubsub_owner_default"),
+ convertors(convertors) {
}
PubSubOwnerDefaultConvertor::~PubSubOwnerDefaultConvertor() {
}
-boost::shared_ptr<PubSubOwnerDefault> PubSubOwnerDefaultConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerDefault> result = boost::make_shared<PubSubOwnerDefault>();
- lua_getfield(L, -1, "data");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<Form> payload = boost::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
- result->setData(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOwnerDefault> PubSubOwnerDefaultConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerDefault> result = std::make_shared<PubSubOwnerDefault>();
+ lua_getfield(L, -1, "data");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<Form> payload = std::dynamic_pointer_cast<Form>(convertors->convertFromLuaUntyped(L, -1, "form"))) {
+ result->setData(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOwnerDefaultConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerDefault> payload) {
- lua_createtable(L, 0, 0);
- if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
- lua_setfield(L, -2, "data");
- }
+void PubSubOwnerDefaultConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerDefault> payload) {
+ lua_createtable(L, 0, 0);
+ if (convertors->convertToLuaUntyped(L, payload->getData()) > 0) {
+ lua_setfield(L, -2, "data");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerDefaultConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerDefault",
- "This table has the following fields:\n\n"
- "- `data`: @{Form}\n"
- );
+ return Documentation(
+ "PubSubOwnerDefault",
+ "This table has the following fields:\n\n"
+ "- `data`: @{Form}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h b/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h
index 932c3ae..ae0f018 100644
--- a/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerDefaultConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerDefault.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerDefault.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubOwnerDefaultConvertor : public GenericLuaElementConvertor<PubSubOwnerDefault> {
- public:
- PubSubOwnerDefaultConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerDefaultConvertor();
+ class PubSubOwnerDefaultConvertor : public GenericLuaElementConvertor<PubSubOwnerDefault> {
+ public:
+ PubSubOwnerDefaultConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubOwnerDefaultConvertor();
- virtual boost::shared_ptr<PubSubOwnerDefault> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerDefault>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubOwnerDefault> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerDefault>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.cpp
index e6e2b4f..3733d74 100644
--- a/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.cpp
@@ -1,60 +1,58 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubOwnerDeleteConvertor::PubSubOwnerDeleteConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerDelete>("pubsub_owner_delete"),
- convertors(convertors) {
+PubSubOwnerDeleteConvertor::PubSubOwnerDeleteConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubOwnerDelete>("pubsub_owner_delete"),
+ convertors(convertors) {
}
PubSubOwnerDeleteConvertor::~PubSubOwnerDeleteConvertor() {
}
-boost::shared_ptr<PubSubOwnerDelete> PubSubOwnerDeleteConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerDelete> result = boost::make_shared<PubSubOwnerDelete>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "redirect");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubOwnerRedirect> payload = boost::dynamic_pointer_cast<PubSubOwnerRedirect>(convertors->convertFromLuaUntyped(L, -1, "pubsub_owner_redirect"))) {
- result->setRedirect(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOwnerDelete> PubSubOwnerDeleteConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerDelete> result = std::make_shared<PubSubOwnerDelete>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "redirect");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubOwnerRedirect> payload = std::dynamic_pointer_cast<PubSubOwnerRedirect>(convertors->convertFromLuaUntyped(L, -1, "pubsub_owner_redirect"))) {
+ result->setRedirect(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOwnerDeleteConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerDelete> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (convertors->convertToLuaUntyped(L, payload->getRedirect()) > 0) {
- lua_setfield(L, -2, "redirect");
- }
+void PubSubOwnerDeleteConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerDelete> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (convertors->convertToLuaUntyped(L, payload->getRedirect()) > 0) {
+ lua_setfield(L, -2, "redirect");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerDeleteConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerDelete",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `redirect`: @{PubSubOwnerRedirect}\n"
- );
+ return Documentation(
+ "PubSubOwnerDelete",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `redirect`: @{PubSubOwnerRedirect}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h b/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h
index a48dcf9..54a2cf9 100644
--- a/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerDeleteConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerDelete.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerDelete.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubOwnerDeleteConvertor : public GenericLuaElementConvertor<PubSubOwnerDelete> {
- public:
- PubSubOwnerDeleteConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerDeleteConvertor();
+ class PubSubOwnerDeleteConvertor : public GenericLuaElementConvertor<PubSubOwnerDelete> {
+ public:
+ PubSubOwnerDeleteConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubOwnerDeleteConvertor();
- virtual boost::shared_ptr<PubSubOwnerDelete> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerDelete>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubOwnerDelete> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerDelete>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.cpp
index 5b605bd..98c6355 100644
--- a/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubOwnerPurgeConvertor::PubSubOwnerPurgeConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerPurge>("pubsub_owner_purge"),
- convertors(convertors) {
+PubSubOwnerPurgeConvertor::PubSubOwnerPurgeConvertor() :
+ GenericLuaElementConvertor<PubSubOwnerPurge>("pubsub_owner_purge") {
}
PubSubOwnerPurgeConvertor::~PubSubOwnerPurgeConvertor() {
}
-boost::shared_ptr<PubSubOwnerPurge> PubSubOwnerPurgeConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerPurge> result = boost::make_shared<PubSubOwnerPurge>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOwnerPurge> PubSubOwnerPurgeConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerPurge> result = std::make_shared<PubSubOwnerPurge>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOwnerPurgeConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerPurge> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
+void PubSubOwnerPurgeConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerPurge> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerPurgeConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerPurge",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- );
+ return Documentation(
+ "PubSubOwnerPurge",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h b/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h
index 45bba63..4696f45 100644
--- a/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerPurgeConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerPurge.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerPurge.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubOwnerPurgeConvertor : public GenericLuaElementConvertor<PubSubOwnerPurge> {
- public:
- PubSubOwnerPurgeConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerPurgeConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubOwnerPurge> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerPurge>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubOwnerPurgeConvertor : public GenericLuaElementConvertor<PubSubOwnerPurge> {
+ public:
+ PubSubOwnerPurgeConvertor();
+ virtual ~PubSubOwnerPurgeConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubOwnerPurge> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerPurge>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.cpp
index 4ac5573..8fc20d2 100644
--- a/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubOwnerRedirectConvertor::PubSubOwnerRedirectConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerRedirect>("pubsub_owner_redirect"),
- convertors(convertors) {
+PubSubOwnerRedirectConvertor::PubSubOwnerRedirectConvertor() :
+ GenericLuaElementConvertor<PubSubOwnerRedirect>("pubsub_owner_redirect") {
}
PubSubOwnerRedirectConvertor::~PubSubOwnerRedirectConvertor() {
}
-boost::shared_ptr<PubSubOwnerRedirect> PubSubOwnerRedirectConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerRedirect> result = boost::make_shared<PubSubOwnerRedirect>();
- lua_getfield(L, -1, "uri");
- if (lua_isstring(L, -1)) {
- result->setURI(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOwnerRedirect> PubSubOwnerRedirectConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerRedirect> result = std::make_shared<PubSubOwnerRedirect>();
+ lua_getfield(L, -1, "uri");
+ if (lua_isstring(L, -1)) {
+ result->setURI(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOwnerRedirectConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerRedirect> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getURI().c_str());
- lua_setfield(L, -2, "uri");
+void PubSubOwnerRedirectConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerRedirect> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getURI().c_str());
+ lua_setfield(L, -2, "uri");
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerRedirectConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerRedirect",
- "This table has the following fields:\n\n"
- "- `uri`: string\n"
- );
+ return Documentation(
+ "PubSubOwnerRedirect",
+ "This table has the following fields:\n\n"
+ "- `uri`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h b/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h
index e563f97..3517a49 100644
--- a/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerRedirectConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerRedirect.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerRedirect.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubOwnerRedirectConvertor : public GenericLuaElementConvertor<PubSubOwnerRedirect> {
- public:
- PubSubOwnerRedirectConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerRedirectConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubOwnerRedirect> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerRedirect>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubOwnerRedirectConvertor : public GenericLuaElementConvertor<PubSubOwnerRedirect> {
+ public:
+ PubSubOwnerRedirectConvertor();
+ virtual ~PubSubOwnerRedirectConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubOwnerRedirect> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerRedirect>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.cpp
index 844d669..e0b3687 100644
--- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.cpp
@@ -1,81 +1,76 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubOwnerSubscriptionConvertor::PubSubOwnerSubscriptionConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerSubscription>("pubsub_owner_subscription"),
- convertors(convertors) {
+PubSubOwnerSubscriptionConvertor::PubSubOwnerSubscriptionConvertor() :
+ GenericLuaElementConvertor<PubSubOwnerSubscription>("pubsub_owner_subscription") {
}
PubSubOwnerSubscriptionConvertor::~PubSubOwnerSubscriptionConvertor() {
}
-boost::shared_ptr<PubSubOwnerSubscription> PubSubOwnerSubscriptionConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerSubscription> result = boost::make_shared<PubSubOwnerSubscription>();
- lua_getfield(L, -1, "jid");
- if (lua_isstring(L, -1)) {
- result->setJID(JID(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription");
- if (lua_isstring(L, -1)) {
- if (std::string(lua_tostring(L, -1)) == "none") {
- result->setSubscription(PubSubOwnerSubscription::None);
- }
- if (std::string(lua_tostring(L, -1)) == "pending") {
- result->setSubscription(PubSubOwnerSubscription::Pending);
- }
- if (std::string(lua_tostring(L, -1)) == "subscribed") {
- result->setSubscription(PubSubOwnerSubscription::Subscribed);
- }
- if (std::string(lua_tostring(L, -1)) == "unconfigured") {
- result->setSubscription(PubSubOwnerSubscription::Unconfigured);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubOwnerSubscription> PubSubOwnerSubscriptionConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerSubscription> result = std::make_shared<PubSubOwnerSubscription>();
+ lua_getfield(L, -1, "jid");
+ if (lua_isstring(L, -1)) {
+ result->setJID(JID(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription");
+ if (lua_isstring(L, -1)) {
+ if (std::string(lua_tostring(L, -1)) == "none") {
+ result->setSubscription(PubSubOwnerSubscription::None);
+ }
+ if (std::string(lua_tostring(L, -1)) == "pending") {
+ result->setSubscription(PubSubOwnerSubscription::Pending);
+ }
+ if (std::string(lua_tostring(L, -1)) == "subscribed") {
+ result->setSubscription(PubSubOwnerSubscription::Subscribed);
+ }
+ if (std::string(lua_tostring(L, -1)) == "unconfigured") {
+ result->setSubscription(PubSubOwnerSubscription::Unconfigured);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubOwnerSubscriptionConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerSubscription> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- switch (payload->getSubscription()) {
- case PubSubOwnerSubscription::None:
- lua_pushstring(L, "none");
- break;
- case PubSubOwnerSubscription::Pending:
- lua_pushstring(L, "pending");
- break;
- case PubSubOwnerSubscription::Subscribed:
- lua_pushstring(L, "subscribed");
- break;
- case PubSubOwnerSubscription::Unconfigured:
- lua_pushstring(L, "unconfigured");
- break;
- }
- lua_setfield(L, -2, "subscription");
+void PubSubOwnerSubscriptionConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerSubscription> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ switch (payload->getSubscription()) {
+ case PubSubOwnerSubscription::None:
+ lua_pushstring(L, "none");
+ break;
+ case PubSubOwnerSubscription::Pending:
+ lua_pushstring(L, "pending");
+ break;
+ case PubSubOwnerSubscription::Subscribed:
+ lua_pushstring(L, "subscribed");
+ break;
+ case PubSubOwnerSubscription::Unconfigured:
+ lua_pushstring(L, "unconfigured");
+ break;
+ }
+ lua_setfield(L, -2, "subscription");
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerSubscriptionConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerSubscription",
- "This table has the following fields:\n\n"
- "- `jid`: jid (string)\n"
- "- `subscription`: `\"none\"`, `\"pending\"`, `\"subscribed\"`, or `\"unconfigured\"`\n"
- );
+ return Documentation(
+ "PubSubOwnerSubscription",
+ "This table has the following fields:\n\n"
+ "- `jid`: jid (string)\n"
+ "- `subscription`: `\"none\"`, `\"pending\"`, `\"subscribed\"`, or `\"unconfigured\"`\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h b/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h
index 6742013..2908654 100644
--- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerSubscription.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerSubscription.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubOwnerSubscriptionConvertor : public GenericLuaElementConvertor<PubSubOwnerSubscription> {
- public:
- PubSubOwnerSubscriptionConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerSubscriptionConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubOwnerSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerSubscription>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubOwnerSubscriptionConvertor : public GenericLuaElementConvertor<PubSubOwnerSubscription> {
+ public:
+ PubSubOwnerSubscriptionConvertor();
+ virtual ~PubSubOwnerSubscriptionConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubOwnerSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerSubscription>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp
index d061b2d..88085b5 100644
--- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.cpp
@@ -1,77 +1,76 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubOwnerSubscriptionsConvertor::PubSubOwnerSubscriptionsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubOwnerSubscriptions>("pubsub_owner_subscriptions"),
- convertors(convertors) {
+PubSubOwnerSubscriptionsConvertor::PubSubOwnerSubscriptionsConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubOwnerSubscriptions>("pubsub_owner_subscriptions"),
+ convertors(convertors) {
}
PubSubOwnerSubscriptionsConvertor::~PubSubOwnerSubscriptionsConvertor() {
}
-boost::shared_ptr<PubSubOwnerSubscriptions> PubSubOwnerSubscriptionsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubOwnerSubscriptions> result = boost::make_shared<PubSubOwnerSubscriptions>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubOwnerSubscription> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubOwnerSubscription> payload = boost::dynamic_pointer_cast<PubSubOwnerSubscription>(convertors->convertFromLuaUntyped(L, -1, "pubsub_owner_subscription"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubOwnerSubscriptions> PubSubOwnerSubscriptionsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubOwnerSubscriptions> result = std::make_shared<PubSubOwnerSubscriptions>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubOwnerSubscription> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubOwnerSubscription> payload = std::dynamic_pointer_cast<PubSubOwnerSubscription>(convertors->convertFromLuaUntyped(L, -1, "pubsub_owner_subscription"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setSubscriptions(items);
- }
- return result;
+ result->setSubscriptions(items);
+ }
+ return result;
}
-void PubSubOwnerSubscriptionsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubOwnerSubscriptions> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (!payload->getSubscriptions().empty()) {
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubOwnerSubscription> item, payload->getSubscriptions()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- }
+void PubSubOwnerSubscriptionsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubOwnerSubscriptions> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (!payload->getSubscriptions().empty()) {
+ {
+ int i = 0;
+ for (auto&& item : payload->getSubscriptions()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubOwnerSubscriptionsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubOwnerSubscriptions",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `subscriptions`: array<@{PubSubOwnerSubscription}>\n"
- );
+ return Documentation(
+ "PubSubOwnerSubscriptions",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `subscriptions`: array<@{PubSubOwnerSubscription}>\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h
index dbdff67..c89b814 100644
--- a/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubOwnerSubscriptionsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubOwnerSubscriptions.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubOwnerSubscriptions.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubOwnerSubscriptionsConvertor : public GenericLuaElementConvertor<PubSubOwnerSubscriptions> {
- public:
- PubSubOwnerSubscriptionsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubOwnerSubscriptionsConvertor();
+ class PubSubOwnerSubscriptionsConvertor : public GenericLuaElementConvertor<PubSubOwnerSubscriptions> {
+ public:
+ PubSubOwnerSubscriptionsConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubOwnerSubscriptionsConvertor();
- virtual boost::shared_ptr<PubSubOwnerSubscriptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubOwnerSubscriptions>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubOwnerSubscriptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubOwnerSubscriptions>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubPublishConvertor.cpp b/Sluift/ElementConvertors/PubSubPublishConvertor.cpp
index 961d210..63c97bc 100644
--- a/Sluift/ElementConvertors/PubSubPublishConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubPublishConvertor.cpp
@@ -1,81 +1,80 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubPublishConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubPublishConvertor::PubSubPublishConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubPublish>("pubsub_publish"),
- convertors(convertors) {
+PubSubPublishConvertor::PubSubPublishConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubPublish>("pubsub_publish"),
+ convertors(convertors) {
}
PubSubPublishConvertor::~PubSubPublishConvertor() {
}
-boost::shared_ptr<PubSubPublish> PubSubPublishConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubPublish> result = boost::make_shared<PubSubPublish>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "items");
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubItem> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubItem> payload = boost::dynamic_pointer_cast<PubSubItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_item"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubPublish> PubSubPublishConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubPublish> result = std::make_shared<PubSubPublish>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "items");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubItem> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubItem> payload = std::dynamic_pointer_cast<PubSubItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_item"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setItems(items);
- }
- lua_pop(L, 1);
- return result;
+ result->setItems(items);
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubPublishConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubPublish> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (!payload->getItems().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- lua_setfield(L, -2, "items");
- }
+void PubSubPublishConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubPublish> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (!payload->getItems().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
+ {
+ int i = 0;
+ for (auto&& item : payload->getItems()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ lua_setfield(L, -2, "items");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubPublishConvertor::getDocumentation() const {
- return Documentation(
- "PubSubPublish",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `items`: array<@{PubSubItem}>\n"
- );
+ return Documentation(
+ "PubSubPublish",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `items`: array<@{PubSubItem}>\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubPublishConvertor.h b/Sluift/ElementConvertors/PubSubPublishConvertor.h
index 6deda0e..1765caf 100644
--- a/Sluift/ElementConvertors/PubSubPublishConvertor.h
+++ b/Sluift/ElementConvertors/PubSubPublishConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubPublish.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubPublish.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubPublishConvertor : public GenericLuaElementConvertor<PubSubPublish> {
- public:
- PubSubPublishConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubPublishConvertor();
+ class PubSubPublishConvertor : public GenericLuaElementConvertor<PubSubPublish> {
+ public:
+ PubSubPublishConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubPublishConvertor();
- virtual boost::shared_ptr<PubSubPublish> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubPublish>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubPublish> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubPublish>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubRetractConvertor.cpp b/Sluift/ElementConvertors/PubSubRetractConvertor.cpp
index abf19df..c070ad6 100644
--- a/Sluift/ElementConvertors/PubSubRetractConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubRetractConvertor.cpp
@@ -1,89 +1,90 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubRetractConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubRetractConvertor::PubSubRetractConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubRetract>("pubsub_retract"),
- convertors(convertors) {
+PubSubRetractConvertor::PubSubRetractConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubRetract>("pubsub_retract"),
+ convertors(convertors) {
}
PubSubRetractConvertor::~PubSubRetractConvertor() {
}
-boost::shared_ptr<PubSubRetract> PubSubRetractConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubRetract> result = boost::make_shared<PubSubRetract>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "items");
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubItem> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubItem> payload = boost::dynamic_pointer_cast<PubSubItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_item"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubRetract> PubSubRetractConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubRetract> result = std::make_shared<PubSubRetract>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "items");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubItem> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubItem> payload = std::dynamic_pointer_cast<PubSubItem>(convertors->convertFromLuaUntyped(L, -1, "pubsub_item"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setItems(items);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "notify");
- if (lua_isboolean(L, -1)) {
- result->setNotify(lua_toboolean(L, -1));
- }
- lua_pop(L, 1);
- return result;
+ result->setItems(items);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "notify");
+ if (lua_isboolean(L, -1)) {
+ result->setNotify(lua_toboolean(L, -1));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubRetractConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubRetract> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getNode().c_str());
- lua_setfield(L, -2, "node");
- if (!payload->getItems().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubItem> item, payload->getItems()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- lua_setfield(L, -2, "items");
- }
- lua_pushboolean(L, payload->isNotify());
- lua_setfield(L, -2, "notify");
+void PubSubRetractConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubRetract> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getNode().c_str());
+ lua_setfield(L, -2, "node");
+ if (!payload->getItems().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(payload->getItems().size()), 0);
+ {
+ int i = 0;
+ for (auto&& item : payload->getItems()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ lua_setfield(L, -2, "items");
+ }
+ if (payload->isNotify().is_initialized()) {
+ lua_pushboolean(L, payload->isNotify().get_value_or(false));
+ lua_setfield(L, -2, "notify");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubRetractConvertor::getDocumentation() const {
- return Documentation(
- "PubSubRetract",
- "This table has the following fields:\n\n"
- "- `node`: string\n"
- "- `items`: array<@{PubSubItem}>\n"
- "- `notify`: boolean\n"
- );
+ return Documentation(
+ "PubSubRetract",
+ "This table has the following fields:\n\n"
+ "- `node`: string\n"
+ "- `items`: array<@{PubSubItem}>\n"
+ "- `notify`: boolean\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubRetractConvertor.h b/Sluift/ElementConvertors/PubSubRetractConvertor.h
index 46aa71b..13f7d0d 100644
--- a/Sluift/ElementConvertors/PubSubRetractConvertor.h
+++ b/Sluift/ElementConvertors/PubSubRetractConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubRetract.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubRetract.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubRetractConvertor : public GenericLuaElementConvertor<PubSubRetract> {
- public:
- PubSubRetractConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubRetractConvertor();
+ class PubSubRetractConvertor : public GenericLuaElementConvertor<PubSubRetract> {
+ public:
+ PubSubRetractConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubRetractConvertor();
- virtual boost::shared_ptr<PubSubRetract> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubRetract>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubRetract> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubRetract>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubSubscribeConvertor.cpp b/Sluift/ElementConvertors/PubSubSubscribeConvertor.cpp
index 64be818..bb5eb61 100644
--- a/Sluift/ElementConvertors/PubSubSubscribeConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubSubscribeConvertor.cpp
@@ -1,70 +1,68 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubSubscribeConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubSubscribeConvertor::PubSubSubscribeConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubSubscribe>("pubsub_subscribe"),
- convertors(convertors) {
+PubSubSubscribeConvertor::PubSubSubscribeConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubSubscribe>("pubsub_subscribe"),
+ convertors(convertors) {
}
PubSubSubscribeConvertor::~PubSubSubscribeConvertor() {
}
-boost::shared_ptr<PubSubSubscribe> PubSubSubscribeConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubSubscribe> result = boost::make_shared<PubSubSubscribe>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "jid");
- if (lua_isstring(L, -1)) {
- result->setJID(JID(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "options");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubOptions> payload = boost::dynamic_pointer_cast<PubSubOptions>(convertors->convertFromLuaUntyped(L, -1, "pubsub_options"))) {
- result->setOptions(payload);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubSubscribe> PubSubSubscribeConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubSubscribe> result = std::make_shared<PubSubSubscribe>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "jid");
+ if (lua_isstring(L, -1)) {
+ result->setJID(JID(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "options");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubOptions> payload = std::dynamic_pointer_cast<PubSubOptions>(convertors->convertFromLuaUntyped(L, -1, "pubsub_options"))) {
+ result->setOptions(payload);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubSubscribeConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubSubscribe> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- lua_pushstring(L, payload->getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- if (convertors->convertToLuaUntyped(L, payload->getOptions()) > 0) {
- lua_setfield(L, -2, "options");
- }
+void PubSubSubscribeConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubSubscribe> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ lua_pushstring(L, payload->getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ if (convertors->convertToLuaUntyped(L, payload->getOptions()) > 0) {
+ lua_setfield(L, -2, "options");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubSubscribeConvertor::getDocumentation() const {
- return Documentation(
- "PubSubSubscribe",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `jid`: jid (string)\n"
- "- `options`: @{PubSubOptions}\n"
- );
+ return Documentation(
+ "PubSubSubscribe",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `jid`: jid (string)\n"
+ "- `options`: @{PubSubOptions}\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubSubscribeConvertor.h b/Sluift/ElementConvertors/PubSubSubscribeConvertor.h
index 5a7aefe..238f677 100644
--- a/Sluift/ElementConvertors/PubSubSubscribeConvertor.h
+++ b/Sluift/ElementConvertors/PubSubSubscribeConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubSubscribe.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubSubscribe.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubSubscribeConvertor : public GenericLuaElementConvertor<PubSubSubscribe> {
- public:
- PubSubSubscribeConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubSubscribeConvertor();
+ class PubSubSubscribeConvertor : public GenericLuaElementConvertor<PubSubSubscribe> {
+ public:
+ PubSubSubscribeConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubSubscribeConvertor();
- virtual boost::shared_ptr<PubSubSubscribe> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubSubscribe>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubSubscribe> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscribe>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.cpp
index 8a068ff..01da15f 100644
--- a/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.cpp
@@ -1,49 +1,44 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubSubscribeOptionsConvertor::PubSubSubscribeOptionsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubSubscribeOptions>("pubsub_subscribe_options"),
- convertors(convertors) {
+PubSubSubscribeOptionsConvertor::PubSubSubscribeOptionsConvertor() :
+ GenericLuaElementConvertor<PubSubSubscribeOptions>("pubsub_subscribe_options") {
}
PubSubSubscribeOptionsConvertor::~PubSubSubscribeOptionsConvertor() {
}
-boost::shared_ptr<PubSubSubscribeOptions> PubSubSubscribeOptionsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubSubscribeOptions> result = boost::make_shared<PubSubSubscribeOptions>();
- lua_getfield(L, -1, "required");
- if (lua_isboolean(L, -1)) {
- result->setRequired(lua_toboolean(L, -1));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubSubscribeOptions> PubSubSubscribeOptionsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubSubscribeOptions> result = std::make_shared<PubSubSubscribeOptions>();
+ lua_getfield(L, -1, "required");
+ if (lua_isboolean(L, -1)) {
+ result->setRequired(lua_toboolean(L, -1));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubSubscribeOptionsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubSubscribeOptions> payload) {
- lua_createtable(L, 0, 0);
- lua_pushboolean(L, payload->isRequired());
- lua_setfield(L, -2, "required");
+void PubSubSubscribeOptionsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubSubscribeOptions> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushboolean(L, payload->isRequired());
+ lua_setfield(L, -2, "required");
}
boost::optional<LuaElementConvertor::Documentation> PubSubSubscribeOptionsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubSubscribeOptions",
- "This table has the following fields:\n\n"
- "- `required`: boolean\n"
- );
+ return Documentation(
+ "PubSubSubscribeOptions",
+ "This table has the following fields:\n\n"
+ "- `required`: boolean\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h b/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h
index a36e7bb..fed8779 100644
--- a/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubSubscribeOptionsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubSubscribeOptions.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubSubscribeOptions.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubSubscribeOptionsConvertor : public GenericLuaElementConvertor<PubSubSubscribeOptions> {
- public:
- PubSubSubscribeOptionsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubSubscribeOptionsConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubSubscribeOptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubSubscribeOptions>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubSubscribeOptionsConvertor : public GenericLuaElementConvertor<PubSubSubscribeOptions> {
+ public:
+ PubSubSubscribeOptionsConvertor();
+ virtual ~PubSubSubscribeOptionsConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubSubscribeOptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscribeOptions>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubSubscriptionConvertor.cpp b/Sluift/ElementConvertors/PubSubSubscriptionConvertor.cpp
index 3aad76e..65c6474 100644
--- a/Sluift/ElementConvertors/PubSubSubscriptionConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubSubscriptionConvertor.cpp
@@ -1,112 +1,110 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubSubscriptionConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+#include <lua.hpp>
#include <Sluift/LuaElementConvertors.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-PubSubSubscriptionConvertor::PubSubSubscriptionConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubSubscription>("pubsub_subscription"),
- convertors(convertors) {
+PubSubSubscriptionConvertor::PubSubSubscriptionConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubSubscription>("pubsub_subscription"),
+ convertors(convertors) {
}
PubSubSubscriptionConvertor::~PubSubSubscriptionConvertor() {
}
-boost::shared_ptr<PubSubSubscription> PubSubSubscriptionConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubSubscription> result = boost::make_shared<PubSubSubscription>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription_id");
- if (lua_isstring(L, -1)) {
- result->setSubscriptionID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "jid");
- if (lua_isstring(L, -1)) {
- result->setJID(JID(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "options");
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubSubscribeOptions> payload = boost::dynamic_pointer_cast<PubSubSubscribeOptions>(convertors->convertFromLuaUntyped(L, -1, "pubsub_subscribe_options"))) {
- result->setOptions(payload);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription");
- if (lua_isstring(L, -1)) {
- if (std::string(lua_tostring(L, -1)) == "none") {
- result->setSubscription(PubSubSubscription::None);
- }
- if (std::string(lua_tostring(L, -1)) == "pending") {
- result->setSubscription(PubSubSubscription::Pending);
- }
- if (std::string(lua_tostring(L, -1)) == "subscribed") {
- result->setSubscription(PubSubSubscription::Subscribed);
- }
- if (std::string(lua_tostring(L, -1)) == "unconfigured") {
- result->setSubscription(PubSubSubscription::Unconfigured);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubSubscription> PubSubSubscriptionConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubSubscription> result = std::make_shared<PubSubSubscription>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription_id");
+ if (lua_isstring(L, -1)) {
+ result->setSubscriptionID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "jid");
+ if (lua_isstring(L, -1)) {
+ result->setJID(JID(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "options");
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubSubscribeOptions> payload = std::dynamic_pointer_cast<PubSubSubscribeOptions>(convertors->convertFromLuaUntyped(L, -1, "pubsub_subscribe_options"))) {
+ result->setOptions(payload);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription");
+ if (lua_isstring(L, -1)) {
+ if (std::string(lua_tostring(L, -1)) == "none") {
+ result->setSubscription(PubSubSubscription::None);
+ }
+ if (std::string(lua_tostring(L, -1)) == "pending") {
+ result->setSubscription(PubSubSubscription::Pending);
+ }
+ if (std::string(lua_tostring(L, -1)) == "subscribed") {
+ result->setSubscription(PubSubSubscription::Subscribed);
+ }
+ if (std::string(lua_tostring(L, -1)) == "unconfigured") {
+ result->setSubscription(PubSubSubscription::Unconfigured);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubSubscriptionConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubSubscription> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- if (payload->getSubscriptionID()) {
- lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
- lua_setfield(L, -2, "subscription_id");
- }
- lua_pushstring(L, payload->getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- if (convertors->convertToLuaUntyped(L, payload->getOptions()) > 0) {
- lua_setfield(L, -2, "options");
- }
- switch (payload->getSubscription()) {
- case PubSubSubscription::None:
- lua_pushstring(L, "none");
- break;
- case PubSubSubscription::Pending:
- lua_pushstring(L, "pending");
- break;
- case PubSubSubscription::Subscribed:
- lua_pushstring(L, "subscribed");
- break;
- case PubSubSubscription::Unconfigured:
- lua_pushstring(L, "unconfigured");
- break;
- }
- lua_setfield(L, -2, "subscription");
+void PubSubSubscriptionConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubSubscription> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (payload->getSubscriptionID()) {
+ lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
+ lua_setfield(L, -2, "subscription_id");
+ }
+ lua_pushstring(L, payload->getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ if (convertors->convertToLuaUntyped(L, payload->getOptions()) > 0) {
+ lua_setfield(L, -2, "options");
+ }
+ switch (payload->getSubscription()) {
+ case PubSubSubscription::None:
+ lua_pushstring(L, "none");
+ break;
+ case PubSubSubscription::Pending:
+ lua_pushstring(L, "pending");
+ break;
+ case PubSubSubscription::Subscribed:
+ lua_pushstring(L, "subscribed");
+ break;
+ case PubSubSubscription::Unconfigured:
+ lua_pushstring(L, "unconfigured");
+ break;
+ }
+ lua_setfield(L, -2, "subscription");
}
boost::optional<LuaElementConvertor::Documentation> PubSubSubscriptionConvertor::getDocumentation() const {
- return Documentation(
- "PubSubSubscription",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `subscription_id`: string (Optional)\n"
- "- `jid`: jid (string)\n"
- "- `options`: @{PubSubSubscribeOptions}\n"
- "- `subscription`: `\"none\"`, `\"pending\"`, `\"subscribed\"`, or `\"unconfigured\"`\n"
- );
+ return Documentation(
+ "PubSubSubscription",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `subscription_id`: string (Optional)\n"
+ "- `jid`: jid (string)\n"
+ "- `options`: @{PubSubSubscribeOptions}\n"
+ "- `subscription`: `\"none\"`, `\"pending\"`, `\"subscribed\"`, or `\"unconfigured\"`\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h b/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h
index 6d09ddf..5635181 100644
--- a/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h
+++ b/Sluift/ElementConvertors/PubSubSubscriptionConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubSubscription.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubSubscription.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubSubscriptionConvertor : public GenericLuaElementConvertor<PubSubSubscription> {
- public:
- PubSubSubscriptionConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubSubscriptionConvertor();
+ class PubSubSubscriptionConvertor : public GenericLuaElementConvertor<PubSubSubscription> {
+ public:
+ PubSubSubscriptionConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubSubscriptionConvertor();
- virtual boost::shared_ptr<PubSubSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubSubscription>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubSubscription> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscription>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp
index 5e66f2f..3712192 100644
--- a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.cpp
@@ -1,79 +1,78 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/LuaElementConvertors.h>
-#include <Swiften/Base/foreach.h>
+#include <lua.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <Sluift/LuaElementConvertors.h>
using namespace Swift;
-PubSubSubscriptionsConvertor::PubSubSubscriptionsConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubSubscriptions>("pubsub_subscriptions"),
- convertors(convertors) {
+PubSubSubscriptionsConvertor::PubSubSubscriptionsConvertor(LuaElementConvertors* convertors) :
+ GenericLuaElementConvertor<PubSubSubscriptions>("pubsub_subscriptions"),
+ convertors(convertors) {
}
PubSubSubscriptionsConvertor::~PubSubSubscriptionsConvertor() {
}
-boost::shared_ptr<PubSubSubscriptions> PubSubSubscriptionsConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubSubscriptions> result = boost::make_shared<PubSubSubscriptions>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< boost::shared_ptr<PubSubSubscription> > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- if (boost::shared_ptr<PubSubSubscription> payload = boost::dynamic_pointer_cast<PubSubSubscription>(convertors->convertFromLuaUntyped(L, -1, "pubsub_subscription"))) {
- items.push_back(payload);
- }
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<PubSubSubscriptions> PubSubSubscriptionsConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubSubscriptions> result = std::make_shared<PubSubSubscriptions>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::shared_ptr<PubSubSubscription> > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ if (std::shared_ptr<PubSubSubscription> payload = std::dynamic_pointer_cast<PubSubSubscription>(convertors->convertFromLuaUntyped(L, -1, "pubsub_subscription"))) {
+ items.push_back(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
- result->setSubscriptions(items);
- }
- return result;
+ result->setSubscriptions(items);
+ }
+ return result;
}
-void PubSubSubscriptionsConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubSubscriptions> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- if (!payload->getSubscriptions().empty()) {
- {
- int i = 0;
- foreach(boost::shared_ptr<PubSubSubscription> item, payload->getSubscriptions()) {
- if (convertors->convertToLuaUntyped(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- }
+void PubSubSubscriptionsConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubSubscriptions> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ if (!payload->getSubscriptions().empty()) {
+ {
+ int i = 0;
+ for (auto&& item : payload->getSubscriptions()) {
+ if (convertors->convertToLuaUntyped(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubSubscriptionsConvertor::getDocumentation() const {
- return Documentation(
- "PubSubSubscriptions",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `subscriptions`: array<@{PubSubSubscription}>\n"
- );
+ return Documentation(
+ "PubSubSubscriptions",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `subscriptions`: array<@{PubSubSubscription}>\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h
index 70fc159..2c941e6 100644
--- a/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h
+++ b/Sluift/ElementConvertors/PubSubSubscriptionsConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,23 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubSubscriptions.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubSubscriptions.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class PubSubSubscriptionsConvertor : public GenericLuaElementConvertor<PubSubSubscriptions> {
- public:
- PubSubSubscriptionsConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubSubscriptionsConvertor();
+ class PubSubSubscriptionsConvertor : public GenericLuaElementConvertor<PubSubSubscriptions> {
+ public:
+ PubSubSubscriptionsConvertor(LuaElementConvertors* convertors);
+ virtual ~PubSubSubscriptionsConvertor();
- virtual boost::shared_ptr<PubSubSubscriptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubSubscriptions>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<PubSubSubscriptions> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubSubscriptions>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
- private:
- LuaElementConvertors* convertors;
- };
+ private:
+ LuaElementConvertors* convertors;
+ };
}
diff --git a/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.cpp b/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.cpp
index 4b515ea..056c84c 100644
--- a/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.cpp
+++ b/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.cpp
@@ -1,69 +1,64 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-
-
+#include <memory>
-
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-PubSubUnsubscribeConvertor::PubSubUnsubscribeConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<PubSubUnsubscribe>("pubsub_unsubscribe"),
- convertors(convertors) {
+PubSubUnsubscribeConvertor::PubSubUnsubscribeConvertor() :
+ GenericLuaElementConvertor<PubSubUnsubscribe>("pubsub_unsubscribe") {
}
PubSubUnsubscribeConvertor::~PubSubUnsubscribeConvertor() {
}
-boost::shared_ptr<PubSubUnsubscribe> PubSubUnsubscribeConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<PubSubUnsubscribe> result = boost::make_shared<PubSubUnsubscribe>();
- lua_getfield(L, -1, "node");
- if (lua_isstring(L, -1)) {
- result->setNode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "jid");
- if (lua_isstring(L, -1)) {
- result->setJID(JID(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "subscription_id");
- if (lua_isstring(L, -1)) {
- result->setSubscriptionID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<PubSubUnsubscribe> PubSubUnsubscribeConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<PubSubUnsubscribe> result = std::make_shared<PubSubUnsubscribe>();
+ lua_getfield(L, -1, "node");
+ if (lua_isstring(L, -1)) {
+ result->setNode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "jid");
+ if (lua_isstring(L, -1)) {
+ result->setJID(JID(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "subscription_id");
+ if (lua_isstring(L, -1)) {
+ result->setSubscriptionID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void PubSubUnsubscribeConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<PubSubUnsubscribe> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getNode()) {
- lua_pushstring(L, (*payload->getNode()).c_str());
- lua_setfield(L, -2, "node");
- }
- lua_pushstring(L, payload->getJID().toString().c_str());
- lua_setfield(L, -2, "jid");
- if (payload->getSubscriptionID()) {
- lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
- lua_setfield(L, -2, "subscription_id");
- }
+void PubSubUnsubscribeConvertor::doConvertToLua(lua_State* L, std::shared_ptr<PubSubUnsubscribe> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getNode()) {
+ lua_pushstring(L, (*payload->getNode()).c_str());
+ lua_setfield(L, -2, "node");
+ }
+ lua_pushstring(L, payload->getJID().toString().c_str());
+ lua_setfield(L, -2, "jid");
+ if (payload->getSubscriptionID()) {
+ lua_pushstring(L, (*payload->getSubscriptionID()).c_str());
+ lua_setfield(L, -2, "subscription_id");
+ }
}
boost::optional<LuaElementConvertor::Documentation> PubSubUnsubscribeConvertor::getDocumentation() const {
- return Documentation(
- "PubSubUnsubscribe",
- "This table has the following fields:\n\n"
- "- `node`: string (Optional)\n"
- "- `jid`: jid (string)\n"
- "- `subscription_id`: string (Optional)\n"
- );
+ return Documentation(
+ "PubSubUnsubscribe",
+ "This table has the following fields:\n\n"
+ "- `node`: string (Optional)\n"
+ "- `jid`: jid (string)\n"
+ "- `subscription_id`: string (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h b/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h
index e075298..7270917 100644
--- a/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h
+++ b/Sluift/ElementConvertors/PubSubUnsubscribeConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/PubSubUnsubscribe.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/PubSubUnsubscribe.h>
namespace Swift {
- class LuaElementConvertors;
-
- class PubSubUnsubscribeConvertor : public GenericLuaElementConvertor<PubSubUnsubscribe> {
- public:
- PubSubUnsubscribeConvertor(LuaElementConvertors* convertors);
- virtual ~PubSubUnsubscribeConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<PubSubUnsubscribe> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<PubSubUnsubscribe>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class PubSubUnsubscribeConvertor : public GenericLuaElementConvertor<PubSubUnsubscribe> {
+ public:
+ PubSubUnsubscribeConvertor();
+ virtual ~PubSubUnsubscribeConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<PubSubUnsubscribe> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<PubSubUnsubscribe>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/RawXMLElementConvertor.cpp b/Sluift/ElementConvertors/RawXMLElementConvertor.cpp
index e859079..9688677 100644
--- a/Sluift/ElementConvertors/RawXMLElementConvertor.cpp
+++ b/Sluift/ElementConvertors/RawXMLElementConvertor.cpp
@@ -1,17 +1,18 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/RawXMLElementConvertor.h>
-#include <iostream>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <lua.hpp>
#include <Swiften/Elements/RawXMLPayload.h>
#include <Swiften/Serializer/PayloadSerializer.h>
+
#include <Sluift/Lua/Check.h>
using namespace Swift;
@@ -22,20 +23,20 @@ RawXMLElementConvertor::RawXMLElementConvertor() {
RawXMLElementConvertor::~RawXMLElementConvertor() {
}
-boost::shared_ptr<Element> RawXMLElementConvertor::convertFromLua(lua_State* L, int index, const std::string& type) {
- if (type == "xml") {
- return boost::make_shared<RawXMLPayload>(std::string(Lua::checkString(L, index)));
- }
- return boost::shared_ptr<Payload>();
+std::shared_ptr<Element> RawXMLElementConvertor::convertFromLua(lua_State* L, int index, const std::string& type) {
+ if (type == "xml") {
+ return std::make_shared<RawXMLPayload>(std::string(Lua::checkString(L, index)));
+ }
+ return std::shared_ptr<Payload>();
}
-boost::optional<std::string> RawXMLElementConvertor::convertToLua(lua_State* L, boost::shared_ptr<Element> element) {
- boost::shared_ptr<Payload> payload = boost::dynamic_pointer_cast<Payload>(element);
- if (!payload) {
- return boost::optional<std::string>();
- }
- PayloadSerializer* serializer = serializers.getPayloadSerializer(payload);
- assert(serializer);
- lua_pushstring(L, serializer->serialize(payload).c_str());
- return std::string("xml");
+boost::optional<std::string> RawXMLElementConvertor::convertToLua(lua_State* L, std::shared_ptr<Element> element) {
+ std::shared_ptr<Payload> payload = std::dynamic_pointer_cast<Payload>(element);
+ if (!payload) {
+ return boost::optional<std::string>();
+ }
+ PayloadSerializer* serializer = serializers.getPayloadSerializer(payload);
+ assert(serializer);
+ lua_pushstring(L, serializer->serialize(payload).c_str());
+ return std::string("xml");
}
diff --git a/Sluift/ElementConvertors/RawXMLElementConvertor.h b/Sluift/ElementConvertors/RawXMLElementConvertor.h
index 98be763..79f648f 100644
--- a/Sluift/ElementConvertors/RawXMLElementConvertor.h
+++ b/Sluift/ElementConvertors/RawXMLElementConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,20 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
#include <Sluift/LuaElementConvertor.h>
-#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
namespace Swift {
- class RawXMLElementConvertor : public LuaElementConvertor {
- public:
- RawXMLElementConvertor();
- virtual ~RawXMLElementConvertor();
+ class RawXMLElementConvertor : public LuaElementConvertor {
+ public:
+ RawXMLElementConvertor();
+ virtual ~RawXMLElementConvertor();
- virtual boost::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE;
- virtual boost::optional<std::string> convertToLua(lua_State*, boost::shared_ptr<Element>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<Element> convertFromLua(lua_State*, int index, const std::string& type) SWIFTEN_OVERRIDE;
+ virtual boost::optional<std::string> convertToLua(lua_State*, std::shared_ptr<Element>) SWIFTEN_OVERRIDE;
- private:
- FullPayloadSerializerCollection serializers;
- };
+ private:
+ FullPayloadSerializerCollection serializers;
+ };
}
diff --git a/Sluift/ElementConvertors/ResultSetConvertor.cpp b/Sluift/ElementConvertors/ResultSetConvertor.cpp
index 79eb00d..7762a79 100644
--- a/Sluift/ElementConvertors/ResultSetConvertor.cpp
+++ b/Sluift/ElementConvertors/ResultSetConvertor.cpp
@@ -1,116 +1,116 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
-#include <boost/numeric/conversion/cast.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <lua.hpp>
#include <Sluift/ElementConvertors/ResultSetConvertor.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <memory>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
using namespace Swift;
-ResultSetConvertor::ResultSetConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<ResultSet>("result_set"),
- convertors(convertors) {
+ResultSetConvertor::ResultSetConvertor() :
+ GenericLuaElementConvertor<ResultSet>("result_set") {
}
ResultSetConvertor::~ResultSetConvertor() {
}
-boost::shared_ptr<ResultSet> ResultSetConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<ResultSet> result = boost::make_shared<ResultSet>();
- lua_getfield(L, -1, "max_items");
- if (lua_isstring(L, -1)) {
- result->setMaxItems(boost::numeric_cast<int>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "count");
- if (lua_isnumber(L, -1)) {
- result->setCount(boost::numeric_cast<int>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "index");
- if (lua_isnumber(L, -1)) {
- result->setIndex(boost::numeric_cast<int>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "first_id_index");
- if (lua_isstring(L, -1)) {
- result->setFirstIDIndex(boost::numeric_cast<int>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "first_id");
- if (lua_isstring(L, -1)) {
- result->setFirstID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "last_id");
- if (lua_isstring(L, -1)) {
- result->setLastID(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "after");
- if (lua_isstring(L, -1)) {
- result->setAfter(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "before");
- if (lua_isstring(L, -1)) {
- result->setBefore(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<ResultSet> ResultSetConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<ResultSet> result = std::make_shared<ResultSet>();
+ lua_getfield(L, -1, "max_items");
+ if (lua_isstring(L, -1)) {
+ result->setMaxItems(boost::numeric_cast<int>(lua_tonumber(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "count");
+ if (lua_isnumber(L, -1)) {
+ result->setCount(boost::numeric_cast<int>(lua_tonumber(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "index");
+ if (lua_isnumber(L, -1)) {
+ result->setIndex(boost::numeric_cast<int>(lua_tonumber(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "first_id_index");
+ if (lua_isstring(L, -1)) {
+ result->setFirstIDIndex(boost::numeric_cast<int>(lua_tonumber(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "first_id");
+ if (lua_isstring(L, -1)) {
+ result->setFirstID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "last_id");
+ if (lua_isstring(L, -1)) {
+ result->setLastID(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "after");
+ if (lua_isstring(L, -1)) {
+ result->setAfter(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "before");
+ if (lua_isstring(L, -1)) {
+ result->setBefore(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void ResultSetConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<ResultSet> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getMaxItems()) {
- lua_pushnumber(L, *payload->getMaxItems());
- lua_setfield(L, -2, "max_items");
- }
- if (payload->getCount()) {
- lua_pushnumber(L, *payload->getCount());
- lua_setfield(L, -2, "count");
- }
- if (payload->getIndex()) {
- lua_pushnumber(L, *payload->getIndex());
- lua_setfield(L, -2, "index");
- }
- if (payload->getFirstIDIndex()) {
- lua_pushnumber(L, *payload->getFirstIDIndex());
- lua_setfield(L, -2, "first_id_index");
- }
- if (payload->getFirstID()) {
- lua_pushstring(L, (*payload->getFirstID()).c_str());
- lua_setfield(L, -2, "first_id");
- }
- if (payload->getLastID()) {
- lua_pushstring(L, (*payload->getLastID()).c_str());
- lua_setfield(L, -2, "last_id");
- }
- if (payload->getAfter()) {
- lua_pushstring(L, (*payload->getAfter()).c_str());
- lua_setfield(L, -2, "after");
- }
- if (payload->getBefore()) {
- lua_pushstring(L, (*payload->getBefore()).c_str());
- lua_setfield(L, -2, "before");
- }
+void ResultSetConvertor::doConvertToLua(lua_State* L, std::shared_ptr<ResultSet> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getMaxItems()) {
+ lua_pushnumber(L, *payload->getMaxItems());
+ lua_setfield(L, -2, "max_items");
+ }
+ if (payload->getCount()) {
+ lua_pushnumber(L, *payload->getCount());
+ lua_setfield(L, -2, "count");
+ }
+ if (payload->getIndex()) {
+ lua_pushnumber(L, *payload->getIndex());
+ lua_setfield(L, -2, "index");
+ }
+ if (payload->getFirstIDIndex()) {
+ lua_pushnumber(L, *payload->getFirstIDIndex());
+ lua_setfield(L, -2, "first_id_index");
+ }
+ if (payload->getFirstID()) {
+ lua_pushstring(L, (*payload->getFirstID()).c_str());
+ lua_setfield(L, -2, "first_id");
+ }
+ if (payload->getLastID()) {
+ lua_pushstring(L, (*payload->getLastID()).c_str());
+ lua_setfield(L, -2, "last_id");
+ }
+ if (payload->getAfter()) {
+ lua_pushstring(L, (*payload->getAfter()).c_str());
+ lua_setfield(L, -2, "after");
+ }
+ if (payload->getBefore()) {
+ lua_pushstring(L, (*payload->getBefore()).c_str());
+ lua_setfield(L, -2, "before");
+ }
}
boost::optional<LuaElementConvertor::Documentation> ResultSetConvertor::getDocumentation() const {
- return Documentation(
- "ResultSet",
- "This table has the following fields:\n\n"
- "- `max_items`: number (Optional)\n"
- "- `count`: number (Optional)\n"
- "- `first_id_index`: number (Optional)\n"
- "- `first_id`: string (Optional)\n"
- "- `last_id`: string (Optional)\n"
- "- `after`: string (Optional)\n"
- );
+ return Documentation(
+ "ResultSet",
+ "This table has the following fields:\n\n"
+ "- `max_items`: number (Optional)\n"
+ "- `count`: number (Optional)\n"
+ "- `first_id_index`: number (Optional)\n"
+ "- `first_id`: string (Optional)\n"
+ "- `last_id`: string (Optional)\n"
+ "- `after`: string (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/ResultSetConvertor.h b/Sluift/ElementConvertors/ResultSetConvertor.h
index 50a6836..e1b826c 100644
--- a/Sluift/ElementConvertors/ResultSetConvertor.h
+++ b/Sluift/ElementConvertors/ResultSetConvertor.h
@@ -1,29 +1,27 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Sluift/GenericLuaElementConvertor.h>
#include <Swiften/Base/Override.h>
#include <Swiften/Elements/ResultSet.h>
-namespace Swift {
- class LuaElementConvertors;
+#include <Sluift/GenericLuaElementConvertor.h>
- class ResultSetConvertor : public GenericLuaElementConvertor<ResultSet> {
- public:
- ResultSetConvertor(LuaElementConvertors* convertors);
- virtual ~ResultSetConvertor();
+namespace Swift {
+ class LuaElementConvertors;
- virtual boost::shared_ptr<ResultSet> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<ResultSet>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class ResultSetConvertor : public GenericLuaElementConvertor<ResultSet> {
+ public:
+ ResultSetConvertor();
+ virtual ~ResultSetConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<ResultSet> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<ResultSet>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/SConscript b/Sluift/ElementConvertors/SConscript
index 265017b..0bf8022 100644
--- a/Sluift/ElementConvertors/SConscript
+++ b/Sluift/ElementConvertors/SConscript
@@ -2,53 +2,55 @@
Import('env')
convertors = [
- env.File("PubSubRetractConvertor.cpp"),
- env.File("PubSubAffiliationsConvertor.cpp"),
- env.File("PubSubPublishConvertor.cpp"),
- env.File("PubSubItemsConvertor.cpp"),
- env.File("PubSubOwnerRedirectConvertor.cpp"),
- env.File("PubSubEventRedirectConvertor.cpp"),
- env.File("UserTuneConvertor.cpp"),
- env.File("PubSubConfigureConvertor.cpp"),
- env.File("PubSubEventDisassociateConvertor.cpp"),
- env.File("PubSubOwnerAffiliationsConvertor.cpp"),
- env.File("PubSubOwnerConfigureConvertor.cpp"),
- env.File("UserLocationConvertor.cpp"),
- env.File("PubSubSubscribeOptionsConvertor.cpp"),
- env.File("PubSubOwnerSubscriptionsConvertor.cpp"),
- env.File("PubSubDefaultConvertor.cpp"),
- env.File("PubSubEventCollectionConvertor.cpp"),
- env.File("PubSubEventSubscriptionConvertor.cpp"),
- env.File("PubSubEventRetractConvertor.cpp"),
- env.File("PubSubItemConvertor.cpp"),
- env.File("PubSubUnsubscribeConvertor.cpp"),
- env.File("PubSubEventDeleteConvertor.cpp"),
- env.File("PubSubCreateConvertor.cpp"),
- env.File("PubSubOwnerPurgeConvertor.cpp"),
- env.File("PubSubEventItemsConvertor.cpp"),
- env.File("PubSubOptionsConvertor.cpp"),
- env.File("PubSubEventItemConvertor.cpp"),
- env.File("PubSubOwnerSubscriptionConvertor.cpp"),
- env.File("PubSubOwnerAffiliationConvertor.cpp"),
- env.File("PubSubEventPurgeConvertor.cpp"),
- env.File("PubSubAffiliationConvertor.cpp"),
- env.File("PubSubSubscribeConvertor.cpp"),
- env.File("PubSubOwnerDeleteConvertor.cpp"),
- env.File("PubSubOwnerDefaultConvertor.cpp"),
- env.File("PubSubSubscriptionsConvertor.cpp"),
- env.File("PubSubEventAssociateConvertor.cpp"),
- env.File("PubSubSubscriptionConvertor.cpp"),
- env.File("SecurityLabelConvertor.cpp"),
- env.File("PubSubEventConfigurationConvertor.cpp"),
- env.File("IQConvertor.cpp"),
- env.File("PresenceConvertor.cpp"),
- env.File("MessageConvertor.cpp"),
- env.File("ResultSetConvertor.cpp"),
- env.File("ForwardedConvertor.cpp"),
- env.File("MAMResultConvertor.cpp"),
- env.File("MAMQueryConvertor.cpp"),
- env.File("MAMFinConvertor.cpp"),
- env.File("SubjectConvertor.cpp"),
- env.File("IsodeIQDelegationConvertor.cpp")
+ env.File("PubSubRetractConvertor.cpp"),
+ env.File("PubSubAffiliationsConvertor.cpp"),
+ env.File("PubSubPublishConvertor.cpp"),
+ env.File("PubSubItemsConvertor.cpp"),
+ env.File("PubSubOwnerRedirectConvertor.cpp"),
+ env.File("PubSubEventRedirectConvertor.cpp"),
+ env.File("UserTuneConvertor.cpp"),
+ env.File("PubSubConfigureConvertor.cpp"),
+ env.File("PubSubEventDisassociateConvertor.cpp"),
+ env.File("PubSubOwnerAffiliationsConvertor.cpp"),
+ env.File("PubSubOwnerConfigureConvertor.cpp"),
+ env.File("UserLocationConvertor.cpp"),
+ env.File("PubSubSubscribeOptionsConvertor.cpp"),
+ env.File("PubSubOwnerSubscriptionsConvertor.cpp"),
+ env.File("PubSubDefaultConvertor.cpp"),
+ env.File("PubSubEventCollectionConvertor.cpp"),
+ env.File("PubSubEventSubscriptionConvertor.cpp"),
+ env.File("PubSubEventRetractConvertor.cpp"),
+ env.File("PubSubItemConvertor.cpp"),
+ env.File("PubSubUnsubscribeConvertor.cpp"),
+ env.File("PubSubEventDeleteConvertor.cpp"),
+ env.File("PubSubCreateConvertor.cpp"),
+ env.File("PubSubOwnerPurgeConvertor.cpp"),
+ env.File("PubSubEventItemsConvertor.cpp"),
+ env.File("PubSubOptionsConvertor.cpp"),
+ env.File("PubSubEventItemConvertor.cpp"),
+ env.File("PubSubOwnerSubscriptionConvertor.cpp"),
+ env.File("PubSubOwnerAffiliationConvertor.cpp"),
+ env.File("PubSubEventPurgeConvertor.cpp"),
+ env.File("PubSubAffiliationConvertor.cpp"),
+ env.File("PubSubSubscribeConvertor.cpp"),
+ env.File("PubSubOwnerDeleteConvertor.cpp"),
+ env.File("PubSubOwnerDefaultConvertor.cpp"),
+ env.File("PubSubSubscriptionsConvertor.cpp"),
+ env.File("PubSubEventAssociateConvertor.cpp"),
+ env.File("PubSubSubscriptionConvertor.cpp"),
+ env.File("SecurityLabelConvertor.cpp"),
+ env.File("PubSubEventConfigurationConvertor.cpp"),
+ env.File("IQConvertor.cpp"),
+ env.File("PresenceConvertor.cpp"),
+ env.File("MessageConvertor.cpp"),
+ env.File("ResultSetConvertor.cpp"),
+ env.File("ForwardedConvertor.cpp"),
+ env.File("MAMResultConvertor.cpp"),
+ env.File("MAMQueryConvertor.cpp"),
+ env.File("MAMFinConvertor.cpp"),
+ env.File("CarbonsReceivedConvertor.cpp"),
+ env.File("CarbonsSentConvertor.cpp"),
+ env.File("SubjectConvertor.cpp"),
+ env.File("IsodeIQDelegationConvertor.cpp")
]
Return('convertors')
diff --git a/Sluift/ElementConvertors/SecurityLabelConvertor.cpp b/Sluift/ElementConvertors/SecurityLabelConvertor.cpp
index cfaeb7d..21d9a8f 100644
--- a/Sluift/ElementConvertors/SecurityLabelConvertor.cpp
+++ b/Sluift/ElementConvertors/SecurityLabelConvertor.cpp
@@ -1,101 +1,98 @@
/*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/SecurityLabelConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <boost/numeric/conversion/cast.hpp>
+#include <memory>
-#include <Swiften/Base/foreach.h>
+#include <boost/numeric/conversion/cast.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-SecurityLabelConvertor::SecurityLabelConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<SecurityLabel>("security_label"),
- convertors(convertors) {
+SecurityLabelConvertor::SecurityLabelConvertor() :
+ GenericLuaElementConvertor<SecurityLabel>("security_label") {
}
SecurityLabelConvertor::~SecurityLabelConvertor() {
}
-boost::shared_ptr<SecurityLabel> SecurityLabelConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<SecurityLabel> result = boost::make_shared<SecurityLabel>();
- lua_getfield(L, -1, "equivalent_labels");
- if (lua_type(L, -1) == LUA_TTABLE) {
- std::vector< std::string > items;
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (lua_isstring(L, -1)) {
- items.push_back(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- }
+std::shared_ptr<SecurityLabel> SecurityLabelConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<SecurityLabel> result = std::make_shared<SecurityLabel>();
+ lua_getfield(L, -1, "equivalent_labels");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ std::vector< std::string > items;
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (lua_isstring(L, -1)) {
+ items.push_back(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ }
- result->setEquivalentLabels(items);
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "foreground_color");
- if (lua_isstring(L, -1)) {
- result->setForegroundColor(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "display_marking");
- if (lua_isstring(L, -1)) {
- result->setDisplayMarking(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "background_color");
- if (lua_isstring(L, -1)) {
- result->setBackgroundColor(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "label");
- if (lua_isstring(L, -1)) {
- result->setLabel(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+ result->setEquivalentLabels(items);
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "foreground_color");
+ if (lua_isstring(L, -1)) {
+ result->setForegroundColor(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "display_marking");
+ if (lua_isstring(L, -1)) {
+ result->setDisplayMarking(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "background_color");
+ if (lua_isstring(L, -1)) {
+ result->setBackgroundColor(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "label");
+ if (lua_isstring(L, -1)) {
+ result->setLabel(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void SecurityLabelConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<SecurityLabel> payload) {
- lua_createtable(L, 0, 0);
- if (!payload->getEquivalentLabels().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(payload->getEquivalentLabels().size()), 0);
- {
- int i = 0;
- foreach(const std::string& item, payload->getEquivalentLabels()) {
- lua_pushstring(L, item.c_str());
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- lua_setfield(L, -2, "equivalent_labels");
- }
- lua_pushstring(L, payload->getForegroundColor().c_str());
- lua_setfield(L, -2, "foreground_color");
- lua_pushstring(L, payload->getDisplayMarking().c_str());
- lua_setfield(L, -2, "display_marking");
- lua_pushstring(L, payload->getBackgroundColor().c_str());
- lua_setfield(L, -2, "background_color");
- lua_pushstring(L, payload->getLabel().c_str());
- lua_setfield(L, -2, "label");
+void SecurityLabelConvertor::doConvertToLua(lua_State* L, std::shared_ptr<SecurityLabel> payload) {
+ lua_createtable(L, 0, 0);
+ if (!payload->getEquivalentLabels().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(payload->getEquivalentLabels().size()), 0);
+ {
+ int i = 0;
+ for (const auto& item : payload->getEquivalentLabels()) {
+ lua_pushstring(L, item.c_str());
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ lua_setfield(L, -2, "equivalent_labels");
+ }
+ lua_pushstring(L, payload->getForegroundColor().c_str());
+ lua_setfield(L, -2, "foreground_color");
+ lua_pushstring(L, payload->getDisplayMarking().c_str());
+ lua_setfield(L, -2, "display_marking");
+ lua_pushstring(L, payload->getBackgroundColor().c_str());
+ lua_setfield(L, -2, "background_color");
+ lua_pushstring(L, payload->getLabel().c_str());
+ lua_setfield(L, -2, "label");
}
boost::optional<LuaElementConvertor::Documentation> SecurityLabelConvertor::getDocumentation() const {
- return Documentation(
- "SecurityLabel",
- "This table has the following fields:\n\n"
- "- `equivalent_labels`: array<string>\n"
- "- `foreground_color`: string\n"
- "- `display_marking`: string\n"
- "- `background_color`: string\n"
- "- `label`: string\n"
- );
+ return Documentation(
+ "SecurityLabel",
+ "This table has the following fields:\n\n"
+ "- `equivalent_labels`: array<string>\n"
+ "- `foreground_color`: string\n"
+ "- `display_marking`: string\n"
+ "- `background_color`: string\n"
+ "- `label`: string\n"
+ );
}
diff --git a/Sluift/ElementConvertors/SecurityLabelConvertor.h b/Sluift/ElementConvertors/SecurityLabelConvertor.h
index 8e489c0..a0e7fea 100644
--- a/Sluift/ElementConvertors/SecurityLabelConvertor.h
+++ b/Sluift/ElementConvertors/SecurityLabelConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/SecurityLabel.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/SecurityLabel.h>
namespace Swift {
- class LuaElementConvertors;
-
- class SecurityLabelConvertor : public GenericLuaElementConvertor<SecurityLabel> {
- public:
- SecurityLabelConvertor(LuaElementConvertors* convertors);
- virtual ~SecurityLabelConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<SecurityLabel> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<SecurityLabel>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class SecurityLabelConvertor : public GenericLuaElementConvertor<SecurityLabel> {
+ public:
+ SecurityLabelConvertor();
+ virtual ~SecurityLabelConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<SecurityLabel> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<SecurityLabel>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/SoftwareVersionConvertor.cpp b/Sluift/ElementConvertors/SoftwareVersionConvertor.cpp
index d621593..f997a45 100644
--- a/Sluift/ElementConvertors/SoftwareVersionConvertor.cpp
+++ b/Sluift/ElementConvertors/SoftwareVersionConvertor.cpp
@@ -1,14 +1,17 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/SoftwareVersionConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
+
#include <Sluift/Lua/Check.h>
using namespace Swift;
@@ -19,32 +22,32 @@ SoftwareVersionConvertor::SoftwareVersionConvertor() : GenericLuaElementConverto
SoftwareVersionConvertor::~SoftwareVersionConvertor() {
}
-boost::shared_ptr<SoftwareVersion> SoftwareVersionConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<SoftwareVersion> result = boost::make_shared<SoftwareVersion>();
- lua_getfield(L, -1, "name");
- if (!lua_isnil(L, -1)) {
- result->setName(std::string(Lua::checkString(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "version");
- if (!lua_isnil(L, -1)) {
- result->setVersion(std::string(Lua::checkString(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "os");
- if (!lua_isnil(L, -1)) {
- result->setOS(std::string(Lua::checkString(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<SoftwareVersion> SoftwareVersionConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<SoftwareVersion> result = std::make_shared<SoftwareVersion>();
+ lua_getfield(L, -1, "name");
+ if (!lua_isnil(L, -1)) {
+ result->setName(std::string(Lua::checkString(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "version");
+ if (!lua_isnil(L, -1)) {
+ result->setVersion(std::string(Lua::checkString(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "os");
+ if (!lua_isnil(L, -1)) {
+ result->setOS(std::string(Lua::checkString(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void SoftwareVersionConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<SoftwareVersion> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getName().c_str());
- lua_setfield(L, -2, "name");
- lua_pushstring(L, payload->getVersion().c_str());
- lua_setfield(L, -2, "version");
- lua_pushstring(L, payload->getOS().c_str());
- lua_setfield(L, -2, "os");
+void SoftwareVersionConvertor::doConvertToLua(lua_State* L, std::shared_ptr<SoftwareVersion> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getName().c_str());
+ lua_setfield(L, -2, "name");
+ lua_pushstring(L, payload->getVersion().c_str());
+ lua_setfield(L, -2, "version");
+ lua_pushstring(L, payload->getOS().c_str());
+ lua_setfield(L, -2, "os");
}
diff --git a/Sluift/ElementConvertors/SoftwareVersionConvertor.h b/Sluift/ElementConvertors/SoftwareVersionConvertor.h
index aded40a..29b1483 100644
--- a/Sluift/ElementConvertors/SoftwareVersionConvertor.h
+++ b/Sluift/ElementConvertors/SoftwareVersionConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,17 +7,17 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/SoftwareVersion.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/SoftwareVersion.h>
namespace Swift {
- class SoftwareVersionConvertor : public GenericLuaElementConvertor<SoftwareVersion> {
- public:
- SoftwareVersionConvertor();
- virtual ~SoftwareVersionConvertor();
+ class SoftwareVersionConvertor : public GenericLuaElementConvertor<SoftwareVersion> {
+ public:
+ SoftwareVersionConvertor();
+ virtual ~SoftwareVersionConvertor();
- virtual boost::shared_ptr<SoftwareVersion> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<SoftwareVersion>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<SoftwareVersion> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<SoftwareVersion>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/StanzaConvertor.h b/Sluift/ElementConvertors/StanzaConvertor.h
index b3e75cf..bdaaad3 100644
--- a/Sluift/ElementConvertors/StanzaConvertor.h
+++ b/Sluift/ElementConvertors/StanzaConvertor.h
@@ -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.
*/
@@ -8,81 +8,81 @@
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/GenericLuaElementConvertor.h>
-#include <Sluift/LuaElementConvertors.h>
-#include <Sluift/Lua/Exception.h>
-#include <Swiften/Base/foreach.h>
-#include <Swiften/Elements/Payload.h>
#include <Swiften/Elements/IQ.h>
-#include <Swiften/Elements/Presence.h>
#include <Swiften/Elements/Message.h>
+#include <Swiften/Elements/Payload.h>
+#include <Swiften/Elements/Presence.h>
+
+#include <Sluift/GenericLuaElementConvertor.h>
+#include <Sluift/Lua/Exception.h>
+#include <Sluift/LuaElementConvertors.h>
namespace Swift {
- template <typename T> class StanzaConvertor : public GenericLuaElementConvertor<T> {
- public:
- StanzaConvertor(const std::string& tag)
- : GenericLuaElementConvertor<T>(tag) {
- }
+ template <typename T> class StanzaConvertor : public GenericLuaElementConvertor<T> {
+ public:
+ StanzaConvertor(const std::string& tag)
+ : GenericLuaElementConvertor<T>(tag) {
+ }
- virtual ~StanzaConvertor() {
- }
+ virtual ~StanzaConvertor() {
+ }
- boost::shared_ptr<T> getStanza(lua_State* L, LuaElementConvertors* convertors) {
- boost::shared_ptr<T> result = boost::make_shared<T>();
- lua_getfield(L, -1, "id");
- if (lua_isstring(L, -1)) {
- result->setID(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "from");
- if (lua_isstring(L, -1)) {
- result->setFrom(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "to");
- if (lua_isstring(L, -1)) {
- result->setTo(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "payloads");
- if (lua_type(L, -1) == LUA_TTABLE) {
- for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
- lua_pushnumber(L, i + 1);
- lua_gettable(L, -2);
- if (!lua_isnil(L, -1)) {
- boost::shared_ptr<Payload> payload = boost::dynamic_pointer_cast<Payload>(convertors->convertFromLua(L, -1));
- if (!!payload) {
- result->addPayload(payload);
- }
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- return result;
- }
+ std::shared_ptr<T> getStanza(lua_State* L, LuaElementConvertors* convertors) {
+ std::shared_ptr<T> result = std::make_shared<T>();
+ lua_getfield(L, -1, "id");
+ if (lua_isstring(L, -1)) {
+ result->setID(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "from");
+ if (lua_isstring(L, -1)) {
+ result->setFrom(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "to");
+ if (lua_isstring(L, -1)) {
+ result->setTo(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "payloads");
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ for(size_t i = 0; i < lua_objlen(L, -1); ++i) {
+ lua_pushnumber(L, i + 1);
+ lua_gettable(L, -2);
+ if (!lua_isnil(L, -1)) {
+ std::shared_ptr<Payload> payload = std::dynamic_pointer_cast<Payload>(convertors->convertFromLua(L, -1));
+ if (!!payload) {
+ result->addPayload(payload);
+ }
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
+ }
- void pushStanza(lua_State* L, const boost::shared_ptr<T> stanza, LuaElementConvertors* convertors) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, stanza->getID().c_str());
- lua_setfield(L, -2, "id");
- lua_pushstring(L, stanza->getFrom().toString().c_str());
- lua_setfield(L, -2, "from");
- lua_pushstring(L, stanza->getTo().toString().c_str());
- lua_setfield(L, -2, "to");
- if (!stanza->getPayloads().empty()) {
- lua_createtable(L, boost::numeric_cast<int>(stanza->getPayloads().size()), 0);
- {
- int i = 0;
- foreach(const boost::shared_ptr<Payload> &item, stanza->getPayloads()) {
- if (convertors->convertToLua(L, item) > 0) {
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- ++i;
- }
- }
- }
- lua_setfield(L, -2, "payloads");
- }
- }
- };
+ void pushStanza(lua_State* L, const std::shared_ptr<T> stanza, LuaElementConvertors* convertors) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, stanza->getID().c_str());
+ lua_setfield(L, -2, "id");
+ lua_pushstring(L, stanza->getFrom().toString().c_str());
+ lua_setfield(L, -2, "from");
+ lua_pushstring(L, stanza->getTo().toString().c_str());
+ lua_setfield(L, -2, "to");
+ if (!stanza->getPayloads().empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(stanza->getPayloads().size()), 0);
+ {
+ int i = 0;
+ for (const auto& item : stanza->getPayloads()) {
+ if (convertors->convertToLua(L, item) > 0) {
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ ++i;
+ }
+ }
+ }
+ lua_setfield(L, -2, "payloads");
+ }
+ }
+ };
}
diff --git a/Sluift/ElementConvertors/StatusConvertor.cpp b/Sluift/ElementConvertors/StatusConvertor.cpp
index 9dc3585..eed4044 100644
--- a/Sluift/ElementConvertors/StatusConvertor.cpp
+++ b/Sluift/ElementConvertors/StatusConvertor.cpp
@@ -1,14 +1,17 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/StatusConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
+
#include <Sluift/Lua/Check.h>
using namespace Swift;
@@ -19,18 +22,18 @@ StatusConvertor::StatusConvertor() : GenericLuaElementConvertor<Status>("status"
StatusConvertor::~StatusConvertor() {
}
-boost::shared_ptr<Status> StatusConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Status> result = boost::make_shared<Status>();
- lua_getfield(L, -1, "text");
- if (lua_isstring(L, -1)) {
- result->setText(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<Status> StatusConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Status> result = std::make_shared<Status>();
+ lua_getfield(L, -1, "text");
+ if (lua_isstring(L, -1)) {
+ result->setText(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void StatusConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Status> payload) {
- lua_createtable(L, 0, 0);
- lua_pushstring(L, payload->getText().c_str());
- lua_setfield(L, -2, "text");
+void StatusConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Status> payload) {
+ lua_createtable(L, 0, 0);
+ lua_pushstring(L, payload->getText().c_str());
+ lua_setfield(L, -2, "text");
}
diff --git a/Sluift/ElementConvertors/StatusConvertor.h b/Sluift/ElementConvertors/StatusConvertor.h
index 2e39f27..53da0ad 100644
--- a/Sluift/ElementConvertors/StatusConvertor.h
+++ b/Sluift/ElementConvertors/StatusConvertor.h
@@ -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.
*/
@@ -7,17 +7,17 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/Status.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/Status.h>
namespace Swift {
- class StatusConvertor : public GenericLuaElementConvertor<Status> {
- public:
- StatusConvertor();
- virtual ~StatusConvertor();
+ class StatusConvertor : public GenericLuaElementConvertor<Status> {
+ public:
+ StatusConvertor();
+ virtual ~StatusConvertor();
- virtual boost::shared_ptr<Status> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Status>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<Status> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Status>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/StatusShowConvertor.cpp b/Sluift/ElementConvertors/StatusShowConvertor.cpp
index 43098ef..6d0a067 100644
--- a/Sluift/ElementConvertors/StatusShowConvertor.cpp
+++ b/Sluift/ElementConvertors/StatusShowConvertor.cpp
@@ -1,14 +1,17 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/StatusShowConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
+
#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Exception.h>
@@ -20,55 +23,55 @@ StatusShowConvertor::StatusShowConvertor() : GenericLuaElementConvertor<StatusSh
StatusShowConvertor::~StatusShowConvertor() {
}
-boost::shared_ptr<StatusShow> StatusShowConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<StatusShow> result = boost::make_shared<StatusShow>();
- lua_getfield(L, -1, "type");
- if (lua_isstring(L, -1)) {
- result->setType(convertStatusShowTypeFromString(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<StatusShow> StatusShowConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<StatusShow> result = std::make_shared<StatusShow>();
+ lua_getfield(L, -1, "type");
+ if (lua_isstring(L, -1)) {
+ result->setType(convertStatusShowTypeFromString(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void StatusShowConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<StatusShow> payload) {
- lua_createtable(L, 0, 0);
- const std::string show = convertStatusShowTypeToString(payload->getType());
- if (!show.empty()) {
- lua_pushstring(L, show.c_str());
- lua_setfield(L, -2, "type");
- }
+void StatusShowConvertor::doConvertToLua(lua_State* L, std::shared_ptr<StatusShow> payload) {
+ lua_createtable(L, 0, 0);
+ const std::string show = convertStatusShowTypeToString(payload->getType());
+ if (!show.empty()) {
+ lua_pushstring(L, show.c_str());
+ lua_setfield(L, -2, "type");
+ }
}
std::string StatusShowConvertor::convertStatusShowTypeToString(const StatusShow::Type &show) {
- switch (show) {
- case StatusShow::Online: return "online";
- case StatusShow::FFC: return "ffc";
- case StatusShow::Away: return "away";
- case StatusShow::XA: return "xa";
- case StatusShow::DND: return "dnd";
- case StatusShow::None: return "";
- }
- assert(false);
- return "";
+ switch (show) {
+ case StatusShow::Online: return "online";
+ case StatusShow::FFC: return "ffc";
+ case StatusShow::Away: return "away";
+ case StatusShow::XA: return "xa";
+ case StatusShow::DND: return "dnd";
+ case StatusShow::None: return "";
+ }
+ assert(false);
+ return "";
}
StatusShow::Type StatusShowConvertor::convertStatusShowTypeFromString(const std::string& show) {
- if (show == "online") {
- return StatusShow::Online;
- }
- else if (show == "ffc") {
- return StatusShow::FFC;
- }
- else if (show == "away") {
- return StatusShow::Away;
- }
- else if (show == "xa") {
- return StatusShow::XA;
- }
- else if (show == "dnd") {
- return StatusShow::DND;
- }
- else {
- throw Lua::Exception("Illegal status show: '" + show + "'");
- }
+ if (show == "online") {
+ return StatusShow::Online;
+ }
+ else if (show == "ffc") {
+ return StatusShow::FFC;
+ }
+ else if (show == "away") {
+ return StatusShow::Away;
+ }
+ else if (show == "xa") {
+ return StatusShow::XA;
+ }
+ else if (show == "dnd") {
+ return StatusShow::DND;
+ }
+ else {
+ throw Lua::Exception("Illegal status show: '" + show + "'");
+ }
}
diff --git a/Sluift/ElementConvertors/StatusShowConvertor.h b/Sluift/ElementConvertors/StatusShowConvertor.h
index 6447c4e..1521ca3 100644
--- a/Sluift/ElementConvertors/StatusShowConvertor.h
+++ b/Sluift/ElementConvertors/StatusShowConvertor.h
@@ -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.
*/
@@ -7,20 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/StatusShow.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/StatusShow.h>
namespace Swift {
- class StatusShowConvertor : public GenericLuaElementConvertor<StatusShow> {
- public:
- StatusShowConvertor();
- virtual ~StatusShowConvertor();
+ class StatusShowConvertor : public GenericLuaElementConvertor<StatusShow> {
+ public:
+ StatusShowConvertor();
+ virtual ~StatusShowConvertor();
- virtual boost::shared_ptr<StatusShow> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<StatusShow>) SWIFTEN_OVERRIDE;
+ virtual std::shared_ptr<StatusShow> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<StatusShow>) SWIFTEN_OVERRIDE;
- static std::string convertStatusShowTypeToString(const StatusShow::Type &show);
- static StatusShow::Type convertStatusShowTypeFromString(const std::string& show);
- };
+ static std::string convertStatusShowTypeToString(const StatusShow::Type &show);
+ static StatusShow::Type convertStatusShowTypeFromString(const std::string& show);
+ };
}
diff --git a/Sluift/ElementConvertors/SubjectConvertor.cpp b/Sluift/ElementConvertors/SubjectConvertor.cpp
index 893073f..ae03564 100644
--- a/Sluift/ElementConvertors/SubjectConvertor.cpp
+++ b/Sluift/ElementConvertors/SubjectConvertor.cpp
@@ -1,13 +1,15 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/SubjectConvertor.h>
+#include <memory>
+
#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+
#include <Sluift/Lua/LuaUtils.h>
using namespace Swift;
@@ -18,18 +20,18 @@ SubjectConvertor::SubjectConvertor() : GenericLuaElementConvertor<Subject>("subj
SubjectConvertor::~SubjectConvertor() {
}
-boost::shared_ptr<Subject> SubjectConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<Subject> result = boost::make_shared<Subject>();
- if (boost::optional<std::string> value = Lua::getStringField(L, -1, "text")) {
- result->setText(*value);
- }
- return result;
+std::shared_ptr<Subject> SubjectConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<Subject> result = std::make_shared<Subject>();
+ if (boost::optional<std::string> value = Lua::getStringField(L, -1, "text")) {
+ result->setText(*value);
+ }
+ return result;
}
-void SubjectConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<Subject> payload) {
- lua_createtable(L, 0, 0);
- if (!payload->getText().empty()) {
- lua_pushstring(L, payload->getText().c_str());
- lua_setfield(L, -2, "text");
- }
+void SubjectConvertor::doConvertToLua(lua_State* L, std::shared_ptr<Subject> payload) {
+ lua_createtable(L, 0, 0);
+ if (!payload->getText().empty()) {
+ lua_pushstring(L, payload->getText().c_str());
+ lua_setfield(L, -2, "text");
+ }
}
diff --git a/Sluift/ElementConvertors/SubjectConvertor.h b/Sluift/ElementConvertors/SubjectConvertor.h
index d517b1e..1520004 100644
--- a/Sluift/ElementConvertors/SubjectConvertor.h
+++ b/Sluift/ElementConvertors/SubjectConvertor.h
@@ -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.
*/
@@ -7,19 +7,19 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/Subject.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/Subject.h>
namespace Swift {
- class LuaElementConvertors;
+ class LuaElementConvertors;
- class SubjectConvertor : public GenericLuaElementConvertor<Subject> {
- public:
- SubjectConvertor();
- virtual ~SubjectConvertor();
+ class SubjectConvertor : public GenericLuaElementConvertor<Subject> {
+ public:
+ SubjectConvertor();
+ virtual ~SubjectConvertor();
- virtual boost::shared_ptr<Subject> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<Subject>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<Subject> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<Subject>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/UserLocationConvertor.cpp b/Sluift/ElementConvertors/UserLocationConvertor.cpp
index 2d546dd..253ca36 100644
--- a/Sluift/ElementConvertors/UserLocationConvertor.cpp
+++ b/Sluift/ElementConvertors/UserLocationConvertor.cpp
@@ -1,261 +1,258 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/UserLocationConvertor.h>
+#include <memory>
+
#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/DateTime.h>
-#pragma clang diagnostic ignored "-Wunused-private-field"
-
using namespace Swift;
-UserLocationConvertor::UserLocationConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<UserLocation>("user_location"),
- convertors(convertors) {
+UserLocationConvertor::UserLocationConvertor() :
+ GenericLuaElementConvertor<UserLocation>("user_location") {
}
UserLocationConvertor::~UserLocationConvertor() {
}
-boost::shared_ptr<UserLocation> UserLocationConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<UserLocation> result = boost::make_shared<UserLocation>();
- lua_getfield(L, -1, "area");
- if (lua_isstring(L, -1)) {
- result->setArea(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "altitude");
- if (lua_isnumber(L, -1)) {
- result->setAltitude(boost::numeric_cast<float>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "locality");
- if (lua_isstring(L, -1)) {
- result->setLocality(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "latitude");
- if (lua_isnumber(L, -1)) {
- result->setLatitude(boost::numeric_cast<float>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "accuracy");
- if (lua_isnumber(L, -1)) {
- result->setAccuracy(boost::numeric_cast<float>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "description");
- if (lua_isstring(L, -1)) {
- result->setDescription(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "country_code");
- if (lua_isstring(L, -1)) {
- result->setCountryCode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "timestamp");
- if (lua_isstring(L, -1)) {
- result->setTimestamp(stringToDateTime(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "floor");
- if (lua_isstring(L, -1)) {
- result->setFloor(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "building");
- if (lua_isstring(L, -1)) {
- result->setBuilding(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "room");
- if (lua_isstring(L, -1)) {
- result->setRoom(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "country");
- if (lua_isstring(L, -1)) {
- result->setCountry(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "region");
- if (lua_isstring(L, -1)) {
- result->setRegion(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "uri");
- if (lua_isstring(L, -1)) {
- result->setURI(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "longitude");
- if (lua_isnumber(L, -1)) {
- result->setLongitude(boost::numeric_cast<float>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "error");
- if (lua_isnumber(L, -1)) {
- result->setError(boost::numeric_cast<float>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "postal_code");
- if (lua_isstring(L, -1)) {
- result->setPostalCode(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "bearing");
- if (lua_isnumber(L, -1)) {
- result->setBearing(boost::numeric_cast<float>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "text");
- if (lua_isstring(L, -1)) {
- result->setText(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "datum");
- if (lua_isstring(L, -1)) {
- result->setDatum(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "street");
- if (lua_isstring(L, -1)) {
- result->setStreet(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "speed");
- if (lua_isnumber(L, -1)) {
- result->setSpeed(boost::numeric_cast<float>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<UserLocation> UserLocationConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<UserLocation> result = std::make_shared<UserLocation>();
+ lua_getfield(L, -1, "area");
+ if (lua_isstring(L, -1)) {
+ result->setArea(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "altitude");
+ if (lua_isnumber(L, -1)) {
+ result->setAltitude(lua_tonumber(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "locality");
+ if (lua_isstring(L, -1)) {
+ result->setLocality(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "latitude");
+ if (lua_isnumber(L, -1)) {
+ result->setLatitude(lua_tonumber(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "accuracy");
+ if (lua_isnumber(L, -1)) {
+ result->setAccuracy(lua_tonumber(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "description");
+ if (lua_isstring(L, -1)) {
+ result->setDescription(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "country_code");
+ if (lua_isstring(L, -1)) {
+ result->setCountryCode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "timestamp");
+ if (lua_isstring(L, -1)) {
+ result->setTimestamp(stringToDateTime(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "floor");
+ if (lua_isstring(L, -1)) {
+ result->setFloor(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "building");
+ if (lua_isstring(L, -1)) {
+ result->setBuilding(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "room");
+ if (lua_isstring(L, -1)) {
+ result->setRoom(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "country");
+ if (lua_isstring(L, -1)) {
+ result->setCountry(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "region");
+ if (lua_isstring(L, -1)) {
+ result->setRegion(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "uri");
+ if (lua_isstring(L, -1)) {
+ result->setURI(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "longitude");
+ if (lua_isnumber(L, -1)) {
+ result->setLongitude(lua_tonumber(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "error");
+ if (lua_isnumber(L, -1)) {
+ result->setError(lua_tonumber(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "postal_code");
+ if (lua_isstring(L, -1)) {
+ result->setPostalCode(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "bearing");
+ if (lua_isnumber(L, -1)) {
+ result->setBearing(lua_tonumber(L, -1));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "text");
+ if (lua_isstring(L, -1)) {
+ result->setText(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "datum");
+ if (lua_isstring(L, -1)) {
+ result->setDatum(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "street");
+ if (lua_isstring(L, -1)) {
+ result->setStreet(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "speed");
+ if (lua_isnumber(L, -1)) {
+ result->setSpeed(lua_tonumber(L, -1));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void UserLocationConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<UserLocation> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getArea()) {
- lua_pushstring(L, (*payload->getArea()).c_str());
- lua_setfield(L, -2, "area");
- }
- if (payload->getAltitude()) {
- lua_pushnumber(L, (*payload->getAltitude()));
- lua_setfield(L, -2, "altitude");
- }
- if (payload->getLocality()) {
- lua_pushstring(L, (*payload->getLocality()).c_str());
- lua_setfield(L, -2, "locality");
- }
- if (payload->getLatitude()) {
- lua_pushnumber(L, (*payload->getLatitude()));
- lua_setfield(L, -2, "latitude");
- }
- if (payload->getAccuracy()) {
- lua_pushnumber(L, (*payload->getAccuracy()));
- lua_setfield(L, -2, "accuracy");
- }
- if (payload->getDescription()) {
- lua_pushstring(L, (*payload->getDescription()).c_str());
- lua_setfield(L, -2, "description");
- }
- if (payload->getCountryCode()) {
- lua_pushstring(L, (*payload->getCountryCode()).c_str());
- lua_setfield(L, -2, "country_code");
- }
- if (payload->getTimestamp()) {
- lua_pushstring(L, dateTimeToString((*payload->getTimestamp())).c_str());
- lua_setfield(L, -2, "timestamp");
- }
- if (payload->getFloor()) {
- lua_pushstring(L, (*payload->getFloor()).c_str());
- lua_setfield(L, -2, "floor");
- }
- if (payload->getBuilding()) {
- lua_pushstring(L, (*payload->getBuilding()).c_str());
- lua_setfield(L, -2, "building");
- }
- if (payload->getRoom()) {
- lua_pushstring(L, (*payload->getRoom()).c_str());
- lua_setfield(L, -2, "room");
- }
- if (payload->getCountry()) {
- lua_pushstring(L, (*payload->getCountry()).c_str());
- lua_setfield(L, -2, "country");
- }
- if (payload->getRegion()) {
- lua_pushstring(L, (*payload->getRegion()).c_str());
- lua_setfield(L, -2, "region");
- }
- if (payload->getURI()) {
- lua_pushstring(L, (*payload->getURI()).c_str());
- lua_setfield(L, -2, "uri");
- }
- if (payload->getLongitude()) {
- lua_pushnumber(L, (*payload->getLongitude()));
- lua_setfield(L, -2, "longitude");
- }
- if (payload->getError()) {
- lua_pushnumber(L, (*payload->getError()));
- lua_setfield(L, -2, "error");
- }
- if (payload->getPostalCode()) {
- lua_pushstring(L, (*payload->getPostalCode()).c_str());
- lua_setfield(L, -2, "postal_code");
- }
- if (payload->getBearing()) {
- lua_pushnumber(L, (*payload->getBearing()));
- lua_setfield(L, -2, "bearing");
- }
- if (payload->getText()) {
- lua_pushstring(L, (*payload->getText()).c_str());
- lua_setfield(L, -2, "text");
- }
- if (payload->getDatum()) {
- lua_pushstring(L, (*payload->getDatum()).c_str());
- lua_setfield(L, -2, "datum");
- }
- if (payload->getStreet()) {
- lua_pushstring(L, (*payload->getStreet()).c_str());
- lua_setfield(L, -2, "street");
- }
- if (payload->getSpeed()) {
- lua_pushnumber(L, (*payload->getSpeed()));
- lua_setfield(L, -2, "speed");
- }
+void UserLocationConvertor::doConvertToLua(lua_State* L, std::shared_ptr<UserLocation> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getArea()) {
+ lua_pushstring(L, (*payload->getArea()).c_str());
+ lua_setfield(L, -2, "area");
+ }
+ if (payload->getAltitude()) {
+ lua_pushnumber(L, (*payload->getAltitude()));
+ lua_setfield(L, -2, "altitude");
+ }
+ if (payload->getLocality()) {
+ lua_pushstring(L, (*payload->getLocality()).c_str());
+ lua_setfield(L, -2, "locality");
+ }
+ if (payload->getLatitude()) {
+ lua_pushnumber(L, (*payload->getLatitude()));
+ lua_setfield(L, -2, "latitude");
+ }
+ if (payload->getAccuracy()) {
+ lua_pushnumber(L, (*payload->getAccuracy()));
+ lua_setfield(L, -2, "accuracy");
+ }
+ if (payload->getDescription()) {
+ lua_pushstring(L, (*payload->getDescription()).c_str());
+ lua_setfield(L, -2, "description");
+ }
+ if (payload->getCountryCode()) {
+ lua_pushstring(L, (*payload->getCountryCode()).c_str());
+ lua_setfield(L, -2, "country_code");
+ }
+ if (payload->getTimestamp()) {
+ lua_pushstring(L, dateTimeToString((*payload->getTimestamp())).c_str());
+ lua_setfield(L, -2, "timestamp");
+ }
+ if (payload->getFloor()) {
+ lua_pushstring(L, (*payload->getFloor()).c_str());
+ lua_setfield(L, -2, "floor");
+ }
+ if (payload->getBuilding()) {
+ lua_pushstring(L, (*payload->getBuilding()).c_str());
+ lua_setfield(L, -2, "building");
+ }
+ if (payload->getRoom()) {
+ lua_pushstring(L, (*payload->getRoom()).c_str());
+ lua_setfield(L, -2, "room");
+ }
+ if (payload->getCountry()) {
+ lua_pushstring(L, (*payload->getCountry()).c_str());
+ lua_setfield(L, -2, "country");
+ }
+ if (payload->getRegion()) {
+ lua_pushstring(L, (*payload->getRegion()).c_str());
+ lua_setfield(L, -2, "region");
+ }
+ if (payload->getURI()) {
+ lua_pushstring(L, (*payload->getURI()).c_str());
+ lua_setfield(L, -2, "uri");
+ }
+ if (payload->getLongitude()) {
+ lua_pushnumber(L, (*payload->getLongitude()));
+ lua_setfield(L, -2, "longitude");
+ }
+ if (payload->getError()) {
+ lua_pushnumber(L, (*payload->getError()));
+ lua_setfield(L, -2, "error");
+ }
+ if (payload->getPostalCode()) {
+ lua_pushstring(L, (*payload->getPostalCode()).c_str());
+ lua_setfield(L, -2, "postal_code");
+ }
+ if (payload->getBearing()) {
+ lua_pushnumber(L, (*payload->getBearing()));
+ lua_setfield(L, -2, "bearing");
+ }
+ if (payload->getText()) {
+ lua_pushstring(L, (*payload->getText()).c_str());
+ lua_setfield(L, -2, "text");
+ }
+ if (payload->getDatum()) {
+ lua_pushstring(L, (*payload->getDatum()).c_str());
+ lua_setfield(L, -2, "datum");
+ }
+ if (payload->getStreet()) {
+ lua_pushstring(L, (*payload->getStreet()).c_str());
+ lua_setfield(L, -2, "street");
+ }
+ if (payload->getSpeed()) {
+ lua_pushnumber(L, (*payload->getSpeed()));
+ lua_setfield(L, -2, "speed");
+ }
}
boost::optional<LuaElementConvertor::Documentation> UserLocationConvertor::getDocumentation() const {
- return Documentation(
- "UserLocation",
- "This table has the following fields:\n\n"
- "- `area`: string (Optional)\n"
- "- `altitude`: @{float} (Optional)\n"
- "- `locality`: string (Optional)\n"
- "- `latitude`: @{float} (Optional)\n"
- "- `accuracy`: @{float} (Optional)\n"
- "- `description`: string (Optional)\n"
- "- `country_code`: string (Optional)\n"
- "- `timestamp`: datetime (string) (Optional)\n"
- "- `floor`: string (Optional)\n"
- "- `building`: string (Optional)\n"
- "- `room`: string (Optional)\n"
- "- `country`: string (Optional)\n"
- "- `region`: string (Optional)\n"
- "- `uri`: string (Optional)\n"
- "- `longitude`: @{float} (Optional)\n"
- "- `error`: @{float} (Optional)\n"
- "- `postal_code`: string (Optional)\n"
- "- `bearing`: @{float} (Optional)\n"
- "- `text`: string (Optional)\n"
- "- `datum`: string (Optional)\n"
- "- `street`: string (Optional)\n"
- "- `speed`: @{float} (Optional)\n"
- );
+ return Documentation(
+ "UserLocation",
+ "This table has the following fields:\n\n"
+ "- `area`: string (Optional)\n"
+ "- `altitude`: @{float} (Optional)\n"
+ "- `locality`: string (Optional)\n"
+ "- `latitude`: @{float} (Optional)\n"
+ "- `accuracy`: @{float} (Optional)\n"
+ "- `description`: string (Optional)\n"
+ "- `country_code`: string (Optional)\n"
+ "- `timestamp`: datetime (string) (Optional)\n"
+ "- `floor`: string (Optional)\n"
+ "- `building`: string (Optional)\n"
+ "- `room`: string (Optional)\n"
+ "- `country`: string (Optional)\n"
+ "- `region`: string (Optional)\n"
+ "- `uri`: string (Optional)\n"
+ "- `longitude`: @{float} (Optional)\n"
+ "- `error`: @{float} (Optional)\n"
+ "- `postal_code`: string (Optional)\n"
+ "- `bearing`: @{float} (Optional)\n"
+ "- `text`: string (Optional)\n"
+ "- `datum`: string (Optional)\n"
+ "- `street`: string (Optional)\n"
+ "- `speed`: @{float} (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/UserLocationConvertor.h b/Sluift/ElementConvertors/UserLocationConvertor.h
index 7582fed..36e3a0b 100644
--- a/Sluift/ElementConvertors/UserLocationConvertor.h
+++ b/Sluift/ElementConvertors/UserLocationConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/UserLocation.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/UserLocation.h>
namespace Swift {
- class LuaElementConvertors;
-
- class UserLocationConvertor : public GenericLuaElementConvertor<UserLocation> {
- public:
- UserLocationConvertor(LuaElementConvertors* convertors);
- virtual ~UserLocationConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<UserLocation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<UserLocation>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class UserLocationConvertor : public GenericLuaElementConvertor<UserLocation> {
+ public:
+ UserLocationConvertor();
+ virtual ~UserLocationConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<UserLocation> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<UserLocation>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/UserTuneConvertor.cpp b/Sluift/ElementConvertors/UserTuneConvertor.cpp
index 0ce09e9..a9e1bee 100644
--- a/Sluift/ElementConvertors/UserTuneConvertor.cpp
+++ b/Sluift/ElementConvertors/UserTuneConvertor.cpp
@@ -1,111 +1,108 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/UserTuneConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <boost/numeric/conversion/cast.hpp>
-
+#include <memory>
+#include <boost/numeric/conversion/cast.hpp>
-#pragma clang diagnostic ignored "-Wunused-private-field"
+#include <lua.hpp>
using namespace Swift;
-UserTuneConvertor::UserTuneConvertor(LuaElementConvertors* convertors) :
- GenericLuaElementConvertor<UserTune>("user_tune"),
- convertors(convertors) {
+UserTuneConvertor::UserTuneConvertor() :
+ GenericLuaElementConvertor<UserTune>("user_tune") {
}
UserTuneConvertor::~UserTuneConvertor() {
}
-boost::shared_ptr<UserTune> UserTuneConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<UserTune> result = boost::make_shared<UserTune>();
- lua_getfield(L, -1, "rating");
- if (lua_isnumber(L, -1)) {
- result->setRating(boost::numeric_cast<unsigned int>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "title");
- if (lua_isstring(L, -1)) {
- result->setTitle(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "track");
- if (lua_isstring(L, -1)) {
- result->setTrack(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "artist");
- if (lua_isstring(L, -1)) {
- result->setArtist(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "uri");
- if (lua_isstring(L, -1)) {
- result->setURI(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "source");
- if (lua_isstring(L, -1)) {
- result->setSource(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "length");
- if (lua_isnumber(L, -1)) {
- result->setLength(boost::numeric_cast<unsigned int>(lua_tonumber(L, -1)));
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<UserTune> UserTuneConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<UserTune> result = std::make_shared<UserTune>();
+ lua_getfield(L, -1, "rating");
+ if (lua_isnumber(L, -1)) {
+ result->setRating(boost::numeric_cast<unsigned int>(lua_tonumber(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "title");
+ if (lua_isstring(L, -1)) {
+ result->setTitle(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "track");
+ if (lua_isstring(L, -1)) {
+ result->setTrack(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "artist");
+ if (lua_isstring(L, -1)) {
+ result->setArtist(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "uri");
+ if (lua_isstring(L, -1)) {
+ result->setURI(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "source");
+ if (lua_isstring(L, -1)) {
+ result->setSource(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "length");
+ if (lua_isnumber(L, -1)) {
+ result->setLength(boost::numeric_cast<unsigned int>(lua_tonumber(L, -1)));
+ }
+ lua_pop(L, 1);
+ return result;
}
-void UserTuneConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<UserTune> payload) {
- lua_createtable(L, 0, 0);
- if (payload->getRating()) {
- lua_pushnumber(L, (*payload->getRating()));
- lua_setfield(L, -2, "rating");
- }
- if (payload->getTitle()) {
- lua_pushstring(L, (*payload->getTitle()).c_str());
- lua_setfield(L, -2, "title");
- }
- if (payload->getTrack()) {
- lua_pushstring(L, (*payload->getTrack()).c_str());
- lua_setfield(L, -2, "track");
- }
- if (payload->getArtist()) {
- lua_pushstring(L, (*payload->getArtist()).c_str());
- lua_setfield(L, -2, "artist");
- }
- if (payload->getURI()) {
- lua_pushstring(L, (*payload->getURI()).c_str());
- lua_setfield(L, -2, "uri");
- }
- if (payload->getSource()) {
- lua_pushstring(L, (*payload->getSource()).c_str());
- lua_setfield(L, -2, "source");
- }
- if (payload->getLength()) {
- lua_pushnumber(L, (*payload->getLength()));
- lua_setfield(L, -2, "length");
- }
+void UserTuneConvertor::doConvertToLua(lua_State* L, std::shared_ptr<UserTune> payload) {
+ lua_createtable(L, 0, 0);
+ if (payload->getRating()) {
+ lua_pushnumber(L, (*payload->getRating()));
+ lua_setfield(L, -2, "rating");
+ }
+ if (payload->getTitle()) {
+ lua_pushstring(L, (*payload->getTitle()).c_str());
+ lua_setfield(L, -2, "title");
+ }
+ if (payload->getTrack()) {
+ lua_pushstring(L, (*payload->getTrack()).c_str());
+ lua_setfield(L, -2, "track");
+ }
+ if (payload->getArtist()) {
+ lua_pushstring(L, (*payload->getArtist()).c_str());
+ lua_setfield(L, -2, "artist");
+ }
+ if (payload->getURI()) {
+ lua_pushstring(L, (*payload->getURI()).c_str());
+ lua_setfield(L, -2, "uri");
+ }
+ if (payload->getSource()) {
+ lua_pushstring(L, (*payload->getSource()).c_str());
+ lua_setfield(L, -2, "source");
+ }
+ if (payload->getLength()) {
+ lua_pushnumber(L, (*payload->getLength()));
+ lua_setfield(L, -2, "length");
+ }
}
boost::optional<LuaElementConvertor::Documentation> UserTuneConvertor::getDocumentation() const {
- return Documentation(
- "UserTune",
- "This table has the following fields:\n\n"
- "- `rating`: number (Optional)\n"
- "- `title`: string (Optional)\n"
- "- `track`: string (Optional)\n"
- "- `artist`: string (Optional)\n"
- "- `uri`: string (Optional)\n"
- "- `source`: string (Optional)\n"
- "- `length`: number (Optional)\n"
- );
+ return Documentation(
+ "UserTune",
+ "This table has the following fields:\n\n"
+ "- `rating`: number (Optional)\n"
+ "- `title`: string (Optional)\n"
+ "- `track`: string (Optional)\n"
+ "- `artist`: string (Optional)\n"
+ "- `uri`: string (Optional)\n"
+ "- `source`: string (Optional)\n"
+ "- `length`: number (Optional)\n"
+ );
}
diff --git a/Sluift/ElementConvertors/UserTuneConvertor.h b/Sluift/ElementConvertors/UserTuneConvertor.h
index e5d0c36..ba57747 100644
--- a/Sluift/ElementConvertors/UserTuneConvertor.h
+++ b/Sluift/ElementConvertors/UserTuneConvertor.h
@@ -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.
*/
@@ -7,23 +7,20 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/UserTune.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/UserTune.h>
namespace Swift {
- class LuaElementConvertors;
-
- class UserTuneConvertor : public GenericLuaElementConvertor<UserTune> {
- public:
- UserTuneConvertor(LuaElementConvertors* convertors);
- virtual ~UserTuneConvertor();
+ class LuaElementConvertors;
- virtual boost::shared_ptr<UserTune> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<UserTune>) SWIFTEN_OVERRIDE;
- virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ class UserTuneConvertor : public GenericLuaElementConvertor<UserTune> {
+ public:
+ UserTuneConvertor();
+ virtual ~UserTuneConvertor();
- private:
- LuaElementConvertors* convertors;
- };
+ virtual std::shared_ptr<UserTune> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<UserTune>) SWIFTEN_OVERRIDE;
+ virtual boost::optional<Documentation> getDocumentation() const SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/VCardConvertor.cpp b/Sluift/ElementConvertors/VCardConvertor.cpp
index 451e0ab..ad521b3 100644
--- a/Sluift/ElementConvertors/VCardConvertor.cpp
+++ b/Sluift/ElementConvertors/VCardConvertor.cpp
@@ -1,18 +1,22 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/VCardConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
-#include <Sluift/Lua/LuaUtils.h>
+
+#include <lua.hpp>
+
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Base/DateTime.h>
+#include <Sluift/Lua/LuaUtils.h>
+
using namespace Swift;
VCardConvertor::VCardConvertor() : GenericLuaElementConvertor<VCard>("vcard") {
@@ -21,609 +25,609 @@ VCardConvertor::VCardConvertor() : GenericLuaElementConvertor<VCard>("vcard") {
VCardConvertor::~VCardConvertor() {
}
-boost::shared_ptr<VCard> VCardConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<VCard> result = boost::make_shared<VCard>();
- lua_getfield(L, -1, "fullname");
- if (lua_isstring(L, -1)) {
- result->setFullName(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "familyname");
- if (lua_isstring(L, -1)) {
- result->setFamilyName(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "givenname");
- if (lua_isstring(L, -1)) {
- result->setGivenName(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "middlename");
- if (lua_isstring(L, -1)) {
- result->setMiddleName(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "prefix");
- if (lua_isstring(L, -1)) {
- result->setPrefix(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "suffix");
- if (lua_isstring(L, -1)) {
- result->setSuffix(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "nick");
- if (lua_isstring(L, -1)) {
- result->setNickname(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "description");
- if (lua_isstring(L, -1)) {
- result->setDescription(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "photo");
- if (lua_isstring(L, -1)) {
- size_t len;
- const char* data = lua_tolstring(L, -1, &len);
- result->setPhoto(createByteArray(data, len));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "phototype");
- if (lua_isstring(L, -1)) {
- result->setPhotoType(std::string(lua_tostring(L, -1)));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "birthday");
- if (lua_isstring(L, -1)) {
- result->setBirthday(stringToDateTime(std::string(lua_tostring(L, -1))));
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "email");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- VCard::EMailAddress emailAddress;
- emailAddress.address = Lua::getStringField(L, -1, "address").get_value_or("");
- if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
- emailAddress.isHome = *home;
- }
- if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
- emailAddress.isWork = *work;
- }
- if (boost::optional<bool> internet = Lua::getBooleanField(L, -1, "internet")) {
- emailAddress.isInternet = *internet;
- }
- if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
- emailAddress.isPreferred = *preferred;
- }
- if (boost::optional<bool> x400 = Lua::getBooleanField(L, -1, "x400")) {
- emailAddress.isX400 = *x400;
- }
- result->addEMailAddress(emailAddress);
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "telephone");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- VCard::Telephone telephone;
- telephone.number = Lua::getStringField(L, -1, "number").get_value_or("");
- if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
- telephone.isHome = *home;
- }
- if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
- telephone.isWork = *work;
- }
- if (boost::optional<bool> voice = Lua::getBooleanField(L, -1, "voice")) {
- telephone.isVoice = *voice;
- }
- if (boost::optional<bool> fax = Lua::getBooleanField(L, -1, "fax")) {
- telephone.isFax = *fax;
- }
- if (boost::optional<bool> pager = Lua::getBooleanField(L, -1, "pager")) {
- telephone.isPager = *pager;
- }
- if (boost::optional<bool> msg = Lua::getBooleanField(L, -1, "msg")) {
- telephone.isMSG = *msg;
- }
- if (boost::optional<bool> cell = Lua::getBooleanField(L, -1, "cell")) {
- telephone.isCell = *cell;
- }
- if (boost::optional<bool> video = Lua::getBooleanField(L, -1, "video")) {
- telephone.isVideo = *video;
- }
- if (boost::optional<bool> bbs = Lua::getBooleanField(L, -1, "bbs")) {
- telephone.isBBS = *bbs;
- }
- if (boost::optional<bool> modem = Lua::getBooleanField(L, -1, "modem")) {
- telephone.isModem = *modem;
- }
- if (boost::optional<bool> isdn = Lua::getBooleanField(L, -1, "isdn")) {
- telephone.isISDN = *isdn;
- }
- if (boost::optional<bool> pcs = Lua::getBooleanField(L, -1, "pcs")) {
- telephone.isPCS = *pcs;
- }
- if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
- telephone.isPreferred = *preferred;
- }
- result->addTelephone(telephone);
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "address");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- VCard::Address address;
- address.poBox = Lua::getStringField(L, -1, "pobox").get_value_or("");
- address.addressExtension = Lua::getStringField(L, -1, "extension").get_value_or("");
- address.street = Lua::getStringField(L, -1, "street").get_value_or("");
- address.locality = Lua::getStringField(L, -1, "locality").get_value_or("");
- address.region = Lua::getStringField(L, -1, "region").get_value_or("");
- address.postalCode = Lua::getStringField(L, -1, "postalcode").get_value_or("");
- address.country = Lua::getStringField(L, -1, "country").get_value_or("");
- if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
- address.isHome = *home;
- }
- if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
- address.isWork = *work;
- }
- if (boost::optional<bool> postal = Lua::getBooleanField(L, -1, "postal")) {
- address.isPostal = *postal;
- }
- if (boost::optional<bool> parcel = Lua::getBooleanField(L, -1, "parcel")) {
- address.isParcel = *parcel;
- }
- if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
- address.isPreferred = *preferred;
- }
- if (boost::optional<bool> domestic = Lua::getBooleanField(L, -1, "domestic")) {
- if (*domestic) {
- address.deliveryType = VCard::DomesticDelivery;
- }
- }
- if (boost::optional<bool> international = Lua::getBooleanField(L, -1, "international")) {
- if (*international) {
- address.deliveryType = VCard::InternationalDelivery;
- }
- }
- result->addAddress(address);
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "addresslabel");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- VCard::AddressLabel addresslabel;
- lua_getfield(L, -1, "lines");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- addresslabel.lines.push_back(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
- addresslabel.isHome = *home;
- }
- if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
- addresslabel.isWork = *work;
- }
- if (boost::optional<bool> postal = Lua::getBooleanField(L, -1, "postal")) {
- addresslabel.isPostal = *postal;
- }
- if (boost::optional<bool> parcel = Lua::getBooleanField(L, -1, "parcel")) {
- addresslabel.isParcel = *parcel;
- }
- if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
- addresslabel.isPreferred = *preferred;
- }
- if (boost::optional<bool> domestic = Lua::getBooleanField(L, -1, "domestic")) {
- if (*domestic) {
- addresslabel.deliveryType = VCard::DomesticDelivery;
- }
- }
- if (boost::optional<bool> international = Lua::getBooleanField(L, -1, "international")) {
- if (*international) {
- addresslabel.deliveryType = VCard::InternationalDelivery;
- }
- }
- result->addAddressLabel(addresslabel);
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "organization");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- VCard::Organization organization;
- organization.name = Lua::getStringField(L, -1, "name").get_value_or("");
- lua_getfield(L, -1, "units");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- organization.units.push_back(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- result->addOrganization(organization);
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "jid");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- result->addJID(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "title");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- result->addTitle(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "role");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- result->addRole(lua_tostring(L, -1));
- }
- lua_pop(L, 1); }
- }
- lua_pop(L, 1);
- lua_getfield(L, -1, "url");
- if (lua_istable(L, -1)) {
- for (lua_pushnil(L); lua_next(L, -2); ) {
- if (lua_isstring(L, -1)) {
- result->addURL(lua_tostring(L, -1));
- }
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- return result;
+std::shared_ptr<VCard> VCardConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<VCard> result = std::make_shared<VCard>();
+ lua_getfield(L, -1, "fullname");
+ if (lua_isstring(L, -1)) {
+ result->setFullName(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "familyname");
+ if (lua_isstring(L, -1)) {
+ result->setFamilyName(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "givenname");
+ if (lua_isstring(L, -1)) {
+ result->setGivenName(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "middlename");
+ if (lua_isstring(L, -1)) {
+ result->setMiddleName(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "prefix");
+ if (lua_isstring(L, -1)) {
+ result->setPrefix(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "suffix");
+ if (lua_isstring(L, -1)) {
+ result->setSuffix(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "nick");
+ if (lua_isstring(L, -1)) {
+ result->setNickname(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "description");
+ if (lua_isstring(L, -1)) {
+ result->setDescription(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "photo");
+ if (lua_isstring(L, -1)) {
+ size_t len;
+ const char* data = lua_tolstring(L, -1, &len);
+ result->setPhoto(createByteArray(data, len));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "phototype");
+ if (lua_isstring(L, -1)) {
+ result->setPhotoType(std::string(lua_tostring(L, -1)));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "birthday");
+ if (lua_isstring(L, -1)) {
+ result->setBirthday(stringToDateTime(std::string(lua_tostring(L, -1))));
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "email");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ VCard::EMailAddress emailAddress;
+ emailAddress.address = Lua::getStringField(L, -1, "address").get_value_or("");
+ if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
+ emailAddress.isHome = *home;
+ }
+ if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
+ emailAddress.isWork = *work;
+ }
+ if (boost::optional<bool> internet = Lua::getBooleanField(L, -1, "internet")) {
+ emailAddress.isInternet = *internet;
+ }
+ if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
+ emailAddress.isPreferred = *preferred;
+ }
+ if (boost::optional<bool> x400 = Lua::getBooleanField(L, -1, "x400")) {
+ emailAddress.isX400 = *x400;
+ }
+ result->addEMailAddress(emailAddress);
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "telephone");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ VCard::Telephone telephone;
+ telephone.number = Lua::getStringField(L, -1, "number").get_value_or("");
+ if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
+ telephone.isHome = *home;
+ }
+ if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
+ telephone.isWork = *work;
+ }
+ if (boost::optional<bool> voice = Lua::getBooleanField(L, -1, "voice")) {
+ telephone.isVoice = *voice;
+ }
+ if (boost::optional<bool> fax = Lua::getBooleanField(L, -1, "fax")) {
+ telephone.isFax = *fax;
+ }
+ if (boost::optional<bool> pager = Lua::getBooleanField(L, -1, "pager")) {
+ telephone.isPager = *pager;
+ }
+ if (boost::optional<bool> msg = Lua::getBooleanField(L, -1, "msg")) {
+ telephone.isMSG = *msg;
+ }
+ if (boost::optional<bool> cell = Lua::getBooleanField(L, -1, "cell")) {
+ telephone.isCell = *cell;
+ }
+ if (boost::optional<bool> video = Lua::getBooleanField(L, -1, "video")) {
+ telephone.isVideo = *video;
+ }
+ if (boost::optional<bool> bbs = Lua::getBooleanField(L, -1, "bbs")) {
+ telephone.isBBS = *bbs;
+ }
+ if (boost::optional<bool> modem = Lua::getBooleanField(L, -1, "modem")) {
+ telephone.isModem = *modem;
+ }
+ if (boost::optional<bool> isdn = Lua::getBooleanField(L, -1, "isdn")) {
+ telephone.isISDN = *isdn;
+ }
+ if (boost::optional<bool> pcs = Lua::getBooleanField(L, -1, "pcs")) {
+ telephone.isPCS = *pcs;
+ }
+ if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
+ telephone.isPreferred = *preferred;
+ }
+ result->addTelephone(telephone);
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "address");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ VCard::Address address;
+ address.poBox = Lua::getStringField(L, -1, "pobox").get_value_or("");
+ address.addressExtension = Lua::getStringField(L, -1, "extension").get_value_or("");
+ address.street = Lua::getStringField(L, -1, "street").get_value_or("");
+ address.locality = Lua::getStringField(L, -1, "locality").get_value_or("");
+ address.region = Lua::getStringField(L, -1, "region").get_value_or("");
+ address.postalCode = Lua::getStringField(L, -1, "postalcode").get_value_or("");
+ address.country = Lua::getStringField(L, -1, "country").get_value_or("");
+ if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
+ address.isHome = *home;
+ }
+ if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
+ address.isWork = *work;
+ }
+ if (boost::optional<bool> postal = Lua::getBooleanField(L, -1, "postal")) {
+ address.isPostal = *postal;
+ }
+ if (boost::optional<bool> parcel = Lua::getBooleanField(L, -1, "parcel")) {
+ address.isParcel = *parcel;
+ }
+ if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
+ address.isPreferred = *preferred;
+ }
+ if (boost::optional<bool> domestic = Lua::getBooleanField(L, -1, "domestic")) {
+ if (*domestic) {
+ address.deliveryType = VCard::DomesticDelivery;
+ }
+ }
+ if (boost::optional<bool> international = Lua::getBooleanField(L, -1, "international")) {
+ if (*international) {
+ address.deliveryType = VCard::InternationalDelivery;
+ }
+ }
+ result->addAddress(address);
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "addresslabel");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ VCard::AddressLabel addresslabel;
+ lua_getfield(L, -1, "lines");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ addresslabel.lines.push_back(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ if (boost::optional<bool> home = Lua::getBooleanField(L, -1, "home")) {
+ addresslabel.isHome = *home;
+ }
+ if (boost::optional<bool> work = Lua::getBooleanField(L, -1, "work")) {
+ addresslabel.isWork = *work;
+ }
+ if (boost::optional<bool> postal = Lua::getBooleanField(L, -1, "postal")) {
+ addresslabel.isPostal = *postal;
+ }
+ if (boost::optional<bool> parcel = Lua::getBooleanField(L, -1, "parcel")) {
+ addresslabel.isParcel = *parcel;
+ }
+ if (boost::optional<bool> preferred = Lua::getBooleanField(L, -1, "preferred")) {
+ addresslabel.isPreferred = *preferred;
+ }
+ if (boost::optional<bool> domestic = Lua::getBooleanField(L, -1, "domestic")) {
+ if (*domestic) {
+ addresslabel.deliveryType = VCard::DomesticDelivery;
+ }
+ }
+ if (boost::optional<bool> international = Lua::getBooleanField(L, -1, "international")) {
+ if (*international) {
+ addresslabel.deliveryType = VCard::InternationalDelivery;
+ }
+ }
+ result->addAddressLabel(addresslabel);
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "organization");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ VCard::Organization organization;
+ organization.name = Lua::getStringField(L, -1, "name").get_value_or("");
+ lua_getfield(L, -1, "units");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ organization.units.push_back(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ result->addOrganization(organization);
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "jid");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ result->addJID(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "title");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ result->addTitle(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "role");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ result->addRole(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1); }
+ }
+ lua_pop(L, 1);
+ lua_getfield(L, -1, "url");
+ if (lua_istable(L, -1)) {
+ for (lua_pushnil(L); lua_next(L, -2); ) {
+ if (lua_isstring(L, -1)) {
+ result->addURL(lua_tostring(L, -1));
+ }
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ return result;
}
-void VCardConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<VCard> payload) {
- lua_newtable(L);
- if (!payload->getFullName().empty()) {
- lua_pushstring(L, payload->getFullName().c_str());
- lua_setfield(L, -2, "fullname");
- }
- if (!payload->getFamilyName().empty()) {
- lua_pushstring(L, payload->getFamilyName().c_str());
- lua_setfield(L, -2, "familyname");
- }
- if (!payload->getGivenName().empty()) {
- lua_pushstring(L, payload->getGivenName().c_str());
- lua_setfield(L, -2, "givenname");
- }
- if (!payload->getMiddleName().empty()) {
- lua_pushstring(L, payload->getMiddleName().c_str());
- lua_setfield(L, -2, "middlename");
- }
- if (!payload->getPrefix().empty()) {
- lua_pushstring(L, payload->getPrefix().c_str());
- lua_setfield(L, -2, "prefix");
- }
- if (!payload->getSuffix().empty()) {
- lua_pushstring(L, payload->getSuffix().c_str());
- lua_setfield(L, -2, "suffix");
- }
- if (!payload->getNickname().empty()) {
- lua_pushstring(L, payload->getNickname().c_str());
- lua_setfield(L, -2, "nick");
- }
- if (!payload->getDescription().empty()) {
- lua_pushstring(L, payload->getDescription().c_str());
- lua_setfield(L, -2, "description");
- }
- if (!payload->getPhoto().empty()) {
- lua_pushlstring(L, reinterpret_cast<const char*>(vecptr(payload->getPhoto())), payload->getPhoto().size());
- lua_setfield(L, -2, "photo");
- }
- if (!payload->getPhotoType().empty()) {
- lua_pushstring(L, payload->getPhotoType().c_str());
- lua_setfield(L, -2, "phototype");
- }
- if (!payload->getBirthday().is_not_a_date_time()) {
- lua_pushstring(L, dateTimeToString(payload->getBirthday()).c_str());
- lua_setfield(L, -2, "birthday");
- }
- const std::vector<VCard::EMailAddress>& emails = payload->getEMailAddresses();
- if (!emails.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(emails.size()), 0);
- for (size_t i = 0; i < emails.size(); ++i) {
- lua_createtable(L, 0, 0);
- if (!emails[i].address.empty()) {
- lua_pushstring(L, emails[i].address.c_str());
- lua_setfield(L, -2, "address");
- }
- if (emails[i].isHome) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "home");
- }
- if (emails[i].isWork) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "work");
- }
- if (emails[i].isInternet) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "internet");
- }
- if (emails[i].isPreferred) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "preferred");
- }
- if (emails[i].isX400) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "x400");
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "email");
- }
- const std::vector<VCard::Telephone>& telephones = payload->getTelephones();
- if (!telephones.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(telephones.size()), 0);
- for (size_t i = 0; i < telephones.size(); ++i) {
- lua_createtable(L, 0, 0);
- if (!telephones[i].number.empty()) {
- lua_pushstring(L, telephones[i].number.c_str());
- lua_setfield(L, -2, "number");
- }
- if (telephones[i].isHome) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "home");
- }
- if (telephones[i].isWork) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "work");
- }
- if (telephones[i].isVoice) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "voice");
- }
- if (telephones[i].isFax) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "fax");
- }
- if (telephones[i].isPager) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "pager");
- }
- if (telephones[i].isMSG) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "msg");
- }
- if (telephones[i].isCell) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "cell");
- }
- if (telephones[i].isVideo) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "video");
- }
- if (telephones[i].isBBS) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "bbs");
- }
- if (telephones[i].isModem) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "modem");
- }
- if (telephones[i].isISDN) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "isdn");
- }
- if (telephones[i].isPCS) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "pcs");
- }
- if (telephones[i].isPreferred) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "preferred");
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "telephone");
- }
- const std::vector<VCard::Address>& addresses = payload->getAddresses();
- if (!addresses.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(addresses.size()), 0);
- for (size_t i = 0; i < addresses.size(); ++i) {
- lua_createtable(L, 0, 0);
- if (!addresses[i].poBox.empty()) {
- lua_pushstring(L, addresses[i].poBox.c_str());
- lua_setfield(L, -2, "pobox");
- }
- if (!addresses[i].addressExtension.empty()) {
- lua_pushstring(L, addresses[i].addressExtension.c_str());
- lua_setfield(L, -2, "extension");
- }
- if (!addresses[i].street.empty()) {
- lua_pushstring(L, addresses[i].street.c_str());
- lua_setfield(L, -2, "street");
- }
- if (!addresses[i].locality.empty()) {
- lua_pushstring(L, addresses[i].locality.c_str());
- lua_setfield(L, -2, "locality");
- }
- if (!addresses[i].region.empty()) {
- lua_pushstring(L, addresses[i].region.c_str());
- lua_setfield(L, -2, "region");
- }
- if (!addresses[i].postalCode.empty()) {
- lua_pushstring(L, addresses[i].postalCode.c_str());
- lua_setfield(L, -2, "postalcode");
- }
- if (!addresses[i].country.empty()) {
- lua_pushstring(L, addresses[i].country.c_str());
- lua_setfield(L, -2, "country");
- }
- if (addresses[i].isHome) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "home");
- }
- if (addresses[i].isWork) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "work");
- }
- if (addresses[i].isPostal) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "postal");
- }
- if (addresses[i].isParcel) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "parcel");
- }
- if (addresses[i].isPreferred) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "preferred");
- }
- if (addresses[i].deliveryType == VCard::DomesticDelivery) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "domestic");
- }
- if (addresses[i].deliveryType == VCard::InternationalDelivery) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "international");
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "address");
- }
- const std::vector<VCard::AddressLabel>& addresslabels = payload->getAddressLabels();
- if (!addresslabels.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(addresslabels.size()), 0);
- for (size_t i = 0; i < addresslabels.size(); ++i) {
- lua_createtable(L, 0, 0);
- const std::vector<std::string>& lines = addresslabels[i].lines;
- if (!lines.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(addresslabels[i].lines.size()), 0);
- for (size_t j = 0; j < lines.size(); ++j) {
- if (!lines[j].empty()) {
- lua_pushstring(L, lines[j].c_str());
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(j+1));
- }
- lua_setfield(L, -2, "lines");
- }
- if (addresslabels[i].isHome) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "home");
- }
- if (addresslabels[i].isWork) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "work");
- }
- if (addresslabels[i].isPostal) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "postal");
- }
- if (addresslabels[i].isParcel) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "parcel");
- }
- if (addresslabels[i].isPreferred) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "preferred");
- }
- if (addresslabels[i].deliveryType == VCard::DomesticDelivery) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "domestic");
- }
- if (addresslabels[i].deliveryType == VCard::InternationalDelivery) {
- lua_pushboolean(L, true);
- lua_setfield(L, -2, "international");
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "addresslabel");
- }
- const std::vector<VCard::Organization>& organizations = payload->getOrganizations();
- if (!organizations.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(organizations.size()), 0);
- for (size_t i = 0; i < organizations.size(); ++i) {
- lua_createtable(L, 0, 0);
- if (!organizations[i].name.empty()) {
- lua_pushstring(L, organizations[i].name.c_str());
- lua_setfield(L, -2, "name");
- }
- const std::vector<std::string>& units = organizations[i].units;
- if (!units.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(organizations[i].units.size()), 0);
- for (size_t j = 0; j < units.size(); ++j) {
- if (!units[j].empty()) {
- lua_pushstring(L, units[j].c_str());
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(j+1));
- }
- lua_setfield(L, -2, "units");
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "organization");
- }
- const std::vector<JID>& jids = payload->getJIDs();
- if (!jids.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(jids.size()), 0);
- for (size_t i = 0; i < jids.size(); ++i) {
- if (!jids[i].toString().empty()) {
- lua_pushstring(L, jids[i].toString().c_str());
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "jid");
- }
- const std::vector<std::string>& titles = payload->getTitles();
- if (!titles.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(titles.size()), 0);
- for (size_t i = 0; i < titles.size(); ++i) {
- if (!titles[i].empty()) {
- lua_pushstring(L, titles[i].c_str());
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "title");
- }
- const std::vector<std::string>& roles = payload->getRoles();
- if (!roles.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(roles.size()), 0);
- for (size_t i = 0; i < roles.size(); ++i) {
- if (!roles[i].empty()) {
- lua_pushstring(L, roles[i].c_str());
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "role");
- }
- const std::vector<std::string>& urls = payload->getURLs();
- if (!urls.empty()) {
- lua_createtable(L, boost::numeric_cast<int>(urls.size()), 0);
- for (size_t i = 0; i < urls.size(); ++i) {
- if (!urls[i].empty()) {
- lua_pushstring(L, urls[i].c_str());
- }
- lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
- }
- lua_setfield(L, -2, "url");
- }
+void VCardConvertor::doConvertToLua(lua_State* L, std::shared_ptr<VCard> payload) {
+ lua_newtable(L);
+ if (!payload->getFullName().empty()) {
+ lua_pushstring(L, payload->getFullName().c_str());
+ lua_setfield(L, -2, "fullname");
+ }
+ if (!payload->getFamilyName().empty()) {
+ lua_pushstring(L, payload->getFamilyName().c_str());
+ lua_setfield(L, -2, "familyname");
+ }
+ if (!payload->getGivenName().empty()) {
+ lua_pushstring(L, payload->getGivenName().c_str());
+ lua_setfield(L, -2, "givenname");
+ }
+ if (!payload->getMiddleName().empty()) {
+ lua_pushstring(L, payload->getMiddleName().c_str());
+ lua_setfield(L, -2, "middlename");
+ }
+ if (!payload->getPrefix().empty()) {
+ lua_pushstring(L, payload->getPrefix().c_str());
+ lua_setfield(L, -2, "prefix");
+ }
+ if (!payload->getSuffix().empty()) {
+ lua_pushstring(L, payload->getSuffix().c_str());
+ lua_setfield(L, -2, "suffix");
+ }
+ if (!payload->getNickname().empty()) {
+ lua_pushstring(L, payload->getNickname().c_str());
+ lua_setfield(L, -2, "nick");
+ }
+ if (!payload->getDescription().empty()) {
+ lua_pushstring(L, payload->getDescription().c_str());
+ lua_setfield(L, -2, "description");
+ }
+ if (!payload->getPhoto().empty()) {
+ lua_pushlstring(L, reinterpret_cast<const char*>(vecptr(payload->getPhoto())), payload->getPhoto().size());
+ lua_setfield(L, -2, "photo");
+ }
+ if (!payload->getPhotoType().empty()) {
+ lua_pushstring(L, payload->getPhotoType().c_str());
+ lua_setfield(L, -2, "phototype");
+ }
+ if (!payload->getBirthday().is_not_a_date_time()) {
+ lua_pushstring(L, dateTimeToString(payload->getBirthday()).c_str());
+ lua_setfield(L, -2, "birthday");
+ }
+ const std::vector<VCard::EMailAddress>& emails = payload->getEMailAddresses();
+ if (!emails.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(emails.size()), 0);
+ for (size_t i = 0; i < emails.size(); ++i) {
+ lua_createtable(L, 0, 0);
+ if (!emails[i].address.empty()) {
+ lua_pushstring(L, emails[i].address.c_str());
+ lua_setfield(L, -2, "address");
+ }
+ if (emails[i].isHome) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "home");
+ }
+ if (emails[i].isWork) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "work");
+ }
+ if (emails[i].isInternet) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "internet");
+ }
+ if (emails[i].isPreferred) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "preferred");
+ }
+ if (emails[i].isX400) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "x400");
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "email");
+ }
+ const std::vector<VCard::Telephone>& telephones = payload->getTelephones();
+ if (!telephones.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(telephones.size()), 0);
+ for (size_t i = 0; i < telephones.size(); ++i) {
+ lua_createtable(L, 0, 0);
+ if (!telephones[i].number.empty()) {
+ lua_pushstring(L, telephones[i].number.c_str());
+ lua_setfield(L, -2, "number");
+ }
+ if (telephones[i].isHome) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "home");
+ }
+ if (telephones[i].isWork) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "work");
+ }
+ if (telephones[i].isVoice) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "voice");
+ }
+ if (telephones[i].isFax) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "fax");
+ }
+ if (telephones[i].isPager) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "pager");
+ }
+ if (telephones[i].isMSG) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "msg");
+ }
+ if (telephones[i].isCell) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "cell");
+ }
+ if (telephones[i].isVideo) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "video");
+ }
+ if (telephones[i].isBBS) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "bbs");
+ }
+ if (telephones[i].isModem) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "modem");
+ }
+ if (telephones[i].isISDN) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "isdn");
+ }
+ if (telephones[i].isPCS) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "pcs");
+ }
+ if (telephones[i].isPreferred) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "preferred");
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "telephone");
+ }
+ const std::vector<VCard::Address>& addresses = payload->getAddresses();
+ if (!addresses.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(addresses.size()), 0);
+ for (size_t i = 0; i < addresses.size(); ++i) {
+ lua_createtable(L, 0, 0);
+ if (!addresses[i].poBox.empty()) {
+ lua_pushstring(L, addresses[i].poBox.c_str());
+ lua_setfield(L, -2, "pobox");
+ }
+ if (!addresses[i].addressExtension.empty()) {
+ lua_pushstring(L, addresses[i].addressExtension.c_str());
+ lua_setfield(L, -2, "extension");
+ }
+ if (!addresses[i].street.empty()) {
+ lua_pushstring(L, addresses[i].street.c_str());
+ lua_setfield(L, -2, "street");
+ }
+ if (!addresses[i].locality.empty()) {
+ lua_pushstring(L, addresses[i].locality.c_str());
+ lua_setfield(L, -2, "locality");
+ }
+ if (!addresses[i].region.empty()) {
+ lua_pushstring(L, addresses[i].region.c_str());
+ lua_setfield(L, -2, "region");
+ }
+ if (!addresses[i].postalCode.empty()) {
+ lua_pushstring(L, addresses[i].postalCode.c_str());
+ lua_setfield(L, -2, "postalcode");
+ }
+ if (!addresses[i].country.empty()) {
+ lua_pushstring(L, addresses[i].country.c_str());
+ lua_setfield(L, -2, "country");
+ }
+ if (addresses[i].isHome) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "home");
+ }
+ if (addresses[i].isWork) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "work");
+ }
+ if (addresses[i].isPostal) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "postal");
+ }
+ if (addresses[i].isParcel) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "parcel");
+ }
+ if (addresses[i].isPreferred) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "preferred");
+ }
+ if (addresses[i].deliveryType == VCard::DomesticDelivery) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "domestic");
+ }
+ if (addresses[i].deliveryType == VCard::InternationalDelivery) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "international");
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "address");
+ }
+ const std::vector<VCard::AddressLabel>& addresslabels = payload->getAddressLabels();
+ if (!addresslabels.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(addresslabels.size()), 0);
+ for (size_t i = 0; i < addresslabels.size(); ++i) {
+ lua_createtable(L, 0, 0);
+ const std::vector<std::string>& lines = addresslabels[i].lines;
+ if (!lines.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(addresslabels[i].lines.size()), 0);
+ for (size_t j = 0; j < lines.size(); ++j) {
+ if (!lines[j].empty()) {
+ lua_pushstring(L, lines[j].c_str());
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(j+1));
+ }
+ lua_setfield(L, -2, "lines");
+ }
+ if (addresslabels[i].isHome) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "home");
+ }
+ if (addresslabels[i].isWork) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "work");
+ }
+ if (addresslabels[i].isPostal) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "postal");
+ }
+ if (addresslabels[i].isParcel) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "parcel");
+ }
+ if (addresslabels[i].isPreferred) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "preferred");
+ }
+ if (addresslabels[i].deliveryType == VCard::DomesticDelivery) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "domestic");
+ }
+ if (addresslabels[i].deliveryType == VCard::InternationalDelivery) {
+ lua_pushboolean(L, true);
+ lua_setfield(L, -2, "international");
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "addresslabel");
+ }
+ const std::vector<VCard::Organization>& organizations = payload->getOrganizations();
+ if (!organizations.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(organizations.size()), 0);
+ for (size_t i = 0; i < organizations.size(); ++i) {
+ lua_createtable(L, 0, 0);
+ if (!organizations[i].name.empty()) {
+ lua_pushstring(L, organizations[i].name.c_str());
+ lua_setfield(L, -2, "name");
+ }
+ const std::vector<std::string>& units = organizations[i].units;
+ if (!units.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(organizations[i].units.size()), 0);
+ for (size_t j = 0; j < units.size(); ++j) {
+ if (!units[j].empty()) {
+ lua_pushstring(L, units[j].c_str());
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(j+1));
+ }
+ lua_setfield(L, -2, "units");
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "organization");
+ }
+ const std::vector<JID>& jids = payload->getJIDs();
+ if (!jids.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(jids.size()), 0);
+ for (size_t i = 0; i < jids.size(); ++i) {
+ if (!jids[i].toString().empty()) {
+ lua_pushstring(L, jids[i].toString().c_str());
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "jid");
+ }
+ const std::vector<std::string>& titles = payload->getTitles();
+ if (!titles.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(titles.size()), 0);
+ for (size_t i = 0; i < titles.size(); ++i) {
+ if (!titles[i].empty()) {
+ lua_pushstring(L, titles[i].c_str());
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "title");
+ }
+ const std::vector<std::string>& roles = payload->getRoles();
+ if (!roles.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(roles.size()), 0);
+ for (size_t i = 0; i < roles.size(); ++i) {
+ if (!roles[i].empty()) {
+ lua_pushstring(L, roles[i].c_str());
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "role");
+ }
+ const std::vector<std::string>& urls = payload->getURLs();
+ if (!urls.empty()) {
+ lua_createtable(L, boost::numeric_cast<int>(urls.size()), 0);
+ for (size_t i = 0; i < urls.size(); ++i) {
+ if (!urls[i].empty()) {
+ lua_pushstring(L, urls[i].c_str());
+ }
+ lua_rawseti(L, -2, boost::numeric_cast<int>(i+1));
+ }
+ lua_setfield(L, -2, "url");
+ }
}
diff --git a/Sluift/ElementConvertors/VCardConvertor.h b/Sluift/ElementConvertors/VCardConvertor.h
index 135eff0..d63ef10 100644
--- a/Sluift/ElementConvertors/VCardConvertor.h
+++ b/Sluift/ElementConvertors/VCardConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,17 +7,17 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/VCard.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/VCard.h>
namespace Swift {
- class VCardConvertor : public GenericLuaElementConvertor<VCard> {
- public:
- VCardConvertor();
- virtual ~VCardConvertor();
+ class VCardConvertor : public GenericLuaElementConvertor<VCard> {
+ public:
+ VCardConvertor();
+ virtual ~VCardConvertor();
- virtual boost::shared_ptr<VCard> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<VCard>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<VCard> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<VCard>) SWIFTEN_OVERRIDE;
+ };
}
diff --git a/Sluift/ElementConvertors/VCardUpdateConvertor.cpp b/Sluift/ElementConvertors/VCardUpdateConvertor.cpp
index 579f064..21c3d68 100644
--- a/Sluift/ElementConvertors/VCardUpdateConvertor.cpp
+++ b/Sluift/ElementConvertors/VCardUpdateConvertor.cpp
@@ -1,14 +1,17 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Sluift/ElementConvertors/VCardUpdateConvertor.h>
-#include <lua.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
+
#include <boost/numeric/conversion/cast.hpp>
+
+#include <lua.hpp>
+
#include <Sluift/Lua/LuaUtils.h>
using namespace Swift;
@@ -19,18 +22,18 @@ VCardUpdateConvertor::VCardUpdateConvertor() : GenericLuaElementConvertor<VCardU
VCardUpdateConvertor::~VCardUpdateConvertor() {
}
-boost::shared_ptr<VCardUpdate> VCardUpdateConvertor::doConvertFromLua(lua_State* L) {
- boost::shared_ptr<VCardUpdate> result = boost::make_shared<VCardUpdate>();
- if (boost::optional<std::string> value = Lua::getStringField(L, -1, "photo_hash")) {
- result->setPhotoHash(*value);
- }
- return result;
+std::shared_ptr<VCardUpdate> VCardUpdateConvertor::doConvertFromLua(lua_State* L) {
+ std::shared_ptr<VCardUpdate> result = std::make_shared<VCardUpdate>();
+ if (boost::optional<std::string> value = Lua::getStringField(L, -1, "photo_hash")) {
+ result->setPhotoHash(*value);
+ }
+ return result;
}
-void VCardUpdateConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<VCardUpdate> payload) {
- lua_newtable(L);
- if (!payload->getPhotoHash().empty()) {
- lua_pushstring(L, payload->getPhotoHash().c_str());
- lua_setfield(L, -2, "photo_hash");
- }
+void VCardUpdateConvertor::doConvertToLua(lua_State* L, std::shared_ptr<VCardUpdate> payload) {
+ lua_newtable(L);
+ if (!payload->getPhotoHash().empty()) {
+ lua_pushstring(L, payload->getPhotoHash().c_str());
+ lua_setfield(L, -2, "photo_hash");
+ }
}
diff --git a/Sluift/ElementConvertors/VCardUpdateConvertor.h b/Sluift/ElementConvertors/VCardUpdateConvertor.h
index b6ffac7..851f3b1 100644
--- a/Sluift/ElementConvertors/VCardUpdateConvertor.h
+++ b/Sluift/ElementConvertors/VCardUpdateConvertor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -7,17 +7,17 @@
#pragma once
#include <Swiften/Base/Override.h>
+#include <Swiften/Elements/VCardUpdate.h>
#include <Sluift/GenericLuaElementConvertor.h>
-#include <Swiften/Elements/VCardUpdate.h>
namespace Swift {
- class VCardUpdateConvertor : public GenericLuaElementConvertor<VCardUpdate> {
- public:
- VCardUpdateConvertor();
- virtual ~VCardUpdateConvertor();
+ class VCardUpdateConvertor : public GenericLuaElementConvertor<VCardUpdate> {
+ public:
+ VCardUpdateConvertor();
+ virtual ~VCardUpdateConvertor();
- virtual boost::shared_ptr<VCardUpdate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
- virtual void doConvertToLua(lua_State*, boost::shared_ptr<VCardUpdate>) SWIFTEN_OVERRIDE;
- };
+ virtual std::shared_ptr<VCardUpdate> doConvertFromLua(lua_State*) SWIFTEN_OVERRIDE;
+ virtual void doConvertToLua(lua_State*, std::shared_ptr<VCardUpdate>) SWIFTEN_OVERRIDE;
+ };
}