是否有任何现有工具可以转换 c++头文件到头文件 +执行?

发布于 2024-09-11 20:06:52 字数 207 浏览 5 评论 0原文

我倾向于将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蘸点软妹酱 2024-09-18 20:06:52

试试Lzz

Try Lzz.

薄荷梦 2024-09-18 20:06:52

视觉辅助具有执行此操作的重构工具。您可以将其绑定到键盘快捷键,这样您就可以根据具体情况进行操作,而不是自动操作。

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.

黯然#的苍凉 2024-09-18 20:06:52

作为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文