Arkanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
preprocessor.cpp
Go to the documentation of this file.
2
5
6void Preprocessor::save_current_run_params(const fs::path& path) {
7 std::vector<std::string> config_content;
8
9 std::string path_message = PATH_MESSAGE + path.string();
10
11 auto end = std::chrono::system_clock::now();
12 std::time_t end_time = std::chrono::system_clock::to_time_t(end);
13 std::string time_message = TIME_MESSAGE + std::string(std::ctime(&end_time));
14
15 config_content.push_back(path_message);
16 config_content.push_back(time_message);
17
18 Utils::write_file_generic(Config::config().base_path / Config::config().name_container / CONFIG_PATH, config_content);
19}
20
21std::vector<std::string> Preprocessor::read_current_run_params() {
22 std::vector<std::string> content;
24
25 std::ifstream infile(file_path);
26 if (!infile.is_open()) {
27 std::cerr << "Error: could not open " << file_path << "\n";
28 return content;
29 }
30
31 std::string line;
32 while (std::getline(infile, line)) {
33 if (line.rfind(PATH_MESSAGE, 0) == 0) {
34 line = line.substr(std::string(PATH_MESSAGE).size());
35 }
36 else if (line.rfind(TIME_MESSAGE, 0) == 0) {
37 line = line.substr(std::string(TIME_MESSAGE).size());
38 }
39
40 content.push_back(line);
41 }
42
43 return content;
44}
static Config & config()
Gets the singleton configuration instance.
Definition config.cpp:37
fs::path base_path
Default base path for temporary files.
Definition config.hpp:42
fs::path name_container
Name of the cache container.
Definition config.hpp:44
static constexpr const char * CONFIG_PATH
Configuration file path.
static std::vector< std::string > read_current_run_params()
read preprocessing parameters runs
static void save_current_run_params(const fs::path &path)
Saves preprocessing parameters for future runs.
Configuration management interface.
void write_file_generic(const fs::path &file_path, const std::vector< std::string > &content)
Writes content to a file at specified path.
Definition utils.cpp:26
Defines utility functions used across all files.