/* * Copyright (c) 2013 Remko Tronçon * Licensed under the GNU General Public License. * See the COPYING file for more information. */ #include #include #include #include #include #include using namespace Swift; VCardConvertor::VCardConvertor() : GenericLuaElementConvertor("vcard") { } VCardConvertor::~VCardConvertor() { } boost::shared_ptr VCardConvertor::doConvertFromLua(lua_State* L) { boost::shared_ptr result = boost::make_shared(); 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); // TODO return result; } void VCardConvertor::doConvertToLua(lua_State* L, boost::shared_ptr payload) { lua_newtable(L); if (!payload->getPhoto().empty()) { lua_pushlstring(L, reinterpret_cast(vecptr(payload->getPhoto())), payload->getPhoto().size()); lua_setfield(L, -2, "photo"); } }