diff options
Diffstat (limited to 'src/corelib/tools/qlocale_p.h')
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index f7adb021b6..7eb8b7372c 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -254,25 +254,21 @@ public: return float(d); } - double stringToDouble(const QChar *begin, int len, bool *ok, - QLocale::NumberOptions number_options) const; - qint64 stringToLongLong(const QChar *begin, int len, int base, bool *ok, - QLocale::NumberOptions number_options) const; - quint64 stringToUnsLongLong(const QChar *begin, int len, int base, bool *ok, - QLocale::NumberOptions number_options) 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, QLocale::NumberOptions number_options, + double stringToDouble(QStringView str, bool *ok, QLocale::NumberOptions options) const; + qint64 stringToLongLong(QStringView str, int base, bool *ok, QLocale::NumberOptions options) const; + quint64 stringToUnsLongLong(QStringView str, int base, bool *ok, QLocale::NumberOptions options) const; + + static double bytearrayToDouble(const char *num, bool *ok); + // this function is used in QIntValidator (QtGui) + Q_CORE_EXPORT static qint64 bytearrayToLongLong(const char *num, int base, bool *ok); + static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok); + + bool numberToCLocale(QStringView s, QLocale::NumberOptions number_options, 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, + Q_CORE_EXPORT bool validateChars(QStringView str, NumberMode numMode, QByteArray *buff, int decDigits = -1, QLocale::NumberOptions number_options = QLocale::DefaultNumberOptions) const; public: @@ -304,6 +300,9 @@ public: quint16 m_narrow_day_names_idx, m_narrow_day_names_size; quint16 m_am_idx, m_am_size; quint16 m_pm_idx, m_pm_size; + quint16 m_byte_idx, m_byte_size; + quint16 m_byte_si_quantified_idx, m_byte_si_quantified_size; + quint16 m_byte_iec_quantified_idx, m_byte_iec_quantified_size; char m_currency_iso_code[3]; quint16 m_currency_symbol_idx, m_currency_symbol_size; quint16 m_currency_display_name_idx, m_currency_display_name_size; @@ -349,23 +348,16 @@ public: QByteArray bcp47Name(char separator = '-') const; - // ### QByteArray::fromRawData would be more optimal - inline QString languageCode() const { return QLocalePrivate::languageToCode(QLocale::Language(m_data->m_language_id)); } - inline QString scriptCode() const { return QLocalePrivate::scriptToCode(QLocale::Script(m_data->m_script_id)); } - inline QString countryCode() const { return QLocalePrivate::countryToCode(QLocale::Country(m_data->m_country_id)); } - - static QString languageToCode(QLocale::Language language); - static QString scriptToCode(QLocale::Script script); - static QString countryToCode(QLocale::Country country); - static QLocale::Language codeToLanguage(const QChar *code, int len) Q_DECL_NOTHROW; - static QLocale::Language codeToLanguage(const QString &code) Q_DECL_NOTHROW { return codeToLanguage(code.data(), code.size()); } - static QLocale::Language codeToLanguage(const QStringRef &code) Q_DECL_NOTHROW { return codeToLanguage(code.data(), code.size()); } - static QLocale::Script codeToScript(const QChar *code, int len) Q_DECL_NOTHROW; - static QLocale::Script codeToScript(const QString &code) Q_DECL_NOTHROW { return codeToScript(code.data(), code.size()); } - static QLocale::Script codeToScript(const QStringRef &code) Q_DECL_NOTHROW { return codeToScript(code.data(), code.size()); } - static QLocale::Country codeToCountry(const QChar *code, int len) Q_DECL_NOTHROW; - static QLocale::Country codeToCountry(const QString &code) Q_DECL_NOTHROW { return codeToCountry(code.data(), code.size()); } - static QLocale::Country codeToCountry(const QStringRef &code) Q_DECL_NOTHROW { return codeToCountry(code.data(), code.size()); } + inline QLatin1String languageCode() const { return QLocalePrivate::languageToCode(QLocale::Language(m_data->m_language_id)); } + inline QLatin1String scriptCode() const { return QLocalePrivate::scriptToCode(QLocale::Script(m_data->m_script_id)); } + inline QLatin1String countryCode() const { return QLocalePrivate::countryToCode(QLocale::Country(m_data->m_country_id)); } + + static QLatin1String languageToCode(QLocale::Language language); + static QLatin1String scriptToCode(QLocale::Script script); + static QLatin1String countryToCode(QLocale::Country country); + static QLocale::Language codeToLanguage(QStringView code) Q_DECL_NOTHROW; + static QLocale::Script codeToScript(QStringView code) Q_DECL_NOTHROW; + static QLocale::Country codeToCountry(QStringView code) Q_DECL_NOTHROW; static void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Script &script, QLocale::Country &cntry); @@ -373,7 +365,7 @@ public: static void updateSystemPrivate(); - QString dateTimeToString(const QString &format, const QDateTime &datetime, + QString dateTimeToString(QStringView format, const QDateTime &datetime, const QDate &dateOnly, const QTime &timeOnly, const QLocale *q) const; @@ -423,9 +415,9 @@ inline char QLocaleData::digitToCLocale(QChar in) const return 0; } -QString qt_readEscapedFormatString(const QString &format, int *idx); +QString qt_readEscapedFormatString(QStringView format, int *idx); bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QString &cntry); -int qt_repeatCount(const QString &s, int i); +int qt_repeatCount(QStringView s); enum { AsciiSpaceMask = (1 << (' ' - 1)) | (1 << ('\t' - 1)) | // 9: HT - horizontal tab |