7

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?

Dave Ceddia
  • 1,480
  • 2
  • 17
  • 24
  • This is the domain of IDE add-ons. Visual Assist for Visual Studio does this for example. Shop around to see what fits yours. – Hans Passant Oct 25 '10 at 21:23
  • My IDE is generally just vim ;) I can use Xcode too. – Dave Ceddia Oct 25 '10 at 22:16
  • 2
    possible duplicate of [Seeking code stub generator (from header files)](http://stackoverflow.com/questions/2020568/seeking-code-stub-generator-from-header-files) – Fred Foo Oct 26 '10 at 14:41
  • I am sure you could find vim scripts doing that. I use emacs and I added very usefull scripts for C++. – Julio Guerra Oct 27 '10 at 01:17
  • Are vim tools from duplicate candidate really command line tools? Not everyone use vi, emacs or even ctags. – Basilevs Oct 27 '10 at 12:24

2 Answers2

1

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
  • 6,325
  • 4
  • 22
  • 28
1

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
  • 684
  • 6
  • 15