Add qstrntod as qstrtod overload, which takes a len parameter
Add qstrntod as an overload for qstrtod, which takes a len parameter, so one can pass character arrays which are not null-terminated. Change-Id: I8c1c6c3627043c1d6ec6eb712efa3abc9e5e9e00 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
29af35f352
commit
20a2ba6d74
@ -534,11 +534,21 @@ QString &exponentForm(QChar zero, QChar decimal, QChar exponential,
|
||||
}
|
||||
|
||||
double qstrtod(const char *s00, const char **se, bool *ok)
|
||||
{
|
||||
const int len = static_cast<int>(strlen(s00));
|
||||
Q_ASSERT(len >= 0);
|
||||
return qstrntod(s00, len, se, ok);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Converts the initial portion of the string pointed to by \a s00 to a double, using the 'C' locale.
|
||||
*/
|
||||
double qstrntod(const char *s00, int len, const char **se, bool *ok)
|
||||
{
|
||||
int processed = 0;
|
||||
bool nonNullOk = false;
|
||||
int len = static_cast<int>(strlen(s00));
|
||||
Q_ASSERT(len >= 0);
|
||||
double d = asciiToDouble(s00, len, nonNullOk, processed, TrailingJunkAllowed);
|
||||
if (se)
|
||||
*se = s00 + processed;
|
||||
|
@ -115,6 +115,7 @@ inline bool isZero(double d)
|
||||
}
|
||||
|
||||
Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
|
||||
Q_CORE_EXPORT double qstrntod(const char *s00, int len, char const **se, bool *ok);
|
||||
qlonglong qstrtoll(const char *nptr, const char **endptr, int base, bool *ok);
|
||||
qulonglong qstrtoull(const char *nptr, const char **endptr, int base, bool *ok);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user