Hi C++ experts,
I am looking for a script which given a structure made of basic types
can generate a C++ class which encapsulate the structure and it also generates
the stream in and stream out method for the structure

int a ;
char b;
string c;

output a class C {
int a ;
char b;
string c;

// appropriates functions
// stream in and stream out methods to convert the structure into byte stream as well as 
// construct the class back from a byte stream

I have used propertiary script like this before , just wondering whether any opensource script can do same or else do I need to write one again :-( ?

8 Years
Discussion Span
Last Post by mike_2000_17

There are some tools for "code refactoring", I have looked for good ones that are free or opensource, but to no avail. Visual C++ has apparently very good tools for code refactoring, but I have not used them.

In this case, you want to use a serialization library like the one in Boost to do those stream in and stream out functions. There are also plenty of other libraries in Boost that can be useful for this like the preprocessor library, the template meta-programming library (MPL), or even the group Bind/Lambda/Phoenix/Spirit. You'll probably will find what you need there, try not to use scripts as code factories, the preprocessor and templates are much better options.

Votes + Comments
Thanks Mike.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.