extract location and whether it is final from a paths line
| 49 | |
| 50 | /// extract location and whether it is final from a paths line |
| 51 | static std::pair<Location, bool> getLocation(const string &path) |
| 52 | { |
| 53 | |
| 54 | auto model_name = path.substr(0, path.find(utils::minor_sep)); |
| 55 | |
| 56 | auto name_pos = path.rfind(model_name); |
| 57 | auto end_elm = path.find(utils::major_sep, name_pos); |
| 58 | |
| 59 | auto element = path.substr(name_pos, end_elm - name_pos); |
| 60 | |
| 61 | auto loc_parts = utils::split(element, utils::minor_sep); |
| 62 | |
| 63 | auto loc = Location(stoi(loc_parts[1]), stoi(loc_parts[2]), |
| 64 | stoi(loc_parts[3]), stoi(loc_parts[4])); |
| 65 | |
| 66 | bool is_final = false; |
| 67 | |
| 68 | if (end_elm == path.size() - 1) |
| 69 | { |
| 70 | is_final = true; |
| 71 | } |
| 72 | else |
| 73 | { |
| 74 | auto rem = path.substr(end_elm + 1); |
| 75 | auto loc_parts = utils::split(rem, utils::minor_sep, true); |
| 76 | |
| 77 | if (stoi(loc_parts[1]) == 0 && stoi(loc_parts[2]) == 0 && |
| 78 | stoi(loc_parts[3]) == 0 && stoi(loc_parts[4]) == 0) |
| 79 | { |
| 80 | is_final = true; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | return std::make_pair(loc, is_final); |
| 85 | } |
| 86 | |
| 87 | static const Location empty_location{}; |
| 88 | static const string empty_string{""}; |
no test coverage detected