Re: object serialization
Tony Kostanjsek <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Have you taken a look at Pluto? Haven't tried it myself yet, but maybe it fits your use case. Best, Tony http://lua-users.org/wiki/PlutoLibrary On 22.04.2011, at 03:28, Szymon Gatner <[email protected]> wrote: > Hi, > > what would be the simple and elegant way to do serialization / > persistance of a specific luabind::object? > > I only need to save numeric and string values and tables of them. I > was thinking about recursive visitation like so: > > void visit(const luabind::object& obj) > { > using namespace luabind; > > if (type(obj) == LUA_TTABLE) > { > cout << "{" << endl; > > for (luabind::iterator it(obj); it != luabind::iterator(); ++it) > { > if (type(it.key()) == LUA_TSTRING) > { > if (type(*it) != LUA_TTABLE) > { > cout << it.key() << " = " << *it << endl; > } > else > { > visit(*it); > } > } > } > > cout << "}" << endl; > } > } > > cout is used here to print name/value pairs but in real case actual > persistance code would be used. > > Am I going the right way? > > Cheers, > Szymon > > ------------------------------------------------------------------------------ > Fulfilling the Lean Software Promise > Lean software platforms are now widely adopted and the benefits have been > demonstrated beyond question. Learn why your peers are replacing JEE > containers with lightweight application servers - and what you can gain > from the move. http://p.sf.net/sfu/vmware-sfemails > _______________________________________________ > luabind-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/luabind-user ------------------------------------------------------------------------------ Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails