Script for separating implementation from headers in a .h file(用于将实现与 .h 文件中的标头分开的脚本)
问题描述
有时,在处理小类时,将实现分离在 .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/
这篇关于用于将实现与 .h 文件中的标头分开的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:用于将实现与 .h 文件中的标头分开的脚本


基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- CString 到 char* 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05