MCPcopy Create free account
hub / github.com/MediaArea/MediaInfoLib / Location_Compare

Function Location_Compare

Source/MediaInfo/File__Analyze_Streams.cpp:174–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172};
173const size_t digit_to_precision_Size = sizeof(digit_to_precision) / sizeof(*digit_to_precision);
174bool Location_Compare(const string& Current, const string& CompareTo, bool& Replace)
175{
176 auto Split = [](const string& Value, size_t& Start, size_t* Pos3, size_t* Size3) {
177 auto degree_pos = Value.find("\xC2\xB0", Start);
178 if (degree_pos == string::npos) {
179 return true;
180 }
181 auto degree_dot_pos = Value.find('.', Start);
182 if (degree_dot_pos > degree_pos) {
183 degree_dot_pos = degree_pos;
184 }
185 else {
186 degree_dot_pos++;
187 }
188 Pos3[0] = Start;
189 Start = Value.find(' ', Start);
190 if (Start == string::npos) {
191 Start = Value.size();
192 }
193
194 auto minute_pos = Value.find('\'', degree_pos);
195 if (minute_pos != string::npos) {
196 return true; // Not supported
197 }
198
199 Size3[0] = degree_pos - degree_dot_pos;
200 Pos3[1] = Start;
201 Size3[1] = 0;
202 Pos3[2] = Start;
203 Size3[2] = 0;
204 return false;
205 };
206 size_t Start0 = 0;
207 bool Fail = false;
208 size_t Pos[2][3][3];
209 size_t Size[2][3][3];
210 Fail |= Split(Current, Start0, Pos[0][0], Size[0][0]);
211 Start0++;
212 Fail |= Split(Current, Start0, Pos[0][1], Size[0][1]);
213 size_t Start1 = 0;
214 Fail |= Split(CompareTo, Start1, Pos[1][0], Size[1][0]);
215 Start1++;
216 Fail |= Split(CompareTo, Start1, Pos[1][1], Size[1][1]);
217 if (Fail) {
218 return false;
219 }
220 string OldLocale;
221 auto OldLocale_Temp = setlocale(LC_NUMERIC, nullptr);
222 if (OldLocale_Temp && (*OldLocale_Temp != 'C' || *(OldLocale_Temp + 1))) {
223 OldLocale = OldLocale_Temp;
224 setlocale(LC_NUMERIC, "C");
225 }
226 auto Current_Deg = strtof(Current.c_str() + Pos[0][0][0], nullptr);
227 auto CompareTo_Deg = strtof(CompareTo.c_str() + Pos[0][0][0], nullptr);
228 if (!OldLocale.empty()) {
229 setlocale(LC_NUMERIC, OldLocale.c_str());
230 }
231 auto Diff_Deg = CompareTo_Deg - Current_Deg;

Callers 1

FillMethod · 0.85

Calls 3

sizeMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected