MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / getLocation

Function getLocation

cp-profiler/src/cpprofiler/name_map.cpp:51–85  ·  view source on GitHub ↗

extract location and whether it is final from a paths line

Source from the content-addressed store, hash-verified

49
50/// extract location and whether it is final from a paths line
51static 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
87static const Location empty_location{};
88static const string empty_string{""};

Callers 1

initializeMethod · 0.85

Calls 4

splitFunction · 0.85
LocationClass · 0.85
findMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected