MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / MapCoord

Method MapCoord

src/core/map_coord.cpp:394–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394MapCoord::MapCoord(QStringRef& text)
395: MapCoord{}
396{
397 const int len = text.length();
398 if (Q_UNLIKELY(len < 2))
399 throw std::invalid_argument("Premature end of data");
400
401 auto data = text.constData();
402 int i = 0;
403
404 qint64 x64 = data[0].unicode();
405 if (x64 == '-')
406 {
407 x64 = '0' - data[1].unicode();
408 for (i = 2; i != len; ++i)
409 {
410 auto c = data[i].unicode();
411 if (c < '0' || c > '9')
412 break;
413 else
414 x64 = 10*x64 + '0' - c;
415 }
416 }
417 else if (x64 >= '0' && x64 <= '9')
418 {
419 x64 -= '0';
420 for (i = 1; i != len; ++i)
421 {
422 auto c = data[i].unicode();
423 if (c < '0' || c > '9')
424 break;
425 else
426 x64 = 10*x64 + c - '0';
427 }
428 }
429
430 ++i;
431 if (Q_UNLIKELY(i+1 >= len))
432 throw std::invalid_argument("Premature end of data");
433
434 qint64 y64 = data[i].unicode();
435 if (y64 == '-')
436 {
437 ++i;
438 y64 = '0' - data[i].unicode();
439 for (++i; i != len; ++i)
440 {
441 auto c = data[i].unicode();
442 if (c < '0' || c > '9')
443 break;
444 else
445 y64 = 10*y64 + '0' - c;
446 }
447 }
448 else if (y64 >= '0' && y64 <= '9')
449 {
450 y64 -= '0';
451 for (++i; i != len; ++i)

Callers

nothing calls this directly

Calls 4

handleBoundsOffsetFunction · 0.85
ensureBoundsForQint32Function · 0.85
FlagsEnum · 0.50
lengthMethod · 0.45

Tested by

no test coverage detected