lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all,
 
    I am not too sure whether anyone has done this, but i would like to take a lua table and then dump the contents of the table to a file (or buffer) of some sort, this table might contain things such as strings and numbers and also tables itself.recurse into other tables and so forth. I want to then take this dumped table data and be able to read it from a totally seperate c based application, preferably without having to have all the lua stuff to load and save chunks and so forth. So i was wondering whether anyone out there has done a mechanism such as this, or whether it already exists and i have just missed something.
 
    The implementation that I am thinking along the lines of is that a call is made to some function, lets say lua_serialize(), this would then serialize the lua table to a buffer or file. Naturally i am also assuming there would be support for deserialization. The actual serialization process would perhaps just create a c structure for storage of the various types strings, and lua numbers, and tables, and then just traverse each item in the table recursively and on getting each new item writing an entry to this. Of course there are some types that cannot be serialized, such as c functions and so forth, but for my particular application i am just interested in tables, and the contents of the table.
 
Cheers,
 
    Andrew Stanley Teirney