Automatically generate serialization code?

Hi there. I am looking for ideas about automatically generating the serialization helpers. Boost serialization library would be used - the question is about a simple (hopefully) and foolproof way of automatically creating the helpers. The classed that need serialization are modified on a daily basis by other developers. Maintaining the serialization code manually isn't an option - looking for an automated way. One possible approach: 1) Run a parser that scans the C++ code and identifies the data members of the classes that declare serialize() 2) Generate .inl files (one for each class to be serialized) with the boost::serialize() methods 3) Include the .inl files in the corresponding .cpps 4) Compile and link... An idea thrown by someone was to get the data members by getting the symbols from the .obj files - but this would require two compiles - one to generate the object files from where the symbols would be extracted, then another one... Definitely someone else had solved this problem (with the above approach or a different one). Please let me know your opinions. Regards, Alex ____________________________________________________________________________________ You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com

On Sun, 30 Mar 2008 14:41:16 -0700, Alex Idar wrote:
I am looking for ideas about automatically generating the serialization helpers. Boost serialization library would be used - the question is about a simple (hopefully) and foolproof way of automatically creating the helpers.
I've always thought about this problem but have always decided that it
would be too inflexible. Anyway, here is one possible solution using the
Boost Preprocessor library:
#include <string>
#include <iostream>
#include <sstream>
#include

Sohail Somani
On Sun, 30 Mar 2008 14:41:16 -0700, Alex Idar wrote:
I am looking for ideas about automatically generating the serialization helpers. Boost serialization library would be used - the question is about a simple (hopefully) and foolproof way of automatically creating the helpers.
Thank you. This is an interesting idea - I'll have to look a bit at the Boost preprocessor then. I'm wondering, have you have already covered all situations? The example gives a good starting point, but I'm thinking of having support for: 1) Serialization of the base classes 2) Case when the data member is a pointer to a base class - talking about registration like ar.register_type(...) Let me know if you dealt with the above points as well - I'll have to think myself how to add support for these cases. The devil is in the details... Would be nice to solve the points above - and maybe bring the syntax closer to what varaible declarations look like. Thanks, Alex
participants (2)
-
Alex Idar
-
Sohail Somani