自动将按值传递更改为按引用传递
我有数百个函数,从手动 java 到 c++ 端口。在结果c++代码中,我希望将按值传递的参数更改为按引用传递:
from:
void funcName1( Type1 t1, Type2 t2, int i);
to:
void funcName2( Type1& t1, Type2& t2, int i);
最好保留原始类型(如 int、float)不变。
有什么重构工具可以自动化这个过程吗?一些正则表达式技巧?
或者有什么工具可以将可移植的java代码转换为c++吗?
I have many hundreds of functions from a manual java to c++ port. In the result c++ code, I wish to change parameters passed by value to passed by reference:
from:
void funcName1( Type1 t1, Type2 t2, int i);
to:
void funcName2( Type1& t1, Type2& t2, int i);
Preferably leave the primitive types such as int, float unchanged.
Any refactoring tools to automate this process? Some regular expression tricks?
Or any tool that converts portable java code to c++?
尝试创建 2 个正则表达式:
从第一个匹配组 1 将为您提供:
针对此输出运行第二个正则表达式,组 1 将是:
如果您使用的是 java,则可以使用以下命令快速转换:
Try creating 2 regular expressions:
Matching group 1 from the first will give you:
Run the second against this output and group 1 will be:
If you're using java, you can convert quickly with: