用于将实现与 .h 文件中的标头分开的脚本

2022-01-11 00:00:00 header c++

有时,在处理小类时,将实现分离在 .cpp 文件中是一件很痛苦的事情,所以我将所有代码放在头文件中(孩子们,不要这样做).

Sometimes, when working with small classes, it's a pain in the ass to separate the implementation in a .cpp file, so I put all the code in the header file (kids, don't do this).

但是,最终这些课程变得越来越大,我必须进行我一开始没有做的分离.

However, eventually these classes grow big time and I have to make the separation that I didn't do in the beginning.

事实上,这是一个机械过程,可以通过脚本或类似的东西完美地完成,我确定有人已经想到了这一点.

The fact is that this is a mechanic process that could be perfectly done by a script or something like that, and I'm sure someone out there has already thought of this.

那么,你知道有什么脚本可以获取一个 .h 文件,实现所有函数体,然后返回一个剥离的 .h 文件和一个填充良好的 .cpp 文件吗?

So, do you know of any script that could get a .h file, with all the function bodies implemented, and then return a stripped .h file and a nicely filled .cpp file?

推荐答案

我也为此感到内疚 - 虽然我以前从未真正考虑过自动拆分,因为通常有相关的项目和测试文件需要接触.

I'm guilty of this as well - although I've never really thought about automating the split before, as there are usually related project and test files to touch.

不过,将其自动化的想法很有趣.我看到的最有前途的工具是这个:

The idea of automating this is interesting, though. The most promising tool I see out there is this one:

http://os.inf.tu-dresden.de/~hohmuth/prj/preprocess/

相关文章