diff options
Diffstat (limited to 'src/corelib/tools/qlocale_p.h')
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 0063990125..ac12f03356 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -188,6 +188,15 @@ public: ForcePoint = Alternate }; + enum GroupSeparatorMode { + FailOnGroupSeparators, + ParseGroupSeparators + }; + + enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode }; + + typedef QVarLengthArray<char, 256> CharBuff; + static QString doubleToString(const QChar zero, const QChar plus, const QChar minus, const QChar exponent, const QChar group, const QChar decimal, @@ -218,6 +227,24 @@ public: int width = -1, unsigned flags = NoFlags) const; + double stringToDouble(const QChar *begin, int len, bool *ok, GroupSeparatorMode group_sep_mode) const; + qint64 stringToLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; + quint64 stringToUnsLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; + + // these functions are used in QIntValidator (QtGui) + Q_CORE_EXPORT static double bytearrayToDouble(const char *num, bool *ok, bool *overflow = 0); + Q_CORE_EXPORT static qint64 bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow = 0); + Q_CORE_EXPORT static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok); + + bool numberToCLocale(const QChar *str, int len, + GroupSeparatorMode group_sep_mode, + CharBuff *result) const; + inline char digitToCLocale(QChar c) const; + + // this function is used in QIntValidator (QtGui) + Q_CORE_EXPORT bool validateChars(const QString &str, NumberMode numMode, QByteArray *buff, int decDigits = -1) const; + +public: quint16 m_language_id, m_script_id, m_country_id; quint16 m_decimal, m_group, m_list, m_percent, m_zero, m_minus, m_plus, m_exponential; @@ -302,30 +329,8 @@ public: QLocale::MeasurementSystem measurementSystem() const; - enum GroupSeparatorMode { - FailOnGroupSeparators, - ParseGroupSeparators - }; - - double stringToDouble(const QChar *begin, int len, bool *ok, GroupSeparatorMode group_sep_mode) const; - qint64 stringToLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; - quint64 stringToUnsLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; - - static double bytearrayToDouble(const char *num, bool *ok, bool *overflow = 0); - static qint64 bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow = 0); - static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok); - - typedef QVarLengthArray<char, 256> CharBuff; - bool numberToCLocale(const QChar *str, int len, - GroupSeparatorMode group_sep_mode, - CharBuff *result) const; - inline char digitToCLocale(QChar c) const; - static void updateSystemPrivate(); - enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode }; - bool validateChars(const QString &str, NumberMode numMode, QByteArray *buff, int decDigits = -1) const; - QString dateTimeToString(const QString &format, const QDateTime &datetime, const QDate &dateOnly, const QTime &timeOnly, const QLocale *q) const; @@ -343,37 +348,34 @@ inline QLocalePrivate *QSharedDataPointer<QLocalePrivate>::clone() return QLocalePrivate::create(d->m_data, d->m_numberOptions); } -inline char QLocalePrivate::digitToCLocale(QChar in) const +inline char QLocaleData::digitToCLocale(QChar in) const { - const QChar _zero = zero(); - const QChar _group = group(); - const ushort zeroUnicode = _zero.unicode(); - const ushort tenUnicode = zeroUnicode + 10; + const ushort tenUnicode = m_zero + 10; - if (in.unicode() >= zeroUnicode && in.unicode() < tenUnicode) - return '0' + in.unicode() - zeroUnicode; + if (in.unicode() >= m_zero && in.unicode() < tenUnicode) + return '0' + in.unicode() - m_zero; if (in.unicode() >= '0' && in.unicode() <= '9') return in.toLatin1(); - if (in == plus() || in == QLatin1Char('+')) + if (in == m_plus || in == QLatin1Char('+')) return '+'; - if (in == minus() || in == QLatin1Char('-') || in == QChar(0x2212)) + if (in == m_minus || in == QLatin1Char('-') || in == QChar(0x2212)) return '-'; - if (in == decimal()) + if (in == m_decimal) return '.'; - if (in == group()) + if (in == m_group) return ','; - if (in == exponential() || in == exponential().toUpper()) + if (in == m_exponential || in == QChar::toUpper(m_exponential)) return 'e'; // In several languages group() is the char 0xA0, which looks like a space. // People use a regular space instead of it and complain it doesn't work. - if (_group.unicode() == 0xA0 && in.unicode() == ' ') + if (m_group == 0xA0 && in.unicode() == ' ') return ','; return 0; |