Reputation: 95639
I have a bunch of C++ header files with various class and function declarations. So far, when I've been writing the C++ source file implementations of the declared classes and functions, I've been manually:
Only after all that work, which doesn't really do anything, can I actually go about implementing the functions. I am wondering if there is a tool out there somewhere that can automatically generate a ".cpp" file from a ".h" file, where the resulting ".cpp" contains empty stubs for the functions declared in the ".h" file (and for which an inline definition hasn't been given). A UNIX-friendly commandline tool would be preferred. Thanks.
UPDATE: A cross-platform tool would be ideal. If not, I am working on Mac OS X 10.6.
Upvotes: 31
Views: 20957
Reputation: 74
I tried Lazy C++ but it seems to be out of date and not maintained anymore. It doesn't support the latest C++14 standard either.
That's why I decided to write my own tool in Java using ANTLR4. It's called Score and you can find it here: https://github.com/underrated/Score
At the moment it's in its infancy and might be full of bugs but I plan to improve it. So give it a try if you want and report any bugs on the project's github page. I'll try to fix them as fast as possible.
Upvotes: 1
Reputation: 19213
I found myself in your situation lately and manned up to write my own tool -- impl_me. It's a small Ruby script that uses SWIG as a parser backend. It writes to stdout so you can combine with your favorite nix toolset find
/grep
/sed
/awk
to tweak for your own preferences.
Because it's written in Ruby, it should be cross platform. SWIG is also cross platform so everything should be OK.
It's quite primitive at this stage and isn't as robust as Lazy C++ in terms of parsing strange templates and stuffs. Contributions are welcome :)
Upvotes: 7
Reputation: 4492
The eclipse CDT has an "Implement method" feature which does just that (one method at a time). There is also a "Generate Getters and Setters" feature which also generates the appropriate code in the function bodies.
Upvotes: 4
Reputation: 89185
Lazy C++ appears to be designed to address precisely that problem.
Upvotes: 25