4vector<string> Path::split_path(
string string_path){
7 for(
auto c : string_path){
21int Path::find_position_start_relative_path(){
22 int sz = tokens.size();
24 for(
int i = 0; i < sz-1; i++){
25 if(tokens[i] == BASE_INIT_STRING && tokens[i+1] == SOURCE_STRING){
29 assert(
ret != sz &&
"PATH NOT VALID FOR THE TOOL");
34 return tokens.empty();
41 tokens = split_path(string_path);
42 position_start_relative_path = find_position_start_relative_path();
45string Path::build_string_path(vector<string> path){
48 for(
int i = 0; i < sz; i++){
49 string_path += path[i];
57string Path::build_base_path(
string base){
61 vector<string> path = tokens;
62 int pos_change = position_start_relative_path-1;
63 path[pos_change] = base;
64 string string_path = build_string_path(path);
69 return build_base_path(SOURCE_STRING);
73 return build_base_path(HEADER_STRING);
77 string ret = build_base_path(INFO_STRING);
81 ret = remove_extension(
ret);
85 ret += JSON_EXTENSION;
89vector<string> Path::get_tokens_from_relative_path(){
90 vector<string> token_relative_path = tokens;
91 token_relative_path.pop_back();
92 int to_remove = position_start_relative_path;
93 reverse(token_relative_path.begin(),token_relative_path.end());
94 for(
int i = 0; i < to_remove; i++){
95 token_relative_path.pop_back();
97 reverse(token_relative_path.begin(),token_relative_path.end());
98 return token_relative_path;
101string Path::remove_extension(
string token){
102 while(!token.empty()){
103 auto c = token.back();
116 vector<string> token_relative_path = get_tokens_from_relative_path();
117 string string_path = build_string_path(token_relative_path);
125 string function_name = tokens.back();
126 function_name = remove_extension(function_name);
127 return function_name;
131 vector<string> tokens_relative_1 = get_tokens_from_relative_path();
132 vector<string> tokens_relative_2 = path.get_tokens_from_relative_path();
133 int minimum_size_tokens = min(tokens_relative_1.size(),tokens_relative_2.size());
134 vector<string> common_folders;
135 for(
int i = 0; i < minimum_size_tokens; i++){
136 auto token_1 = tokens_relative_1[i];
137 auto token_2 = tokens_relative_2[i];
138 if(token_1 == token_2){
139 common_folders.push_back(token_1);
144 return common_folders;
148 return tokens < path.tokens;
153 return relative_path_plus_function_name.find(pattern) != string::npos;
Path manipulation class for tool-specific directory structure.
bool contains_given_pattern(string pattern)
Checks for pattern in path.
string build_source_path()
Builds source file path.
string build_info_path()
Builds metadata file path.
string build_relative_path()
Builds relative path portion.
string build_header_path()
Builds header file path.
bool operator<(const Path &path) const
Path comparison operator.
bool is_empty()
Checks if path is empty.
vector< string > get_common_folders(Path path)
Finds common folders with another path.
Path()
Default constructor.
string build_function_name()
Extracts function name from path.
Path abstraction for temporary codebase.