3void Preprocessor::save_current_run_params(
string path){
4 vector<string> config_content;
6 string path_message = PATH_MESSAGE + path;
8 auto end = std::chrono::system_clock::now();
9 std::time_t end_time = std::chrono::system_clock::to_time_t(end);
10 string time_message = TIME_MESSAGE + std::ctime(&end_time);
12 config_content.push_back(path_message);
13 config_content.push_back(time_message);
18tuple<string,double,bool> Preprocessor::read_parameters(){
19 cout << INITIAL_MESSAGE <<
'\n';
20 string path,similarity_message;
22 cout << PROJECT_PATH_MESSAGE <<
'\n';
25 cout << MINIMUM_SIMILARITY_MESSAGE <<
'\n';
26 cin >> similarity_message;
27 double similarity = stod(similarity_message);
29 bool use_duplication_finder_by_tool=
false;
32 cout << MESSAGE_DUPLICATION_FINDER_TYPE_1 <<
'\n';
33 cout << MESSAGE_DUPLICATION_FINDER_TYPE_2 <<
'\n';
34 cout << MESSAGE_DUPLICATION_FINDER_TYPE_3 <<
'\n';
38 use_duplication_finder_by_tool =
true;
40 use_duplication_finder_by_tool =
false;
42 cout << INVALID_CODE_DUPLICATION_FINDER <<
'\n';
49 return {path,similarity,use_duplication_finder_by_tool};
52void Preprocessor::preprocess(
string path,
double similarity,
bool use_duplication_finder_by_tool){
53 cout << BREAKER_MESSAGE <<
'\n';
58 string command_rm_tmp =
"rm -r -f " + base_path +
"/";
59 system(command_rm_tmp.c_str());
60 FunctionBreaker function_breaker(path);
62 cout << DUPLICATION_MESSAGE <<
'\n';
64 if(use_duplication_finder_by_tool){
65 DuplicationFinderTool duplicationFinder(base_path,similarity);
66 duplicationFinder.execute();
68 DuplicationFinderDiff duplicationFinder(base_path,similarity);
69 duplicationFinder.execute();
72 save_current_run_params(path);
74 cout << END_MESSAGE <<
'\n';
81 auto [path,similarity,use_duplication_finder_by_tool] = read_parameters();
82 preprocess(path,similarity,use_duplication_finder_by_tool);
90 preprocess(path,similarity,
true);
Singleton configuration manager class.
static Config * config()
Gets the singleton configuration instance.
string getBasePath()
Gets the current base path.
Preprocessor(bool force_preprocess)
Constructs preprocessor with optional forcing.
bool does_file_exist(string file_path)
Checks if a file exists at the given path.
void write_file_generic(string file_path, vector< string > content)
Writes content to a file at specified path.
Codebase preprocessing interface.