是否有任何现有工具可以转换 c++头文件到头文件 +执行?
我倾向于将 C++ 类原型化为独立类,即:
class BlahBlahBlah
{
public:
void SomeMethod()
{
// some code here
}
};
然后当我对设计感到满意时,我会将其转换为 .h/.cpp 对。这主要是一项机械任务,那么有没有任何工具可以帮助解决这个问题?
I tend to prototype C++ classes as a self-contained class, i.e. like:
class BlahBlahBlah
{
public:
void SomeMethod()
{
// some code here
}
};
and then later when I am happy with the design I will turn it into a .h/.cpp pair. This is mostly a mechanical task so is there any tool out there that can help with that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试Lzz。
Try Lzz.
视觉辅助具有执行此操作的重构工具。您可以将其绑定到键盘快捷键,这样您就可以根据具体情况进行操作,而不是自动操作。
Visual Assist has a refactor tool that does this. You can bind it to a keyboard shortcut so you can do it case-by-case, rather than robotically.
作为 Lzz 的替代方案,您可以考虑查看 Preprocess - 预处理器C 和 C++ 模块。与Lzz不同的是,它确实保留了评论。然而,它确实有一些限制。它不支持命名空间或嵌套类。但由于它是用 PERL 编写的,我想扩展和定制不会太困难。
还有 inlsplit:内联 C++ 源代码和标头分割器。这是一个非常简单的 awk 脚本,它解析单个 .inl 文件,并将所有带有 @ 的成员函数放在其原型后面的源文件中,仅保留标头中的声明。还有一个 @source 标签,可以让代码直接进入实现。相比lzz和preprocess,它非常轻量。不过现在已经废弃了,没有新的开发。
As an alternative to Lzz you might consider taking a look at Preprocess - A preprocessor for C and C++ modules. Unlike Lzz, it does preserve comments. However, it does have some limitations. It does not support namespaces or nested classes. But since it's written in PERL and I imagine it would not be too difficult to extend and customize.
There is also inlsplit: Inline C++ Source and Header splitter. It is a very simple awk script which parses a single .inl file and places all member functions with a @ folowing their prototype into the source file, keeping only the declaration in the header. There is also a @source tag for code to go straight into the implementation. Compared to lzz and preprocess, it is very lightweight. However it has been abandoned and there is no new development.