#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Simulate user inputs for the tool auto findText = "GetUserData"; auto replaceText = "FetchUserProfile"; auto sourceCode = R"( // Deprecated: Use FetchUserProfile instead of GetUserData function GetUserData(id) { print("Calling GetUserData is not recommended."); return http.get("/users/" + id); } var user = GetUserData(123); )"; { uCalc::Transformer refactorTool; refactorTool.Owned(); // Causes refactorTool to be released when it goes out of scope // 1. Define rules to ignore comments. These have the highest precedence. refactorTool.SkipOver("// {text}"); refactorTool.SkipOver("/* {text} */"); // 2. Define the replacement rule. QuoteSensitive is true by default, protecting strings. auto rule = refactorTool.FromTo(findText, replaceText); // 3. Run the transformation and print the result. cout << refactorTool.Transform(sourceCode) << endl; } }