/* * Copyright (c) 2014-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include #include #include #include #include #include using namespace Swift; DelayConvertor::DelayConvertor() : GenericLuaElementConvertor("delay") { } DelayConvertor::~DelayConvertor() { } std::shared_ptr DelayConvertor::doConvertFromLua(lua_State* L) { std::shared_ptr result = std::make_shared(); 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, std::shared_ptr 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"); }