I would like to add a single line of code at the beginning of each function in my c++ visual studio 2015 project.
It would take months to manually add a line into each function. Are there any quick way or tool to solve this problem ?
function examples are:
void Class::Func1(CATUnicodeString& Record ) const{ //some code }
Class1::Class1():CATBaseUnknown() ,_usDrawingNumber( "" ){ //some code }
Class1::~Class1() { //some code }
I need to handle all of these function definitions
Sample:
void func1()
{
//code
}
int func2()
{
//code
}
char* func3()
{
//code
}
/* more functions */
bool func100()
{
//code
}
//I want them to become:
void func1()
{
myMacro;
//code
}
int func2()
{
myMacro;
//code
}
char* func3()
{
myMacro;
//code
}
/* more functions */
bool func100()
{
myMacro;
//code
}
I found similar answers explaining about regex,aspect programming,__pender. As I am a beginner, its hard to understand those concepts.
Expectation is: I would like to give the path of workspace folder and tool will fetch all cpp files in that and add the macro at required place.
If this tool doesn't exist,Please guide if similar tool can be build using any technology like .net,java or python.
Replace
(^.*\(.*\).*\n{)\n(.*)
with$1\nmyMacro\n$2
Explanation:
Demo
RE:
I found similar answers explaining about regex,aspect programming,__pender. As I am a beginner, its hard to understand those concepts.
Use Find replace in Visual Studio ;)
The site linked in the demo also provides a code in
C#/python
which can be modified a little and can be used as a 'tool' to convert the files you need