| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qlocale.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | static QSystemLocale *_systemLocale = 0; | - | ||||||||||||||||||||||||
| 12 | class QSystemLocaleSingleton: public QSystemLocale | - | ||||||||||||||||||||||||
| 13 | { | - | ||||||||||||||||||||||||
| 14 | public: | - | ||||||||||||||||||||||||
| 15 | QSystemLocaleSingleton() : QSystemLocale(true) {} | - | ||||||||||||||||||||||||
| 16 | }; | - | ||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | namespace { namespace Q_QGS_QSystemLocale_globalSystemLocale { typedef QSystemLocaleSingleton Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QSystemLocaleSingleton, Q_QGS_QSystemLocale_globalSystemLocale::innerFunction, Q_QGS_QSystemLocale_globalSystemLocale::guard> QSystemLocale_globalSystemLocale; | - | ||||||||||||||||||||||||
| 19 | static QLocaleData *system_data = 0; | - | ||||||||||||||||||||||||
| namespace { namespace Q_QGS_globalLocaleData { typedef QLocaleData Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } }static QGlobalStatic<QLocaleData , Q_QGS_globalLocaleData::innerFunction, Q_QGS_globalLocaleData::guard>globalLocaleData; | ||||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | QLocale::Language QLocalePrivate::codeToLanguage(const QString &code) | - | ||||||||||||||||||||||||
| {QChar *code, int len= code.length();) noexcept | ||||||||||||||||||||||||||
| 31 | { | - | ||||||||||||||||||||||||
| 32 | if (len != 2
| 0-2372 | ||||||||||||||||||||||||
| 33 | return never executed: QLocale::C;return QLocale::C;never executed: return QLocale::C; | 0 | ||||||||||||||||||||||||
| 34 | ushort uc1 = code[0].toLower().unicode(); | - | ||||||||||||||||||||||||
| 35 | ushort uc2 = code[1].toLower().unicode(); | - | ||||||||||||||||||||||||
| 36 | ushort uc3 = len > 2
| 0-2372 | ||||||||||||||||||||||||
| 37 | - | |||||||||||||||||||||||||
| 38 | const unsigned char *c = language_code_list; | - | ||||||||||||||||||||||||
| 39 | for (; *
| 7-80935 | ||||||||||||||||||||||||
| 40 | if (uc1 == c[0]
| 14-75733 | ||||||||||||||||||||||||
| 41 | return executed 2365 times by 25 tests: QLocale::Language((c - language_code_list)/3);return QLocale::Language((c - language_code_list)/3);Executed by:
executed 2365 times by 25 tests: return QLocale::Language((c - language_code_list)/3);Executed by:
| 2365 | ||||||||||||||||||||||||
| 42 | } executed 78570 times by 25 tests: end of blockExecuted by:
| 78570 | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | if (uc1 == 'n'
| 0-7 | ||||||||||||||||||||||||
| 46 | static_assert(bool(QLocale::Norwegian == QLocale::NorwegianBokmal), "QLocale::Norwegian == QLocale::NorwegianBokmal"); | - | ||||||||||||||||||||||||
| 47 | return executed 7 times by 2 tests: QLocale::Norwegian;return QLocale::Norwegian;Executed by:
executed 7 times by 2 tests: return QLocale::Norwegian;Executed by:
| 7 | ||||||||||||||||||||||||
| 48 | } | - | ||||||||||||||||||||||||
| 49 | if (uc1 == 't'
| 0 | ||||||||||||||||||||||||
| 50 | static_assert(bool(QLocale::Tagalog == QLocale::Filipino), "QLocale::Tagalog == QLocale::Filipino"); | - | ||||||||||||||||||||||||
| 51 | return never executed: QLocale::Tagalog;return QLocale::Tagalog;never executed: return QLocale::Tagalog; | 0 | ||||||||||||||||||||||||
| 52 | } | - | ||||||||||||||||||||||||
| 53 | if (uc1 == 's'
| 0 | ||||||||||||||||||||||||
| 54 | static_assert(bool(QLocale::SerboCroatian == QLocale::Serbian), "QLocale::SerboCroatian == QLocale::Serbian"); | - | ||||||||||||||||||||||||
| 55 | return never executed: QLocale::SerboCroatian;return QLocale::SerboCroatian;never executed: return QLocale::SerboCroatian; | 0 | ||||||||||||||||||||||||
| 56 | } | - | ||||||||||||||||||||||||
| 57 | if (uc1 == 'm'
| 0 | ||||||||||||||||||||||||
| 58 | static_assert(bool(QLocale::Moldavian == QLocale::Romanian), "QLocale::Moldavian == QLocale::Romanian"); | - | ||||||||||||||||||||||||
| 59 | return never executed: QLocale::Moldavian;return QLocale::Moldavian;never executed: return QLocale::Moldavian; | 0 | ||||||||||||||||||||||||
| 60 | } | - | ||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | if (uc1 == 'i'
| 0 | ||||||||||||||||||||||||
| 63 | return never executed: QLocale::Hebrew;return QLocale::Hebrew;never executed: return QLocale::Hebrew; | 0 | ||||||||||||||||||||||||
| 64 | if (uc1 == 'i'
| 0 | ||||||||||||||||||||||||
| 65 | return never executed: QLocale::Indonesian;return QLocale::Indonesian;never executed: return QLocale::Indonesian; | 0 | ||||||||||||||||||||||||
| 66 | if (uc1 == 'j'
| 0 | ||||||||||||||||||||||||
| 67 | return never executed: QLocale::Yiddish;return QLocale::Yiddish;never executed: return QLocale::Yiddish; | 0 | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | return never executed: QLocale::C;return QLocale::C;never executed: return QLocale::C; | 0 | ||||||||||||||||||||||||
| 70 | } | - | ||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | QLocale::Script QLocalePrivate::codeToScript(const QString &code) | - | ||||||||||||||||||||||||
| {QChar *code, int len= code.length();) noexcept | ||||||||||||||||||||||||||
| 73 | { | - | ||||||||||||||||||||||||
| 74 | if (len != 4
| 0-2372 | ||||||||||||||||||||||||
| 75 | return executed 2372 times by 25 tests: QLocale::AnyScript;return QLocale::AnyScript;Executed by:
executed 2372 times by 25 tests: return QLocale::AnyScript;Executed by:
| 2372 | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | unsigned char c0 = code.at([0).].toUpper().toLatin1(); | - | ||||||||||||||||||||||||
| 79 | unsigned char c1 = code.at([1).].toLower().toLatin1(); | - | ||||||||||||||||||||||||
| 80 | unsigned char c2 = code.at([2).].toLower().toLatin1(); | - | ||||||||||||||||||||||||
| 81 | unsigned char c3 = code.at([3).].toLower().toLatin1(); | - | ||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | const unsigned char *c = script_code_list; | - | ||||||||||||||||||||||||
| 84 | for (int i = 0; i < QLocale::LastScript
| 0 | ||||||||||||||||||||||||
| 85 | if (c0 == c[0]
| 0 | ||||||||||||||||||||||||
| 86 | return never executed: QLocale::Script(i);return QLocale::Script(i);never executed: return QLocale::Script(i); | 0 | ||||||||||||||||||||||||
| 87 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 88 | return never executed: QLocale::AnyScript;return QLocale::AnyScript;never executed: return QLocale::AnyScript; | 0 | ||||||||||||||||||||||||
| 89 | } | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | QLocale::Country QLocalePrivate::codeToCountry(const QString &code) | - | ||||||||||||||||||||||||
| {QChar *code, int len= code.length();) noexcept | ||||||||||||||||||||||||||
| 92 | { | - | ||||||||||||||||||||||||
| 93 | if (len != 2
| 0-2717 | ||||||||||||||||||||||||
| 94 | return executed 76 times by 6 tests: QLocale::AnyCountry;return QLocale::AnyCountry;Executed by:
executed 76 times by 6 tests: return QLocale::AnyCountry;Executed by:
| 76 | ||||||||||||||||||||||||
| 95 | ushort uc1 = code[0].toUpper().unicode(); | - | ||||||||||||||||||||||||
| 96 | ushort uc2 = code[1].toUpper().unicode(); | - | ||||||||||||||||||||||||
| 97 | ushort uc3 = len > 2
| 0-2717 | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | const unsigned char *c = country_code_list; | - | ||||||||||||||||||||||||
| 100 | for (; *
| 0-550758 | ||||||||||||||||||||||||
| 101 | if (uc1 == c[0]
| 0-540225 | ||||||||||||||||||||||||
| 102 | return executed 2716 times by 22 tests: QLocale::Country((c - country_code_list)/3);return QLocale::Country((c - country_code_list)/3);Executed by:
executed 2716 times by 22 tests: return QLocale::Country((c - country_code_list)/3);Executed by:
| 2716 | ||||||||||||||||||||||||
| 103 | } executed 548042 times by 22 tests: end of blockExecuted by:
| 548042 | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | return never executed: QLocale::AnyCountry;return QLocale::AnyCountry;never executed: return QLocale::AnyCountry; | 0 | ||||||||||||||||||||||||
| 106 | } | - | ||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | QString QLocalePrivate::languageToCode(QLocale::Language language) | - | ||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||
| 110 | if (language == QLocale::AnyLanguage) | - | ||||||||||||||||||||||||
| 111 | return QString(); | - | ||||||||||||||||||||||||
| 112 | if (language == QLocale::C) | - | ||||||||||||||||||||||||
| 113 | return QLatin1String("C"); | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | const unsigned char *c = language_code_list + 3*(uint(language)); | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | code[0] = ushort(c[0]); | - | ||||||||||||||||||||||||
| 120 | code[1] = ushort(c[1]); | - | ||||||||||||||||||||||||
| 121 | if (c[2] != 0) | - | ||||||||||||||||||||||||
| 122 | code[2] = ushort(c[2]); | - | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | return code; | - | ||||||||||||||||||||||||
| 125 | } | - | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | QString QLocalePrivate::scriptToCode(QLocale::Script script) | - | ||||||||||||||||||||||||
| 128 | { | - | ||||||||||||||||||||||||
| 129 | if (script == QLocale::AnyScript || script > QLocale::LastScript) | - | ||||||||||||||||||||||||
| 130 | return QString(); | - | ||||||||||||||||||||||||
| 131 | const unsigned char *c = script_code_list + 4*(uint(script)); | - | ||||||||||||||||||||||||
| 132 | return QString::fromLatin1((const char *)c, 4); | - | ||||||||||||||||||||||||
| 133 | } | - | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | QString QLocalePrivate::countryToCode(QLocale::Country country) | - | ||||||||||||||||||||||||
| 136 | { | - | ||||||||||||||||||||||||
| 137 | if (country == QLocale::AnyCountry) | - | ||||||||||||||||||||||||
| 138 | return QString(); | - | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | const unsigned char *c = country_code_list + 3*(uint(country)); | - | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | code[0] = ushort(c[0]); | - | ||||||||||||||||||||||||
| 145 | code[1] = ushort(c[1]); | - | ||||||||||||||||||||||||
| 146 | if (c[2] != 0) | - | ||||||||||||||||||||||||
| 147 | code[2] = ushort(c[2]); | - | ||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | return code; | - | ||||||||||||||||||||||||
| 150 | } | - | ||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | static bool addLikelySubtags(QLocaleId &localeId) | - | ||||||||||||||||||||||||
| 154 | { | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | const int likely_subtags_count = sizeof(likely_subtags) / sizeof(likely_subtags[0]); | - | ||||||||||||||||||||||||
| 157 | const QLocaleId *p = likely_subtags; | - | ||||||||||||||||||||||||
| 158 | const QLocaleId *const e = p + likely_subtags_count; | - | ||||||||||||||||||||||||
| 159 | for ( ; p < e; p += 2) { | - | ||||||||||||||||||||||||
| 160 | if (localeId == p[0]) { | - | ||||||||||||||||||||||||
| 161 | localeId = p[1]; | - | ||||||||||||||||||||||||
| 162 | return true; | - | ||||||||||||||||||||||||
| 163 | } | - | ||||||||||||||||||||||||
| 164 | } | - | ||||||||||||||||||||||||
| 165 | return false; | - | ||||||||||||||||||||||||
| 166 | } | - | ||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | QLocaleId QLocaleId::withLikelySubtagsAdded() const | - | ||||||||||||||||||||||||
| 169 | { | - | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | if (language_id || script_id || country_id) { | - | ||||||||||||||||||||||||
| 172 | QLocaleId id = QLocaleId::fromIds(language_id, script_id, country_id); | - | ||||||||||||||||||||||||
| 173 | if (addLikelySubtags(id)) | - | ||||||||||||||||||||||||
| 174 | return id; | - | ||||||||||||||||||||||||
| 175 | } | - | ||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||
| 177 | if (country_id) { | - | ||||||||||||||||||||||||
| 178 | QLocaleId id = QLocaleId::fromIds(language_id, script_id, 0); | - | ||||||||||||||||||||||||
| 179 | if (addLikelySubtags(id)) { | - | ||||||||||||||||||||||||
| 180 | id.country_id = country_id; | - | ||||||||||||||||||||||||
| 181 | return id; | - | ||||||||||||||||||||||||
| 182 | } | - | ||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | if (script_id) { | - | ||||||||||||||||||||||||
| 186 | QLocaleId id = QLocaleId::fromIds(language_id, 0, country_id); | - | ||||||||||||||||||||||||
| 187 | if (addLikelySubtags(id)) { | - | ||||||||||||||||||||||||
| 188 | id.script_id = script_id; | - | ||||||||||||||||||||||||
| 189 | return id; | - | ||||||||||||||||||||||||
| 190 | } | - | ||||||||||||||||||||||||
| 191 | } | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | if (script_id && country_id) { | - | ||||||||||||||||||||||||
| 194 | QLocaleId id = QLocaleId::fromIds(language_id, 0, 0); | - | ||||||||||||||||||||||||
| 195 | if (addLikelySubtags(id)) { | - | ||||||||||||||||||||||||
| 196 | id.script_id = script_id; | - | ||||||||||||||||||||||||
| 197 | id.country_id = country_id; | - | ||||||||||||||||||||||||
| 198 | return id; | - | ||||||||||||||||||||||||
| 199 | } | - | ||||||||||||||||||||||||
| 200 | } | - | ||||||||||||||||||||||||
| 201 | return *this; | - | ||||||||||||||||||||||||
| 202 | } | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | QLocaleId QLocaleId::withLikelySubtagsRemoved() const | - | ||||||||||||||||||||||||
| 205 | { | - | ||||||||||||||||||||||||
| 206 | QLocaleId max = withLikelySubtagsAdded(); | - | ||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||
| 208 | { | - | ||||||||||||||||||||||||
| 209 | QLocaleId id = QLocaleId::fromIds(language_id, 0, 0); | - | ||||||||||||||||||||||||
| 210 | if (id.withLikelySubtagsAdded() == max) | - | ||||||||||||||||||||||||
| 211 | return id; | - | ||||||||||||||||||||||||
| 212 | } | - | ||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | if (country_id) { | - | ||||||||||||||||||||||||
| 215 | QLocaleId id = QLocaleId::fromIds(language_id, 0, country_id); | - | ||||||||||||||||||||||||
| 216 | if (id.withLikelySubtagsAdded() == max) | - | ||||||||||||||||||||||||
| 217 | return id; | - | ||||||||||||||||||||||||
| 218 | } | - | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | if (script_id) { | - | ||||||||||||||||||||||||
| 221 | QLocaleId id = QLocaleId::fromIds(language_id, script_id, 0); | - | ||||||||||||||||||||||||
| 222 | if (id.withLikelySubtagsAdded() == max) | - | ||||||||||||||||||||||||
| 223 | return id; | - | ||||||||||||||||||||||||
| 224 | } | - | ||||||||||||||||||||||||
| 225 | return max; | - | ||||||||||||||||||||||||
| 226 | } | - | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | QByteArray QLocaleId::name(char separator) const | - | ||||||||||||||||||||||||
| 229 | { | - | ||||||||||||||||||||||||
| 230 | if (language_id == QLocale::AnyLanguage) | - | ||||||||||||||||||||||||
| 231 | return QByteArray(); | - | ||||||||||||||||||||||||
| 232 | if (language_id == QLocale::C) | - | ||||||||||||||||||||||||
| 233 | return ([]() -> QByteArray { enum { Size = sizeof("C") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "C" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | - | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | const unsigned char *lang = language_code_list + 3 * language_id; | - | ||||||||||||||||||||||||
| 236 | const unsigned char *script = | - | ||||||||||||||||||||||||
| 237 | (script_id != QLocale::AnyScript ? script_code_list + 4 * script_id : 0); | - | ||||||||||||||||||||||||
| 238 | const unsigned char *country = | - | ||||||||||||||||||||||||
| 239 | (country_id != QLocale::AnyCountry ? country_code_list + 3 * country_id : 0); | - | ||||||||||||||||||||||||
| 240 | char len = (lang[2] != 0 ? 3 : 2) + (script ? 4+1 : 0) + (country ? (country[2] != 0 ? 3 : 2)+1 : 0); | - | ||||||||||||||||||||||||
| 241 | QByteArray name(len, Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 242 | char *uc = name.data(); | - | ||||||||||||||||||||||||
| 243 | *uc++ = lang[0]; | - | ||||||||||||||||||||||||
| 244 | *uc++ = lang[1]; | - | ||||||||||||||||||||||||
| 245 | if (lang[2] != 0) | - | ||||||||||||||||||||||||
| 246 | *uc++ = lang[2]; | - | ||||||||||||||||||||||||
| 247 | if (script) { | - | ||||||||||||||||||||||||
| 248 | *uc++ = separator; | - | ||||||||||||||||||||||||
| 249 | *uc++ = script[0]; | - | ||||||||||||||||||||||||
| 250 | *uc++ = script[1]; | - | ||||||||||||||||||||||||
| 251 | *uc++ = script[2]; | - | ||||||||||||||||||||||||
| 252 | *uc++ = script[3]; | - | ||||||||||||||||||||||||
| 253 | } | - | ||||||||||||||||||||||||
| 254 | if (country) { | - | ||||||||||||||||||||||||
| 255 | *uc++ = separator; | - | ||||||||||||||||||||||||
| 256 | *uc++ = country[0]; | - | ||||||||||||||||||||||||
| 257 | *uc++ = country[1]; | - | ||||||||||||||||||||||||
| 258 | if (country[2] != 0) | - | ||||||||||||||||||||||||
| 259 | *uc++ = country[2]; | - | ||||||||||||||||||||||||
| 260 | } | - | ||||||||||||||||||||||||
| 261 | return name; | - | ||||||||||||||||||||||||
| 262 | } | - | ||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | QByteArray QLocalePrivate::bcp47Name(char separator) const | - | ||||||||||||||||||||||||
| 265 | { | - | ||||||||||||||||||||||||
| 266 | if (m_data->m_language_id == QLocale::AnyLanguage) | - | ||||||||||||||||||||||||
| 267 | return QByteArray(); | - | ||||||||||||||||||||||||
| 268 | if (m_data->m_language_id == QLocale::C) | - | ||||||||||||||||||||||||
| 269 | return ([]() -> QByteArray { enum { Size = sizeof("C") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "C" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()); | - | ||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | QLocaleId localeId = QLocaleId::fromIds(m_data->m_language_id, m_data->m_script_id, m_data->m_country_id); | - | ||||||||||||||||||||||||
| 272 | return localeId.withLikelySubtagsRemoved().name(separator); | - | ||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country) | - | ||||||||||||||||||||||||
| 276 | { | - | ||||||||||||||||||||||||
| 277 | QLocaleId localeId = QLocaleId::fromIds(language, script, country); | - | ||||||||||||||||||||||||
| 278 | localeId = localeId.withLikelySubtagsAdded(); | - | ||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | uint idx = locale_index[localeId.language_id]; | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | const QLocaleData *data = locale_data + idx; | - | ||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | if (idx == 0) | - | ||||||||||||||||||||||||
| 285 | return data; | - | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | ((!(data->m_language_id == localeId.language_id)) ? qt_assert("data->m_language_id == localeId.language_id",__FILE__,347350) : qt_noop()); | - | ||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | if (localeId.script_id != QLocale::AnyScript && localeId.country_id != QLocale::AnyCountry) { | - | ||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | do { | - | ||||||||||||||||||||||||
| 292 | if (data->m_script_id == localeId.script_id && data->m_country_id == localeId.country_id) | - | ||||||||||||||||||||||||
| 293 | return data; | - | ||||||||||||||||||||||||
| 294 | ++data; | - | ||||||||||||||||||||||||
| 295 | } while (data->m_language_id == localeId.language_id); | - | ||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | localeId.script_id = QLocale::AnyScript; | - | ||||||||||||||||||||||||
| 299 | data = locale_data + idx; | - | ||||||||||||||||||||||||
| 300 | } | - | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | if (localeId.script_id == QLocale::AnyScript && localeId.country_id == QLocale::AnyCountry) | - | ||||||||||||||||||||||||
| 303 | return data; | - | ||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | if (localeId.script_id == QLocale::AnyScript) { | - | ||||||||||||||||||||||||
| 306 | do { | - | ||||||||||||||||||||||||
| 307 | if (data->m_country_id == localeId.country_id) | - | ||||||||||||||||||||||||
| 308 | return data; | - | ||||||||||||||||||||||||
| 309 | ++data; | - | ||||||||||||||||||||||||
| 310 | } while (data->m_language_id == localeId.language_id); | - | ||||||||||||||||||||||||
| 311 | } else if (localeId.country_id == QLocale::AnyCountry) { | - | ||||||||||||||||||||||||
| 312 | do { | - | ||||||||||||||||||||||||
| 313 | if (data->m_script_id == localeId.script_id) | - | ||||||||||||||||||||||||
| 314 | return data; | - | ||||||||||||||||||||||||
| 315 | ++data; | - | ||||||||||||||||||||||||
| 316 | } while (data->m_language_id == localeId.language_id); | - | ||||||||||||||||||||||||
| 317 | } | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | return locale_data + idx; | - | ||||||||||||||||||||||||
| 320 | } | - | ||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | static bool parse_locale_tag(const QString &input, int &i, QString *result, const QString &separators) | - | ||||||||||||||||||||||||
| 323 | { | - | ||||||||||||||||||||||||
| 324 | *result = QString(8, Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 325 | QChar *pch = result->data(); | - | ||||||||||||||||||||||||
| 326 | const QChar *uc = input.data() + i; | - | ||||||||||||||||||||||||
| 327 | const int l = input.length(); | - | ||||||||||||||||||||||||
| 328 | int size = 0; | - | ||||||||||||||||||||||||
| 329 | for (; i < l && size < 8; ++i, ++size) { | - | ||||||||||||||||||||||||
| 330 | if (separators.contains(*uc)) | - | ||||||||||||||||||||||||
| 331 | break; | - | ||||||||||||||||||||||||
| 332 | if (! ((uc->unicode() >= 'a' && uc->unicode() <= 'z') || | - | ||||||||||||||||||||||||
| 333 | (uc->unicode() >= 'A' && uc->unicode() <= 'Z') || | - | ||||||||||||||||||||||||
| 334 | (uc->unicode() >= '0' && uc->unicode() <= '9')) ) | - | ||||||||||||||||||||||||
| 335 | return false; | - | ||||||||||||||||||||||||
| 336 | *pch++ = *uc++; | - | ||||||||||||||||||||||||
| 337 | } | - | ||||||||||||||||||||||||
| 338 | result->truncate(size); | - | ||||||||||||||||||||||||
| 339 | return true; | - | ||||||||||||||||||||||||
| 340 | } | - | ||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QString &cntry) | - | ||||||||||||||||||||||||
| 343 | { | - | ||||||||||||||||||||||||
| 344 | const int length = name.length(); | - | ||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||
| 346 | lang = script = cntry = QString(); | - | ||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | const QString separators = ([]() -> QString { enum { Size = sizeof(u"" "_-.@")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "_-.@" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | - | ||||||||||||||||||||||||
| 349 | enum ParserState { NoState, LangState, ScriptState, CountryState }; | - | ||||||||||||||||||||||||
| 350 | ParserState state = LangState; | - | ||||||||||||||||||||||||
| 351 | for (int i = 0; i < length && state != NoState; ) { | - | ||||||||||||||||||||||||
| 352 | QString value; | - | ||||||||||||||||||||||||
| 353 | if (!parse_locale_tag(name, i, &value, separators) ||value.isEmpty()) | - | ||||||||||||||||||||||||
| 354 | break; | - | ||||||||||||||||||||||||
| 355 | QChar sep = i < length ? name.at(i) : QChar(); | - | ||||||||||||||||||||||||
| 356 | switch (state) { | - | ||||||||||||||||||||||||
| 357 | case LangState: | - | ||||||||||||||||||||||||
| 358 | if (!sep.isNull() && !separators.contains(sep)) { | - | ||||||||||||||||||||||||
| 359 | state = NoState; | - | ||||||||||||||||||||||||
| 360 | break; | - | ||||||||||||||||||||||||
| 361 | } | - | ||||||||||||||||||||||||
| 362 | lang = value; | - | ||||||||||||||||||||||||
| 363 | if (i == length) { | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | state = NoState; | - | ||||||||||||||||||||||||
| 366 | break; | - | ||||||||||||||||||||||||
| 367 | } | - | ||||||||||||||||||||||||
| 368 | state = ScriptState; | - | ||||||||||||||||||||||||
| 369 | break; | - | ||||||||||||||||||||||||
| 370 | case ScriptState: { | - | ||||||||||||||||||||||||
| 371 | QString scripts = QString::fromLatin1((const char *)script_code_list, sizeof(script_code_list) - 1); | - | ||||||||||||||||||||||||
| 372 | if (value.length() == 4 && scripts.indexOf(value) % 4 == 0) { | - | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | script = value; | - | ||||||||||||||||||||||||
| 375 | state = CountryState; | - | ||||||||||||||||||||||||
| 376 | } else { | - | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | cntry = value; | - | ||||||||||||||||||||||||
| 379 | state = NoState; | - | ||||||||||||||||||||||||
| 380 | } | - | ||||||||||||||||||||||||
| 381 | break; | - | ||||||||||||||||||||||||
| 382 | } | - | ||||||||||||||||||||||||
| 383 | case CountryState: | - | ||||||||||||||||||||||||
| 384 | cntry = value; | - | ||||||||||||||||||||||||
| 385 | state = NoState; | - | ||||||||||||||||||||||||
| 386 | break; | - | ||||||||||||||||||||||||
| 387 | case NoState: | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | QMessageLogger(__FILE__, 449452, __PRETTY_FUNCTION__).warning("QLocale: This should never happen"); | - | ||||||||||||||||||||||||
| 390 | break; | - | ||||||||||||||||||||||||
| 391 | } | - | ||||||||||||||||||||||||
| 392 | ++i; | - | ||||||||||||||||||||||||
| 393 | } | - | ||||||||||||||||||||||||
| 394 | return lang.length() == 2 || lang.length() == 3; | - | ||||||||||||||||||||||||
| 395 | } | - | ||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||
| 397 | void QLocalePrivate::getLangAndCountry(const QString &name, QLocale::Language &lang, | - | ||||||||||||||||||||||||
| 398 | QLocale::Script &script, QLocale::Country &cntry) | - | ||||||||||||||||||||||||
| 399 | { | - | ||||||||||||||||||||||||
| 400 | lang = QLocale::C; | - | ||||||||||||||||||||||||
| 401 | script = QLocale::AnyScript; | - | ||||||||||||||||||||||||
| 402 | cntry = QLocale::AnyCountry; | - | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | QString lang_code; | - | ||||||||||||||||||||||||
| 405 | QString script_code; | - | ||||||||||||||||||||||||
| 406 | QString cntry_code; | - | ||||||||||||||||||||||||
| 407 | if (!qt_splitLocaleName(name, lang_code, script_code, cntry_code)) | - | ||||||||||||||||||||||||
| 408 | return; | - | ||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | lang = QLocalePrivate::codeToLanguage(lang_code); | - | ||||||||||||||||||||||||
| 411 | if (lang == QLocale::C) | - | ||||||||||||||||||||||||
| 412 | return; | - | ||||||||||||||||||||||||
| 413 | script = QLocalePrivate::codeToScript(script_code); | - | ||||||||||||||||||||||||
| 414 | cntry = QLocalePrivate::codeToCountry(cntry_code); | - | ||||||||||||||||||||||||
| 415 | } | - | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | static const QLocaleData *findLocaleData(const QString &name) | - | ||||||||||||||||||||||||
| 418 | { | - | ||||||||||||||||||||||||
| 419 | QLocale::Language lang; | - | ||||||||||||||||||||||||
| 420 | QLocale::Script script; | - | ||||||||||||||||||||||||
| 421 | QLocale::Country cntry; | - | ||||||||||||||||||||||||
| 422 | QLocalePrivate::getLangAndCountry(name, lang, script, cntry); | - | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | return QLocaleData::findLocaleData(lang, script, cntry); | - | ||||||||||||||||||||||||
| 425 | } | - | ||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | QString qt_readEscapedFormatString(const QString &format, int *idx) | - | ||||||||||||||||||||||||
| 428 | { | - | ||||||||||||||||||||||||
| 429 | int &i = *idx; | - | ||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||
| 431 | ((!(format.at(i) == QLatin1Char('\''))) ? qt_assert("format.at(i) == QLatin1Char('\\'')",__FILE__,491494) : qt_noop()); | - | ||||||||||||||||||||||||
| 432 | ++i; | - | ||||||||||||||||||||||||
| 433 | if (i == format.size()) | - | ||||||||||||||||||||||||
| 434 | return QString(); | - | ||||||||||||||||||||||||
| 435 | if (format.at(i).unicode() == '\'') { | - | ||||||||||||||||||||||||
| 436 | ++i; | - | ||||||||||||||||||||||||
| 437 | return QLatin1String("'"); | - | ||||||||||||||||||||||||
| 438 | } | - | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | QString result; | - | ||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | while (i < format.size()) { | - | ||||||||||||||||||||||||
| 443 | if (format.at(i).unicode() == '\'') { | - | ||||||||||||||||||||||||
| 444 | if (i + 1 < format.size() && format.at(i + 1).unicode() == '\'') { | - | ||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | result.append(QLatin1Char('\'')); | - | ||||||||||||||||||||||||
| 447 | i += 2; | - | ||||||||||||||||||||||||
| 448 | } else { | - | ||||||||||||||||||||||||
| 449 | break; | - | ||||||||||||||||||||||||
| 450 | } | - | ||||||||||||||||||||||||
| 451 | } else { | - | ||||||||||||||||||||||||
| 452 | result.append(format.at(i++)); | - | ||||||||||||||||||||||||
| 453 | } | - | ||||||||||||||||||||||||
| 454 | } | - | ||||||||||||||||||||||||
| 455 | if (i < format.size()) | - | ||||||||||||||||||||||||
| 456 | ++i; | - | ||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | return result; | - | ||||||||||||||||||||||||
| 459 | } | - | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | int qt_repeatCount(const QString &s, int i) | - | ||||||||||||||||||||||||
| 462 | { | - | ||||||||||||||||||||||||
| 463 | QChar c = s.at(i); | - | ||||||||||||||||||||||||
| 464 | int j = i + 1; | - | ||||||||||||||||||||||||
| 465 | while (j < s.size() && s.at(j) == c) | - | ||||||||||||||||||||||||
| 466 | ++j; | - | ||||||||||||||||||||||||
| 467 | return j - i; | - | ||||||||||||||||||||||||
| 468 | } | - | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | static const QLocaleData *default_data = 0; | - | ||||||||||||||||||||||||
| 471 | static uintQLocale::NumberOptions default_number_options = 0QLocale::DefaultNumberOptions; | - | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | static const QLocaleData *const c_data = locale_data; | - | ||||||||||||||||||||||||
| 474 | static QLocalePrivate *c_private() | - | ||||||||||||||||||||||||
| 475 | { | - | ||||||||||||||||||||||||
| 476 | static QLocalePrivate c_locale = { c_data, { 1 }, QLocale::OmitGroupSeparator }; | - | ||||||||||||||||||||||||
| 477 | return &c_locale; | - | ||||||||||||||||||||||||
| 478 | } | - | ||||||||||||||||||||||||
| 479 | QSystemLocale::QSystemLocale() | - | ||||||||||||||||||||||||
| 480 | { | - | ||||||||||||||||||||||||
| 481 | delete _systemLocale; | - | ||||||||||||||||||||||||
| 482 | _systemLocale = this; | - | ||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | if (system_data) | - | ||||||||||||||||||||||||
| 485 | system_data->m_language_id = 0; | - | ||||||||||||||||||||||||
| 486 | } | - | ||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||
| 491 | QSystemLocale::QSystemLocale(bool) | - | ||||||||||||||||||||||||
| 492 | { } | - | ||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||
| 497 | QSystemLocale::~QSystemLocale() | - | ||||||||||||||||||||||||
| 498 | { | - | ||||||||||||||||||||||||
| 499 | if (_systemLocale == this) { | - | ||||||||||||||||||||||||
| 500 | _systemLocale = 0; | - | ||||||||||||||||||||||||
| 501 | - | |||||||||||||||||||||||||
| 502 | if (system_data) | - | ||||||||||||||||||||||||
| 503 | system_data->m_language_id = 0; | - | ||||||||||||||||||||||||
| 504 | } | - | ||||||||||||||||||||||||
| 505 | } | - | ||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||
| 507 | static const QSystemLocale *systemLocale() | - | ||||||||||||||||||||||||
| 508 | { | - | ||||||||||||||||||||||||
| 509 | if (_systemLocale) | - | ||||||||||||||||||||||||
| 510 | return _systemLocale; | - | ||||||||||||||||||||||||
| 511 | return QSystemLocale_globalSystemLocale(); | - | ||||||||||||||||||||||||
| 512 | } | - | ||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | void QLocalePrivate::updateSystemPrivate() | - | ||||||||||||||||||||||||
| 515 | { | - | ||||||||||||||||||||||||
| 516 | const QSystemLocale *sys_locale = systemLocale(); | - | ||||||||||||||||||||||||
| 517 | if (!system_data
| 0-1016 | ||||||||||||||||||||||||
| 518 | system_data = globalLocaleData();&globalLocaleData; executed 1016 times by 12 tests: system_data = &globalLocaleData;Executed by:
| 1016 | ||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||
| 521 | sys_locale->query(QSystemLocale::LocaleChanged, QVariant()); | - | ||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | *system_data = *sys_locale->fallbackUiLocale().d->m_data; | - | ||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||
| 525 | QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant()); | - | ||||||||||||||||||||||||
| 526 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 527 | system_data->m_language_id = res.toInt(); | - | ||||||||||||||||||||||||
| 528 | system_data->m_script_id = QLocale::AnyScript; | - | ||||||||||||||||||||||||
| 529 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 530 | res = sys_locale->query(QSystemLocale::CountryId, QVariant()); | - | ||||||||||||||||||||||||
| 531 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 532 | system_data->m_country_id = res.toInt(); | - | ||||||||||||||||||||||||
| 533 | system_data->m_script_id = QLocale::AnyScript; | - | ||||||||||||||||||||||||
| 534 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 535 | res = sys_locale->query(QSystemLocale::ScriptId, QVariant()); | - | ||||||||||||||||||||||||
| 536 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 537 | system_data->m_script_id = res.toInt(); never executed: system_data->m_script_id = res.toInt(); | 0 | ||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||
| 539 | res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant()); | - | ||||||||||||||||||||||||
| 540 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 541 | system_data->m_decimal = res.toString().at(0).unicode(); executed 1015 times by 12 tests: system_data->m_decimal = res.toString().at(0).unicode();Executed by:
| 1015 | ||||||||||||||||||||||||
| 542 | - | |||||||||||||||||||||||||
| 543 | res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant()); | - | ||||||||||||||||||||||||
| 544 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 545 | system_data->m_group = res.toString().at(0).unicode(); executed 1015 times by 12 tests: system_data->m_group = res.toString().at(0).unicode();Executed by:
| 1015 | ||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||
| 547 | res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant()); | - | ||||||||||||||||||||||||
| 548 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 549 | system_data->m_zero = res.toString().at(0).unicode(); executed 1015 times by 12 tests: system_data->m_zero = res.toString().at(0).unicode();Executed by:
| 1015 | ||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||
| 551 | res = sys_locale->query(QSystemLocale::NegativeSign, QVariant()); | - | ||||||||||||||||||||||||
| 552 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 553 | system_data->m_minus = res.toString().at(0).unicode(); executed 1015 times by 12 tests: system_data->m_minus = res.toString().at(0).unicode();Executed by:
| 1015 | ||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | res = sys_locale->query(QSystemLocale::PositiveSign, QVariant()); | - | ||||||||||||||||||||||||
| 556 | if (!res.isNull()
| 0-1015 | ||||||||||||||||||||||||
| 557 | system_data->m_plus = res.toString().at(0).unicode(); executed 1015 times by 12 tests: system_data->m_plus = res.toString().at(0).unicode();Executed by:
| 1015 | ||||||||||||||||||||||||
| 558 | } executed 1015 times by 12 tests: end of blockExecuted by:
| 1015 | ||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||
| 561 | static const QLocaleData *systemData() | - | ||||||||||||||||||||||||
| 562 | { | - | ||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||
| 565 | if (!system_data || system_data->m_language_id == 0) | - | ||||||||||||||||||||||||
| 566 | QLocalePrivate::updateSystemPrivate(); | - | ||||||||||||||||||||||||
| 567 | - | |||||||||||||||||||||||||
| 568 | return system_data; | - | ||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||
| 572 | } | - | ||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||
| 574 | static const QLocaleData *defaultData() | - | ||||||||||||||||||||||||
| 575 | { | - | ||||||||||||||||||||||||
| 576 | if (!default_data) | - | ||||||||||||||||||||||||
| 577 | default_data = systemData(); | - | ||||||||||||||||||||||||
| 578 | return default_data; | - | ||||||||||||||||||||||||
| 579 | } | - | ||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | const QLocaleData *QLocaleData::c() | - | ||||||||||||||||||||||||
| 582 | { | - | ||||||||||||||||||||||||
| 583 | ((!(locale_index[QLocale::C] == 0)) ? qt_assert("locale_index[QLocale::C] == 0",__FILE__,656659) : qt_noop()); | - | ||||||||||||||||||||||||
| 584 | return c_data; | - | ||||||||||||||||||||||||
| 585 | } | - | ||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | static inline QString getLocaleData(const ushort *data, int size) | - | ||||||||||||||||||||||||
| 588 | { | - | ||||||||||||||||||||||||
| 589 | return size > 0 ? QString::fromRawData(reinterpret_cast<const QChar *>(data), size) : QString(); | - | ||||||||||||||||||||||||
| 590 | } | - | ||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||
| 592 | static QString getLocaleListData(const ushort *data, int size, int index) | - | ||||||||||||||||||||||||
| 593 | { | - | ||||||||||||||||||||||||
| 594 | static const ushort separator = ';'; | - | ||||||||||||||||||||||||
| 595 | while (index && size > 0) { | - | ||||||||||||||||||||||||
| 596 | while (*data != separator) | - | ||||||||||||||||||||||||
| 597 | ++data, --size; | - | ||||||||||||||||||||||||
| 598 | --index; | - | ||||||||||||||||||||||||
| 599 | ++data; | - | ||||||||||||||||||||||||
| 600 | --size; | - | ||||||||||||||||||||||||
| 601 | } | - | ||||||||||||||||||||||||
| 602 | const ushort *end = data; | - | ||||||||||||||||||||||||
| 603 | while (size > 0 && *end != separator) | - | ||||||||||||||||||||||||
| 604 | ++end, --size; | - | ||||||||||||||||||||||||
| 605 | return getLocaleData(data, end - data); | - | ||||||||||||||||||||||||
| 606 | } | - | ||||||||||||||||||||||||
| 607 | - | |||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||
| 609 | - | |||||||||||||||||||||||||
| 610 | QDataStream &operator<<(QDataStream &ds, const QLocale &l) | - | ||||||||||||||||||||||||
| 611 | { | - | ||||||||||||||||||||||||
| 612 | ds << l.name(); | - | ||||||||||||||||||||||||
| 613 | return ds; | - | ||||||||||||||||||||||||
| 614 | } | - | ||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||
| 616 | QDataStream &operator>>(QDataStream &ds, QLocale &l) | - | ||||||||||||||||||||||||
| 617 | { | - | ||||||||||||||||||||||||
| 618 | QString s; | - | ||||||||||||||||||||||||
| 619 | ds >> s; | - | ||||||||||||||||||||||||
| 620 | l = QLocale(s); | - | ||||||||||||||||||||||||
| 621 | return ds; | - | ||||||||||||||||||||||||
| 622 | } | - | ||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||
| 624 | - | |||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||
| 626 | static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1; | - | ||||||||||||||||||||||||
| 627 | - | |||||||||||||||||||||||||
| 628 | namespace { namespace Q_QGS_defaultLocalePrivate { typedef QSharedDataPointer<QLocalePrivate> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (QLocalePrivate::create(defaultData(), default_number_options)))) : value (QLocalePrivate::create(defaultData(), default_number_options)) { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QSharedDataPointer<QLocalePrivate>, Q_QGS_defaultLocalePrivate::innerFunction, Q_QGS_defaultLocalePrivate::guard> defaultLocalePrivate; | - | ||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| 630 | - | |||||||||||||||||||||||||
| 631 | static QLocalePrivate *localePrivateByName(const QString &name) | - | ||||||||||||||||||||||||
| 632 | { | - | ||||||||||||||||||||||||
| 633 | if (name == QLatin1String("C")
| 3171-7883 | ||||||||||||||||||||||||
| 634 | return executed 7883 times by 6 tests: c_private();return c_private();Executed by:
executed 7883 times by 6 tests: return c_private();Executed by:
| 7883 | ||||||||||||||||||||||||
| 635 | const QLocaleData *data = findLocaleData(name); | - | ||||||||||||||||||||||||
| 636 | return executed 3170 times by 26 tests: QLocalePrivate::create(data, data->m_language_id == QLocale::C ?return QLocalePrivate::create(data, data->m_language_id == QLocale::C ? QLocale::OmitGroupSeparator : QLocale::DefaultNumberOptions);Executed by:
executed 3170 times by 26 tests: return QLocalePrivate::create(data, data->m_language_id == QLocale::C ? QLocale::OmitGroupSeparator : QLocale::DefaultNumberOptions);Executed by:
| 3170 | ||||||||||||||||||||||||
| 637 | QLocale::OmitGroupSeparator : 0QLocale::DefaultNumberOptions); executed 3170 times by 26 tests: return QLocalePrivate::create(data, data->m_language_id == QLocale::C ? QLocale::OmitGroupSeparator : QLocale::DefaultNumberOptions);Executed by:
| 3170 | ||||||||||||||||||||||||
| 638 | } | - | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Script script, | - | ||||||||||||||||||||||||
| 641 | QLocale::Country country) | - | ||||||||||||||||||||||||
| 642 | { | - | ||||||||||||||||||||||||
| 643 | if (language == QLocale::C
| 64-131284 | ||||||||||||||||||||||||
| 644 | return executed 131284 times by 117 tests: c_private();return c_private();Executed by:
executed 131284 times by 117 tests: return c_private();Executed by:
| 131284 | ||||||||||||||||||||||||
| 645 | - | |||||||||||||||||||||||||
| 646 | const QLocaleData *data = QLocaleData::findLocaleData(language, script, country); | - | ||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||
| 648 | intQLocale::NumberOptions numberOptions = 0QLocale::DefaultNumberOptions; | - | ||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||
| 651 | if (data->m_language_id == QLocale::C
| 0-64 | ||||||||||||||||||||||||
| 652 | numberOptions = default_number_options; | - | ||||||||||||||||||||||||
| 653 | data = defaultData(); | - | ||||||||||||||||||||||||
| 654 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 655 | return executed 64 times by 12 tests: QLocalePrivate::create(data, numberOptions);return QLocalePrivate::create(data, numberOptions);Executed by:
executed 64 times by 12 tests: return QLocalePrivate::create(data, numberOptions);Executed by:
| 64 | ||||||||||||||||||||||||
| 656 | } | - | ||||||||||||||||||||||||
| 657 | - | |||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | QLocale::QLocale(QLocalePrivate &dd) | - | ||||||||||||||||||||||||
| 663 | : d(&dd) | - | ||||||||||||||||||||||||
| 664 | {} | - | ||||||||||||||||||||||||
| 665 | QLocale::QLocale(const QString &name) | - | ||||||||||||||||||||||||
| 666 | : d(localePrivateByName(name)) | - | ||||||||||||||||||||||||
| 667 | { | - | ||||||||||||||||||||||||
| 668 | } | - | ||||||||||||||||||||||||
| 669 | QLocale::QLocale() | - | ||||||||||||||||||||||||
| 670 | : d(*defaultLocalePrivate) | - | ||||||||||||||||||||||||
| 671 | { | - | ||||||||||||||||||||||||
| 672 | } | - | ||||||||||||||||||||||||
| 673 | QLocale::QLocale(Language language, Country country) | - | ||||||||||||||||||||||||
| 674 | : d(findLocalePrivate(language, QLocale::AnyScript, country)) | - | ||||||||||||||||||||||||
| 675 | { | - | ||||||||||||||||||||||||
| 676 | } | - | ||||||||||||||||||||||||
| 677 | QLocale::QLocale(Language language, Script script, Country country) | - | ||||||||||||||||||||||||
| 678 | : d(findLocalePrivate(language, script, country)) | - | ||||||||||||||||||||||||
| 679 | { | - | ||||||||||||||||||||||||
| 680 | } | - | ||||||||||||||||||||||||
| 681 | - | |||||||||||||||||||||||||
| 682 | - | |||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||
| 684 | - | |||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||
| 686 | QLocale::QLocale(const QLocale &other) | - | ||||||||||||||||||||||||
| 687 | { | - | ||||||||||||||||||||||||
| 688 | d = other.d; | - | ||||||||||||||||||||||||
| 689 | } | - | ||||||||||||||||||||||||
| 690 | - | |||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||
| 695 | QLocale::~QLocale() | - | ||||||||||||||||||||||||
| 696 | { | - | ||||||||||||||||||||||||
| 697 | } | - | ||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | - | |||||||||||||||||||||||||
| 704 | QLocale &QLocale::operator=(const QLocale &other) | - | ||||||||||||||||||||||||
| 705 | { | - | ||||||||||||||||||||||||
| 706 | d = other.d; | - | ||||||||||||||||||||||||
| 707 | return *this; | - | ||||||||||||||||||||||||
| 708 | } | - | ||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||
| 710 | bool QLocale::operator==(const QLocale &other) const | - | ||||||||||||||||||||||||
| 711 | { | - | ||||||||||||||||||||||||
| 712 | return d->m_data == other.d->m_data && d->m_numberOptions == other.d->m_numberOptions; | - | ||||||||||||||||||||||||
| 713 | } | - | ||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||
| 715 | bool QLocale::operator!=(const QLocale &other) const | - | ||||||||||||||||||||||||
| 716 | { | - | ||||||||||||||||||||||||
| 717 | return d->m_data != other.d->m_data || d->m_numberOptions != other.d->m_numberOptions; | - | ||||||||||||||||||||||||
| 718 | } | - | ||||||||||||||||||||||||
| 719 | uint qHash(const QLocale &key, uint seed) noexcept | - | ||||||||||||||||||||||||
| 720 | { | - | ||||||||||||||||||||||||
| 721 | QtPrivate::QHashCombine hash; | - | ||||||||||||||||||||||||
| 722 | seed = hash(seed, key.d->m_data); | - | ||||||||||||||||||||||||
| 723 | seed = hash(seed, key.d->m_numberOptions); | - | ||||||||||||||||||||||||
| 724 | return never executed: seed;return seed;never executed: return seed; | 0 | ||||||||||||||||||||||||
| 725 | } | - | ||||||||||||||||||||||||
| 726 | - | |||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||
| 733 | void QLocale::setNumberOptions(NumberOptions options) | - | ||||||||||||||||||||||||
| 734 | { | - | ||||||||||||||||||||||||
| 735 | d->m_numberOptions = options; | - | ||||||||||||||||||||||||
| 736 | } | - | ||||||||||||||||||||||||
| 737 | QLocale::NumberOptions QLocale::numberOptions() const | - | ||||||||||||||||||||||||
| 738 | { | - | ||||||||||||||||||||||||
| 739 | return executed 3878 times by 30 tests: static_cast<NumberOptionNumberOptions>(d->m_numberOptions);return static_cast<NumberOptions>(d->m_numberOptions);Executed by:
executed 3878 times by 30 tests: return static_cast<NumberOptions>(d->m_numberOptions);Executed by:
| 3878 | ||||||||||||||||||||||||
| 740 | } | - | ||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | - | |||||||||||||||||||||||||
| 748 | QString QLocale::quoteString(const QString &str, QuotationStyle style) const | - | ||||||||||||||||||||||||
| 749 | { | - | ||||||||||||||||||||||||
| 750 | return quoteString(&str, style); | - | ||||||||||||||||||||||||
| 751 | } | - | ||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||
| 758 | QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const | - | ||||||||||||||||||||||||
| 759 | { | - | ||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||
| 761 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 762 | QVariant res; | - | ||||||||||||||||||||||||
| 763 | if (style == QLocale::AlternateQuotation) | - | ||||||||||||||||||||||||
| 764 | res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation, QVariant::fromValue(str)); | - | ||||||||||||||||||||||||
| 765 | if (res.isNull() || style == QLocale::StandardQuotation) | - | ||||||||||||||||||||||||
| 766 | res = systemLocale()->query(QSystemLocale::StringToStandardQuotation, QVariant::fromValue(str)); | - | ||||||||||||||||||||||||
| 767 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 768 | return res.toString(); | - | ||||||||||||||||||||||||
| 769 | } | - | ||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||
| 772 | if (style == QLocale::StandardQuotation) | - | ||||||||||||||||||||||||
| 773 | return QChar(d->m_data->m_quotation_start) % str % QChar(d->m_data->m_quotation_end); | - | ||||||||||||||||||||||||
| 774 | else | - | ||||||||||||||||||||||||
| 775 | return QChar(d->m_data->m_alternate_quotation_start) % str % QChar(d->m_data->m_alternate_quotation_end); | - | ||||||||||||||||||||||||
| 776 | } | - | ||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||
| 779 | - | |||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | QString QLocale::createSeparatedList(const QStringList &list) const | - | ||||||||||||||||||||||||
| 785 | { | - | ||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||
| 787 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 788 | QVariant res; | - | ||||||||||||||||||||||||
| 789 | res = systemLocale()->query(QSystemLocale::ListToSeparatedString, QVariant::fromValue(list)); | - | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 792 | return res.toString(); | - | ||||||||||||||||||||||||
| 793 | } | - | ||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||
| 796 | const int size = list.size(); | - | ||||||||||||||||||||||||
| 797 | if (size == 1) { | - | ||||||||||||||||||||||||
| 798 | return list.at(0); | - | ||||||||||||||||||||||||
| 799 | } else if (size == 2) { | - | ||||||||||||||||||||||||
| 800 | QString format = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_two_idx, d->m_data->m_list_pattern_part_two_size); | - | ||||||||||||||||||||||||
| 801 | return format.arg(list.at(0), list.at(1)); | - | ||||||||||||||||||||||||
| 802 | } else if (size > 2) { | - | ||||||||||||||||||||||||
| 803 | QString formatStart = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_start_idx, d->m_data->m_list_pattern_part_start_size); | - | ||||||||||||||||||||||||
| 804 | QString formatMid = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_mid_idx, d->m_data->m_list_pattern_part_mid_size); | - | ||||||||||||||||||||||||
| 805 | QString formatEnd = getLocaleData(list_pattern_part_data + d->m_data->m_list_pattern_part_end_idx, d->m_data->m_list_pattern_part_end_size); | - | ||||||||||||||||||||||||
| 806 | QString result = formatStart.arg(list.at(0), list.at(1)); | - | ||||||||||||||||||||||||
| 807 | for (int i = 2; i < size - 1; ++i) | - | ||||||||||||||||||||||||
| 808 | result = formatMid.arg(result, list.at(i)); | - | ||||||||||||||||||||||||
| 809 | result = formatEnd.arg(result, list.at(size - 1)); | - | ||||||||||||||||||||||||
| 810 | return result; | - | ||||||||||||||||||||||||
| 811 | } | - | ||||||||||||||||||||||||
| 812 | - | |||||||||||||||||||||||||
| 813 | return QString(); | - | ||||||||||||||||||||||||
| 814 | } | - | ||||||||||||||||||||||||
| 815 | void QLocale::setDefault(const QLocale &locale) | - | ||||||||||||||||||||||||
| 816 | { | - | ||||||||||||||||||||||||
| 817 | default_data = locale.d->m_data; | - | ||||||||||||||||||||||||
| 818 | default_number_options = locale.numberOptions(); | - | ||||||||||||||||||||||||
| 819 | - | |||||||||||||||||||||||||
| 820 | if (defaultLocalePrivate.exists()) { | - | ||||||||||||||||||||||||
| 821 | - | |||||||||||||||||||||||||
| 822 | *defaultLocalePrivate = locale.d; | - | ||||||||||||||||||||||||
| 823 | } | - | ||||||||||||||||||||||||
| 824 | } | - | ||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||
| 828 | - | |||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | QLocale::Language QLocale::language() const | - | ||||||||||||||||||||||||
| 832 | { | - | ||||||||||||||||||||||||
| 833 | return Language(d->languageId()); | - | ||||||||||||||||||||||||
| 834 | } | - | ||||||||||||||||||||||||
| 835 | QLocale::Script QLocale::script() const | - | ||||||||||||||||||||||||
| 836 | { | - | ||||||||||||||||||||||||
| 837 | return Script(d->m_data->m_script_id); | - | ||||||||||||||||||||||||
| 838 | } | - | ||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||
| 843 | - | |||||||||||||||||||||||||
| 844 | - | |||||||||||||||||||||||||
| 845 | QLocale::Country QLocale::country() const | - | ||||||||||||||||||||||||
| 846 | { | - | ||||||||||||||||||||||||
| 847 | return Country(d->countryId()); | - | ||||||||||||||||||||||||
| 848 | } | - | ||||||||||||||||||||||||
| 849 | QString QLocale::name() const | - | ||||||||||||||||||||||||
| 850 | { | - | ||||||||||||||||||||||||
| 851 | Language l = language(); | - | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | QString result = d->languageCode(); | - | ||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||
| 855 | if (l == C) | - | ||||||||||||||||||||||||
| 856 | return result; | - | ||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||
| 858 | Country c = country(); | - | ||||||||||||||||||||||||
| 859 | if (c == AnyCountry) | - | ||||||||||||||||||||||||
| 860 | return result; | - | ||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||
| 862 | result.append(QLatin1Char('_')); | - | ||||||||||||||||||||||||
| 863 | result.append(d->countryCode()); | - | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | return result; | - | ||||||||||||||||||||||||
| 866 | } | - | ||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | static qlonglong toIntegral_helper(const QLocaleData *d, const QChar *data, int len, bool *ok, | - | ||||||||||||||||||||||||
| 869 | QLocaleDataQLocale::GroupSeparatorModeNumberOptions mode, qlonglong) | - | ||||||||||||||||||||||||
| 870 | { | - | ||||||||||||||||||||||||
| 871 | return executed 1226 times by 16 tests: d->stringToLongLong(data, len, 10, ok, mode);return d->stringToLongLong(data, len, 10, ok, mode);Executed by:
executed 1226 times by 16 tests: return d->stringToLongLong(data, len, 10, ok, mode);Executed by:
| 1226 | ||||||||||||||||||||||||
| 872 | } | - | ||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | static qulonglong toIntegral_helper(const QLocaleData *d, const QChar *data, int len, bool *ok, | - | ||||||||||||||||||||||||
| 875 | QLocaleDataQLocale::GroupSeparatorModeNumberOptions mode, qulonglong) | - | ||||||||||||||||||||||||
| 876 | { | - | ||||||||||||||||||||||||
| 877 | return executed 15675 times by 11 tests: d->stringToUnsLongLong(data, len, 10, ok, mode);return d->stringToUnsLongLong(data, len, 10, ok, mode);Executed by:
executed 15675 times by 11 tests: return d->stringToUnsLongLong(data, len, 10, ok, mode);Executed by:
| 15675 | ||||||||||||||||||||||||
| 878 | } | - | ||||||||||||||||||||||||
| 879 | - | |||||||||||||||||||||||||
| 880 | template <typename T> static inline | - | ||||||||||||||||||||||||
| 881 | T toIntegral_helper(const QLocalePrivate *d, const QChar *data, int len, bool *ok) | - | ||||||||||||||||||||||||
| 882 | { | - | ||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||
| 884 | const bool isUnsigned = T(0) < T(-1); | - | ||||||||||||||||||||||||
| 885 | typedef typename QtPrivate::QConditional<isUnsigned, qulonglong, qlonglong>::Type Int64; | - | ||||||||||||||||||||||||
| QLocaleData::GroupSeparatorMode mode | ||||||||||||||||||||||||||
| = d->m_numberOptions & QLocale::RejectGroupSeparator | ||||||||||||||||||||||||||
| ? QLocaleData::FailOnGroupSeparators | ||||||||||||||||||||||||||
| : QLocaleData::ParseGroupSeparators; | ||||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | Int64 val = toIntegral_helper(d->m_data, data, len, ok, moded->m_numberOptions, Int64()); | - | ||||||||||||||||||||||||
| 889 | if (T(val) != val
| 0-16901 | ||||||||||||||||||||||||
| 890 | if (ok
| 0 | ||||||||||||||||||||||||
| 891 | * never executed: ok = false;*ok = false;never executed: *ok = false; | 0 | ||||||||||||||||||||||||
| 892 | val = 0; | - | ||||||||||||||||||||||||
| 893 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 894 | return executed 16901 times by 23 tests: T(val);return T(val);Executed by:
executed 16901 times by 23 tests: return T(val);Executed by:
| 16901 | ||||||||||||||||||||||||
| 895 | } | - | ||||||||||||||||||||||||
| 896 | QString QLocale::bcp47Name() const | - | ||||||||||||||||||||||||
| 897 | { | - | ||||||||||||||||||||||||
| 898 | return QString::fromLatin1(d->bcp47Name()); | - | ||||||||||||||||||||||||
| 899 | } | - | ||||||||||||||||||||||||
| 900 | - | |||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||
| 903 | - | |||||||||||||||||||||||||
| 904 | - | |||||||||||||||||||||||||
| 905 | - | |||||||||||||||||||||||||
| 906 | - | |||||||||||||||||||||||||
| 907 | QString QLocale::languageToString(Language language) | - | ||||||||||||||||||||||||
| 908 | { | - | ||||||||||||||||||||||||
| 909 | if (uint(language) > uint(QLocale::LastLanguage)) | - | ||||||||||||||||||||||||
| 910 | return QLatin1String("Unknown"); | - | ||||||||||||||||||||||||
| 911 | return QLatin1String(language_name_list + language_name_index[language]); | - | ||||||||||||||||||||||||
| 912 | } | - | ||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||
| 915 | - | |||||||||||||||||||||||||
| 916 | - | |||||||||||||||||||||||||
| 917 | - | |||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||
| 920 | QString QLocale::countryToString(Country country) | - | ||||||||||||||||||||||||
| 921 | { | - | ||||||||||||||||||||||||
| 922 | if (uint(country) > uint(QLocale::LastCountry)) | - | ||||||||||||||||||||||||
| 923 | return QLatin1String("Unknown"); | - | ||||||||||||||||||||||||
| 924 | return QLatin1String(country_name_list + country_name_index[country]); | - | ||||||||||||||||||||||||
| 925 | } | - | ||||||||||||||||||||||||
| 926 | QString QLocale::scriptToString(QLocale::Script script) | - | ||||||||||||||||||||||||
| 927 | { | - | ||||||||||||||||||||||||
| 928 | if (uint(script) > uint(QLocale::LastScript)) | - | ||||||||||||||||||||||||
| 929 | return QLatin1String("Unknown"); | - | ||||||||||||||||||||||||
| 930 | return QLatin1String(script_name_list + script_name_index[script]); | - | ||||||||||||||||||||||||
| 931 | } | - | ||||||||||||||||||||||||
| 932 | short QLocale::toShort(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 933 | { | - | ||||||||||||||||||||||||
| 934 | return toIntegral_helper<short>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 935 | } | - | ||||||||||||||||||||||||
| 936 | ushort QLocale::toUShort(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 937 | { | - | ||||||||||||||||||||||||
| 938 | return toIntegral_helper<ushort>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 939 | } | - | ||||||||||||||||||||||||
| 940 | int QLocale::toInt(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 941 | { | - | ||||||||||||||||||||||||
| 942 | return toIntegral_helper<int>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 943 | } | - | ||||||||||||||||||||||||
| 944 | uint QLocale::toUInt(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 945 | { | - | ||||||||||||||||||||||||
| 946 | return toIntegral_helper<uint>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 947 | } | - | ||||||||||||||||||||||||
| 948 | qlonglong QLocale::toLongLong(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 949 | { | - | ||||||||||||||||||||||||
| 950 | return toIntegral_helper<qlonglong>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 951 | } | - | ||||||||||||||||||||||||
| 952 | qulonglong QLocale::toULongLong(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 953 | { | - | ||||||||||||||||||||||||
| 954 | return toIntegral_helper<qulonglong>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 955 | } | - | ||||||||||||||||||||||||
| 956 | float QLocale::toFloat(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 957 | { | - | ||||||||||||||||||||||||
| 958 | return QLocaleData::convertDoubleToFloat(toDouble(s, ok), ok); | - | ||||||||||||||||||||||||
| 959 | } | - | ||||||||||||||||||||||||
| 960 | double QLocale::toDouble(const QString &s, bool *ok) const | - | ||||||||||||||||||||||||
| 961 | { | - | ||||||||||||||||||||||||
| 962 | QLocaleData::GroupSeparatorMode mode | 1212 | ||||||||||||||||||||||||
| = d->m_numberOptions & RejectGroupSeparator | ||||||||||||||||||||||||||
| ? QLocaleData::FailOnGroupSeparators | ||||||||||||||||||||||||||
| : QLocaleData::ParseGroupSeparators;return executed 1212 times by 7 tests: d->m_data->stringToDouble(s.constData(), s.size(), ok, moded->m_numberOptions);return d->m_data->stringToDouble(s.constData(), s.size(), ok, d->m_numberOptions);Executed by:
executed 1212 times by 7 tests: return d->m_data->stringToDouble(s.constData(), s.size(), ok, d->m_numberOptions);Executed by:
| ||||||||||||||||||||||||||
| 963 | } | - | ||||||||||||||||||||||||
| 964 | short QLocale::toShort(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 965 | { | - | ||||||||||||||||||||||||
| 966 | return toIntegral_helper<short>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 967 | } | - | ||||||||||||||||||||||||
| 968 | ushort QLocale::toUShort(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 969 | { | - | ||||||||||||||||||||||||
| 970 | return toIntegral_helper<ushort>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 971 | } | - | ||||||||||||||||||||||||
| 972 | int QLocale::toInt(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 973 | { | - | ||||||||||||||||||||||||
| 974 | return toIntegral_helper<int>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 975 | } | - | ||||||||||||||||||||||||
| 976 | uint QLocale::toUInt(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 977 | { | - | ||||||||||||||||||||||||
| 978 | return toIntegral_helper<uint>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 979 | } | - | ||||||||||||||||||||||||
| 980 | qlonglong QLocale::toLongLong(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 981 | { | - | ||||||||||||||||||||||||
| 982 | return toIntegral_helper<qlonglong>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 983 | } | - | ||||||||||||||||||||||||
| 984 | qulonglong QLocale::toULongLong(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 985 | { | - | ||||||||||||||||||||||||
| 986 | return toIntegral_helper<qulonglong>(d, s.constData(), s.size(), ok); | - | ||||||||||||||||||||||||
| 987 | } | - | ||||||||||||||||||||||||
| 988 | float QLocale::toFloat(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 989 | { | - | ||||||||||||||||||||||||
| 990 | return QLocaleData::convertDoubleToFloat(toDouble(s, ok), ok); | - | ||||||||||||||||||||||||
| 991 | } | - | ||||||||||||||||||||||||
| 992 | double QLocale::toDouble(const QStringRef &s, bool *ok) const | - | ||||||||||||||||||||||||
| 993 | { | - | ||||||||||||||||||||||||
| 994 | QLocaleData::GroupSeparatorMode mode | 0 | ||||||||||||||||||||||||
| = d->m_numberOptions & RejectGroupSeparator | ||||||||||||||||||||||||||
| ? QLocaleData::FailOnGroupSeparators | ||||||||||||||||||||||||||
| : QLocaleData::ParseGroupSeparators;return never executed: d->m_data->stringToDouble(s.constData(), s.size(), ok, moded->m_numberOptions);return d->m_data->stringToDouble(s.constData(), s.size(), ok, d->m_numberOptions);never executed: return d->m_data->stringToDouble(s.constData(), s.size(), ok, d->m_numberOptions); | ||||||||||||||||||||||||||
| 995 | } | - | ||||||||||||||||||||||||
| 996 | QString QLocale::toString(qlonglong i) const | - | ||||||||||||||||||||||||
| 997 | { | - | ||||||||||||||||||||||||
| 998 | int flags = d->m_numberOptions & OmitGroupSeparator | - | ||||||||||||||||||||||||
| 999 | ? 0 | - | ||||||||||||||||||||||||
| 1000 | : QLocaleData::ThousandsGroup; | - | ||||||||||||||||||||||||
| 1001 | - | |||||||||||||||||||||||||
| 1002 | return d->m_data->longLongToString(i, -1, 10, -1, flags); | - | ||||||||||||||||||||||||
| 1003 | } | - | ||||||||||||||||||||||||
| 1004 | - | |||||||||||||||||||||||||
| 1005 | - | |||||||||||||||||||||||||
| 1006 | - | |||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | - | |||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||
| 1011 | QString QLocale::toString(qulonglong i) const | - | ||||||||||||||||||||||||
| 1012 | { | - | ||||||||||||||||||||||||
| 1013 | int flags = d->m_numberOptions & OmitGroupSeparator | - | ||||||||||||||||||||||||
| 1014 | ? 0 | - | ||||||||||||||||||||||||
| 1015 | : QLocaleData::ThousandsGroup; | - | ||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||
| 1017 | return d->m_data->unsLongLongToString(i, -1, 10, -1, flags); | - | ||||||||||||||||||||||||
| 1018 | } | - | ||||||||||||||||||||||||
| 1019 | - | |||||||||||||||||||||||||
| 1020 | - | |||||||||||||||||||||||||
| 1021 | - | |||||||||||||||||||||||||
| 1022 | - | |||||||||||||||||||||||||
| 1023 | - | |||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||
| 1026 | QString QLocale::toString(const QDate &date, const QString &format) const | - | ||||||||||||||||||||||||
| 1027 | { | - | ||||||||||||||||||||||||
| 1028 | return d->dateTimeToString(format, QDateTime(), date, QTime(), this); | - | ||||||||||||||||||||||||
| 1029 | } | - | ||||||||||||||||||||||||
| 1030 | - | |||||||||||||||||||||||||
| 1031 | - | |||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | QString QLocale::toString(const QDate &date, FormatType format) const | - | ||||||||||||||||||||||||
| 1037 | { | - | ||||||||||||||||||||||||
| 1038 | if (!date.isValid()) | - | ||||||||||||||||||||||||
| 1039 | return QString(); | - | ||||||||||||||||||||||||
| 1040 | - | |||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||
| 1042 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1043 | QVariant res = systemLocale()->query(format == LongFormat | - | ||||||||||||||||||||||||
| 1044 | ? QSystemLocale::DateToStringLong : QSystemLocale::DateToStringShort, | - | ||||||||||||||||||||||||
| 1045 | date); | - | ||||||||||||||||||||||||
| 1046 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1047 | return res.toString(); | - | ||||||||||||||||||||||||
| 1048 | } | - | ||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||
| 1051 | QString format_str = dateFormat(format); | - | ||||||||||||||||||||||||
| 1052 | return toString(date, format_str); | - | ||||||||||||||||||||||||
| 1053 | } | - | ||||||||||||||||||||||||
| 1054 | - | |||||||||||||||||||||||||
| 1055 | static bool timeFormatContainsAP(const QString &format) | - | ||||||||||||||||||||||||
| 1056 | { | - | ||||||||||||||||||||||||
| 1057 | int i = 0; | - | ||||||||||||||||||||||||
| 1058 | while (i < format.size()) { | - | ||||||||||||||||||||||||
| 1059 | if (format.at(i).unicode() == '\'') { | - | ||||||||||||||||||||||||
| 1060 | qt_readEscapedFormatString(format, &i); | - | ||||||||||||||||||||||||
| 1061 | continue; | - | ||||||||||||||||||||||||
| 1062 | } | - | ||||||||||||||||||||||||
| 1063 | - | |||||||||||||||||||||||||
| 1064 | if (format.at(i).toLower().unicode() == 'a') | - | ||||||||||||||||||||||||
| 1065 | return true; | - | ||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||
| 1067 | ++i; | - | ||||||||||||||||||||||||
| 1068 | } | - | ||||||||||||||||||||||||
| 1069 | return false; | - | ||||||||||||||||||||||||
| 1070 | } | - | ||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||
| 1072 | - | |||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | - | |||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||
| 1077 | QString QLocale::toString(const QTime &time, const QString &format) const | - | ||||||||||||||||||||||||
| 1078 | { | - | ||||||||||||||||||||||||
| 1079 | return d->dateTimeToString(format, QDateTime(), QDate(), time, this); | - | ||||||||||||||||||||||||
| 1080 | } | - | ||||||||||||||||||||||||
| 1081 | QString QLocale::toString(const QDateTime &dateTime, const QString &format) const | - | ||||||||||||||||||||||||
| 1082 | { | - | ||||||||||||||||||||||||
| 1083 | return d->dateTimeToString(format, dateTime, QDate(), QTime(), this); | - | ||||||||||||||||||||||||
| 1084 | } | - | ||||||||||||||||||||||||
| 1085 | QString QLocale::toString(const QDateTime &dateTime, FormatType format) const | - | ||||||||||||||||||||||||
| 1086 | { | - | ||||||||||||||||||||||||
| 1087 | if (!dateTime.isValid()) | - | ||||||||||||||||||||||||
| 1088 | return QString(); | - | ||||||||||||||||||||||||
| 1089 | - | |||||||||||||||||||||||||
| 1090 | - | |||||||||||||||||||||||||
| 1091 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1092 | QVariant res = systemLocale()->query(format == LongFormat | - | ||||||||||||||||||||||||
| 1093 | ? QSystemLocale::DateTimeToStringLong | - | ||||||||||||||||||||||||
| 1094 | : QSystemLocale::DateTimeToStringShort, | - | ||||||||||||||||||||||||
| 1095 | dateTime); | - | ||||||||||||||||||||||||
| 1096 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1097 | return res.toString(); | - | ||||||||||||||||||||||||
| 1098 | } | - | ||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | - | |||||||||||||||||||||||||
| 1101 | const QString format_str = dateTimeFormat(format); | - | ||||||||||||||||||||||||
| 1102 | return toString(dateTime, format_str); | - | ||||||||||||||||||||||||
| 1103 | } | - | ||||||||||||||||||||||||
| 1104 | - | |||||||||||||||||||||||||
| 1105 | - | |||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | - | |||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | QString QLocale::toString(const QTime &time, FormatType format) const | - | ||||||||||||||||||||||||
| 1112 | { | - | ||||||||||||||||||||||||
| 1113 | if (!time.isValid()) | - | ||||||||||||||||||||||||
| 1114 | return QString(); | - | ||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||
| 1116 | - | |||||||||||||||||||||||||
| 1117 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1118 | QVariant res = systemLocale()->query(format == LongFormat | - | ||||||||||||||||||||||||
| 1119 | ? QSystemLocale::TimeToStringLong : QSystemLocale::TimeToStringShort, | - | ||||||||||||||||||||||||
| 1120 | time); | - | ||||||||||||||||||||||||
| 1121 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1122 | return res.toString(); | - | ||||||||||||||||||||||||
| 1123 | } | - | ||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||
| 1125 | - | |||||||||||||||||||||||||
| 1126 | QString format_str = timeFormat(format); | - | ||||||||||||||||||||||||
| 1127 | return toString(time, format_str); | - | ||||||||||||||||||||||||
| 1128 | } | - | ||||||||||||||||||||||||
| 1129 | QString QLocale::dateFormat(FormatType format) const | - | ||||||||||||||||||||||||
| 1130 | { | - | ||||||||||||||||||||||||
| 1131 | - | |||||||||||||||||||||||||
| 1132 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1133 | QVariant res = systemLocale()->query(format == LongFormat | - | ||||||||||||||||||||||||
| 1134 | ? QSystemLocale::DateFormatLong : QSystemLocale::DateFormatShort, | - | ||||||||||||||||||||||||
| 1135 | QVariant()); | - | ||||||||||||||||||||||||
| 1136 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1137 | return res.toString(); | - | ||||||||||||||||||||||||
| 1138 | } | - | ||||||||||||||||||||||||
| 1139 | - | |||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | quint32 idx, size; | - | ||||||||||||||||||||||||
| 1142 | switch (format) { | - | ||||||||||||||||||||||||
| 1143 | case LongFormat: | - | ||||||||||||||||||||||||
| 1144 | idx = d->m_data->m_long_date_format_idx; | - | ||||||||||||||||||||||||
| 1145 | size = d->m_data->m_long_date_format_size; | - | ||||||||||||||||||||||||
| 1146 | break; | - | ||||||||||||||||||||||||
| 1147 | default: | - | ||||||||||||||||||||||||
| 1148 | idx = d->m_data->m_short_date_format_idx; | - | ||||||||||||||||||||||||
| 1149 | size = d->m_data->m_short_date_format_size; | - | ||||||||||||||||||||||||
| 1150 | break; | - | ||||||||||||||||||||||||
| 1151 | } | - | ||||||||||||||||||||||||
| 1152 | return getLocaleData(date_format_data + idx, size); | - | ||||||||||||||||||||||||
| 1153 | } | - | ||||||||||||||||||||||||
| 1154 | QString QLocale::timeFormat(FormatType format) const | - | ||||||||||||||||||||||||
| 1155 | { | - | ||||||||||||||||||||||||
| 1156 | - | |||||||||||||||||||||||||
| 1157 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1158 | QVariant res = systemLocale()->query(format == LongFormat | - | ||||||||||||||||||||||||
| 1159 | ? QSystemLocale::TimeFormatLong : QSystemLocale::TimeFormatShort, | - | ||||||||||||||||||||||||
| 1160 | QVariant()); | - | ||||||||||||||||||||||||
| 1161 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1162 | return res.toString(); | - | ||||||||||||||||||||||||
| 1163 | } | - | ||||||||||||||||||||||||
| 1164 | - | |||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | quint32 idx, size; | - | ||||||||||||||||||||||||
| 1167 | switch (format) { | - | ||||||||||||||||||||||||
| 1168 | case LongFormat: | - | ||||||||||||||||||||||||
| 1169 | idx = d->m_data->m_long_time_format_idx; | - | ||||||||||||||||||||||||
| 1170 | size = d->m_data->m_long_time_format_size; | - | ||||||||||||||||||||||||
| 1171 | break; | - | ||||||||||||||||||||||||
| 1172 | default: | - | ||||||||||||||||||||||||
| 1173 | idx = d->m_data->m_short_time_format_idx; | - | ||||||||||||||||||||||||
| 1174 | size = d->m_data->m_short_time_format_size; | - | ||||||||||||||||||||||||
| 1175 | break; | - | ||||||||||||||||||||||||
| 1176 | } | - | ||||||||||||||||||||||||
| 1177 | return getLocaleData(time_format_data + idx, size); | - | ||||||||||||||||||||||||
| 1178 | } | - | ||||||||||||||||||||||||
| 1179 | QString QLocale::dateTimeFormat(FormatType format) const | - | ||||||||||||||||||||||||
| 1180 | { | - | ||||||||||||||||||||||||
| 1181 | - | |||||||||||||||||||||||||
| 1182 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1183 | QVariant res = systemLocale()->query(format == LongFormat | - | ||||||||||||||||||||||||
| 1184 | ? QSystemLocale::DateTimeFormatLong | - | ||||||||||||||||||||||||
| 1185 | : QSystemLocale::DateTimeFormatShort, | - | ||||||||||||||||||||||||
| 1186 | QVariant()); | - | ||||||||||||||||||||||||
| 1187 | if (!res.isNull()) { | - | ||||||||||||||||||||||||
| 1188 | return res.toString(); | - | ||||||||||||||||||||||||
| 1189 | } | - | ||||||||||||||||||||||||
| 1190 | } | - | ||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||
| 1192 | return dateFormat(format) + QLatin1Char(' ') + timeFormat(format); | - | ||||||||||||||||||||||||
| 1193 | } | - | ||||||||||||||||||||||||
| 1194 | QTime QLocale::toTime(const QString &string, FormatType format) const | - | ||||||||||||||||||||||||
| 1195 | { | - | ||||||||||||||||||||||||
| 1196 | return toTime(string, timeFormat(format)); | - | ||||||||||||||||||||||||
| 1197 | } | - | ||||||||||||||||||||||||
| 1198 | QDate QLocale::toDate(const QString &string, FormatType format) const | - | ||||||||||||||||||||||||
| 1199 | { | - | ||||||||||||||||||||||||
| 1200 | return toDate(string, dateFormat(format)); | - | ||||||||||||||||||||||||
| 1201 | } | - | ||||||||||||||||||||||||
| 1202 | QDateTime QLocale::toDateTime(const QString &string, FormatType format) const | - | ||||||||||||||||||||||||
| 1203 | { | - | ||||||||||||||||||||||||
| 1204 | return toDateTime(string, dateTimeFormat(format)); | - | ||||||||||||||||||||||||
| 1205 | } | - | ||||||||||||||||||||||||
| 1206 | QTime QLocale::toTime(const QString &string, const QString &format) const | - | ||||||||||||||||||||||||
| 1207 | { | - | ||||||||||||||||||||||||
| 1208 | QTime time; | - | ||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||
| 1210 | QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString); | - | ||||||||||||||||||||||||
| 1211 | dt.setDefaultLocale(*this); | - | ||||||||||||||||||||||||
| 1212 | if (dt.parseFormat(format)) | - | ||||||||||||||||||||||||
| 1213 | dt.fromString(string, 0, &time); | - | ||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||
| 1216 | - | |||||||||||||||||||||||||
| 1217 | - | |||||||||||||||||||||||||
| 1218 | return time; | - | ||||||||||||||||||||||||
| 1219 | } | - | ||||||||||||||||||||||||
| 1220 | QDate QLocale::toDate(const QString &string, const QString &format) const | - | ||||||||||||||||||||||||
| 1221 | { | - | ||||||||||||||||||||||||
| 1222 | QDate date; | - | ||||||||||||||||||||||||
| 1223 | - | |||||||||||||||||||||||||
| 1224 | QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString); | - | ||||||||||||||||||||||||
| 1225 | dt.setDefaultLocale(*this); | - | ||||||||||||||||||||||||
| 1226 | if (dt.parseFormat(format)) | - | ||||||||||||||||||||||||
| 1227 | dt.fromString(string, &date, 0); | - | ||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||
| 1229 | - | |||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||
| 1232 | return date; | - | ||||||||||||||||||||||||
| 1233 | } | - | ||||||||||||||||||||||||
| 1234 | QDateTime QLocale::toDateTime(const QString &string, const QString &format) const | - | ||||||||||||||||||||||||
| 1235 | { | - | ||||||||||||||||||||||||
| 1236 | - | |||||||||||||||||||||||||
| 1237 | QTime time; | - | ||||||||||||||||||||||||
| 1238 | QDate date; | - | ||||||||||||||||||||||||
| 1239 | - | |||||||||||||||||||||||||
| 1240 | QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString); | - | ||||||||||||||||||||||||
| 1241 | dt.setDefaultLocale(*this); | - | ||||||||||||||||||||||||
| 1242 | if (dt.parseFormat(format) && dt.fromString(string, &date, &time)) | - | ||||||||||||||||||||||||
| 1243 | return QDateTime(date, time); | - | ||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||
| 1246 | - | |||||||||||||||||||||||||
| 1247 | - | |||||||||||||||||||||||||
| 1248 | return QDateTime(QDate(), QTime(-1, -1, -1)); | - | ||||||||||||||||||||||||
| 1249 | } | - | ||||||||||||||||||||||||
| 1250 | QChar QLocale::decimalPoint() const | - | ||||||||||||||||||||||||
| 1251 | { | - | ||||||||||||||||||||||||
| 1252 | return d->decimal(); | - | ||||||||||||||||||||||||
| 1253 | } | - | ||||||||||||||||||||||||
| 1254 | - | |||||||||||||||||||||||||
| 1255 | - | |||||||||||||||||||||||||
| 1256 | - | |||||||||||||||||||||||||
| 1257 | - | |||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | - | |||||||||||||||||||||||||
| 1260 | QChar QLocale::groupSeparator() const | - | ||||||||||||||||||||||||
| 1261 | { | - | ||||||||||||||||||||||||
| 1262 | return d->group(); | - | ||||||||||||||||||||||||
| 1263 | } | - | ||||||||||||||||||||||||
| 1264 | - | |||||||||||||||||||||||||
| 1265 | - | |||||||||||||||||||||||||
| 1266 | - | |||||||||||||||||||||||||
| 1267 | - | |||||||||||||||||||||||||
| 1268 | - | |||||||||||||||||||||||||
| 1269 | - | |||||||||||||||||||||||||
| 1270 | QChar QLocale::percent() const | - | ||||||||||||||||||||||||
| 1271 | { | - | ||||||||||||||||||||||||
| 1272 | return d->percent(); | - | ||||||||||||||||||||||||
| 1273 | } | - | ||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||
| 1277 | - | |||||||||||||||||||||||||
| 1278 | - | |||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||
| 1280 | QChar QLocale::zeroDigit() const | - | ||||||||||||||||||||||||
| 1281 | { | - | ||||||||||||||||||||||||
| 1282 | return d->zero(); | - | ||||||||||||||||||||||||
| 1283 | } | - | ||||||||||||||||||||||||
| 1284 | - | |||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||
| 1286 | - | |||||||||||||||||||||||||
| 1287 | - | |||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||
| 1289 | - | |||||||||||||||||||||||||
| 1290 | QChar QLocale::negativeSign() const | - | ||||||||||||||||||||||||
| 1291 | { | - | ||||||||||||||||||||||||
| 1292 | return d->minus(); | - | ||||||||||||||||||||||||
| 1293 | } | - | ||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||
| 1295 | - | |||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||
| 1297 | - | |||||||||||||||||||||||||
| 1298 | - | |||||||||||||||||||||||||
| 1299 | - | |||||||||||||||||||||||||
| 1300 | QChar QLocale::positiveSign() const | - | ||||||||||||||||||||||||
| 1301 | { | - | ||||||||||||||||||||||||
| 1302 | return d->plus(); | - | ||||||||||||||||||||||||
| 1303 | } | - | ||||||||||||||||||||||||
| 1304 | - | |||||||||||||||||||||||||
| 1305 | - | |||||||||||||||||||||||||
| 1306 | - | |||||||||||||||||||||||||
| 1307 | - | |||||||||||||||||||||||||
| 1308 | - | |||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | QChar QLocale::exponential() const | - | ||||||||||||||||||||||||
| 1311 | { | - | ||||||||||||||||||||||||
| 1312 | return d->exponential(); | - | ||||||||||||||||||||||||
| 1313 | } | - | ||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||
| 1315 | static bool qIsUpper(char c) | - | ||||||||||||||||||||||||
| 1316 | { | - | ||||||||||||||||||||||||
| 1317 | return c >= 'A' && c <= 'Z'; | - | ||||||||||||||||||||||||
| 1318 | } | - | ||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||
| 1320 | static char qToLower(char c) | - | ||||||||||||||||||||||||
| 1321 | { | - | ||||||||||||||||||||||||
| 1322 | if (c >= 'A' && c <= 'Z') | - | ||||||||||||||||||||||||
| 1323 | return c - 'A' + 'a'; | - | ||||||||||||||||||||||||
| 1324 | else | - | ||||||||||||||||||||||||
| 1325 | return c; | - | ||||||||||||||||||||||||
| 1326 | } | - | ||||||||||||||||||||||||
| 1327 | QString QLocale::toString(double i, char f, int prec) const | - | ||||||||||||||||||||||||
| 1328 | { | - | ||||||||||||||||||||||||
| 1329 | QLocaleData::DoubleForm form = QLocaleData::DFDecimal; | - | ||||||||||||||||||||||||
| 1330 | uint flags = 0; | - | ||||||||||||||||||||||||
| 1331 | - | |||||||||||||||||||||||||
| 1332 | if (qIsUpper(f)
| 0-1272 | ||||||||||||||||||||||||
| 1333 | flags = QLocaleData::CapitalEorX; never executed: flags = QLocaleData::CapitalEorX; | 0 | ||||||||||||||||||||||||
| 1334 | f = qToLower(f); | - | ||||||||||||||||||||||||
| 1335 | - | |||||||||||||||||||||||||
| 1336 | switch (f) { | - | ||||||||||||||||||||||||
| 1337 | case executed 1197 times by 10 tests: 'f':case 'f':Executed by:
executed 1197 times by 10 tests: case 'f':Executed by:
| 1197 | ||||||||||||||||||||||||
| 1338 | form = QLocaleData::DFDecimal; | - | ||||||||||||||||||||||||
| 1339 | break; executed 1197 times by 10 tests: break;Executed by:
| 1197 | ||||||||||||||||||||||||
| 1340 | case never executed: 'e':case 'e':never executed: case 'e': | 0 | ||||||||||||||||||||||||
| 1341 | form = QLocaleData::DFExponent; | - | ||||||||||||||||||||||||
| 1342 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1343 | case executed 75 times by 3 tests: 'g':case 'g':Executed by:
executed 75 times by 3 tests: case 'g':Executed by:
| 75 | ||||||||||||||||||||||||
| 1344 | form = QLocaleData::DFSignificantDigits; | - | ||||||||||||||||||||||||
| 1345 | break; executed 75 times by 3 tests: break;Executed by:
| 75 | ||||||||||||||||||||||||
| 1346 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1347 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1348 | } | - | ||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||
| 1350 | if (!(d->m_numberOptions & OmitGroupSeparator)
| 587-685 | ||||||||||||||||||||||||
| 1351 | flags |= QLocaleData::ThousandsGroup; executed 587 times by 9 tests: flags |= QLocaleData::ThousandsGroup;Executed by:
| 587 | ||||||||||||||||||||||||
| 1352 | if (!(d->m_numberOptions & OmitLeadingZeroInExponent)
| 0-1272 | ||||||||||||||||||||||||
| 1353 | flags |= QLocaleData::ZeroPadExponent executed 1272 times by 10 tests: flags |= QLocaleData::ZeroPadExponent;Executed by:
executed 1272 times by 10 tests: ;flags |= QLocaleData::ZeroPadExponent;Executed by:
executed 1272 times by 10 tests: flags |= QLocaleData::ZeroPadExponent;Executed by:
| 1272 | ||||||||||||||||||||||||
| 1354 | return executed 1272 times by 10 tests: d->m_data->doubleToString(i, prec, form, -1, flags);return d->m_data->doubleToString(i, prec, form, -1, flags);Executed by:
executed 1272 times by 10 tests: return d->m_data->doubleToString(i, prec, form, -1, flags);Executed by:
| 1272 | ||||||||||||||||||||||||
| 1355 | } | - | ||||||||||||||||||||||||
| 1356 | QLocale QLocale::system() | - | ||||||||||||||||||||||||
| 1357 | { | - | ||||||||||||||||||||||||
| 1358 | return QLocale(*QLocalePrivate::create(systemData())); | - | ||||||||||||||||||||||||
| 1359 | } | - | ||||||||||||||||||||||||
| 1360 | QList<QLocale> QLocale::matchingLocales(QLocale::Language language, | - | ||||||||||||||||||||||||
| 1361 | QLocale::Script script, | - | ||||||||||||||||||||||||
| 1362 | QLocale::Country country) | - | ||||||||||||||||||||||||
| 1363 | { | - | ||||||||||||||||||||||||
| 1364 | if (uint(language) > QLocale::LastLanguage || uint(script) > QLocale::LastScript || | - | ||||||||||||||||||||||||
| 1365 | uint(country) > QLocale::LastCountry) | - | ||||||||||||||||||||||||
| 1366 | return QList<QLocale>(); | - | ||||||||||||||||||||||||
| 1367 | - | |||||||||||||||||||||||||
| 1368 | if (language == QLocale::C) | - | ||||||||||||||||||||||||
| 1369 | return QList<QLocale>() << QLocale(QLocale::C); | - | ||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||
| 1371 | QList<QLocale> result; | - | ||||||||||||||||||||||||
| 1372 | if (language == QLocale::AnyLanguage && script == QLocale::AnyScript && country == QLocale::AnyCountry) | - | ||||||||||||||||||||||||
| 1373 | result.reserve(locale_data_size); | - | ||||||||||||||||||||||||
| 1374 | const QLocaleData *data = locale_data + locale_index[language]; | - | ||||||||||||||||||||||||
| 1375 | while ( (data != locale_data + locale_data_size) | - | ||||||||||||||||||||||||
| 1376 | && (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) { | - | ||||||||||||||||||||||||
| 1377 | if ((script == QLocale::AnyScript || data->m_script_id == uint(script)) | - | ||||||||||||||||||||||||
| 1378 | && (country == QLocale::AnyCountry || data->m_country_id == uint(country))) { | - | ||||||||||||||||||||||||
| 1379 | QLocale locale(*QLocalePrivate::create(data)); | - | ||||||||||||||||||||||||
| 1380 | result.append(locale); | - | ||||||||||||||||||||||||
| 1381 | } | - | ||||||||||||||||||||||||
| 1382 | ++data; | - | ||||||||||||||||||||||||
| 1383 | } | - | ||||||||||||||||||||||||
| 1384 | return result; | - | ||||||||||||||||||||||||
| 1385 | } | - | ||||||||||||||||||||||||
| 1386 | QList<QLocale::Country> QLocale::countriesForLanguage(Language language) | - | ||||||||||||||||||||||||
| 1387 | { | - | ||||||||||||||||||||||||
| 1388 | QList<Country> result; | - | ||||||||||||||||||||||||
| 1389 | if (language == C) { | - | ||||||||||||||||||||||||
| 1390 | result << AnyCountry; | - | ||||||||||||||||||||||||
| 1391 | return result; | - | ||||||||||||||||||||||||
| 1392 | } | - | ||||||||||||||||||||||||
| 1393 | - | |||||||||||||||||||||||||
| 1394 | unsigned language_id = language; | - | ||||||||||||||||||||||||
| 1395 | const QLocaleData *data = locale_data + locale_index[language_id]; | - | ||||||||||||||||||||||||
| 1396 | while (data->m_language_id == language_id) { | - | ||||||||||||||||||||||||
| 1397 | const QLocale::Country country = static_cast<Country>(data->m_country_id); | - | ||||||||||||||||||||||||
| 1398 | if (!result.contains(country)) | - | ||||||||||||||||||||||||
| 1399 | result.append(country); | - | ||||||||||||||||||||||||
| 1400 | ++data; | - | ||||||||||||||||||||||||
| 1401 | } | - | ||||||||||||||||||||||||
| 1402 | - | |||||||||||||||||||||||||
| 1403 | return result; | - | ||||||||||||||||||||||||
| 1404 | } | - | ||||||||||||||||||||||||
| 1405 | QString QLocale::monthName(int month, FormatType type) const | - | ||||||||||||||||||||||||
| 1406 | { | - | ||||||||||||||||||||||||
| 1407 | if (month < 1 || month > 12) | - | ||||||||||||||||||||||||
| 1408 | return QString(); | - | ||||||||||||||||||||||||
| 1409 | - | |||||||||||||||||||||||||
| 1410 | - | |||||||||||||||||||||||||
| 1411 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1412 | QVariant res = systemLocale()->query(type == LongFormat | - | ||||||||||||||||||||||||
| 1413 | ? QSystemLocale::MonthNameLong : QSystemLocale::MonthNameShort, | - | ||||||||||||||||||||||||
| 1414 | month); | - | ||||||||||||||||||||||||
| 1415 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1416 | return res.toString(); | - | ||||||||||||||||||||||||
| 1417 | } | - | ||||||||||||||||||||||||
| 1418 | - | |||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||
| 1420 | quint32 idx, size; | - | ||||||||||||||||||||||||
| 1421 | switch (type) { | - | ||||||||||||||||||||||||
| 1422 | case QLocale::LongFormat: | - | ||||||||||||||||||||||||
| 1423 | idx = d->m_data->m_long_month_names_idx; | - | ||||||||||||||||||||||||
| 1424 | size = d->m_data->m_long_month_names_size; | - | ||||||||||||||||||||||||
| 1425 | break; | - | ||||||||||||||||||||||||
| 1426 | case QLocale::ShortFormat: | - | ||||||||||||||||||||||||
| 1427 | idx = d->m_data->m_short_month_names_idx; | - | ||||||||||||||||||||||||
| 1428 | size = d->m_data->m_short_month_names_size; | - | ||||||||||||||||||||||||
| 1429 | break; | - | ||||||||||||||||||||||||
| 1430 | case QLocale::NarrowFormat: | - | ||||||||||||||||||||||||
| 1431 | idx = d->m_data->m_narrow_month_names_idx; | - | ||||||||||||||||||||||||
| 1432 | size = d->m_data->m_narrow_month_names_size; | - | ||||||||||||||||||||||||
| 1433 | break; | - | ||||||||||||||||||||||||
| 1434 | default: | - | ||||||||||||||||||||||||
| 1435 | return QString(); | - | ||||||||||||||||||||||||
| 1436 | } | - | ||||||||||||||||||||||||
| 1437 | return getLocaleListData(months_data + idx, size, month - 1); | - | ||||||||||||||||||||||||
| 1438 | } | - | ||||||||||||||||||||||||
| 1439 | QString QLocale::standaloneMonthName(int month, FormatType type) const | - | ||||||||||||||||||||||||
| 1440 | { | - | ||||||||||||||||||||||||
| 1441 | if (month < 1 || month > 12) | - | ||||||||||||||||||||||||
| 1442 | return QString(); | - | ||||||||||||||||||||||||
| 1443 | - | |||||||||||||||||||||||||
| 1444 | - | |||||||||||||||||||||||||
| 1445 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1446 | QVariant res = systemLocale()->query(type == LongFormat | - | ||||||||||||||||||||||||
| 1447 | ? QSystemLocale::StandaloneMonthNameLong : QSystemLocale::StandaloneMonthNameShort, | - | ||||||||||||||||||||||||
| 1448 | month); | - | ||||||||||||||||||||||||
| 1449 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1450 | return res.toString(); | - | ||||||||||||||||||||||||
| 1451 | } | - | ||||||||||||||||||||||||
| 1452 | - | |||||||||||||||||||||||||
| 1453 | - | |||||||||||||||||||||||||
| 1454 | quint32 idx, size; | - | ||||||||||||||||||||||||
| 1455 | switch (type) { | - | ||||||||||||||||||||||||
| 1456 | case QLocale::LongFormat: | - | ||||||||||||||||||||||||
| 1457 | idx = d->m_data->m_standalone_long_month_names_idx; | - | ||||||||||||||||||||||||
| 1458 | size = d->m_data->m_standalone_long_month_names_size; | - | ||||||||||||||||||||||||
| 1459 | break; | - | ||||||||||||||||||||||||
| 1460 | case QLocale::ShortFormat: | - | ||||||||||||||||||||||||
| 1461 | idx = d->m_data->m_standalone_short_month_names_idx; | - | ||||||||||||||||||||||||
| 1462 | size = d->m_data->m_standalone_short_month_names_size; | - | ||||||||||||||||||||||||
| 1463 | break; | - | ||||||||||||||||||||||||
| 1464 | case QLocale::NarrowFormat: | - | ||||||||||||||||||||||||
| 1465 | idx = d->m_data->m_standalone_narrow_month_names_idx; | - | ||||||||||||||||||||||||
| 1466 | size = d->m_data->m_standalone_narrow_month_names_size; | - | ||||||||||||||||||||||||
| 1467 | break; | - | ||||||||||||||||||||||||
| 1468 | default: | - | ||||||||||||||||||||||||
| 1469 | return QString(); | - | ||||||||||||||||||||||||
| 1470 | } | - | ||||||||||||||||||||||||
| 1471 | QString name = getLocaleListData(months_data + idx, size, month - 1); | - | ||||||||||||||||||||||||
| 1472 | if (name.isEmpty()) | - | ||||||||||||||||||||||||
| 1473 | return monthName(month, type); | - | ||||||||||||||||||||||||
| 1474 | return name; | - | ||||||||||||||||||||||||
| 1475 | } | - | ||||||||||||||||||||||||
| 1476 | QString QLocale::dayName(int day, FormatType type) const | - | ||||||||||||||||||||||||
| 1477 | { | - | ||||||||||||||||||||||||
| 1478 | if (day < 1 || day > 7) | - | ||||||||||||||||||||||||
| 1479 | return QString(); | - | ||||||||||||||||||||||||
| 1480 | - | |||||||||||||||||||||||||
| 1481 | - | |||||||||||||||||||||||||
| 1482 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1483 | QVariant res = systemLocale()->query(type == LongFormat | - | ||||||||||||||||||||||||
| 1484 | ? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort, | - | ||||||||||||||||||||||||
| 1485 | day); | - | ||||||||||||||||||||||||
| 1486 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1487 | return res.toString(); | - | ||||||||||||||||||||||||
| 1488 | } | - | ||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||
| 1490 | if (day == 7) | - | ||||||||||||||||||||||||
| 1491 | day = 0; | - | ||||||||||||||||||||||||
| 1492 | - | |||||||||||||||||||||||||
| 1493 | quint32 idx, size; | - | ||||||||||||||||||||||||
| 1494 | switch (type) { | - | ||||||||||||||||||||||||
| 1495 | case QLocale::LongFormat: | - | ||||||||||||||||||||||||
| 1496 | idx = d->m_data->m_long_day_names_idx; | - | ||||||||||||||||||||||||
| 1497 | size = d->m_data->m_long_day_names_size; | - | ||||||||||||||||||||||||
| 1498 | break; | - | ||||||||||||||||||||||||
| 1499 | case QLocale::ShortFormat: | - | ||||||||||||||||||||||||
| 1500 | idx = d->m_data->m_short_day_names_idx; | - | ||||||||||||||||||||||||
| 1501 | size = d->m_data->m_short_day_names_size; | - | ||||||||||||||||||||||||
| 1502 | break; | - | ||||||||||||||||||||||||
| 1503 | case QLocale::NarrowFormat: | - | ||||||||||||||||||||||||
| 1504 | idx = d->m_data->m_narrow_day_names_idx; | - | ||||||||||||||||||||||||
| 1505 | size = d->m_data->m_narrow_day_names_size; | - | ||||||||||||||||||||||||
| 1506 | break; | - | ||||||||||||||||||||||||
| 1507 | default: | - | ||||||||||||||||||||||||
| 1508 | return QString(); | - | ||||||||||||||||||||||||
| 1509 | } | - | ||||||||||||||||||||||||
| 1510 | return getLocaleListData(days_data + idx, size, day); | - | ||||||||||||||||||||||||
| 1511 | } | - | ||||||||||||||||||||||||
| 1512 | QString QLocale::standaloneDayName(int day, FormatType type) const | - | ||||||||||||||||||||||||
| 1513 | { | - | ||||||||||||||||||||||||
| 1514 | if (day < 1 || day > 7) | - | ||||||||||||||||||||||||
| 1515 | return QString(); | - | ||||||||||||||||||||||||
| 1516 | - | |||||||||||||||||||||||||
| 1517 | - | |||||||||||||||||||||||||
| 1518 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1519 | QVariant res = systemLocale()->query(type == LongFormat | - | ||||||||||||||||||||||||
| 1520 | ? QSystemLocale::DayNameLong : QSystemLocale::DayNameShort, | - | ||||||||||||||||||||||||
| 1521 | day); | - | ||||||||||||||||||||||||
| 1522 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1523 | return res.toString(); | - | ||||||||||||||||||||||||
| 1524 | } | - | ||||||||||||||||||||||||
| 1525 | - | |||||||||||||||||||||||||
| 1526 | if (day == 7) | - | ||||||||||||||||||||||||
| 1527 | day = 0; | - | ||||||||||||||||||||||||
| 1528 | - | |||||||||||||||||||||||||
| 1529 | quint32 idx, size; | - | ||||||||||||||||||||||||
| 1530 | switch (type) { | - | ||||||||||||||||||||||||
| 1531 | case QLocale::LongFormat: | - | ||||||||||||||||||||||||
| 1532 | idx = d->m_data->m_standalone_long_day_names_idx; | - | ||||||||||||||||||||||||
| 1533 | size = d->m_data->m_standalone_long_day_names_size; | - | ||||||||||||||||||||||||
| 1534 | break; | - | ||||||||||||||||||||||||
| 1535 | case QLocale::ShortFormat: | - | ||||||||||||||||||||||||
| 1536 | idx = d->m_data->m_standalone_short_day_names_idx; | - | ||||||||||||||||||||||||
| 1537 | size = d->m_data->m_standalone_short_day_names_size; | - | ||||||||||||||||||||||||
| 1538 | break; | - | ||||||||||||||||||||||||
| 1539 | case QLocale::NarrowFormat: | - | ||||||||||||||||||||||||
| 1540 | idx = d->m_data->m_standalone_narrow_day_names_idx; | - | ||||||||||||||||||||||||
| 1541 | size = d->m_data->m_standalone_narrow_day_names_size; | - | ||||||||||||||||||||||||
| 1542 | break; | - | ||||||||||||||||||||||||
| 1543 | default: | - | ||||||||||||||||||||||||
| 1544 | return QString(); | - | ||||||||||||||||||||||||
| 1545 | } | - | ||||||||||||||||||||||||
| 1546 | QString name = getLocaleListData(days_data + idx, size, day); | - | ||||||||||||||||||||||||
| 1547 | if (name.isEmpty()) | - | ||||||||||||||||||||||||
| 1548 | return dayName(day == 0 ? 7 : day, type); | - | ||||||||||||||||||||||||
| 1549 | return name; | - | ||||||||||||||||||||||||
| 1550 | } | - | ||||||||||||||||||||||||
| 1551 | - | |||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||
| 1553 | - | |||||||||||||||||||||||||
| 1554 | - | |||||||||||||||||||||||||
| 1555 | - | |||||||||||||||||||||||||
| 1556 | - | |||||||||||||||||||||||||
| 1557 | Qt::DayOfWeek QLocale::firstDayOfWeek() const | - | ||||||||||||||||||||||||
| 1558 | { | - | ||||||||||||||||||||||||
| 1559 | - | |||||||||||||||||||||||||
| 1560 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1561 | QVariant res = systemLocale()->query(QSystemLocale::FirstDayOfWeek, QVariant()); | - | ||||||||||||||||||||||||
| 1562 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1563 | return static_cast<Qt::DayOfWeek>(res.toUInt()); | - | ||||||||||||||||||||||||
| 1564 | } | - | ||||||||||||||||||||||||
| 1565 | - | |||||||||||||||||||||||||
| 1566 | return static_cast<Qt::DayOfWeek>(d->m_data->m_first_day_of_week); | - | ||||||||||||||||||||||||
| 1567 | } | - | ||||||||||||||||||||||||
| 1568 | - | |||||||||||||||||||||||||
| 1569 | QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const | - | ||||||||||||||||||||||||
| 1570 | { | - | ||||||||||||||||||||||||
| 1571 | for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) { | - | ||||||||||||||||||||||||
| 1572 | if (ImperialMeasurementSystems[i].languageId == m_data->m_language_id | - | ||||||||||||||||||||||||
| 1573 | && ImperialMeasurementSystems[i].countryId == m_data->m_country_id) { | - | ||||||||||||||||||||||||
| 1574 | return ImperialMeasurementSystems[i].system; | - | ||||||||||||||||||||||||
| 1575 | } | - | ||||||||||||||||||||||||
| 1576 | } | - | ||||||||||||||||||||||||
| 1577 | return QLocale::MetricSystem; | - | ||||||||||||||||||||||||
| 1578 | } | - | ||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||
| 1580 | - | |||||||||||||||||||||||||
| 1581 | - | |||||||||||||||||||||||||
| 1582 | - | |||||||||||||||||||||||||
| 1583 | - | |||||||||||||||||||||||||
| 1584 | - | |||||||||||||||||||||||||
| 1585 | QList<Qt::DayOfWeek> QLocale::weekdays() const | - | ||||||||||||||||||||||||
| 1586 | { | - | ||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||
| 1588 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1589 | QVariant res = systemLocale()->query(QSystemLocale::Weekdays, QVariant()); | - | ||||||||||||||||||||||||
| 1590 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1591 | return static_cast<QList<Qt::DayOfWeek> >(res.value<QList<Qt::DayOfWeek> >()); | - | ||||||||||||||||||||||||
| 1592 | } | - | ||||||||||||||||||||||||
| 1593 | - | |||||||||||||||||||||||||
| 1594 | QList<Qt::DayOfWeek> weekdays; | - | ||||||||||||||||||||||||
| 1595 | quint16 weekendStart = d->m_data->m_weekend_start; | - | ||||||||||||||||||||||||
| 1596 | quint16 weekendEnd = d->m_data->m_weekend_end; | - | ||||||||||||||||||||||||
| 1597 | for (int day = Qt::Monday; day <= Qt::Sunday; day++) { | - | ||||||||||||||||||||||||
| 1598 | if ((weekendEnd >= weekendStart && (day < weekendStart || day > weekendEnd)) || | - | ||||||||||||||||||||||||
| 1599 | (weekendEnd < weekendStart && (day > weekendEnd && day < weekendStart))) | - | ||||||||||||||||||||||||
| 1600 | weekdays << static_cast<Qt::DayOfWeek>(day); | - | ||||||||||||||||||||||||
| 1601 | } | - | ||||||||||||||||||||||||
| 1602 | return weekdays; | - | ||||||||||||||||||||||||
| 1603 | } | - | ||||||||||||||||||||||||
| 1604 | - | |||||||||||||||||||||||||
| 1605 | - | |||||||||||||||||||||||||
| 1606 | - | |||||||||||||||||||||||||
| 1607 | - | |||||||||||||||||||||||||
| 1608 | - | |||||||||||||||||||||||||
| 1609 | - | |||||||||||||||||||||||||
| 1610 | QLocale::MeasurementSystem QLocale::measurementSystem() const | - | ||||||||||||||||||||||||
| 1611 | { | - | ||||||||||||||||||||||||
| 1612 | - | |||||||||||||||||||||||||
| 1613 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1614 | QVariant res = systemLocale()->query(QSystemLocale::MeasurementSystem, QVariant()); | - | ||||||||||||||||||||||||
| 1615 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1616 | return MeasurementSystem(res.toInt()); | - | ||||||||||||||||||||||||
| 1617 | } | - | ||||||||||||||||||||||||
| 1618 | - | |||||||||||||||||||||||||
| 1619 | - | |||||||||||||||||||||||||
| 1620 | return d->measurementSystem(); | - | ||||||||||||||||||||||||
| 1621 | } | - | ||||||||||||||||||||||||
| 1622 | - | |||||||||||||||||||||||||
| 1623 | - | |||||||||||||||||||||||||
| 1624 | - | |||||||||||||||||||||||||
| 1625 | - | |||||||||||||||||||||||||
| 1626 | - | |||||||||||||||||||||||||
| 1627 | - | |||||||||||||||||||||||||
| 1628 | Qt::LayoutDirection QLocale::textDirection() const | - | ||||||||||||||||||||||||
| 1629 | { | - | ||||||||||||||||||||||||
| 1630 | switch (script()) { | - | ||||||||||||||||||||||||
| 1631 | case never executed: case QLocale::AdlamScript:never executed: QLocale::AdlamScript:case QLocale::AdlamScript:never executed: case QLocale::AdlamScript: | 0 | ||||||||||||||||||||||||
| 1632 | case never executed: QLocale::ArabicScript:case QLocale::ArabicScript:never executed: case QLocale::ArabicScript: | 0 | ||||||||||||||||||||||||
| 1633 | case never executed: QLocale::AvestanScript:case QLocale::AvestanScript:never executed: case QLocale::AvestanScript: | 0 | ||||||||||||||||||||||||
| 1634 | case never executed: QLocale::CypriotScript:case QLocale::CypriotScript:never executed: case QLocale::CypriotScript: | 0 | ||||||||||||||||||||||||
| 1635 | case never executed: QLocale::HatranScriptcase QLocale::HatranScript:never executed: :case QLocale::HatranScript:never executed: case QLocale::HatranScript: | 0 | ||||||||||||||||||||||||
| 1636 | case never executed: QLocale::HebrewScript:case QLocale::HebrewScript:never executed: case QLocale::HebrewScript: | 0 | ||||||||||||||||||||||||
| 1637 | case never executed: QLocale::ImperialAramaicScript:case QLocale::ImperialAramaicScript:never executed: case QLocale::ImperialAramaicScript: | 0 | ||||||||||||||||||||||||
| 1638 | case never executed: QLocale::InscriptionalPahlaviScript:case QLocale::InscriptionalPahlaviScript:never executed: case QLocale::InscriptionalPahlaviScript: | 0 | ||||||||||||||||||||||||
| 1639 | case never executed: QLocale::InscriptionalParthianScript:case QLocale::InscriptionalParthianScript:never executed: case QLocale::InscriptionalParthianScript: | 0 | ||||||||||||||||||||||||
| 1640 | case never executed: QLocale::KharoshthiScript:case QLocale::KharoshthiScript:never executed: case QLocale::KharoshthiScript: | 0 | ||||||||||||||||||||||||
| 1641 | case never executed: QLocale::LydianScript:case QLocale::LydianScript:never executed: case QLocale::LydianScript: | 0 | ||||||||||||||||||||||||
| 1642 | case never executed: QLocale::MandaeanScript:case QLocale::MandaeanScript:never executed: case QLocale::MandaeanScript: | 0 | ||||||||||||||||||||||||
| 1643 | case never executed: QLocale::ManichaeanScript:case QLocale::ManichaeanScript:never executed: case QLocale::ManichaeanScript: | 0 | ||||||||||||||||||||||||
| 1644 | case never executed: QLocale::MendeKikakuiScript:case QLocale::MendeKikakuiScript:never executed: case QLocale::MendeKikakuiScript: | 0 | ||||||||||||||||||||||||
| 1645 | case never executed: QLocale::MeroiticCursiveScript:case QLocale::MeroiticCursiveScript:never executed: case QLocale::MeroiticCursiveScript: | 0 | ||||||||||||||||||||||||
| 1646 | case never executed: QLocale::MeroiticScript:case QLocale::MeroiticScript:never executed: case QLocale::MeroiticScript: | 0 | ||||||||||||||||||||||||
| 1647 | case never executed: QLocale::NabataeanScript:case QLocale::NabataeanScript:never executed: case QLocale::NabataeanScript: | 0 | ||||||||||||||||||||||||
| 1648 | case never executed: QLocale::NkoScript:case QLocale::NkoScript:never executed: case QLocale::NkoScript: | 0 | ||||||||||||||||||||||||
| 1649 | case never executed: QLocale::OldHungarianScriptcase QLocale::OldHungarianScript:never executed: :case QLocale::OldHungarianScript:never executed: case QLocale::OldHungarianScript: | 0 | ||||||||||||||||||||||||
| 1650 | case never executed: QLocale::OldNorthArabianScript:case QLocale::OldNorthArabianScript:never executed: case QLocale::OldNorthArabianScript: | 0 | ||||||||||||||||||||||||
| 1651 | case never executed: QLocale::OldSouthArabianScript:case QLocale::OldSouthArabianScript:never executed: case QLocale::OldSouthArabianScript: | 0 | ||||||||||||||||||||||||
| 1652 | case never executed: QLocale::OrkhonScript:case QLocale::OrkhonScript:never executed: case QLocale::OrkhonScript: | 0 | ||||||||||||||||||||||||
| 1653 | case never executed: QLocale::PalmyreneScript:case QLocale::PalmyreneScript:never executed: case QLocale::PalmyreneScript: | 0 | ||||||||||||||||||||||||
| 1654 | case never executed: QLocale::PhoenicianScript:case QLocale::PhoenicianScript:never executed: case QLocale::PhoenicianScript: | 0 | ||||||||||||||||||||||||
| 1655 | case never executed: QLocale::PsalterPahlaviScript:case QLocale::PsalterPahlaviScript:never executed: case QLocale::PsalterPahlaviScript: | 0 | ||||||||||||||||||||||||
| 1656 | case never executed: QLocale::SamaritanScript:case QLocale::SamaritanScript:never executed: case QLocale::SamaritanScript: | 0 | ||||||||||||||||||||||||
| 1657 | case never executed: QLocale::SyriacScript:case QLocale::SyriacScript:never executed: case QLocale::SyriacScript: | 0 | ||||||||||||||||||||||||
| 1658 | case never executed: QLocale::ThaanaScript:case QLocale::ThaanaScript:never executed: case QLocale::ThaanaScript: | 0 | ||||||||||||||||||||||||
| 1659 | return never executed: Qt::RightToLeft;return Qt::RightToLeft;never executed: return Qt::RightToLeft; | 0 | ||||||||||||||||||||||||
| 1660 | default executed 34 times by 34 tests: :default:Executed by:
executed 34 times by 34 tests: default:Executed by:
| 34 | ||||||||||||||||||||||||
| 1661 | break; executed 34 times by 34 tests: break;Executed by:
| 34 | ||||||||||||||||||||||||
| 1662 | } | - | ||||||||||||||||||||||||
| 1663 | return executed 34 times by 34 tests: Qt::LeftToRight;return Qt::LeftToRight;Executed by:
executed 34 times by 34 tests: return Qt::LeftToRight;Executed by:
| 34 | ||||||||||||||||||||||||
| 1664 | } | - | ||||||||||||||||||||||||
| 1665 | QString QLocale::toUpper(const QString &str) const | - | ||||||||||||||||||||||||
| 1666 | { | - | ||||||||||||||||||||||||
| 1667 | - | |||||||||||||||||||||||||
| 1668 | bool ok = true; | - | ||||||||||||||||||||||||
| 1669 | QString result = QIcu::toUpper(d->bcp47Name('_'), str, &ok); | - | ||||||||||||||||||||||||
| 1670 | if (ok) | - | ||||||||||||||||||||||||
| 1671 | return result; | - | ||||||||||||||||||||||||
| 1672 | - | |||||||||||||||||||||||||
| 1673 | - | |||||||||||||||||||||||||
| 1674 | return str.toUpper(); | - | ||||||||||||||||||||||||
| 1675 | } | - | ||||||||||||||||||||||||
| 1676 | QString QLocale::toLower(const QString &str) const | - | ||||||||||||||||||||||||
| 1677 | { | - | ||||||||||||||||||||||||
| 1678 | - | |||||||||||||||||||||||||
| 1679 | bool ok = true; | - | ||||||||||||||||||||||||
| 1680 | const QString result = QIcu::toLower(d->bcp47Name('_'), str, &ok); | - | ||||||||||||||||||||||||
| 1681 | if (ok) | - | ||||||||||||||||||||||||
| 1682 | return result; | - | ||||||||||||||||||||||||
| 1683 | - | |||||||||||||||||||||||||
| 1684 | - | |||||||||||||||||||||||||
| 1685 | return str.toLower(); | - | ||||||||||||||||||||||||
| 1686 | } | - | ||||||||||||||||||||||||
| 1687 | QString QLocale::amText() const | - | ||||||||||||||||||||||||
| 1688 | { | - | ||||||||||||||||||||||||
| 1689 | - | |||||||||||||||||||||||||
| 1690 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1691 | QVariant res = systemLocale()->query(QSystemLocale::AMText, QVariant()); | - | ||||||||||||||||||||||||
| 1692 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1693 | return res.toString(); | - | ||||||||||||||||||||||||
| 1694 | } | - | ||||||||||||||||||||||||
| 1695 | - | |||||||||||||||||||||||||
| 1696 | return getLocaleData(am_data + d->m_data->m_am_idx, d->m_data->m_am_size); | - | ||||||||||||||||||||||||
| 1697 | } | - | ||||||||||||||||||||||||
| 1698 | QString QLocale::pmText() const | - | ||||||||||||||||||||||||
| 1699 | { | - | ||||||||||||||||||||||||
| 1700 | - | |||||||||||||||||||||||||
| 1701 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 1702 | QVariant res = systemLocale()->query(QSystemLocale::PMText, QVariant()); | - | ||||||||||||||||||||||||
| 1703 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 1704 | return res.toString(); | - | ||||||||||||||||||||||||
| 1705 | } | - | ||||||||||||||||||||||||
| 1706 | - | |||||||||||||||||||||||||
| 1707 | return getLocaleData(pm_data + d->m_data->m_pm_idx, d->m_data->m_pm_size); | - | ||||||||||||||||||||||||
| 1708 | } | - | ||||||||||||||||||||||||
| 1709 | - | |||||||||||||||||||||||||
| 1710 | - | |||||||||||||||||||||||||
| 1711 | QString QLocalePrivate::dateTimeToString(const QString &format, const QDateTime &datetime, | - | ||||||||||||||||||||||||
| 1712 | const QDate &dateOnly, const QTime &timeOnly, | - | ||||||||||||||||||||||||
| 1713 | const QLocale *q) const | - | ||||||||||||||||||||||||
| 1714 | { | - | ||||||||||||||||||||||||
| 1715 | QDate date; | - | ||||||||||||||||||||||||
| 1716 | QTime time; | - | ||||||||||||||||||||||||
| 1717 | bool formatDate = false; | - | ||||||||||||||||||||||||
| 1718 | bool formatTime = false; | - | ||||||||||||||||||||||||
| 1719 | if (datetime.isValid()) { | - | ||||||||||||||||||||||||
| 1720 | date = datetime.date(); | - | ||||||||||||||||||||||||
| 1721 | time = datetime.time(); | - | ||||||||||||||||||||||||
| 1722 | formatDate = true; | - | ||||||||||||||||||||||||
| 1723 | formatTime = true; | - | ||||||||||||||||||||||||
| 1724 | } else if (dateOnly.isValid()) { | - | ||||||||||||||||||||||||
| 1725 | date = dateOnly; | - | ||||||||||||||||||||||||
| 1726 | formatDate = true; | - | ||||||||||||||||||||||||
| 1727 | } else if (timeOnly.isValid()) { | - | ||||||||||||||||||||||||
| 1728 | time = timeOnly; | - | ||||||||||||||||||||||||
| 1729 | formatTime = true; | - | ||||||||||||||||||||||||
| 1730 | } else { | - | ||||||||||||||||||||||||
| 1731 | return QString(); | - | ||||||||||||||||||||||||
| 1732 | } | - | ||||||||||||||||||||||||
| 1733 | - | |||||||||||||||||||||||||
| 1734 | QString result; | - | ||||||||||||||||||||||||
| 1735 | - | |||||||||||||||||||||||||
| 1736 | int i = 0; | - | ||||||||||||||||||||||||
| 1737 | while (i < format.size()) { | - | ||||||||||||||||||||||||
| 1738 | if (format.at(i).unicode() == '\'') { | - | ||||||||||||||||||||||||
| 1739 | result.append(qt_readEscapedFormatString(format, &i)); | - | ||||||||||||||||||||||||
| 1740 | continue; | - | ||||||||||||||||||||||||
| 1741 | } | - | ||||||||||||||||||||||||
| 1742 | - | |||||||||||||||||||||||||
| 1743 | const QChar c = format.at(i); | - | ||||||||||||||||||||||||
| 1744 | int repeat = qt_repeatCount(format, i); | - | ||||||||||||||||||||||||
| 1745 | bool used = false; | - | ||||||||||||||||||||||||
| 1746 | if (formatDate) { | - | ||||||||||||||||||||||||
| 1747 | switch (c.unicode()) { | - | ||||||||||||||||||||||||
| 1748 | case 'y': | - | ||||||||||||||||||||||||
| 1749 | used = true; | - | ||||||||||||||||||||||||
| 1750 | if (repeat >= 4) | - | ||||||||||||||||||||||||
| 1751 | repeat = 4; | - | ||||||||||||||||||||||||
| 1752 | else if (repeat >= 2) | - | ||||||||||||||||||||||||
| 1753 | repeat = 2; | - | ||||||||||||||||||||||||
| 1754 | - | |||||||||||||||||||||||||
| 1755 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1756 | case 4: { | - | ||||||||||||||||||||||||
| 1757 | const int yr = date.year(); | - | ||||||||||||||||||||||||
| 1758 | const int len = (yr < 0) ? 5 : 4; | - | ||||||||||||||||||||||||
| 1759 | result.append(m_data->longLongToString(yr, -1, 10, len, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1760 | break; | - | ||||||||||||||||||||||||
| 1761 | } | - | ||||||||||||||||||||||||
| 1762 | case 2: | - | ||||||||||||||||||||||||
| 1763 | result.append(m_data->longLongToString(date.year() % 100, -1, 10, 2, | - | ||||||||||||||||||||||||
| 1764 | QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1765 | break; | - | ||||||||||||||||||||||||
| 1766 | default: | - | ||||||||||||||||||||||||
| 1767 | repeat = 1; | - | ||||||||||||||||||||||||
| 1768 | result.append(c); | - | ||||||||||||||||||||||||
| 1769 | break; | - | ||||||||||||||||||||||||
| 1770 | } | - | ||||||||||||||||||||||||
| 1771 | break; | - | ||||||||||||||||||||||||
| 1772 | - | |||||||||||||||||||||||||
| 1773 | case 'M': | - | ||||||||||||||||||||||||
| 1774 | used = true; | - | ||||||||||||||||||||||||
| 1775 | repeat = qMin(repeat, 4); | - | ||||||||||||||||||||||||
| 1776 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1777 | case 1: | - | ||||||||||||||||||||||||
| 1778 | result.append(m_data->longLongToString(date.month())); | - | ||||||||||||||||||||||||
| 1779 | break; | - | ||||||||||||||||||||||||
| 1780 | case 2: | - | ||||||||||||||||||||||||
| 1781 | result.append(m_data->longLongToString(date.month(), -1, 10, 2, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1782 | break; | - | ||||||||||||||||||||||||
| 1783 | case 3: | - | ||||||||||||||||||||||||
| 1784 | result.append(q->monthName(date.month(), QLocale::ShortFormat)); | - | ||||||||||||||||||||||||
| 1785 | break; | - | ||||||||||||||||||||||||
| 1786 | case 4: | - | ||||||||||||||||||||||||
| 1787 | result.append(q->monthName(date.month(), QLocale::LongFormat)); | - | ||||||||||||||||||||||||
| 1788 | break; | - | ||||||||||||||||||||||||
| 1789 | } | - | ||||||||||||||||||||||||
| 1790 | break; | - | ||||||||||||||||||||||||
| 1791 | - | |||||||||||||||||||||||||
| 1792 | case 'd': | - | ||||||||||||||||||||||||
| 1793 | used = true; | - | ||||||||||||||||||||||||
| 1794 | repeat = qMin(repeat, 4); | - | ||||||||||||||||||||||||
| 1795 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1796 | case 1: | - | ||||||||||||||||||||||||
| 1797 | result.append(m_data->longLongToString(date.day())); | - | ||||||||||||||||||||||||
| 1798 | break; | - | ||||||||||||||||||||||||
| 1799 | case 2: | - | ||||||||||||||||||||||||
| 1800 | result.append(m_data->longLongToString(date.day(), -1, 10, 2, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1801 | break; | - | ||||||||||||||||||||||||
| 1802 | case 3: | - | ||||||||||||||||||||||||
| 1803 | result.append(q->dayName(date.dayOfWeek(), QLocale::ShortFormat)); | - | ||||||||||||||||||||||||
| 1804 | break; | - | ||||||||||||||||||||||||
| 1805 | case 4: | - | ||||||||||||||||||||||||
| 1806 | result.append(q->dayName(date.dayOfWeek(), QLocale::LongFormat)); | - | ||||||||||||||||||||||||
| 1807 | break; | - | ||||||||||||||||||||||||
| 1808 | } | - | ||||||||||||||||||||||||
| 1809 | break; | - | ||||||||||||||||||||||||
| 1810 | - | |||||||||||||||||||||||||
| 1811 | default: | - | ||||||||||||||||||||||||
| 1812 | break; | - | ||||||||||||||||||||||||
| 1813 | } | - | ||||||||||||||||||||||||
| 1814 | } | - | ||||||||||||||||||||||||
| 1815 | if (!used && formatTime) { | - | ||||||||||||||||||||||||
| 1816 | switch (c.unicode()) { | - | ||||||||||||||||||||||||
| 1817 | case 'h': { | - | ||||||||||||||||||||||||
| 1818 | used = true; | - | ||||||||||||||||||||||||
| 1819 | repeat = qMin(repeat, 2); | - | ||||||||||||||||||||||||
| 1820 | int hour = time.hour(); | - | ||||||||||||||||||||||||
| 1821 | if (timeFormatContainsAP(format)) { | - | ||||||||||||||||||||||||
| 1822 | if (hour > 12) | - | ||||||||||||||||||||||||
| 1823 | hour -= 12; | - | ||||||||||||||||||||||||
| 1824 | else if (hour == 0) | - | ||||||||||||||||||||||||
| 1825 | hour = 12; | - | ||||||||||||||||||||||||
| 1826 | } | - | ||||||||||||||||||||||||
| 1827 | - | |||||||||||||||||||||||||
| 1828 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1829 | case 1: | - | ||||||||||||||||||||||||
| 1830 | result.append(m_data->longLongToString(hour)); | - | ||||||||||||||||||||||||
| 1831 | break; | - | ||||||||||||||||||||||||
| 1832 | case 2: | - | ||||||||||||||||||||||||
| 1833 | result.append(m_data->longLongToString(hour, -1, 10, 2, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1834 | break; | - | ||||||||||||||||||||||||
| 1835 | } | - | ||||||||||||||||||||||||
| 1836 | break; | - | ||||||||||||||||||||||||
| 1837 | } | - | ||||||||||||||||||||||||
| 1838 | case 'H': | - | ||||||||||||||||||||||||
| 1839 | used = true; | - | ||||||||||||||||||||||||
| 1840 | repeat = qMin(repeat, 2); | - | ||||||||||||||||||||||||
| 1841 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1842 | case 1: | - | ||||||||||||||||||||||||
| 1843 | result.append(m_data->longLongToString(time.hour())); | - | ||||||||||||||||||||||||
| 1844 | break; | - | ||||||||||||||||||||||||
| 1845 | case 2: | - | ||||||||||||||||||||||||
| 1846 | result.append(m_data->longLongToString(time.hour(), -1, 10, 2, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1847 | break; | - | ||||||||||||||||||||||||
| 1848 | } | - | ||||||||||||||||||||||||
| 1849 | break; | - | ||||||||||||||||||||||||
| 1850 | - | |||||||||||||||||||||||||
| 1851 | case 'm': | - | ||||||||||||||||||||||||
| 1852 | used = true; | - | ||||||||||||||||||||||||
| 1853 | repeat = qMin(repeat, 2); | - | ||||||||||||||||||||||||
| 1854 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1855 | case 1: | - | ||||||||||||||||||||||||
| 1856 | result.append(m_data->longLongToString(time.minute())); | - | ||||||||||||||||||||||||
| 1857 | break; | - | ||||||||||||||||||||||||
| 1858 | case 2: | - | ||||||||||||||||||||||||
| 1859 | result.append(m_data->longLongToString(time.minute(), -1, 10, 2, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1860 | break; | - | ||||||||||||||||||||||||
| 1861 | } | - | ||||||||||||||||||||||||
| 1862 | break; | - | ||||||||||||||||||||||||
| 1863 | - | |||||||||||||||||||||||||
| 1864 | case 's': | - | ||||||||||||||||||||||||
| 1865 | used = true; | - | ||||||||||||||||||||||||
| 1866 | repeat = qMin(repeat, 2); | - | ||||||||||||||||||||||||
| 1867 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1868 | case 1: | - | ||||||||||||||||||||||||
| 1869 | result.append(m_data->longLongToString(time.second())); | - | ||||||||||||||||||||||||
| 1870 | break; | - | ||||||||||||||||||||||||
| 1871 | case 2: | - | ||||||||||||||||||||||||
| 1872 | result.append(m_data->longLongToString(time.second(), -1, 10, 2, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1873 | break; | - | ||||||||||||||||||||||||
| 1874 | } | - | ||||||||||||||||||||||||
| 1875 | break; | - | ||||||||||||||||||||||||
| 1876 | - | |||||||||||||||||||||||||
| 1877 | case 'a': | - | ||||||||||||||||||||||||
| 1878 | used = true; | - | ||||||||||||||||||||||||
| 1879 | if (i + 1 < format.length() && format.at(i + 1).unicode() == 'p') { | - | ||||||||||||||||||||||||
| 1880 | repeat = 2; | - | ||||||||||||||||||||||||
| 1881 | } else { | - | ||||||||||||||||||||||||
| 1882 | repeat = 1; | - | ||||||||||||||||||||||||
| 1883 | } | - | ||||||||||||||||||||||||
| 1884 | result.append(time.hour() < 12 ? q->amText().toLower() : q->pmText().toLower()); | - | ||||||||||||||||||||||||
| 1885 | break; | - | ||||||||||||||||||||||||
| 1886 | - | |||||||||||||||||||||||||
| 1887 | case 'A': | - | ||||||||||||||||||||||||
| 1888 | used = true; | - | ||||||||||||||||||||||||
| 1889 | if (i + 1 < format.length() && format.at(i + 1).unicode() == 'P') { | - | ||||||||||||||||||||||||
| 1890 | repeat = 2; | - | ||||||||||||||||||||||||
| 1891 | } else { | - | ||||||||||||||||||||||||
| 1892 | repeat = 1; | - | ||||||||||||||||||||||||
| 1893 | } | - | ||||||||||||||||||||||||
| 1894 | result.append(time.hour() < 12 ? q->amText().toUpper() : q->pmText().toUpper()); | - | ||||||||||||||||||||||||
| 1895 | break; | - | ||||||||||||||||||||||||
| 1896 | - | |||||||||||||||||||||||||
| 1897 | case 'z': | - | ||||||||||||||||||||||||
| 1898 | used = true; | - | ||||||||||||||||||||||||
| 1899 | if (repeat >= 3) { | - | ||||||||||||||||||||||||
| 1900 | repeat = 3; | - | ||||||||||||||||||||||||
| 1901 | } else { | - | ||||||||||||||||||||||||
| 1902 | repeat = 1; | - | ||||||||||||||||||||||||
| 1903 | } | - | ||||||||||||||||||||||||
| 1904 | switch (repeat) { | - | ||||||||||||||||||||||||
| 1905 | case 1: | - | ||||||||||||||||||||||||
| 1906 | result.append(m_data->longLongToString(time.msec())); | - | ||||||||||||||||||||||||
| 1907 | break; | - | ||||||||||||||||||||||||
| 1908 | case 3: | - | ||||||||||||||||||||||||
| 1909 | result.append(m_data->longLongToString(time.msec(), -1, 10, 3, QLocaleData::ZeroPadded)); | - | ||||||||||||||||||||||||
| 1910 | break; | - | ||||||||||||||||||||||||
| 1911 | } | - | ||||||||||||||||||||||||
| 1912 | break; | - | ||||||||||||||||||||||||
| 1913 | - | |||||||||||||||||||||||||
| 1914 | case 't': | - | ||||||||||||||||||||||||
| 1915 | used = true; | - | ||||||||||||||||||||||||
| 1916 | repeat = 1; | - | ||||||||||||||||||||||||
| 1917 | - | |||||||||||||||||||||||||
| 1918 | if (formatDate) { | - | ||||||||||||||||||||||||
| 1919 | result.append(datetime.timeZoneAbbreviation()); | - | ||||||||||||||||||||||||
| 1920 | } else { | - | ||||||||||||||||||||||||
| 1921 | result.append(QDateTime::currentDateTime().timeZoneAbbreviation()); | - | ||||||||||||||||||||||||
| 1922 | } | - | ||||||||||||||||||||||||
| 1923 | break; | - | ||||||||||||||||||||||||
| 1924 | - | |||||||||||||||||||||||||
| 1925 | default: | - | ||||||||||||||||||||||||
| 1926 | break; | - | ||||||||||||||||||||||||
| 1927 | } | - | ||||||||||||||||||||||||
| 1928 | } | - | ||||||||||||||||||||||||
| 1929 | if (!used) { | - | ||||||||||||||||||||||||
| 1930 | result.append(QString(repeat, c)); | - | ||||||||||||||||||||||||
| 1931 | } | - | ||||||||||||||||||||||||
| 1932 | i += repeat; | - | ||||||||||||||||||||||||
| 1933 | } | - | ||||||||||||||||||||||||
| 1934 | - | |||||||||||||||||||||||||
| 1935 | return result; | - | ||||||||||||||||||||||||
| 1936 | } | - | ||||||||||||||||||||||||
| 1937 | - | |||||||||||||||||||||||||
| 1938 | QString QLocaleData::doubleToString(double d, int precision, DoubleForm form, | - | ||||||||||||||||||||||||
| 1939 | int width, unsigned flags) const | - | ||||||||||||||||||||||||
| 1940 | { | - | ||||||||||||||||||||||||
| 1941 | return doubleToString(m_zero, m_plus, m_minus, m_exponential, m_group, m_decimal, | - | ||||||||||||||||||||||||
| 1942 | d, precision, form, width, flags); | - | ||||||||||||||||||||||||
| 1943 | } | - | ||||||||||||||||||||||||
| 1944 | - | |||||||||||||||||||||||||
| 1945 | QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const QChar minus, | - | ||||||||||||||||||||||||
| 1946 | const QChar exponential, const QChar group, const QChar decimal, | - | ||||||||||||||||||||||||
| 1947 | double d, int precision, DoubleForm form, int width, unsigned flags) | - | ||||||||||||||||||||||||
| 1948 | { | - | ||||||||||||||||||||||||
| 1949 | if (precision != QLocale::FloatingPointShortest
| 168-110478 | ||||||||||||||||||||||||
| 1950 | precision = 6; executed 97694 times by 9 tests: precision = 6;Executed by:
| 97694 | ||||||||||||||||||||||||
| 1951 | if (width < 0
| 7345-103301 | ||||||||||||||||||||||||
| 1952 | width = 0; executed 7345 times by 49 tests: width = 0;Executed by:
| 7345 | ||||||||||||||||||||||||
| 1953 | - | |||||||||||||||||||||||||
| 1954 | bool negative = false; | - | ||||||||||||||||||||||||
| bool special_number= false; | ||||||||||||||||||||||||||
| 1955 | QString num_str; | - | ||||||||||||||||||||||||
| 1956 | - | |||||||||||||||||||||||||
| 1957 | if (qt_is_inf(d)) { | - | ||||||||||||||||||||||||
| num_str = QString::fromLatin1("inf"); | ||||||||||||||||||||||||||
| special_number = trueint decpt; | ||||||||||||||||||||||||||
| 1958 | negativeint bufSize = d < 01; | - | ||||||||||||||||||||||||
| 1959 | } elseif (qt_is_nan(d)) { | 168-110478 | ||||||||||||||||||||||||
num_str = QStringprecision == QLocale
| ||||||||||||||||||||||||||
special_number = true;
| ||||||||||||||||||||||||||
}
| ||||||||||||||||||||||||||
if (!special_number
| ||||||||||||||||||||||||||
| 1960 | { | 168 | ||||||||||||||||||||||||
| int decpt, sign; | ||||||||||||||||||||||||||
| QString digits; | ||||||||||||||||||||||||||
| int modebufSize += DoubleMaxSignificant executed 168 times by 13 tests: ;bufSize += DoubleMaxSignificant;Executed by:
executed 168 times by 13 tests: bufSize += DoubleMaxSignificant;Executed by:
| ||||||||||||||||||||||||||
| 1961 | else if (form == DFDecimal
| 2237-108241 | ||||||||||||||||||||||||
| 1962 | mode = 3bufSize += ((d > (1 << 19)
executed 2237 times by 20 tests: bufSize += ((d > (1 << 19) || d < -(1 << 19)) ? DoubleMaxDigitsBeforeDecimal : 6) + precision;Executed by:
| 35-2237 | ||||||||||||||||||||||||
| 1963 | precision executed 2237 times by 20 tests: bufSize += ((d > (1 << 19) || d < -(1 << 19)) ? DoubleMaxDigitsBeforeDecimal : 6) + precision;Executed by:
executed 2237 times by 20 tests: ;bufSize += ((d > (1 << 19) || d < -(1 << 19)) ? DoubleMaxDigitsBeforeDecimal : 6) + precision;Executed by:
executed 2237 times by 20 tests: bufSize += ((d > (1 << 19) || d < -(1 << 19)) ? DoubleMaxDigitsBeforeDecimal : 6) + precision;Executed by:
| 2237 | ||||||||||||||||||||||||
| 1964 | else | - | ||||||||||||||||||||||||
| 1965 | mode =bufSize += qMax( executed 108241 times by 36 tests: 2;bufSize += qMax(2, precision) + 1;Executed by:
executed 108241 times by 36 tests: bufSize += qMax(2, precision) + 1;Executed by:
| 108241 | ||||||||||||||||||||||||
| int pr = executed 108241 times by 36 tests: bufSize += qMax(2, precision) + 1;Executed by:
executed 108241 times by 36 tests: , precision;bufSize += qMax(2, precision) + 1;Executed by:
executed 108241 times by 36 tests: bufSize += qMax(2, precision) + 1;Executed by:
| ||||||||||||||||||||||||||
| if (form == DFExponent executed 108241 times by 36 tests: bufSize += qMax(2, precision) + 1;Executed by:
executed 108241 times by 36 tests: ) ++pr;bufSize += qMax(2, precision) + 1;Executed by:
executed 108241 times by 36 tests: bufSize += qMax(2, precision) + 1;Executed by:
| ||||||||||||||||||||||||||
| char *rve = 0 executed 108241 times by 36 tests: bufSize += qMax(2, precision) + 1;Executed by:
executed 108241 times by 36 tests: + 1;bufSize += qMax(2, precision) + 1;Executed by:
executed 108241 times by 36 tests: bufSize += qMax(2, precision) + 1;Executed by:
| ||||||||||||||||||||||||||
| 1966 | - | |||||||||||||||||||||||||
| 1967 | QVarLengthArray<char*buff = 0; | - | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| digits = QLatin1String> buf(qdtoabufSize); | ||||||||||||||||||||||||||
| 1968 | int length; | - | ||||||||||||||||||||||||
| 1969 | - | |||||||||||||||||||||||||
| 1970 | doubleToAscii(d, modeform, prprecision, &decptbuf.data(), bufSize, &signnegative, &rvelength, &buff)); | - | ||||||||||||||||||||||||
| } catch (...) {decpt); | ||||||||||||||||||||||||||
| 1971 | - | |||||||||||||||||||||||||
| 1972 | if (buff !=qstrncmp(buf.data(), "inf", 3) ==
| 262-110096 | ||||||||||||||||||||||||
| 1973 | num_str = QString::fromLatin1(buffbuf.data(), length); | - | ||||||||||||||||||||||||
| 1974 | throw;} executed 812 times by 4 tests: if (buff != 0)end of blockExecuted by:
| 812 | ||||||||||||||||||||||||
| freeelse { | ||||||||||||||||||||||||||
| 1975 | QString digits = QString::fromLatin1(buffbuf.data(), length); | - | ||||||||||||||||||||||||
| 1976 | - | |||||||||||||||||||||||||
| 1977 | if (_zero.unicode() != '0'
| 1-109833 | ||||||||||||||||||||||||
| 1978 | ushort z = _zero.unicode() - '0'; | - | ||||||||||||||||||||||||
| 1979 | for (int i = 0; i < digits.length()
| 1-7 | ||||||||||||||||||||||||
| 1980 | reinterpret_cast< executed 7 times by 1 test: ushort *>(digits.data())[i] += z;reinterpret_cast<ushort *>(digits.data())[i] += z;Executed by:
executed 7 times by 1 test: reinterpret_cast<ushort *>(digits.data())[i] += z;Executed by:
| 7 | ||||||||||||||||||||||||
| 1981 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 1982 | - | |||||||||||||||||||||||||
| 1983 | bool always_show_decpt = (flags & Alternate
| 0-105220 | ||||||||||||||||||||||||
| 1984 | switch (form) { | - | ||||||||||||||||||||||||
| 1985 | case executed 17 times by 3 tests: DFExponent:case DFExponent:Executed by:
executed 17 times by 3 tests: {case DFExponent:Executed by:
| 17 | ||||||||||||||||||||||||
| 1986 | num_str = exponentForm(_zero, decimal, exponential, group, plus, minus, | - | ||||||||||||||||||||||||
| 1987 | digits, decpt, precision, PMDecimalDigits, | - | ||||||||||||||||||||||||
| 1988 | always_show_decpt, flags & ZeroPadExponent); | - | ||||||||||||||||||||||||
| 1989 | break; executed 17 times by 3 tests: break;Executed by:
| 17 | ||||||||||||||||||||||||
| 1990 | } | - | ||||||||||||||||||||||||
| 1991 | case executed 2237 times by 20 tests: DFDecimal:case DFDecimal:Executed by:
executed 2237 times by 20 tests: {case DFDecimal:Executed by:
| 2237 | ||||||||||||||||||||||||
| 1992 | num_str = decimalForm(_zero, decimal, group, | - | ||||||||||||||||||||||||
| 1993 | digits, decpt, precision, PMDecimalDigits, | - | ||||||||||||||||||||||||
| 1994 | always_show_decpt, flags & ThousandsGroup); | - | ||||||||||||||||||||||||
| 1995 | break; executed 2237 times by 20 tests: break;Executed by:
| 2237 | ||||||||||||||||||||||||
| 1996 | } | - | ||||||||||||||||||||||||
| 1997 | case executed 107580 times by 42 tests: DFSignificantDigits:case DFSignificantDigits:Executed by:
executed 107580 times by 42 tests: {case DFSignificantDigits:Executed by:
| 107580 | ||||||||||||||||||||||||
| 1998 | PrecisionMode mode = (
| 4610-102970 | ||||||||||||||||||||||||
| 1999 | PMSignificantDigits : PMChopTrailingZeros; | - | ||||||||||||||||||||||||
| 2000 | - | |||||||||||||||||||||||||
| 2001 | int cutoff = precision < 0
| 144-107436 | ||||||||||||||||||||||||
| 2002 | - | |||||||||||||||||||||||||
| 2003 | if (precision == QLocale::FloatingPointShortest
| 1-107436 | ||||||||||||||||||||||||
| 2004 | cutoff = digits.length() + 4; | - | ||||||||||||||||||||||||
| 2005 | if (decpt <= 10
| 0-143 | ||||||||||||||||||||||||
| 2006 | ++cutoff; | - | ||||||||||||||||||||||||
| 2007 | } executed 143 times by 12 tests: else {end of blockExecuted by:
| 143 | ||||||||||||||||||||||||
| 2008 | cutoff += decpt > 100
| 0 | ||||||||||||||||||||||||
| 2009 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2010 | if (!always_show_decpt
| 0-143 | ||||||||||||||||||||||||
| 2011 | ++ executed 56 times by 6 tests: cutoff++cutoff;Executed by:
executed 56 times by 6 tests: ++cutoff;Executed by:
executed 56 times by 6 tests: ;++cutoff;Executed by:
executed 56 times by 6 tests: ++cutoff;Executed by:
| 56 | ||||||||||||||||||||||||
| 2012 | } executed 143 times by 12 tests: end of blockExecuted by:
| 143 | ||||||||||||||||||||||||
| 2013 | - | |||||||||||||||||||||||||
| 2014 | if (decpt != digits.length()
| 1897-54011 | ||||||||||||||||||||||||
| 2015 | num_str = exponentForm(_zero, decimal, exponential, group, plus, minus, executed 6335 times by 5 tests: num_str = exponentForm(_zero, decimal, exponential, group, plus, minus, digits, decpt, precision, mode, always_show_decpt, flags & ZeroPadExponent);Executed by:
| 6335 | ||||||||||||||||||||||||
| 2016 | digits, decpt, precision, mode, executed 6335 times by 5 tests: num_str = exponentForm(_zero, decimal, exponential, group, plus, minus, digits, decpt, precision, mode, always_show_decpt, flags & ZeroPadExponent);Executed by:
| 6335 | ||||||||||||||||||||||||
| 2017 | always_show_decpt, flags & ZeroPadExponent); executed 6335 times by 5 tests: num_str = exponentForm(_zero, decimal, exponential, group, plus, minus, digits, decpt, precision, mode, always_show_decpt, flags & ZeroPadExponent);Executed by:
| 6335 | ||||||||||||||||||||||||
| 2018 | else | - | ||||||||||||||||||||||||
| 2019 | num_str = decimalForm(_zero, decimal, group, executed 101245 times by 42 tests: num_str = decimalForm(_zero, decimal, group, digits, decpt, precision, mode, always_show_decpt, flags & ThousandsGroup);Executed by:
| 101245 | ||||||||||||||||||||||||
| 2020 | digits, decpt, precision, mode, executed 101245 times by 42 tests: num_str = decimalForm(_zero, decimal, group, digits, decpt, precision, mode, always_show_decpt, flags & ThousandsGroup);Executed by:
| 101245 | ||||||||||||||||||||||||
| 2021 | always_show_decpt, flags & ThousandsGroup); executed 101245 times by 42 tests: num_str = decimalForm(_zero, decimal, group, digits, decpt, precision, mode, always_show_decpt, flags & ThousandsGroup);Executed by:
| 101245 | ||||||||||||||||||||||||
| 2022 | break; executed 107580 times by 42 tests: break;Executed by:
| 107580 | ||||||||||||||||||||||||
| 2023 | } | - | ||||||||||||||||||||||||
| 2024 | } | - | ||||||||||||||||||||||||
| 2025 | - | |||||||||||||||||||||||||
| 2026 | negative = sign != 0 && !if (isZero(d);
| 38415-71419 | ||||||||||||||||||||||||
}
| ||||||||||||||||||||||||||
| 2027 | negative = false; executed 38415 times by 24 tests: negative = false;Executed by:
| 38415 | ||||||||||||||||||||||||
| 2028 | - | |||||||||||||||||||||||||
| 2029 | - | |||||||||||||||||||||||||
| 2030 | - | |||||||||||||||||||||||||
| 2031 | if (flags & QLocaleData::ZeroPadded
| 2304-105221 | ||||||||||||||||||||||||
&& !special_number)
| ||||||||||||||||||||||||||
| 2032 | int num_pad_chars = width - num_str.length(); | - | ||||||||||||||||||||||||
| 2033 | - | |||||||||||||||||||||||||
| 2034 | if (negative
| 66-2243 | ||||||||||||||||||||||||
| 2035 | || flags & QLocaleData::AlwaysShowSign
| 1120-1123 | ||||||||||||||||||||||||
| 2036 | || flags & QLocaleData::BlankBeforePositive
| 560-563 | ||||||||||||||||||||||||
| 2037 | -- executed 1746 times by 1 test: num_pad_chars;--num_pad_chars;Executed by:
executed 1746 times by 1 test: --num_pad_chars;Executed by:
| 1746 | ||||||||||||||||||||||||
| 2038 | - | |||||||||||||||||||||||||
| 2039 | for (int i = 0; i < num_pad_chars
| 2309-23653 | ||||||||||||||||||||||||
| 2040 | num_str.prepend(_zero); executed 23653 times by 1 test: num_str.prepend(_zero);Executed by:
| 23653 | ||||||||||||||||||||||||
| 2041 | } executed 2309 times by 1 test: end of blockExecuted by:
| 2309 | ||||||||||||||||||||||||
| 2042 | } executed 109834 times by 55 tests: end of blockExecuted by:
| 109834 | ||||||||||||||||||||||||
| 2043 | - | |||||||||||||||||||||||||
| 2044 | - | |||||||||||||||||||||||||
| 2045 | if (negative
| 22427-88219 | ||||||||||||||||||||||||
| 2046 | num_str.prepend(minus); executed 22427 times by 15 tests: num_str.prepend(minus);Executed by:
| 22427 | ||||||||||||||||||||||||
| 2047 | else if (flags & QLocaleData::AlwaysShowSign
| 4738-83481 | ||||||||||||||||||||||||
| 2048 | num_str.prepend(plus); executed 4738 times by 2 tests: num_str.prepend(plus);Executed by:
| 4738 | ||||||||||||||||||||||||
| 2049 | else if (flags & QLocaleData::BlankBeforePositive
| 2368-81113 | ||||||||||||||||||||||||
| 2050 | num_str.prepend(QLatin1Char(' ')); executed 2368 times by 1 test: num_str.prepend(QLatin1Char(' '));Executed by:
| 2368 | ||||||||||||||||||||||||
| 2051 | - | |||||||||||||||||||||||||
| 2052 | if (flags & QLocaleData::CapitalEorX
| 4999-105647 | ||||||||||||||||||||||||
| 2053 | num_str = num_str.toUpper(); executed 4999 times by 2 tests: num_str = num_str.toUpper();Executed by:
| 4999 | ||||||||||||||||||||||||
| 2054 | - | |||||||||||||||||||||||||
| 2055 | return executed 110646 times by 55 tests: num_str;return num_str;Executed by:
executed 110646 times by 55 tests: return num_str;Executed by:
| 110646 | ||||||||||||||||||||||||
| 2056 | } | - | ||||||||||||||||||||||||
| 2057 | - | |||||||||||||||||||||||||
| 2058 | QString QLocaleData::longLongToString(qlonglong l, int precision, | - | ||||||||||||||||||||||||
| 2059 | int base, int width, | - | ||||||||||||||||||||||||
| 2060 | unsigned flags) const | - | ||||||||||||||||||||||||
| 2061 | { | - | ||||||||||||||||||||||||
| 2062 | return longLongToString(m_zero, m_group, m_plus, m_minus, | - | ||||||||||||||||||||||||
| 2063 | l, precision, base, width, flags); | - | ||||||||||||||||||||||||
| 2064 | } | - | ||||||||||||||||||||||||
| 2065 | - | |||||||||||||||||||||||||
| 2066 | QString QLocaleData::longLongToString(const QChar zero, const QChar group, | - | ||||||||||||||||||||||||
| 2067 | const QChar plus, const QChar minus, | - | ||||||||||||||||||||||||
| 2068 | qlonglong l, int precision, | - | ||||||||||||||||||||||||
| 2069 | int base, int width, | - | ||||||||||||||||||||||||
| 2070 | unsigned flags) | - | ||||||||||||||||||||||||
| 2071 | { | - | ||||||||||||||||||||||||
| 2072 | bool precision_not_specified = false; | - | ||||||||||||||||||||||||
| 2073 | if (precision == -1) { | - | ||||||||||||||||||||||||
| 2074 | precision_not_specified = true; | - | ||||||||||||||||||||||||
| 2075 | precision = 1; | - | ||||||||||||||||||||||||
| 2076 | } | - | ||||||||||||||||||||||||
| 2077 | - | |||||||||||||||||||||||||
| 2078 | bool negative = l < 0; | - | ||||||||||||||||||||||||
| 2079 | if (base != 10) { | - | ||||||||||||||||||||||||
| 2080 | - | |||||||||||||||||||||||||
| 2081 | flags &= ~AlwaysShowSign; | - | ||||||||||||||||||||||||
| 2082 | flags &= ~BlankBeforePositive; | - | ||||||||||||||||||||||||
| 2083 | negative = false; | - | ||||||||||||||||||||||||
| 2084 | } | - | ||||||||||||||||||||||||
| 2085 | - | |||||||||||||||||||||||||
| 2086 | QString num_str; | - | ||||||||||||||||||||||||
| 2087 | if (base == 10) | - | ||||||||||||||||||||||||
| 2088 | num_str = qlltoa(l, base, zero); | - | ||||||||||||||||||||||||
| 2089 | else | - | ||||||||||||||||||||||||
| 2090 | num_str = qulltoa(l, base, zero); | - | ||||||||||||||||||||||||
| 2091 | - | |||||||||||||||||||||||||
| 2092 | uint cnt_thousand_sep = 0; | - | ||||||||||||||||||||||||
| 2093 | if (flags & ThousandsGroup && base == 10) { | - | ||||||||||||||||||||||||
| 2094 | for (int i = num_str.length() - 3; i > 0; i -= 3) { | - | ||||||||||||||||||||||||
| 2095 | num_str.insert(i, group); | - | ||||||||||||||||||||||||
| 2096 | ++cnt_thousand_sep; | - | ||||||||||||||||||||||||
| 2097 | } | - | ||||||||||||||||||||||||
| 2098 | } | - | ||||||||||||||||||||||||
| 2099 | - | |||||||||||||||||||||||||
| 2100 | for (int i = num_str.length() ; i < precision; ++i) | - | ||||||||||||||||||||||||
| 2101 | num_str.prepend(base == 10 ? zero : QChar::fromLatin1('0')); | - | ||||||||||||||||||||||||
| 2102 | - | |||||||||||||||||||||||||
| 2103 | if ((flags & Alternate || flags & ShowBase) | - | ||||||||||||||||||||||||
| 2104 | && base == 8 | - | ||||||||||||||||||||||||
| 2105 | && (num_str.isEmpty() || num_str[0].unicode() != QLatin1Char('0'))) | - | ||||||||||||||||||||||||
| 2106 | num_str.prepend(QLatin1Char('0')); | - | ||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||
| 2108 | - | |||||||||||||||||||||||||
| 2109 | - | |||||||||||||||||||||||||
| 2110 | bool zero_padded = flags & ZeroPadded | - | ||||||||||||||||||||||||
| 2111 | && !(flags & LeftAdjusted) | - | ||||||||||||||||||||||||
| 2112 | && precision_not_specified; | - | ||||||||||||||||||||||||
| 2113 | - | |||||||||||||||||||||||||
| 2114 | if (zero_padded) { | - | ||||||||||||||||||||||||
| 2115 | int num_pad_chars = width - num_str.length(); | - | ||||||||||||||||||||||||
| 2116 | - | |||||||||||||||||||||||||
| 2117 | - | |||||||||||||||||||||||||
| 2118 | if (negative | - | ||||||||||||||||||||||||
| 2119 | || flags & AlwaysShowSign | - | ||||||||||||||||||||||||
| 2120 | || flags & BlankBeforePositive) | - | ||||||||||||||||||||||||
| 2121 | --num_pad_chars; | - | ||||||||||||||||||||||||
| 2122 | - | |||||||||||||||||||||||||
| 2123 | - | |||||||||||||||||||||||||
| 2124 | if (base == 16 && (flags & Alternate || flags & ShowBase)) | - | ||||||||||||||||||||||||
| 2125 | num_pad_chars -= 2; | - | ||||||||||||||||||||||||
| 2126 | - | |||||||||||||||||||||||||
| 2127 | else if (base == 2 && (flags & Alternate || flags & ShowBase)) | - | ||||||||||||||||||||||||
| 2128 | num_pad_chars -= 2; | - | ||||||||||||||||||||||||
| 2129 | - | |||||||||||||||||||||||||
| 2130 | for (int i = 0; i < num_pad_chars; ++i) | - | ||||||||||||||||||||||||
| 2131 | num_str.prepend(base == 10 ? zero : QChar::fromLatin1('0')); | - | ||||||||||||||||||||||||
| 2132 | } | - | ||||||||||||||||||||||||
| 2133 | - | |||||||||||||||||||||||||
| 2134 | if (flags & CapitalEorX) | - | ||||||||||||||||||||||||
| 2135 | num_str = num_str.toUpper(); | - | ||||||||||||||||||||||||
| 2136 | - | |||||||||||||||||||||||||
| 2137 | if (base == 16 && (flags & Alternate || flags & ShowBase)) | - | ||||||||||||||||||||||||
| 2138 | num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x")); | - | ||||||||||||||||||||||||
| 2139 | if (base == 2 && (flags & Alternate || flags & ShowBase)) | - | ||||||||||||||||||||||||
| 2140 | num_str.prepend(QLatin1String(flags & UppercaseBase ? "0B" : "0b")); | - | ||||||||||||||||||||||||
| 2141 | - | |||||||||||||||||||||||||
| 2142 | - | |||||||||||||||||||||||||
| 2143 | if (negative) | - | ||||||||||||||||||||||||
| 2144 | num_str.prepend(minus); | - | ||||||||||||||||||||||||
| 2145 | else if (flags & AlwaysShowSign) | - | ||||||||||||||||||||||||
| 2146 | num_str.prepend(plus); | - | ||||||||||||||||||||||||
| 2147 | else if (flags & BlankBeforePositive) | - | ||||||||||||||||||||||||
| 2148 | num_str.prepend(QLatin1Char(' ')); | - | ||||||||||||||||||||||||
| 2149 | - | |||||||||||||||||||||||||
| 2150 | return num_str; | - | ||||||||||||||||||||||||
| 2151 | } | - | ||||||||||||||||||||||||
| 2152 | - | |||||||||||||||||||||||||
| 2153 | QString QLocaleData::unsLongLongToString(qulonglong l, int precision, | - | ||||||||||||||||||||||||
| 2154 | int base, int width, | - | ||||||||||||||||||||||||
| 2155 | unsigned flags) const | - | ||||||||||||||||||||||||
| 2156 | { | - | ||||||||||||||||||||||||
| 2157 | return unsLongLongToString(m_zero, m_group, m_plus, | - | ||||||||||||||||||||||||
| 2158 | l, precision, base, width, flags); | - | ||||||||||||||||||||||||
| 2159 | } | - | ||||||||||||||||||||||||
| 2160 | - | |||||||||||||||||||||||||
| 2161 | QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, | - | ||||||||||||||||||||||||
| 2162 | const QChar plus, | - | ||||||||||||||||||||||||
| 2163 | qulonglong l, int precision, | - | ||||||||||||||||||||||||
| 2164 | int base, int width, | - | ||||||||||||||||||||||||
| 2165 | unsigned flags) | - | ||||||||||||||||||||||||
| 2166 | { | - | ||||||||||||||||||||||||
| 2167 | bool precision_not_specified = false; | - | ||||||||||||||||||||||||
| 2168 | if (precision == -1) { | - | ||||||||||||||||||||||||
| 2169 | precision_not_specified = true; | - | ||||||||||||||||||||||||
| 2170 | precision = 1; | - | ||||||||||||||||||||||||
| 2171 | } | - | ||||||||||||||||||||||||
| 2172 | - | |||||||||||||||||||||||||
| 2173 | QString num_str = qulltoa(l, base, zero); | - | ||||||||||||||||||||||||
| 2174 | - | |||||||||||||||||||||||||
| 2175 | uint cnt_thousand_sep = 0; | - | ||||||||||||||||||||||||
| 2176 | if (flags & ThousandsGroup && base == 10) { | - | ||||||||||||||||||||||||
| 2177 | for (int i = num_str.length() - 3; i > 0; i -=3) { | - | ||||||||||||||||||||||||
| 2178 | num_str.insert(i, group); | - | ||||||||||||||||||||||||
| 2179 | ++cnt_thousand_sep; | - | ||||||||||||||||||||||||
| 2180 | } | - | ||||||||||||||||||||||||
| 2181 | } | - | ||||||||||||||||||||||||
| 2182 | - | |||||||||||||||||||||||||
| 2183 | for (int i = num_str.length() ; i < precision; ++i) | - | ||||||||||||||||||||||||
| 2184 | num_str.prepend(base == 10 ? zero : QChar::fromLatin1('0')); | - | ||||||||||||||||||||||||
| 2185 | - | |||||||||||||||||||||||||
| 2186 | if ((flags & Alternate || flags & ShowBase) | - | ||||||||||||||||||||||||
| 2187 | && base == 8 | - | ||||||||||||||||||||||||
| 2188 | && (num_str.isEmpty() || num_str[0].unicode() != QLatin1Char('0'))) | - | ||||||||||||||||||||||||
| 2189 | num_str.prepend(QLatin1Char('0')); | - | ||||||||||||||||||||||||
| 2190 | - | |||||||||||||||||||||||||
| 2191 | - | |||||||||||||||||||||||||
| 2192 | - | |||||||||||||||||||||||||
| 2193 | bool zero_padded = flags & ZeroPadded | - | ||||||||||||||||||||||||
| 2194 | && !(flags & LeftAdjusted) | - | ||||||||||||||||||||||||
| 2195 | && precision_not_specified; | - | ||||||||||||||||||||||||
| 2196 | - | |||||||||||||||||||||||||
| 2197 | if (zero_padded) { | - | ||||||||||||||||||||||||
| 2198 | int num_pad_chars = width - num_str.length(); | - | ||||||||||||||||||||||||
| 2199 | - | |||||||||||||||||||||||||
| 2200 | - | |||||||||||||||||||||||||
| 2201 | if (base == 16 && flags & Alternate) | - | ||||||||||||||||||||||||
| 2202 | num_pad_chars -= 2; | - | ||||||||||||||||||||||||
| 2203 | - | |||||||||||||||||||||||||
| 2204 | else if (base == 2 && flags & Alternate) | - | ||||||||||||||||||||||||
| 2205 | num_pad_chars -= 2; | - | ||||||||||||||||||||||||
| 2206 | - | |||||||||||||||||||||||||
| 2207 | for (int i = 0; i < num_pad_chars; ++i) | - | ||||||||||||||||||||||||
| 2208 | num_str.prepend(base == 10 ? zero : QChar::fromLatin1('0')); | - | ||||||||||||||||||||||||
| 2209 | } | - | ||||||||||||||||||||||||
| 2210 | - | |||||||||||||||||||||||||
| 2211 | if (flags & CapitalEorX) | - | ||||||||||||||||||||||||
| 2212 | num_str = num_str.toUpper(); | - | ||||||||||||||||||||||||
| 2213 | - | |||||||||||||||||||||||||
| 2214 | if (base == 16 && (flags & Alternate || flags & ShowBase)) | - | ||||||||||||||||||||||||
| 2215 | num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x")); | - | ||||||||||||||||||||||||
| 2216 | else if (base == 2 && (flags & Alternate || flags & ShowBase)) | - | ||||||||||||||||||||||||
| 2217 | num_str.prepend(QLatin1String(flags & UppercaseBase ? "0B" : "0b")); | - | ||||||||||||||||||||||||
| 2218 | - | |||||||||||||||||||||||||
| 2219 | - | |||||||||||||||||||||||||
| 2220 | if (flags & AlwaysShowSign) | - | ||||||||||||||||||||||||
| 2221 | num_str.prepend(plus); | - | ||||||||||||||||||||||||
| 2222 | else if (flags & BlankBeforePositive) | - | ||||||||||||||||||||||||
| 2223 | num_str.prepend(QLatin1Char(' ')); | - | ||||||||||||||||||||||||
| 2224 | - | |||||||||||||||||||||||||
| 2225 | return num_str; | - | ||||||||||||||||||||||||
| 2226 | } | - | ||||||||||||||||||||||||
| 2227 | bool QLocaleData::numberToCLocale(const QChar *str, int len, GroupSeparatorMode group_sep_modeQLocale::NumberOptions number_options, | - | ||||||||||||||||||||||||
| 2228 | CharBuff *result) const | - | ||||||||||||||||||||||||
| 2229 | { | - | ||||||||||||||||||||||||
| 2230 | const QChar *uc = str; | - | ||||||||||||||||||||||||
| 2231 | int l = len; | - | ||||||||||||||||||||||||
| 2232 | int idx = 0; | - | ||||||||||||||||||||||||
| 2233 | - | |||||||||||||||||||||||||
| 2234 | - | |||||||||||||||||||||||||
| 2235 | while (idx < l
| 268-177012 | ||||||||||||||||||||||||
| 2236 | ++ executed 268 times by 4 tests: idx;++idx;Executed by:
executed 268 times by 4 tests: ++idx;Executed by:
| 268 | ||||||||||||||||||||||||
| 2237 | if (idx == l
| 4310-176744 | ||||||||||||||||||||||||
| 2238 | return executed 4310 times by 11 tests: false;return false;Executed by:
executed 4310 times by 11 tests: return false;Executed by:
| 4310 | ||||||||||||||||||||||||
| 2239 | - | |||||||||||||||||||||||||
| 2240 | - | |||||||||||||||||||||||||
| 2241 | for (; idx < l
| 0-176919 | ||||||||||||||||||||||||
| 2242 | if (!uc[l - 1].isSpace()
| 175-176744 | ||||||||||||||||||||||||
| 2243 | break; executed 176744 times by 92 tests: break;Executed by:
| 176744 | ||||||||||||||||||||||||
| 2244 | } executed 175 times by 5 tests: end of blockExecuted by:
| 175 | ||||||||||||||||||||||||
| 2245 | - | |||||||||||||||||||||||||
| 2246 | int group_cnt = 0; | - | ||||||||||||||||||||||||
| 2247 | int decpt_idx = -1; | - | ||||||||||||||||||||||||
| 2248 | int last_separator_idx = -1; | - | ||||||||||||||||||||||||
| 2249 | int start_of_digits_idx = -1; | - | ||||||||||||||||||||||||
| 2250 | int exponent_idx = -1; | - | ||||||||||||||||||||||||
| 2251 | - | |||||||||||||||||||||||||
| 2252 | while (idx < l
| 175786-545999 | ||||||||||||||||||||||||
| 2253 | const QChar in = uc[idx]; | - | ||||||||||||||||||||||||
| 2254 | - | |||||||||||||||||||||||||
| 2255 | char out = digitToCLocale(in); | - | ||||||||||||||||||||||||
| 2256 | if (out == 0
| 209926-336073 | ||||||||||||||||||||||||
| 2257 | if (in == m_list
| 0-209926 | ||||||||||||||||||||||||
| 2258 | out = ';'; never executed: out = ';'; | 0 | ||||||||||||||||||||||||
| 2259 | else if (in == m_percent
| 4-209922 | ||||||||||||||||||||||||
| 2260 | out = '%'; executed 4 times by 2 tests: out = '%';Executed by:
| 4 | ||||||||||||||||||||||||
| 2261 | - | |||||||||||||||||||||||||
| 2262 | else if (in.unicode() >= 'A'
| 927-208995 | ||||||||||||||||||||||||
| 2263 | out = in.toLower().toLatin1(); executed 207440 times by 15 tests: out = in.toLower().toLatin1();Executed by:
| 207440 | ||||||||||||||||||||||||
| 2264 | else if (in.unicode() >= 'a'
| 5-1535 | ||||||||||||||||||||||||
| 2265 | out = in.toLatin1(); executed 1530 times by 27 tests: out = in.toLatin1();Executed by:
| 1530 | ||||||||||||||||||||||||
| 2266 | else | - | ||||||||||||||||||||||||
| 2267 | break; executed 952 times by 16 tests: break;Executed by:
| 952 | ||||||||||||||||||||||||
| 2268 | } | - | ||||||||||||||||||||||||
| 2269 | - | |||||||||||||||||||||||||
| 2270 | if (group_sep_modenumber_options & QLocale::RejectLeadingZeroInExponent
| 0-545047 | ||||||||||||||||||||||||
| 2271 | if (out
| 0 | ||||||||||||||||||||||||
| 2272 | exponent_idx = idx; | - | ||||||||||||||||||||||||
| 2273 | } never executed: else if (exponent_idx != -1end of block
| 0 | ||||||||||||||||||||||||
| 2274 | if (out >= '1'
| 0 | ||||||||||||||||||||||||
| 2275 | exponent_idx = -1; never executed: exponent_idx = -1; | 0 | ||||||||||||||||||||||||
| 2276 | else if (out == '0'
| 0 | ||||||||||||||||||||||||
| 2277 | return never executed: return false;never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2278 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2279 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2280 | - | |||||||||||||||||||||||||
| 2281 | if (!(number_options & QLocale::RejectGroupSeparator)
| 43490-501557 | ||||||||||||||||||||||||
| 2282 | if (start_of_digits_idx == -1
| 231-25090 | ||||||||||||||||||||||||
| 2283 | start_of_digits_idx = idx; | - | ||||||||||||||||||||||||
| 2284 | } executed 17820 times by 25 tests: else if (out == ','end of blockExecuted by:
| 54-25616 | ||||||||||||||||||||||||
| 2285 | - | |||||||||||||||||||||||||
| 2286 | if (decpt_idx != -1
| 0-54 | ||||||||||||||||||||||||
| 2287 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2288 | - | |||||||||||||||||||||||||
| 2289 | - | |||||||||||||||||||||||||
| 2290 | - | |||||||||||||||||||||||||
| 2291 | if (last_separator_idx != -1
| 3-44 | ||||||||||||||||||||||||
| 2292 | return executed 3 times by 3 tests: false;return false;Executed by:
executed 3 times by 3 tests: return false;Executed by:
| 3 | ||||||||||||||||||||||||
| 2293 | if (last_separator_idx == -1
| 0-44 | ||||||||||||||||||||||||
| 2294 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2295 | - | |||||||||||||||||||||||||
| 2296 | last_separator_idx = idx; | - | ||||||||||||||||||||||||
| 2297 | ++group_cnt; | - | ||||||||||||||||||||||||
| 2298 | - | |||||||||||||||||||||||||
| 2299 | - | |||||||||||||||||||||||||
| 2300 | ++idx; | - | ||||||||||||||||||||||||
| 2301 | continue; executed 51 times by 4 tests: continue;Executed by:
| 51 | ||||||||||||||||||||||||
| 2302 | } else if (out == '.'
| 0-24766 | ||||||||||||||||||||||||
| 2303 | - | |||||||||||||||||||||||||
| 2304 | if (out == '.'
| 0-850 | ||||||||||||||||||||||||
| 2305 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2306 | if (decpt_idx == -1
| 0-858 | ||||||||||||||||||||||||
| 2307 | decpt_idx = idx; executed 858 times by 8 tests: decpt_idx = idx;Executed by:
| 858 | ||||||||||||||||||||||||
| 2308 | - | |||||||||||||||||||||||||
| 2309 | - | |||||||||||||||||||||||||
| 2310 | - | |||||||||||||||||||||||||
| 2311 | if (last_separator_idx != -1
| 3-840 | ||||||||||||||||||||||||
| 2312 | return executed 3 times by 2 tests: false;return false;Executed by:
executed 3 times by 2 tests: return false;Executed by:
| 3 | ||||||||||||||||||||||||
| 2313 | - | |||||||||||||||||||||||||
| 2314 | - | |||||||||||||||||||||||||
| 2315 | last_separator_idx = -1; | - | ||||||||||||||||||||||||
| 2316 | } executed 855 times by 8 tests: end of blockExecuted by:
| 855 | ||||||||||||||||||||||||
| 2317 | } executed 43433 times by 25 tests: end of blockExecuted by:
| 43433 | ||||||||||||||||||||||||
| 2318 | - | |||||||||||||||||||||||||
| 2319 | result->append(out); | - | ||||||||||||||||||||||||
| 2320 | - | |||||||||||||||||||||||||
| 2321 | ++idx; | - | ||||||||||||||||||||||||
| 2322 | } executed 544990 times by 92 tests: end of blockExecuted by:
| 544990 | ||||||||||||||||||||||||
| 2323 | - | |||||||||||||||||||||||||
| 2324 | if (group_sep_mode == ParseGroupSeparators)(!(number_options & QLocale::RejectGroupSeparator)
| 18106-158632 | ||||||||||||||||||||||||
| 2325 | - | |||||||||||||||||||||||||
| 2326 | - | |||||||||||||||||||||||||
| 2327 | if (last_separator_idx + 1 == idx
| 67-18039 | ||||||||||||||||||||||||
| 2328 | return executed 67 times by 3 tests: false;return false;Executed by:
executed 67 times by 3 tests: return false;Executed by:
| 67 | ||||||||||||||||||||||||
| 2329 | - | |||||||||||||||||||||||||
| 2330 | if (last_separator_idx != -1
| 3-18019 | ||||||||||||||||||||||||
| 2331 | return executed 3 times by 1 test: false;return false;Executed by:
executed 3 times by 1 test: return false;Executed by:
| 3 | ||||||||||||||||||||||||
| 2332 | } executed 18036 times by 25 tests: end of blockExecuted by:
| 18036 | ||||||||||||||||||||||||
| 2333 | - | |||||||||||||||||||||||||
| 2334 | result->append('\0'); | - | ||||||||||||||||||||||||
| 2335 | return executed 176668 times by 92 tests: idx == l;return idx == l;Executed by:
executed 176668 times by 92 tests: return idx == l;Executed by:
| 176668 | ||||||||||||||||||||||||
| 2336 | } | - | ||||||||||||||||||||||||
| 2337 | - | |||||||||||||||||||||||||
| 2338 | bool QLocaleData::validateChars(const QString &str, NumberMode numMode, QByteArray *buff, | - | ||||||||||||||||||||||||
| 2339 | int decDigits, bool rejectGroupSeparatorsQLocale::NumberOptions number_options) const | - | ||||||||||||||||||||||||
| 2340 | { | - | ||||||||||||||||||||||||
| 2341 | buff->clear(); | - | ||||||||||||||||||||||||
| 2342 | buff->reserve(str.length()); | - | ||||||||||||||||||||||||
| 2343 | - | |||||||||||||||||||||||||
| 2344 | const bool scientific = numMode == DoubleScientificMode; | - | ||||||||||||||||||||||||
| 2345 | bool lastWasE = false; | - | ||||||||||||||||||||||||
| 2346 | bool lastWasDigit = false; | - | ||||||||||||||||||||||||
| 2347 | int eCnt = 0; | - | ||||||||||||||||||||||||
| 2348 | int decPointCnt = 0; | - | ||||||||||||||||||||||||
| 2349 | bool dec = false; | - | ||||||||||||||||||||||||
| 2350 | int decDigitCnt = 0; | - | ||||||||||||||||||||||||
| 2351 | - | |||||||||||||||||||||||||
| 2352 | for (int i = 0; i < str.length()
| 416-1769 | ||||||||||||||||||||||||
| 2353 | char c = digitToCLocale(str.at(i)); | - | ||||||||||||||||||||||||
| 2354 | - | |||||||||||||||||||||||||
| 2355 | if (c >= '0'
| 124-1453 | ||||||||||||||||||||||||
| 2356 | if (numMode != IntegerMode
| 529-800 | ||||||||||||||||||||||||
| 2357 | - | |||||||||||||||||||||||||
| 2358 | if (dec
| 0-694 | ||||||||||||||||||||||||
| 2359 | return executed 12 times by 1 test: false;return false;Executed by:
executed 12 times by 1 test: return false;Executed by:
| 12 | ||||||||||||||||||||||||
| 2360 | } executed 788 times by 2 tests: end of blockExecuted by:
| 788 | ||||||||||||||||||||||||
| 2361 | - | |||||||||||||||||||||||||
| 2362 | - | |||||||||||||||||||||||||
| 2363 | - | |||||||||||||||||||||||||
| 2364 | if ((number_options & QLocale::RejectLeadingZeroInExponent) && c == '0'
| 0-34 | ||||||||||||||||||||||||
| 2365 | !lastWasDigit
| 0-5 | ||||||||||||||||||||||||
| 2366 | return executed 5 times by 1 test: false;return false;Executed by:
executed 5 times by 1 test: return false;Executed by:
| 5 | ||||||||||||||||||||||||
| 2367 | - | |||||||||||||||||||||||||
| 2368 | lastWasDigit = true; | - | ||||||||||||||||||||||||
| 2369 | } executed 1312 times by 5 tests: else {end of blockExecuted by:
| 1312 | ||||||||||||||||||||||||
| 2370 | switch (c) { | - | ||||||||||||||||||||||||
| 2371 | case executed 74 times by 4 tests: '.':case '.':Executed by:
executed 74 times by 4 tests: case '.':Executed by:
| 74 | ||||||||||||||||||||||||
| 2372 | if (numMode == IntegerMode
| 6-68 | ||||||||||||||||||||||||
| 2373 | - | |||||||||||||||||||||||||
| 2374 | return executed 6 times by 2 tests: false;return false;Executed by:
executed 6 times by 2 tests: return false;Executed by:
| 6 | ||||||||||||||||||||||||
| 2375 | } else { | - | ||||||||||||||||||||||||
| 2376 | - | |||||||||||||||||||||||||
| 2377 | if (++
| 0-68 | ||||||||||||||||||||||||
| 2378 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2379 | - | |||||||||||||||||||||||||
| 2380 | - | |||||||||||||||||||||||||
| 2381 | - | |||||||||||||||||||||||||
| 2382 | - | |||||||||||||||||||||||||
| 2383 | - | |||||||||||||||||||||||||
| 2384 | - | |||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||
| 2386 | dec = true; | - | ||||||||||||||||||||||||
| 2387 | } executed 68 times by 2 tests: end of blockExecuted by:
| 68 | ||||||||||||||||||||||||
| 2388 | break; executed 68 times by 2 tests: break;Executed by:
| 68 | ||||||||||||||||||||||||
| 2389 | - | |||||||||||||||||||||||||
| 2390 | case executed 45 times by 2 tests: '+':case '+':Executed by:
executed 45 times by 2 tests: case '+':Executed by:
| 45 | ||||||||||||||||||||||||
| 2391 | case executed 135 times by 3 tests: '-':case '-':Executed by:
executed 135 times by 3 tests: case '-':Executed by:
| 135 | ||||||||||||||||||||||||
| 2392 | if (scientific
| 72-108 | ||||||||||||||||||||||||
| 2393 | - | |||||||||||||||||||||||||
| 2394 | - | |||||||||||||||||||||||||
| 2395 | if (i != 0
| 0-58 | ||||||||||||||||||||||||
| 2396 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2397 | } executed 72 times by 1 test: else {end of blockExecuted by:
| 72 | ||||||||||||||||||||||||
| 2398 | - | |||||||||||||||||||||||||
| 2399 | - | |||||||||||||||||||||||||
| 2400 | if (i != 0
| 4-104 | ||||||||||||||||||||||||
| 2401 | return executed 4 times by 2 tests: false;return false;Executed by:
executed 4 times by 2 tests: return false;Executed by:
| 4 | ||||||||||||||||||||||||
| 2402 | } executed 104 times by 3 tests: end of blockExecuted by:
| 104 | ||||||||||||||||||||||||
| 2403 | break; executed 176 times by 3 tests: break;Executed by:
| 176 | ||||||||||||||||||||||||
| 2404 | - | |||||||||||||||||||||||||
| 2405 | case executed 19 times by 2 tests: ',':case ',':Executed by:
executed 19 times by 2 tests: case ',':Executed by:
| 19 | ||||||||||||||||||||||||
| 2406 | - | |||||||||||||||||||||||||
| 2407 | if (rejectGroupSeparators((number_options & QLocale::RejectGroupSeparator) || !lastWasDigit
| 2-15 | ||||||||||||||||||||||||
| 2408 | decPointCnt > 0
| 0-15 | ||||||||||||||||||||||||
| 2409 | return executed 4 times by 1 test: false;return false;Executed by:
executed 4 times by 1 test: return false;Executed by:
| 4 | ||||||||||||||||||||||||
| 2410 | break; executed 15 times by 2 tests: break;Executed by:
| 15 | ||||||||||||||||||||||||
| 2411 | - | |||||||||||||||||||||||||
| 2412 | case executed 124 times by 1 test: 'e':case 'e':Executed by:
executed 124 times by 1 test: case 'e':Executed by:
| 124 | ||||||||||||||||||||||||
| 2413 | if (scientific
| 52-72 | ||||||||||||||||||||||||
| 2414 | - | |||||||||||||||||||||||||
| 2415 | if (++
| 0-72 | ||||||||||||||||||||||||
| 2416 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2417 | dec = false; | - | ||||||||||||||||||||||||
| 2418 | } executed 72 times by 1 test: else {end of blockExecuted by:
| 72 | ||||||||||||||||||||||||
| 2419 | - | |||||||||||||||||||||||||
| 2420 | return executed 52 times by 1 test: false;return false;Executed by:
executed 52 times by 1 test: return false;Executed by:
| 52 | ||||||||||||||||||||||||
| 2421 | } | - | ||||||||||||||||||||||||
| 2422 | break; executed 72 times by 1 test: break;Executed by:
| 72 | ||||||||||||||||||||||||
| 2423 | - | |||||||||||||||||||||||||
| 2424 | default executed 43 times by 4 tests: :default:Executed by:
executed 43 times by 4 tests: default:Executed by:
| 43 | ||||||||||||||||||||||||
| 2425 | - | |||||||||||||||||||||||||
| 2426 | return executed 43 times by 4 tests: false;return false;Executed by:
executed 43 times by 4 tests: return false;Executed by:
| 43 | ||||||||||||||||||||||||
| 2427 | } | - | ||||||||||||||||||||||||
| 2428 | lastWasDigit = false; | - | ||||||||||||||||||||||||
| 2429 | } executed 331 times by 4 tests: end of blockExecuted by:
| 331 | ||||||||||||||||||||||||
| 2430 | - | |||||||||||||||||||||||||
| 2431 | lastWasE = c == 'e'; | - | ||||||||||||||||||||||||
| 2432 | if (c != ','
| 15-1628 | ||||||||||||||||||||||||
| 2433 | buff->append(c); executed 1628 times by 5 tests: buff->append(c);Executed by:
| 1628 | ||||||||||||||||||||||||
| 2434 | } executed 1643 times by 5 tests: end of blockExecuted by:
| 1643 | ||||||||||||||||||||||||
| 2435 | - | |||||||||||||||||||||||||
| 2436 | return executed 416 times by 5 tests: true;return true;Executed by:
executed 416 times by 5 tests: return true;Executed by:
| 416 | ||||||||||||||||||||||||
| 2437 | } | - | ||||||||||||||||||||||||
| 2438 | - | |||||||||||||||||||||||||
| 2439 | double QLocaleData::stringToDouble(const QChar *begin, int len, bool *ok, | - | ||||||||||||||||||||||||
| 2440 | GroupSeparatorMode group_sep_modeQLocale::NumberOptions number_options) const | - | ||||||||||||||||||||||||
| 2441 | { | - | ||||||||||||||||||||||||
| 2442 | CharBuff buff; | - | ||||||||||||||||||||||||
| 2443 | if (!numberToCLocale(begin, len, group_sep_modenumber_options, &buff)
| 49-4014 | ||||||||||||||||||||||||
| 2444 | if (ok != 0
| 0-49 | ||||||||||||||||||||||||
| 2445 | * executed 49 times by 5 tests: ok = false;*ok = false;Executed by:
executed 49 times by 5 tests: *ok = false;Executed by:
| 49 | ||||||||||||||||||||||||
| 2446 | return executed 49 times by 5 tests: 0.0;return 0.0;Executed by:
executed 49 times by 5 tests: return 0.0;Executed by:
| 49 | ||||||||||||||||||||||||
| 2447 | } | - | ||||||||||||||||||||||||
| 2448 | return bytearrayToDoubleint processed = 0; | - | ||||||||||||||||||||||||
| 2449 | bool nonNullOk = false; | - | ||||||||||||||||||||||||
| 2450 | double d = asciiToDouble(buff.constData(), okbuff.length() - 1, nonNullOk, processed); | - | ||||||||||||||||||||||||
| 2451 | if (ok
| 1159-2855 | ||||||||||||||||||||||||
| 2452 | * executed 2855 times by 21 tests: ok = nonNullOk;*ok = nonNullOk;Executed by:
executed 2855 times by 21 tests: *ok = nonNullOk;Executed by:
| 2855 | ||||||||||||||||||||||||
| 2453 | return executed 4014 times by 27 tests: d;return d;Executed by:
executed 4014 times by 27 tests: return d;Executed by:
| 4014 | ||||||||||||||||||||||||
| 2454 | } | - | ||||||||||||||||||||||||
| 2455 | - | |||||||||||||||||||||||||
| 2456 | qlonglong QLocaleData::stringToLongLong(const QChar *begin, int len, int base, bool *ok, | - | ||||||||||||||||||||||||
| 2457 | GroupSeparatorMode group_sep_modeQLocale::NumberOptions number_options) const | - | ||||||||||||||||||||||||
| 2458 | { | - | ||||||||||||||||||||||||
| 2459 | CharBuff buff; | - | ||||||||||||||||||||||||
| 2460 | if (!numberToCLocale(begin, len, group_sep_modenumber_options, &buff)
| 4267-153149 | ||||||||||||||||||||||||
| 2461 | if (ok != 0
| 74-4193 | ||||||||||||||||||||||||
| 2462 | * executed 74 times by 8 tests: ok = false;*ok = false;Executed by:
executed 74 times by 8 tests: *ok = false;Executed by:
| 74 | ||||||||||||||||||||||||
| 2463 | return executed 4267 times by 13 tests: 0;return 0;Executed by:
executed 4267 times by 13 tests: return 0;Executed by:
| 4267 | ||||||||||||||||||||||||
| 2464 | } | - | ||||||||||||||||||||||||
| 2465 | - | |||||||||||||||||||||||||
| 2466 | return executed 153149 times by 71 tests: bytearrayToLongLong(buff.constData(), base, ok);return bytearrayToLongLong(buff.constData(), base, ok);Executed by:
executed 153149 times by 71 tests: return bytearrayToLongLong(buff.constData(), base, ok);Executed by:
| 153149 | ||||||||||||||||||||||||
| 2467 | } | - | ||||||||||||||||||||||||
| 2468 | - | |||||||||||||||||||||||||
| 2469 | qulonglong QLocaleData::stringToUnsLongLong(const QChar *begin, int len, int base, bool *ok, | - | ||||||||||||||||||||||||
| 2470 | GroupSeparatorMode group_sep_modeQLocale::NumberOptions number_options) const | - | ||||||||||||||||||||||||
| 2471 | { | - | ||||||||||||||||||||||||
| 2472 | CharBuff buff; | - | ||||||||||||||||||||||||
| 2473 | if (!numberToCLocale(begin, len, group_sep_modenumber_options, &buff)
| 958-18617 | ||||||||||||||||||||||||
| 2474 | if (ok != 0
| 8-950 | ||||||||||||||||||||||||
| 2475 | * executed 950 times by 11 tests: ok = false;*ok = false;Executed by:
executed 950 times by 11 tests: *ok = false;Executed by:
| 950 | ||||||||||||||||||||||||
| 2476 | return executed 958 times by 11 tests: 0;return 0;Executed by:
executed 958 times by 11 tests: return 0;Executed by:
| 958 | ||||||||||||||||||||||||
| 2477 | } | - | ||||||||||||||||||||||||
| 2478 | - | |||||||||||||||||||||||||
| 2479 | return executed 18617 times by 29 tests: bytearrayToUnsLongLong(buff.constData(), base, ok);return bytearrayToUnsLongLong(buff.constData(), base, ok);Executed by:
executed 18617 times by 29 tests: return bytearrayToUnsLongLong(buff.constData(), base, ok);Executed by:
| 18617 | ||||||||||||||||||||||||
| 2480 | } | - | ||||||||||||||||||||||||
| 2481 | - | |||||||||||||||||||||||||
| 2482 | double QLocaleData::bytearrayToDouble(const char *num, bool *ok, bool *overflow) | - | ||||||||||||||||||||||||
| 2483 | { | - | ||||||||||||||||||||||||
| 2484 | if (ok != 0) | - | ||||||||||||||||||||||||
| *ok = true; | ||||||||||||||||||||||||||
| if (overflow != 0) | ||||||||||||||||||||||||||
| *overflowbool nonNullOk = false; | ||||||||||||||||||||||||||
| 2485 | if (*num == '\0') { | - | ||||||||||||||||||||||||
| if (ok != 0) | ||||||||||||||||||||||||||
| *okint len = false; | ||||||||||||||||||||||||||
| return 0.0; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (qstrcmpstatic_cast<int>(strlen(num, "nan") ==)); | ||||||||||||||||||||||||||
| 2486 | ((!(len >= 0) | - | ||||||||||||||||||||||||
| return qt_snan(); | ||||||||||||||||||||||||||
| if (qstrcmp)) ? qt_assert(num,"len "+inf") == 0 || qstrcmp(num,>= "inf") == 0) | ||||||||||||||||||||||||||
| return qt_inf(); | ||||||||||||||||||||||||||
| if (qstrcmp(num0", "-inf"__FILE__,3301) ==: qt_noop()); | ||||||||||||||||||||||||||
| 2487 | int processed = 0) | - | ||||||||||||||||||||||||
| return -qt_inf(); | ||||||||||||||||||||||||||
| bool _ok; | ||||||||||||||||||||||||||
| const char *endptr; | ||||||||||||||||||||||||||
| 2488 | double d = qstrtodasciiToDouble(num, &endptrlen, &_oknonNullOk, processed); | - | ||||||||||||||||||||||||
| 2489 | if (!_ok) { | 0 | ||||||||||||||||||||||||
| if (ok != 0) | ||||||||||||||||||||||||||
| *ok = false; | ||||||||||||||||||||||||||
| if (overflow != 0) | ||||||||||||||||||||||||||
| *overflow = *endptr != '\0'; | ||||||||||||||||||||||||||
| return 0.0; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| if (*endptr != '\0') { | ||||||||||||||||||||||||||
| if (ok != 0) | ||||||||||||||||||||||||||
| *ok = false; | ||||||||||||||||||||||||||
| if (overflow != 0) | ||||||||||||||||||||||||||
| *overflow = false; | ||||||||||||||||||||||||||
| return 0.0; | ||||||||||||||||||||||||||
}if (ok!= 0
| ||||||||||||||||||||||||||
| 2490 | * never executed: ok = truenonNullOk;*ok = nonNullOk;never executed: *ok = nonNullOk; | 0 | ||||||||||||||||||||||||
| 2491 | if (overflow!= 0
| 0 | ||||||||||||||||||||||||
| 2492 | * never executed: overflow = falseprocessed < len;*overflow = processed < len;never executed: *overflow = processed < len; | 0 | ||||||||||||||||||||||||
| 2493 | return never executed: d;return d;never executed: return d; | 0 | ||||||||||||||||||||||||
| 2494 | } | - | ||||||||||||||||||||||||
| 2495 | - | |||||||||||||||||||||||||
| 2496 | qlonglong QLocaleData::bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow) | - | ||||||||||||||||||||||||
| 2497 | { | - | ||||||||||||||||||||||||
| 2498 | bool _ok; | - | ||||||||||||||||||||||||
| 2499 | const char *endptr; | - | ||||||||||||||||||||||||
| 2500 | - | |||||||||||||||||||||||||
| 2501 | if (*num == '\0') { | - | ||||||||||||||||||||||||
| 2502 | if (ok != 0) | - | ||||||||||||||||||||||||
| 2503 | *ok = false; | - | ||||||||||||||||||||||||
| 2504 | if (overflow != 0) | - | ||||||||||||||||||||||||
| 2505 | *overflow = false; | - | ||||||||||||||||||||||||
| 2506 | return 0; | - | ||||||||||||||||||||||||
| 2507 | } | - | ||||||||||||||||||||||||
| 2508 | - | |||||||||||||||||||||||||
| 2509 | qlonglong l = qstrtoll(num, &endptr, base, &_ok); | - | ||||||||||||||||||||||||
| 2510 | - | |||||||||||||||||||||||||
| 2511 | if (!_ok) { | - | ||||||||||||||||||||||||
| 2512 | if (ok != 0) | - | ||||||||||||||||||||||||
| 2513 | *ok = false; | - | ||||||||||||||||||||||||
| 2514 | if (overflow != 0) { | - | ||||||||||||||||||||||||
| 2515 | - | |||||||||||||||||||||||||
| 2516 | - | |||||||||||||||||||||||||
| 2517 | *overflow = *endptr != '\0'; | - | ||||||||||||||||||||||||
| 2518 | } | - | ||||||||||||||||||||||||
| 2519 | return 0; | - | ||||||||||||||||||||||||
| 2520 | } | - | ||||||||||||||||||||||||
| 2521 | - | |||||||||||||||||||||||||
| 2522 | if (*endptr != '\0') { | - | ||||||||||||||||||||||||
| 2523 | - | |||||||||||||||||||||||||
| 2524 | if (ok != 0) | - | ||||||||||||||||||||||||
| 2525 | *ok = false; | - | ||||||||||||||||||||||||
| 2526 | if (overflow != 0) | - | ||||||||||||||||||||||||
| 2527 | *overflow = false; | - | ||||||||||||||||||||||||
| 2528 | return 0; | - | ||||||||||||||||||||||||
| 2529 | } | - | ||||||||||||||||||||||||
| 2530 | - | |||||||||||||||||||||||||
| 2531 | if (ok != 0) | - | ||||||||||||||||||||||||
| 2532 | *ok = true; | - | ||||||||||||||||||||||||
| 2533 | if (overflow != 0) | - | ||||||||||||||||||||||||
| 2534 | *overflow = false; | - | ||||||||||||||||||||||||
| 2535 | return l; | - | ||||||||||||||||||||||||
| 2536 | } | - | ||||||||||||||||||||||||
| 2537 | - | |||||||||||||||||||||||||
| 2538 | qulonglong QLocaleData::bytearrayToUnsLongLong(const char *num, int base, bool *ok) | - | ||||||||||||||||||||||||
| 2539 | { | - | ||||||||||||||||||||||||
| 2540 | bool _ok; | - | ||||||||||||||||||||||||
| 2541 | const char *endptr; | - | ||||||||||||||||||||||||
| 2542 | qulonglong l = qstrtoull(num, &endptr, base, &_ok); | - | ||||||||||||||||||||||||
| 2543 | - | |||||||||||||||||||||||||
| 2544 | if (!_ok || *endptr != '\0') { | - | ||||||||||||||||||||||||
| 2545 | if (ok != 0) | - | ||||||||||||||||||||||||
| 2546 | *ok = false; | - | ||||||||||||||||||||||||
| 2547 | return 0; | - | ||||||||||||||||||||||||
| 2548 | } | - | ||||||||||||||||||||||||
| 2549 | - | |||||||||||||||||||||||||
| 2550 | if (ok != 0) | - | ||||||||||||||||||||||||
| 2551 | *ok = true; | - | ||||||||||||||||||||||||
| 2552 | return l; | - | ||||||||||||||||||||||||
| 2553 | } | - | ||||||||||||||||||||||||
| 2554 | QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const | - | ||||||||||||||||||||||||
| 2555 | { | - | ||||||||||||||||||||||||
| 2556 | - | |||||||||||||||||||||||||
| 2557 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 2558 | QVariant res = systemLocale()->query(QSystemLocale::CurrencySymbol, format); | - | ||||||||||||||||||||||||
| 2559 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 2560 | return res.toString(); | - | ||||||||||||||||||||||||
| 2561 | } | - | ||||||||||||||||||||||||
| 2562 | - | |||||||||||||||||||||||||
| 2563 | quint32 idx, size; | - | ||||||||||||||||||||||||
| 2564 | switch (format) { | - | ||||||||||||||||||||||||
| 2565 | case CurrencySymbol: | - | ||||||||||||||||||||||||
| 2566 | idx = d->m_data->m_currency_symbol_idx; | - | ||||||||||||||||||||||||
| 2567 | size = d->m_data->m_currency_symbol_size; | - | ||||||||||||||||||||||||
| 2568 | return getLocaleData(currency_symbol_data + idx, size); | - | ||||||||||||||||||||||||
| 2569 | case CurrencyDisplayName: | - | ||||||||||||||||||||||||
| 2570 | idx = d->m_data->m_currency_display_name_idx; | - | ||||||||||||||||||||||||
| 2571 | size = d->m_data->m_currency_display_name_size; | - | ||||||||||||||||||||||||
| 2572 | return getLocaleListData(currency_display_name_data + idx, size, 0); | - | ||||||||||||||||||||||||
| 2573 | case CurrencyIsoCode: { | - | ||||||||||||||||||||||||
| 2574 | int len = 0; | - | ||||||||||||||||||||||||
| 2575 | const QLocaleData *data = this->d->m_data; | - | ||||||||||||||||||||||||
| 2576 | for (; len < 3; ++len) | - | ||||||||||||||||||||||||
| 2577 | if (!data->m_currency_iso_code[len]) | - | ||||||||||||||||||||||||
| 2578 | break; | - | ||||||||||||||||||||||||
| 2579 | return len ? QString::fromLatin1(data->m_currency_iso_code, len) : QString(); | - | ||||||||||||||||||||||||
| 2580 | } | - | ||||||||||||||||||||||||
| 2581 | } | - | ||||||||||||||||||||||||
| 2582 | return QString(); | - | ||||||||||||||||||||||||
| 2583 | } | - | ||||||||||||||||||||||||
| 2584 | QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const | - | ||||||||||||||||||||||||
| 2585 | { | - | ||||||||||||||||||||||||
| 2586 | - | |||||||||||||||||||||||||
| 2587 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 2588 | QSystemLocale::CurrencyToStringArgument arg(value, symbol); | - | ||||||||||||||||||||||||
| 2589 | QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg)); | - | ||||||||||||||||||||||||
| 2590 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 2591 | return res.toString(); | - | ||||||||||||||||||||||||
| 2592 | } | - | ||||||||||||||||||||||||
| 2593 | - | |||||||||||||||||||||||||
| 2594 | const QLocalePrivate *d = this->d; | - | ||||||||||||||||||||||||
| 2595 | quint8 idx = d->m_data->m_currency_format_idx; | - | ||||||||||||||||||||||||
| 2596 | quint8 size = d->m_data->m_currency_format_size; | - | ||||||||||||||||||||||||
| 2597 | if (d->m_data->m_currency_negative_format_size && value < 0) { | - | ||||||||||||||||||||||||
| 2598 | idx = d->m_data->m_currency_negative_format_idx; | - | ||||||||||||||||||||||||
| 2599 | size = d->m_data->m_currency_negative_format_size; | - | ||||||||||||||||||||||||
| 2600 | value = -value; | - | ||||||||||||||||||||||||
| 2601 | } | - | ||||||||||||||||||||||||
| 2602 | QString str = toString(value); | - | ||||||||||||||||||||||||
| 2603 | QString sym = symbol.isNull() ? currencySymbol() : symbol; | - | ||||||||||||||||||||||||
| 2604 | if (sym.isEmpty()) | - | ||||||||||||||||||||||||
| 2605 | sym = currencySymbol(QLocale::CurrencyIsoCode); | - | ||||||||||||||||||||||||
| 2606 | QString format = getLocaleData(currency_format_data + idx, size); | - | ||||||||||||||||||||||||
| 2607 | return format.arg(str, sym); | - | ||||||||||||||||||||||||
| 2608 | } | - | ||||||||||||||||||||||||
| 2609 | - | |||||||||||||||||||||||||
| 2610 | - | |||||||||||||||||||||||||
| 2611 | - | |||||||||||||||||||||||||
| 2612 | - | |||||||||||||||||||||||||
| 2613 | - | |||||||||||||||||||||||||
| 2614 | QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const | - | ||||||||||||||||||||||||
| 2615 | { | - | ||||||||||||||||||||||||
| 2616 | - | |||||||||||||||||||||||||
| 2617 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 2618 | QSystemLocale::CurrencyToStringArgument arg(value, symbol); | - | ||||||||||||||||||||||||
| 2619 | QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg)); | - | ||||||||||||||||||||||||
| 2620 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 2621 | return res.toString(); | - | ||||||||||||||||||||||||
| 2622 | } | - | ||||||||||||||||||||||||
| 2623 | - | |||||||||||||||||||||||||
| 2624 | const QLocaleData *data = this->d->m_data; | - | ||||||||||||||||||||||||
| 2625 | quint8 idx = data->m_currency_format_idx; | - | ||||||||||||||||||||||||
| 2626 | quint8 size = data->m_currency_format_size; | - | ||||||||||||||||||||||||
| 2627 | QString str = toString(value); | - | ||||||||||||||||||||||||
| 2628 | QString sym = symbol.isNull() ? currencySymbol() : symbol; | - | ||||||||||||||||||||||||
| 2629 | if (sym.isEmpty()) | - | ||||||||||||||||||||||||
| 2630 | sym = currencySymbol(QLocale::CurrencyIsoCode); | - | ||||||||||||||||||||||||
| 2631 | QString format = getLocaleData(currency_format_data + idx, size); | - | ||||||||||||||||||||||||
| 2632 | return format.arg(str, sym); | - | ||||||||||||||||||||||||
| 2633 | } | - | ||||||||||||||||||||||||
| 2634 | - | |||||||||||||||||||||||||
| 2635 | - | |||||||||||||||||||||||||
| 2636 | - | |||||||||||||||||||||||||
| 2637 | - | |||||||||||||||||||||||||
| 2638 | - | |||||||||||||||||||||||||
| 2639 | - | |||||||||||||||||||||||||
| 2640 | QString QLocale::toCurrencyString(double value, const QString &symbol) const | - | ||||||||||||||||||||||||
| 2641 | { | - | ||||||||||||||||||||||||
| 2642 | return never executed: toCurrencyString(value, symbol, d->m_data->m_currency_digitsreturn toCurrencyString(value, symbol, d->m_data->m_currency_digits);never executed: return toCurrencyString(value, symbol, d->m_data->m_currency_digits);never executed: );return toCurrencyString(value, symbol, d->m_data->m_currency_digits);never executed: return toCurrencyString(value, symbol, d->m_data->m_currency_digits); | 0 | ||||||||||||||||||||||||
| 2643 | } | - | ||||||||||||||||||||||||
| 2644 | QString QLocale::toCurrencyString(double value, const QString &symbol, int precision) const | - | ||||||||||||||||||||||||
| 2645 | { | - | ||||||||||||||||||||||||
| 2646 | - | |||||||||||||||||||||||||
| 2647 | if (d->m_data == systemData()
| 0 | ||||||||||||||||||||||||
| 2648 | QSystemLocale::CurrencyToStringArgument arg(value, symbol); | - | ||||||||||||||||||||||||
| 2649 | QVariant res = systemLocale()->query(QSystemLocale::CurrencyToString, QVariant::fromValue(arg)); | - | ||||||||||||||||||||||||
| 2650 | if (!res.isNull()
| 0 | ||||||||||||||||||||||||
| 2651 | return never executed: res.toString();return res.toString();never executed: return res.toString(); | 0 | ||||||||||||||||||||||||
| 2652 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2653 | - | |||||||||||||||||||||||||
| 2654 | const QLocaleData *data = this->d->m_data; | - | ||||||||||||||||||||||||
| 2655 | quint8 idx = data->m_currency_format_idx; | - | ||||||||||||||||||||||||
| 2656 | quint8 size = data->m_currency_format_size; | - | ||||||||||||||||||||||||
| 2657 | if (data->m_currency_negative_format_size
| 0 | ||||||||||||||||||||||||
| 2658 | idx = data->m_currency_negative_format_idx; | - | ||||||||||||||||||||||||
| 2659 | size = data->m_currency_negative_format_size; | - | ||||||||||||||||||||||||
| 2660 | value = -value; | - | ||||||||||||||||||||||||
| 2661 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2662 | QString str = toString(value, 'f', precision == -1 ? d->m_data->m_currency_digits : precision); | - | ||||||||||||||||||||||||
| 2663 | QString sym = symbol.isNull()
| 0 | ||||||||||||||||||||||||
| 2664 | if (sym.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2665 | sym = currencySymbol(QLocale::CurrencyIsoCode); never executed: sym = currencySymbol(QLocale::CurrencyIsoCode); | 0 | ||||||||||||||||||||||||
| 2666 | QString format = getLocaleData(currency_format_data + idx, size); | - | ||||||||||||||||||||||||
| 2667 | return never executed: format.arg(str, sym);return format.arg(str, sym);never executed: return format.arg(str, sym); | 0 | ||||||||||||||||||||||||
| 2668 | } | - | ||||||||||||||||||||||||
| 2669 | QStringList QLocale::uiLanguages() const | - | ||||||||||||||||||||||||
| 2670 | { | - | ||||||||||||||||||||||||
| 2671 | - | |||||||||||||||||||||||||
| 2672 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 2673 | QVariant res = systemLocale()->query(QSystemLocale::UILanguages, QVariant()); | - | ||||||||||||||||||||||||
| 2674 | if (!res.isNull()) { | - | ||||||||||||||||||||||||
| 2675 | QStringList result = res.toStringList(); | - | ||||||||||||||||||||||||
| 2676 | if (!result.isEmpty()) | - | ||||||||||||||||||||||||
| 2677 | return result; | - | ||||||||||||||||||||||||
| 2678 | } | - | ||||||||||||||||||||||||
| 2679 | } | - | ||||||||||||||||||||||||
| 2680 | - | |||||||||||||||||||||||||
| 2681 | QLocaleId id = QLocaleId::fromIds(d->m_data->m_language_id, d->m_data->m_script_id, d->m_data->m_country_id); | - | ||||||||||||||||||||||||
| 2682 | const QLocaleId max = id.withLikelySubtagsAdded(); | - | ||||||||||||||||||||||||
| 2683 | const QLocaleId min = max.withLikelySubtagsRemoved(); | - | ||||||||||||||||||||||||
| 2684 | - | |||||||||||||||||||||||||
| 2685 | QStringList uiLanguages; | - | ||||||||||||||||||||||||
| 2686 | uiLanguages.append(QString::fromLatin1(min.name())); | - | ||||||||||||||||||||||||
| 2687 | if (id.script_id) { | - | ||||||||||||||||||||||||
| 2688 | id.script_id = 0; | - | ||||||||||||||||||||||||
| 2689 | if (id != min && id.withLikelySubtagsAdded() == max) | - | ||||||||||||||||||||||||
| 2690 | uiLanguages.append(QString::fromLatin1(id.name())); | - | ||||||||||||||||||||||||
| 2691 | } | - | ||||||||||||||||||||||||
| 2692 | if (max != min && max != id) | - | ||||||||||||||||||||||||
| 2693 | uiLanguages.append(QString::fromLatin1(max.name())); | - | ||||||||||||||||||||||||
| 2694 | return uiLanguages; | - | ||||||||||||||||||||||||
| 2695 | } | - | ||||||||||||||||||||||||
| 2696 | QString QLocale::nativeLanguageName() const | - | ||||||||||||||||||||||||
| 2697 | { | - | ||||||||||||||||||||||||
| 2698 | - | |||||||||||||||||||||||||
| 2699 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 2700 | QVariant res = systemLocale()->query(QSystemLocale::NativeLanguageName, QVariant()); | - | ||||||||||||||||||||||||
| 2701 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 2702 | return res.toString(); | - | ||||||||||||||||||||||||
| 2703 | } | - | ||||||||||||||||||||||||
| 2704 | - | |||||||||||||||||||||||||
| 2705 | return getLocaleData(endonyms_data + d->m_data->m_language_endonym_idx, d->m_data->m_language_endonym_size); | - | ||||||||||||||||||||||||
| 2706 | } | - | ||||||||||||||||||||||||
| 2707 | QString QLocale::nativeCountryName() const | - | ||||||||||||||||||||||||
| 2708 | { | - | ||||||||||||||||||||||||
| 2709 | - | |||||||||||||||||||||||||
| 2710 | if (d->m_data == systemData()) { | - | ||||||||||||||||||||||||
| 2711 | QVariant res = systemLocale()->query(QSystemLocale::NativeCountryName, QVariant()); | - | ||||||||||||||||||||||||
| 2712 | if (!res.isNull()) | - | ||||||||||||||||||||||||
| 2713 | return res.toString(); | - | ||||||||||||||||||||||||
| 2714 | } | - | ||||||||||||||||||||||||
| 2715 | - | |||||||||||||||||||||||||
| 2716 | return getLocaleData(endonyms_data + d->m_data->m_country_endonym_idx, d->m_data->m_country_endonym_size); | - | ||||||||||||||||||||||||
| 2717 | } | - | ||||||||||||||||||||||||
| 2718 | - | |||||||||||||||||||||||||
| 2719 | - | |||||||||||||||||||||||||
| 2720 | QDebug operator<<(QDebug dbg, const QLocale &l) | - | ||||||||||||||||||||||||
| 2721 | { | - | ||||||||||||||||||||||||
| 2722 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||
| 2723 | dbg.nospace().noquote() | - | ||||||||||||||||||||||||
| 2724 | << "QLocale(" << QLocale::languageToString(l.language()) | - | ||||||||||||||||||||||||
| 2725 | << ", " << QLocale::scriptToString(l.script()) | - | ||||||||||||||||||||||||
| 2726 | << ", " << QLocale::countryToString(l.country()) << ')'; | - | ||||||||||||||||||||||||
| 2727 | return dbg; | - | ||||||||||||||||||||||||
| 2728 | } | - | ||||||||||||||||||||||||
| 2729 | - | |||||||||||||||||||||||||
| 2730 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |