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
e.g

input
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 :-( ?

Recommended Answers

All 2 Replies

No one has come across this kind of script ? :-(

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.

commented: Thanks Mike. +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.