mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 00:25:35 +08:00
Use QString::arg instead of std::sprintf
This commit is contained in:
@@ -73,12 +73,11 @@ namespace BlackMisc
|
|||||||
dms *= -1.0;
|
dms *= -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char chars[16];
|
QString str = QStringLiteral("%1").arg(dms, 14, 'f', 10, '0'); // 000.0000000000
|
||||||
std::sprintf(chars, "%014.10f", dms); // 000.0000000000
|
values.deg = str.midRef(0, 3).toInt();
|
||||||
values.deg = stringToInt(chars, chars + 3);
|
values.min = str.midRef(4, 2).toInt();
|
||||||
values.min = stringToInt(chars + 4, chars + 6);
|
values.sec = str.midRef(6, 2).toInt();
|
||||||
values.sec = stringToInt(chars + 6, chars + 8);
|
values.fractionalSec = str.midRef(8, 6).toInt() / 1000000.0;
|
||||||
values.fractionalSec = stringToInt(chars + 8, chars + 14) / 1000000.0;
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,15 +234,6 @@ namespace BlackMisc
|
|||||||
//! Convert string to bool
|
//! Convert string to bool
|
||||||
BLACKMISC_EXPORT bool stringToBool(const QString &boolString);
|
BLACKMISC_EXPORT bool stringToBool(const QString &boolString);
|
||||||
|
|
||||||
//! Convert string (begin and end iterators of char) to int
|
|
||||||
template <typename It>
|
|
||||||
int stringToInt(It begin, It end)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
std::for_each(begin, end, [&result](char c) { Q_ASSERT(is09(c)); result *= 10; result += (c - '0'); });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Fuzzy compare for short strings (like ICAO designators)
|
//! Fuzzy compare for short strings (like ICAO designators)
|
||||||
//! \return int 0..100 (100 is perfect match)
|
//! \return int 0..100 (100 is perfect match)
|
||||||
BLACKMISC_EXPORT int fuzzyShortStringComparision(const QString &str1, const QString &str2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
BLACKMISC_EXPORT int fuzzyShortStringComparision(const QString &str1, const QString &str2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||||
|
|||||||
Reference in New Issue
Block a user