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?

5
  • This is the domain of IDE add-ons. Visual Assist for Visual Studio does this for example. Shop around to see what fits yours. Commented Oct 25, 2010 at 21:23
  • My IDE is generally just vim ;) I can use Xcode too. Commented Oct 25, 2010 at 22:16
  • 2
    possible duplicate of Seeking code stub generator (from header files) Commented Oct 26, 2010 at 14:41
  • I am sure you could find vim scripts doing that. I use emacs and I added very usefull scripts for C++. Commented Oct 27, 2010 at 1:17
  • Are vim tools from duplicate candidate really command line tools? Not everyone use vi, emacs or even ctags. Commented Oct 27, 2010 at 12:24

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

It doesn't necessarily need to be a shell script; a plugin would be fine. Something for vim or Xcode would be preferable.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.