开发者

Are there any existing tools to convert c++ header files to header + implementation?

开发者 https://www.devze.com 2023-01-09 02:42 出处:网络
I tend to prototype C++ classes as a self-contained class, i.e. like: class BlahBlahBlah { public: void SomeMethod()

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 开发者_如何学Cso is there any tool out there that can help with that?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消