QLocalePrivate: Generalized numberToCLocale.
Modified QLocalPrivate::numberToCLocale to take a const QChar * and an integer instead of a QString. This allows for passing QStrings and QStringRefs into the same function. Updated the QLocalePrivate::stringToDouble, QLocalePrivate::stringToLongLong, and QLocalePrivate::stringToUnsLongLong to use this new function signature. Change-Id: Ifee5dfcd9b743e1d3b9123a65007c89e8ed93e83 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>bb10
parent
08f8027a0e
commit
b26c9da892
|
|
@ -2892,12 +2892,12 @@ QString QLocalePrivate::unsLongLongToString(const QChar zero, const QChar group,
|
|||
number. We can't detect junk here, since we don't even know the base
|
||||
of the number.
|
||||
*/
|
||||
bool QLocalePrivate::numberToCLocale(const QString &num,
|
||||
bool QLocalePrivate::numberToCLocale(const QChar *str, int len,
|
||||
GroupSeparatorMode group_sep_mode,
|
||||
CharBuff *result) const
|
||||
{
|
||||
const QChar *uc = num.unicode();
|
||||
int l = num.length();
|
||||
const QChar *uc = str;
|
||||
int l = len;
|
||||
int idx = 0;
|
||||
|
||||
// Skip whitespace
|
||||
|
|
@ -3043,7 +3043,13 @@ double QLocalePrivate::stringToDouble(const QString &number, bool *ok,
|
|||
GroupSeparatorMode group_sep_mode) const
|
||||
{
|
||||
CharBuff buff;
|
||||
if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
|
||||
// Do not use the ternary operator - triggers msvc2012 bug in optimized builds
|
||||
QString trimmedNumber;
|
||||
if (group().unicode() == 0xa0)
|
||||
trimmedNumber = number.trimmed();
|
||||
else
|
||||
trimmedNumber = number;
|
||||
if (!numberToCLocale(trimmedNumber.unicode(), trimmedNumber.size(),
|
||||
group_sep_mode, &buff)) {
|
||||
if (ok != 0)
|
||||
*ok = false;
|
||||
|
|
@ -3056,7 +3062,13 @@ qlonglong QLocalePrivate::stringToLongLong(const QString &number, int base,
|
|||
bool *ok, GroupSeparatorMode group_sep_mode) const
|
||||
{
|
||||
CharBuff buff;
|
||||
if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
|
||||
// Do not use the ternary operator - triggers msvc2012 bug in optimized builds
|
||||
QString trimmedNumber;
|
||||
if (group().unicode() == 0xa0)
|
||||
trimmedNumber = number.trimmed();
|
||||
else
|
||||
trimmedNumber = number;
|
||||
if (!numberToCLocale(trimmedNumber.unicode(), trimmedNumber.size(),
|
||||
group_sep_mode, &buff)) {
|
||||
if (ok != 0)
|
||||
*ok = false;
|
||||
|
|
@ -3070,7 +3082,13 @@ qulonglong QLocalePrivate::stringToUnsLongLong(const QString &number, int base,
|
|||
bool *ok, GroupSeparatorMode group_sep_mode) const
|
||||
{
|
||||
CharBuff buff;
|
||||
if (!numberToCLocale(group().unicode() == 0xa0 ? number.trimmed() : number,
|
||||
// Do not use the ternary operator - triggers msvc2012 bug in optimized builds
|
||||
QString trimmedNumber;
|
||||
if (group().unicode() == 0xa0)
|
||||
trimmedNumber = number.trimmed();
|
||||
else
|
||||
trimmedNumber = number;
|
||||
if (!numberToCLocale(trimmedNumber.unicode(), trimmedNumber.size(),
|
||||
group_sep_mode, &buff)) {
|
||||
if (ok != 0)
|
||||
*ok = false;
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ public:
|
|||
static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok);
|
||||
|
||||
typedef QVarLengthArray<char, 256> CharBuff;
|
||||
bool numberToCLocale(const QString &num,
|
||||
bool numberToCLocale(const QChar *str, int len,
|
||||
GroupSeparatorMode group_sep_mode,
|
||||
CharBuff *result) const;
|
||||
inline char digitToCLocale(QChar c) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue