views:

180

answers:

2

The barebones version of a .cpp file is often not much more than a copy of the related header file with some braces instead of semicolons, ClassName:: inserted in a few places, and removing the virtual keyword. Much of it could be generated with a one-line sed command, but it wouldn't be very robust for all the language features (templates come to mind).

Before I go write my own, are there any simple command-line utilities that will take a header file I provide and give me a skeletal .cpp file where I can fill in the blanks?

+1  A: 

Most graphical editors have some plugins available to do that like vim, gedit or Eclipse. But I am not aware of a shell or perl script to do that.

Benoit Thiery
It doesn't necessarily need to be a shell script; a plugin would be fine. Something for vim or Xcode would be preferable.
Dave
Have a look at: http://stackoverflow.com/questions/2020568/seeking-code-stub-generator-from-header-files
Benoit Thiery
A: 

Eclipse CDT has a feature of creating setters/getters provided you have defined variables in your .h. Also it provides "Implement method" - again it looks through your definitions in .h and implements methods giving them empty body. Maybe someone find this usefull.

And don't forget to read question, pointed by larsmans.

PF4Public