Isolator
What is Isolator?
Isolator tool isolates the whole code from a given function or class inside destination code and replaces the isolated function or class from source code inside destination code. It consists of two parts, IsolateFunction and IsolateClass.
Commands:
Isolate Function
isolate f source.cpp destination.cpp "function prototype"
Isolate Class
isolate c source.cpp destination.cpp "class class-name"
By default, it only isolates the class with its member functions' implementation. Adding the option '-all' gives more options:
-
Isolates the class with all its dependent classes (inherited classes and friend classes).
isolate c source.cpp destination.cpp "class class-name" -all t
-
Isolates the class definition only.
isolate c source.cpp destination.cpp "class class-name" -all c
How does it work?
Isolator will search for the desired function\class inside source.cpp and take a copy of it, after that it will search for the desired function\class inside destination.cpp and inserts it in the appropriate place as described below. Searching for a function or class depends on signature matching.
Where it will be inserted?
Isolate fucntion:
Non-member function:
Function's prototype will be inserted in the beginnig of the code, and function's implementation will be inserted at the end of the code.
Member function:
-
The orginal function is implemented inside the class:
Function will be inserted at the end of the class.
-
The orginal function is implemented inside the class:
Function's prototype will be inserted at the end of the class, and function's implementation will be inserted at the end of the code.
Isolate Class:
Class found in destination code:
Original class will be commented and the copied class from source.cpp will be pasted in the exact place of the original class in detination.cpp
Class not found in destination.cpp:
The copied class from source.cpp will be pasted at the end of detination.cpp
Error Scenarios:
The following cases outputs an error message
Isolate Function:
Non-member Functions:
- Function doesn't exist in source.cpp
Member Functions:
-
Parent Class doesn't exist in destination.cpp
-
Function doesn't exist in source.cpp
Isolate Class:
Class:
- Class doesn't exist in source.cpp
Struct:
- Struct doesn't exist in source.cpp
Note
While isolating a member function, writing the class on one lines results with errors. Please write the class on at least 2 lines. Write the class on 2 lines or more inside your .cpp file
DON'T:
class x{}
DO:
class x{
}
For reference on how to write functions' parameters, please check the reference page