| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qstringlist.h" | - |
| 43 | #include "qregexp.h" | - |
| 44 | #include "qregularexpression.h" | - |
| 45 | #include "qunicodetables_p.h" | - |
| 46 | #ifndef QT_NO_TEXTCODEC | - |
| 47 | #include <qtextcodec.h> | - |
| 48 | #endif | - |
| 49 | #include <private/qutfcodec_p.h> | - |
| 50 | #include "qsimd_p.h" | - |
| 51 | #include <qnumeric.h> | - |
| 52 | #include <qdatastream.h> | - |
| 53 | #include <qlist.h> | - |
| 54 | #include "qlocale.h" | - |
| 55 | #include "qlocale_p.h" | - |
| 56 | #include "qstringmatcher.h" | - |
| 57 | #include "qvarlengtharray.h" | - |
| 58 | #include "qtools_p.h" | - |
| 59 | #include "qhash.h" | - |
| 60 | #include "qdebug.h" | - |
| 61 | #include "qendian.h" | - |
| 62 | #include "qcollator_p.h" | - |
| 63 | | - |
| 64 | #ifdef Q_OS_MAC | - |
| 65 | #include <private/qcore_mac_p.h> | - |
| 66 | #endif | - |
| 67 | | - |
| 68 | #include <private/qfunctions_p.h> | - |
| 69 | | - |
| 70 | #include <limits.h> | - |
| 71 | #include <string.h> | - |
| 72 | #include <stdlib.h> | - |
| 73 | #include <stdio.h> | - |
| 74 | #include <stdarg.h> | - |
| 75 | | - |
| 76 | #include "qchar.cpp" | - |
| 77 | #include "qstringmatcher.cpp" | - |
| 78 | | - |
| 79 | #ifdef Q_OS_WIN | - |
| 80 | # include <qt_windows.h> | - |
| 81 | # ifdef Q_OS_WINCE | - |
| 82 | # include <winnls.h> | - |
| 83 | # endif | - |
| 84 | #endif | - |
| 85 | | - |
| 86 | #ifdef truncate | - |
| 87 | # undef truncate | - |
| 88 | #endif | - |
| 89 | | - |
| 90 | #ifndef LLONG_MAX | - |
| 91 | #define LLONG_MAX qint64_C(9223372036854775807) | - |
| 92 | #endif | - |
| 93 | #ifndef LLONG_MIN | - |
| 94 | #define LLONG_MIN (-LLONG_MAX - qint64_C(1)) | - |
| 95 | #endif | - |
| 96 | #ifndef ULLONG_MAX | - |
| 97 | #define ULLONG_MAX quint64_C(18446744073709551615) | - |
| 98 | #endif | - |
| 99 | | - |
| 100 | #define IS_RAW_DATA(d) ((d)->offset != sizeof(QStringData)) | - |
| 101 | | - |
| 102 | QT_BEGIN_NAMESPACE | - |
| 103 | | - |
| 104 | // internal | - |
| 105 | int qFindString(const QChar *haystack, int haystackLen, int from, | - |
| 106 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - |
| 107 | int qFindStringBoyerMoore(const QChar *haystack, int haystackLen, int from, | - |
| 108 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - |
| 109 | static inline int qt_last_index_of(const QChar *haystack, int haystackLen, QChar needle, | - |
| 110 | int from, Qt::CaseSensitivity cs); | - |
| 111 | static inline int qt_string_count(const QChar *haystack, int haystackLen, | - |
| 112 | const QChar *needle, int needleLen, | - |
| 113 | Qt::CaseSensitivity cs); | - |
| 114 | static inline int qt_string_count(const QChar *haystack, int haystackLen, | - |
| 115 | QChar needle, Qt::CaseSensitivity cs); | - |
| 116 | static inline int qt_find_latin1_string(const QChar *hay, int size, QLatin1String needle, | - |
| 117 | int from, Qt::CaseSensitivity cs); | - |
| 118 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - |
| 119 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - |
| 120 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - |
| 121 | QLatin1String needle, Qt::CaseSensitivity cs); | - |
| 122 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - |
| 123 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs); | - |
| 124 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - |
| 125 | QLatin1String needle, Qt::CaseSensitivity cs); | - |
| 126 | | - |
| 127 | // Unicode case-insensitive comparison | - |
| 128 | static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be) | - |
| 129 | { | - |
| 130 | if (a == b) evaluated: a == b| yes Evaluation Count:4326 | yes Evaluation Count:3750133 |
| 4326-3750133 |
| 131 | return (ae - be); executed: return (ae - be);Execution Count:4326 | 4326 |
| 132 | if (a == 0) partially evaluated: a == 0| no Evaluation Count:0 | yes Evaluation Count:3750133 |
| 0-3750133 |
| 133 | return 1; never executed: return 1; | 0 |
| 134 | if (b == 0) partially evaluated: b == 0| no Evaluation Count:0 | yes Evaluation Count:3750133 |
| 0-3750133 |
| 135 | return -1; never executed: return -1; | 0 |
| 136 | | - |
| 137 | const ushort *e = ae; executed (the execution status of this line is deduced): const ushort *e = ae; | - |
| 138 | if (be - b < ae - a) evaluated: be - b < ae - a| yes Evaluation Count:1177908 | yes Evaluation Count:2572225 |
| 1177908-2572225 |
| 139 | e = a + (be - b); executed: e = a + (be - b);Execution Count:1177908 | 1177908 |
| 140 | | - |
| 141 | uint alast = 0; executed (the execution status of this line is deduced): uint alast = 0; | - |
| 142 | uint blast = 0; executed (the execution status of this line is deduced): uint blast = 0; | - |
| 143 | while (a < e) { evaluated: a < e| yes Evaluation Count:11477796 | yes Evaluation Count:295350 |
| 295350-11477796 |
| 144 | // qDebug() << hex << alast << blast; | - |
| 145 | // qDebug() << hex << "*a=" << *a << "alast=" << alast << "folded=" << foldCase (*a, alast); | - |
| 146 | // qDebug() << hex << "*b=" << *b << "blast=" << blast << "folded=" << foldCase (*b, blast); | - |
| 147 | int diff = foldCase(*a, alast) - foldCase(*b, blast); executed (the execution status of this line is deduced): int diff = foldCase(*a, alast) - foldCase(*b, blast); | - |
| 148 | if ((diff)) evaluated: (diff)| yes Evaluation Count:3454783 | yes Evaluation Count:8023013 |
| 3454783-8023013 |
| 149 | return diff; executed: return diff;Execution Count:3454783 | 3454783 |
| 150 | ++a; executed (the execution status of this line is deduced): ++a; | - |
| 151 | ++b; executed (the execution status of this line is deduced): ++b; | - |
| 152 | } executed: }Execution Count:8023013 | 8023013 |
| 153 | if (a == ae) { evaluated: a == ae| yes Evaluation Count:289080 | yes Evaluation Count:6270 |
| 6270-289080 |
| 154 | if (b == be) evaluated: b == be| yes Evaluation Count:283444 | yes Evaluation Count:5636 |
| 5636-283444 |
| 155 | return 0; executed: return 0;Execution Count:283444 | 283444 |
| 156 | return -1; executed: return -1;Execution Count:5636 | 5636 |
| 157 | } | - |
| 158 | return 1; executed: return 1;Execution Count:6270 | 6270 |
| 159 | } | - |
| 160 | | - |
| 161 | // Case-insensitive comparison between a Unicode string and a QLatin1String | - |
| 162 | static int ucstricmp(const ushort *a, const ushort *ae, const uchar *b, const uchar *be) | - |
| 163 | { | - |
| 164 | if (a == 0) { partially evaluated: a == 0| no Evaluation Count:0 | yes Evaluation Count:6225 |
| 0-6225 |
| 165 | if (b == 0) | 0 |
| 166 | return 0; never executed: return 0; | 0 |
| 167 | return 1; never executed: return 1; | 0 |
| 168 | } | - |
| 169 | if (b == 0) partially evaluated: b == 0| no Evaluation Count:0 | yes Evaluation Count:6225 |
| 0-6225 |
| 170 | return -1; never executed: return -1; | 0 |
| 171 | | - |
| 172 | const ushort *e = ae; executed (the execution status of this line is deduced): const ushort *e = ae; | - |
| 173 | if (be - b < ae - a) evaluated: be - b < ae - a| yes Evaluation Count:1854 | yes Evaluation Count:4371 |
| 1854-4371 |
| 174 | e = a + (be - b); executed: e = a + (be - b);Execution Count:1854 | 1854 |
| 175 | | - |
| 176 | while (a < e) { evaluated: a < e| yes Evaluation Count:28654 | yes Evaluation Count:1621 |
| 1621-28654 |
| 177 | int diff = foldCase(*a) - foldCase(*b); executed (the execution status of this line is deduced): int diff = foldCase(*a) - foldCase(*b); | - |
| 178 | if ((diff)) evaluated: (diff)| yes Evaluation Count:4604 | yes Evaluation Count:24050 |
| 4604-24050 |
| 179 | return diff; executed: return diff;Execution Count:4604 | 4604 |
| 180 | ++a; executed (the execution status of this line is deduced): ++a; | - |
| 181 | ++b; executed (the execution status of this line is deduced): ++b; | - |
| 182 | } executed: }Execution Count:24050 | 24050 |
| 183 | if (a == ae) { evaluated: a == ae| yes Evaluation Count:1518 | yes Evaluation Count:103 |
| 103-1518 |
| 184 | if (b == be) evaluated: b == be| yes Evaluation Count:1418 | yes Evaluation Count:100 |
| 100-1418 |
| 185 | return 0; executed: return 0;Execution Count:1418 | 1418 |
| 186 | return -1; executed: return -1;Execution Count:100 | 100 |
| 187 | } | - |
| 188 | return 1; executed: return 1;Execution Count:103 | 103 |
| 189 | } | - |
| 190 | | - |
| 191 | // Unicode case-sensitive compare two same-sized strings | - |
| 192 | static int ucstrncmp(const QChar *a, const QChar *b, int l) | - |
| 193 | { | - |
| 194 | while (l-- && *a == *b) evaluated: l--| yes Evaluation Count:5130892 | yes Evaluation Count:74222 |
evaluated: *a == *b| yes Evaluation Count:4251530 | yes Evaluation Count:879404 |
| 74222-5130892 |
| 195 | a++,b++; executed: a++,b++;Execution Count:4251512 | 4251512 |
| 196 | if (l==-1) evaluated: l==-1| yes Evaluation Count:74222 | yes Evaluation Count:879383 |
| 74222-879383 |
| 197 | return 0; executed: return 0;Execution Count:74223 | 74223 |
| 198 | return a->unicode() - b->unicode(); executed: return a->unicode() - b->unicode();Execution Count:879375 | 879375 |
| 199 | } | - |
| 200 | | - |
| 201 | // Unicode case-sensitive comparison | - |
| 202 | static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen) | - |
| 203 | { | - |
| 204 | if (a == b && alen == blen) evaluated: a == b| yes Evaluation Count:9958 | yes Evaluation Count:950361 |
evaluated: alen == blen| yes Evaluation Count:9957 | yes Evaluation Count:1 |
| 1-950361 |
| 205 | return 0; executed: return 0;Execution Count:9957 | 9957 |
| 206 | int l = qMin(alen, blen); executed (the execution status of this line is deduced): int l = qMin(alen, blen); | - |
| 207 | int cmp = ucstrncmp(a, b, l); executed (the execution status of this line is deduced): int cmp = ucstrncmp(a, b, l); | - |
| 208 | return cmp ? cmp : (alen-blen); executed: return cmp ? cmp : (alen-blen);Execution Count:950411 | 950411 |
| 209 | } | - |
| 210 | | - |
| 211 | // Unicode case-insensitive compare two same-sized strings | - |
| 212 | static int ucstrnicmp(const ushort *a, const ushort *b, int l) | - |
| 213 | { | - |
| 214 | return ucstricmp(a, a + l, b, b + l); executed: return ucstricmp(a, a + l, b, b + l);Execution Count:1170 | 1170 |
| 215 | } | - |
| 216 | | - |
| 217 | // Benchmarking indicates that doing memcmp is much slower than | - |
| 218 | // executing the comparison ourselves. | - |
| 219 | // | - |
| 220 | // The profiling was done on a population of calls to qMemEquals, generated | - |
| 221 | // during a run of the demo browser. The profile of the data (32-bit x86 | - |
| 222 | // Linux) was: | - |
| 223 | // | - |
| 224 | // total number of comparisons: 21353 | - |
| 225 | // longest string compared: 95 | - |
| 226 | // average comparison length: 14.8786 | - |
| 227 | // cache-line crosses: 5661 (13.3%) | - |
| 228 | // alignment histogram: | - |
| 229 | // 0xXXX0 = 512 (1.2%) strings, 0 (0.0%) of which same-aligned | - |
| 230 | // 0xXXX2 = 15087 (35.3%) strings, 5145 (34.1%) of which same-aligned | - |
| 231 | // 0xXXX4 = 525 (1.2%) strings, 0 (0.0%) of which same-aligned | - |
| 232 | // 0xXXX6 = 557 (1.3%) strings, 6 (1.1%) of which same-aligned | - |
| 233 | // 0xXXX8 = 509 (1.2%) strings, 0 (0.0%) of which same-aligned | - |
| 234 | // 0xXXXa = 24358 (57.0%) strings, 9901 (40.6%) of which same-aligned | - |
| 235 | // 0xXXXc = 557 (1.3%) strings, 0 (0.0%) of which same-aligned | - |
| 236 | // 0xXXXe = 601 (1.4%) strings, 15 (2.5%) of which same-aligned | - |
| 237 | // total = 42706 (100%) strings, 15067 (35.3%) of which same-aligned | - |
| 238 | // | - |
| 239 | // 92% of the strings have alignment of 2 or 10, which is due to malloc on | - |
| 240 | // 32-bit Linux returning values aligned to 8 bytes, and offsetof(array, QString::Data) == 18. | - |
| 241 | // | - |
| 242 | // The profile on 64-bit will be different since offsetof(array, QString::Data) == 26. | - |
| 243 | // | - |
| 244 | // The benchmark results were, for a Core-i7 @ 2.67 GHz 32-bit, compiled with -O3 -funroll-loops: | - |
| 245 | // 16-bit loads only: 872,301 CPU ticks [Qt 4.5 / memcmp] | - |
| 246 | // 32- and 16-bit loads: 773,362 CPU ticks [Qt 4.6] | - |
| 247 | // SSE2 "movdqu" 128-bit loads: 618,736 CPU ticks | - |
| 248 | // SSE3 "lddqu" 128-bit loads: 619,954 CPU ticks | - |
| 249 | // SSSE3 "palignr" corrections: 852,147 CPU ticks | - |
| 250 | // SSE4.2 "pcmpestrm": 738,702 CPU ticks | - |
| 251 | // | - |
| 252 | // The same benchmark on an Atom N450 @ 1.66 GHz, is: | - |
| 253 | // 16-bit loads only: 2,185,882 CPU ticks | - |
| 254 | // 32- and 16-bit loads: 1,805,060 CPU ticks | - |
| 255 | // SSE2 "movdqu" 128-bit loads: 2,529,843 CPU ticks | - |
| 256 | // SSE3 "lddqu" 128-bit loads: 2,514,858 CPU ticks | - |
| 257 | // SSSE3 "palignr" corrections: 2,160,325 CPU ticks | - |
| 258 | // SSE4.2 not available | - |
| 259 | // | - |
| 260 | // The conclusion we reach is that alignment the SSE2 unaligned code can gain | - |
| 261 | // 20% improvement in performance in some systems, but suffers a penalty due | - |
| 262 | // to the unaligned loads on others. | - |
| 263 | | - |
| 264 | static bool qMemEquals(const quint16 *a, const quint16 *b, int length) | - |
| 265 | { | - |
| 266 | if (a == b || !length) evaluated: a == b| yes Evaluation Count:718616 | yes Evaluation Count:1759277 |
evaluated: !length| yes Evaluation Count:30698 | yes Evaluation Count:1728587 |
| 30698-1759277 |
| 267 | return true; executed: return true;Execution Count:749314 | 749314 |
| 268 | | - |
| 269 | register union { executed (the execution status of this line is deduced): register union { | - |
| 270 | const quint16 *w; executed (the execution status of this line is deduced): const quint16 *w; | - |
| 271 | const quint32 *d; executed (the execution status of this line is deduced): const quint32 *d; | - |
| 272 | quintptr value; executed (the execution status of this line is deduced): quintptr value; | - |
| 273 | } sa, sb; executed (the execution status of this line is deduced): } sa, sb; | - |
| 274 | sa.w = a; executed (the execution status of this line is deduced): sa.w = a; | - |
| 275 | sb.w = b; executed (the execution status of this line is deduced): sb.w = b; | - |
| 276 | | - |
| 277 | // check alignment | - |
| 278 | if ((sa.value & 2) == (sb.value & 2)) { evaluated: (sa.value & 2) == (sb.value & 2)| yes Evaluation Count:1633053 | yes Evaluation Count:95531 |
| 95531-1633053 |
| 279 | // both addresses have the same alignment | - |
| 280 | if (sa.value & 2) { evaluated: sa.value & 2| yes Evaluation Count:7103 | yes Evaluation Count:1625952 |
| 7103-1625952 |
| 281 | // both addresses are not aligned to 4-bytes boundaries | - |
| 282 | // compare the first character | - |
| 283 | if (*sa.w != *sb.w) evaluated: *sa.w != *sb.w| yes Evaluation Count:6645 | yes Evaluation Count:458 |
| 458-6645 |
| 284 | return false; executed: return false;Execution Count:6645 | 6645 |
| 285 | --length; executed (the execution status of this line is deduced): --length; | - |
| 286 | ++sa.w; executed (the execution status of this line is deduced): ++sa.w; | - |
| 287 | ++sb.w; executed (the execution status of this line is deduced): ++sb.w; | - |
| 288 | | - |
| 289 | // now both addresses are 4-bytes aligned | - |
| 290 | } executed: }Execution Count:458 | 458 |
| 291 | | - |
| 292 | // both addresses are 4-bytes aligned | - |
| 293 | // do a fast 32-bit comparison | - |
| 294 | register const quint32 *e = sa.d + (length >> 1); executed (the execution status of this line is deduced): register const quint32 *e = sa.d + (length >> 1); | - |
| 295 | for ( ; sa.d != e; ++sa.d, ++sb.d) { evaluated: sa.d != e| yes Evaluation Count:13704451 | yes Evaluation Count:1506349 |
| 1506349-13704451 |
| 296 | if (*sa.d != *sb.d) evaluated: *sa.d != *sb.d| yes Evaluation Count:120070 | yes Evaluation Count:13584390 |
| 120070-13584390 |
| 297 | return false; executed: return false;Execution Count:120067 | 120067 |
| 298 | } executed: }Execution Count:13584392 | 13584392 |
| 299 | | - |
| 300 | // do we have a tail? | - |
| 301 | return (length & 1) ? *sa.w == *sb.w : true; executed: return (length & 1) ? *sa.w == *sb.w : true;Execution Count:1506350 | 1506350 |
| 302 | } else { | - |
| 303 | // one of the addresses isn't 4-byte aligned but the other is | - |
| 304 | register const quint16 *e = sa.w + length; executed (the execution status of this line is deduced): register const quint16 *e = sa.w + length; | - |
| 305 | for ( ; sa.w != e; ++sa.w, ++sb.w) { evaluated: sa.w != e| yes Evaluation Count:461818 | yes Evaluation Count:44403 |
| 44403-461818 |
| 306 | if (*sa.w != *sb.w) evaluated: *sa.w != *sb.w| yes Evaluation Count:51128 | yes Evaluation Count:410690 |
| 51128-410690 |
| 307 | return false; executed: return false;Execution Count:51128 | 51128 |
| 308 | } executed: }Execution Count:410690 | 410690 |
| 309 | } executed: }Execution Count:44403 | 44403 |
| 310 | return true; executed: return true;Execution Count:44403 | 44403 |
| 311 | } | - |
| 312 | | - |
| 313 | /*! | - |
| 314 | \internal | - |
| 315 | | - |
| 316 | Returns the index position of the first occurrence of the | - |
| 317 | character \a ch in the string given by \a str and \a len, | - |
| 318 | searching forward from index | - |
| 319 | position \a from. Returns -1 if \a ch could not be found. | - |
| 320 | */ | - |
| 321 | static int findChar(const QChar *str, int len, QChar ch, int from, | - |
| 322 | Qt::CaseSensitivity cs) | - |
| 323 | { | - |
| 324 | const ushort *s = (const ushort *)str; executed (the execution status of this line is deduced): const ushort *s = (const ushort *)str; | - |
| 325 | ushort c = ch.unicode(); executed (the execution status of this line is deduced): ushort c = ch.unicode(); | - |
| 326 | if (from < 0) evaluated: from < 0| yes Evaluation Count:1 | yes Evaluation Count:285312 |
| 1-285312 |
| 327 | from = qMax(from + len, 0); executed: from = qMax(from + len, 0);Execution Count:1 | 1 |
| 328 | if (from < len) { evaluated: from < len| yes Evaluation Count:282232 | yes Evaluation Count:3086 |
| 3086-282232 |
| 329 | const ushort *n = s + from - 1; executed (the execution status of this line is deduced): const ushort *n = s + from - 1; | - |
| 330 | const ushort *e = s + len; executed (the execution status of this line is deduced): const ushort *e = s + len; | - |
| 331 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:281772 | yes Evaluation Count:459 |
| 459-281772 |
| 332 | while (++n != e) evaluated: ++n != e| yes Evaluation Count:2194211 | yes Evaluation Count:158325 |
| 158325-2194211 |
| 333 | if (*n == c) evaluated: *n == c| yes Evaluation Count:123464 | yes Evaluation Count:2070803 |
| 123464-2070803 |
| 334 | return n - s; executed: return n - s;Execution Count:123464 | 123464 |
| 335 | } else { executed: }Execution Count:158316 | 158316 |
| 336 | c = foldCase(c); executed (the execution status of this line is deduced): c = foldCase(c); | - |
| 337 | while (++n != e) evaluated: ++n != e| yes Evaluation Count:797 | yes Evaluation Count:125 |
| 125-797 |
| 338 | if (foldCase(*n) == c) evaluated: foldCase(*n) == c| yes Evaluation Count:334 | yes Evaluation Count:463 |
| 334-463 |
| 339 | return n - s; executed: return n - s;Execution Count:334 | 334 |
| 340 | } executed: }Execution Count:125 | 125 |
| 341 | } | - |
| 342 | return -1; executed: return -1;Execution Count:161528 | 161528 |
| 343 | } | - |
| 344 | | - |
| 345 | #define REHASH(a) \ | - |
| 346 | if (sl_minus_1 < (int)sizeof(int) * CHAR_BIT) \ | - |
| 347 | hashHaystack -= (a) << sl_minus_1; \ | - |
| 348 | hashHaystack <<= 1 | - |
| 349 | | - |
| 350 | inline bool qIsUpper(char ch) | - |
| 351 | { | - |
| 352 | return ch >= 'A' && ch <= 'Z'; executed: return ch >= 'A' && ch <= 'Z';Execution Count:1056766 | 1056766 |
| 353 | } | - |
| 354 | | - |
| 355 | inline bool qIsDigit(char ch) | - |
| 356 | { | - |
| 357 | return ch >= '0' && ch <= '9'; executed: return ch >= '0' && ch <= '9';Execution Count:67314 | 67314 |
| 358 | } | - |
| 359 | | - |
| 360 | inline char qToLower(char ch) | - |
| 361 | { | - |
| 362 | if (ch >= 'A' && ch <= 'Z') partially evaluated: ch >= 'A'| yes Evaluation Count:1056766 | no Evaluation Count:0 |
evaluated: ch <= 'Z'| yes Evaluation Count:4992 | yes Evaluation Count:1051774 |
| 0-1056766 |
| 363 | return ch - 'A' + 'a'; executed: return ch - 'A' + 'a';Execution Count:4992 | 4992 |
| 364 | else | - |
| 365 | return ch; executed: return ch;Execution Count:1051774 | 1051774 |
| 366 | } | - |
| 367 | | - |
| 368 | | - |
| 369 | const QString::Null QString::null = { }; | - |
| 370 | | - |
| 371 | /*! | - |
| 372 | \macro QT_NO_CAST_FROM_ASCII | - |
| 373 | \relates QString | - |
| 374 | | - |
| 375 | Disables automatic conversions from 8-bit strings (char *) to unicode QStrings | - |
| 376 | | - |
| 377 | \sa QT_NO_CAST_TO_ASCII, QT_NO_CAST_FROM_BYTEARRAY | - |
| 378 | */ | - |
| 379 | | - |
| 380 | /*! | - |
| 381 | \macro QT_NO_CAST_TO_ASCII | - |
| 382 | \relates QString | - |
| 383 | | - |
| 384 | disables automatic conversion from QString to 8-bit strings (char *) | - |
| 385 | | - |
| 386 | \sa QT_NO_CAST_FROM_ASCII, QT_NO_CAST_FROM_BYTEARRAY | - |
| 387 | */ | - |
| 388 | | - |
| 389 | /*! | - |
| 390 | \macro QT_ASCII_CAST_WARNINGS | - |
| 391 | \internal | - |
| 392 | \relates QString | - |
| 393 | | - |
| 394 | This macro can be defined to force a warning whenever a function is | - |
| 395 | called that automatically converts between unicode and 8-bit encodings. | - |
| 396 | | - |
| 397 | Note: This only works for compilers that support warnings for | - |
| 398 | deprecated API. | - |
| 399 | | - |
| 400 | \sa QT_NO_CAST_TO_ASCII, QT_NO_CAST_FROM_ASCII | - |
| 401 | */ | - |
| 402 | | - |
| 403 | /*! | - |
| 404 | \class QCharRef | - |
| 405 | \inmodule QtCore | - |
| 406 | \reentrant | - |
| 407 | \brief The QCharRef class is a helper class for QString. | - |
| 408 | | - |
| 409 | \internal | - |
| 410 | | - |
| 411 | \ingroup string-processing | - |
| 412 | | - |
| 413 | When you get an object of type QCharRef, if you can assign to it, | - |
| 414 | the assignment will apply to the character in the string from | - |
| 415 | which you got the reference. That is its whole purpose in life. | - |
| 416 | The QCharRef becomes invalid once modifications are made to the | - |
| 417 | string: if you want to keep the character, copy it into a QChar. | - |
| 418 | | - |
| 419 | Most of the QChar member functions also exist in QCharRef. | - |
| 420 | However, they are not explicitly documented here. | - |
| 421 | | - |
| 422 | \sa QString::operator[](), QString::at(), QChar | - |
| 423 | */ | - |
| 424 | | - |
| 425 | /*! | - |
| 426 | \class QString | - |
| 427 | \inmodule QtCore | - |
| 428 | \reentrant | - |
| 429 | | - |
| 430 | \brief The QString class provides a Unicode character string. | - |
| 431 | | - |
| 432 | \ingroup tools | - |
| 433 | \ingroup shared | - |
| 434 | \ingroup string-processing | - |
| 435 | | - |
| 436 | QString stores a string of 16-bit \l{QChar}s, where each QChar | - |
| 437 | corresponds one Unicode 4.0 character. (Unicode characters | - |
| 438 | with code values above 65535 are stored using surrogate pairs, | - |
| 439 | i.e., two consecutive \l{QChar}s.) | - |
| 440 | | - |
| 441 | \l{Unicode} is an international standard that supports most of the | - |
| 442 | writing systems in use today. It is a superset of US-ASCII (ANSI | - |
| 443 | X3.4-1986) and Latin-1 (ISO 8859-1), and all the US-ASCII/Latin-1 | - |
| 444 | characters are available at the same code positions. | - |
| 445 | | - |
| 446 | Behind the scenes, QString uses \l{implicit sharing} | - |
| 447 | (copy-on-write) to reduce memory usage and to avoid the needless | - |
| 448 | copying of data. This also helps reduce the inherent overhead of | - |
| 449 | storing 16-bit characters instead of 8-bit characters. | - |
| 450 | | - |
| 451 | In addition to QString, Qt also provides the QByteArray class to | - |
| 452 | store raw bytes and traditional 8-bit '\\0'-terminated strings. | - |
| 453 | For most purposes, QString is the class you want to use. It is | - |
| 454 | used throughout the Qt API, and the Unicode support ensures that | - |
| 455 | your applications will be easy to translate if you want to expand | - |
| 456 | your application's market at some point. The two main cases where | - |
| 457 | QByteArray is appropriate are when you need to store raw binary | - |
| 458 | data, and when memory conservation is critical (e.g., with | - |
| 459 | \l{Qt for Embedded Linux}). | - |
| 460 | | - |
| 461 | \tableofcontents | - |
| 462 | | - |
| 463 | \section1 Initializing a String | - |
| 464 | | - |
| 465 | One way to initialize a QString is simply to pass a \c{const char | - |
| 466 | *} to its constructor. For example, the following code creates a | - |
| 467 | QString of size 5 containing the data "Hello": | - |
| 468 | | - |
| 469 | \snippet qstring/main.cpp 0 | - |
| 470 | | - |
| 471 | QString converts the \c{const char *} data into Unicode using the | - |
| 472 | fromUtf8() function. | - |
| 473 | | - |
| 474 | In all of the QString functions that take \c{const char *} | - |
| 475 | parameters, the \c{const char *} is interpreted as a classic | - |
| 476 | C-style '\\0'-terminated string encoded in UTF-8. It is legal for | - |
| 477 | the \c{const char *} parameter to be 0. | - |
| 478 | | - |
| 479 | You can also provide string data as an array of \l{QChar}s: | - |
| 480 | | - |
| 481 | \snippet qstring/main.cpp 1 | - |
| 482 | | - |
| 483 | QString makes a deep copy of the QChar data, so you can modify it | - |
| 484 | later without experiencing side effects. (If for performance | - |
| 485 | reasons you don't want to take a deep copy of the character data, | - |
| 486 | use QString::fromRawData() instead.) | - |
| 487 | | - |
| 488 | Another approach is to set the size of the string using resize() | - |
| 489 | and to initialize the data character per character. QString uses | - |
| 490 | 0-based indexes, just like C++ arrays. To access the character at | - |
| 491 | a particular index position, you can use \l operator[](). On | - |
| 492 | non-const strings, \l operator[]() returns a reference to a | - |
| 493 | character that can be used on the left side of an assignment. For | - |
| 494 | example: | - |
| 495 | | - |
| 496 | \snippet qstring/main.cpp 2 | - |
| 497 | | - |
| 498 | For read-only access, an alternative syntax is to use the at() | - |
| 499 | function: | - |
| 500 | | - |
| 501 | \snippet qstring/main.cpp 3 | - |
| 502 | | - |
| 503 | The at() function can be faster than \l operator[](), because it | - |
| 504 | never causes a \l{deep copy} to occur. Alternatively, use the | - |
| 505 | left(), right(), or mid() functions to extract several characters | - |
| 506 | at a time. | - |
| 507 | | - |
| 508 | A QString can embed '\\0' characters (QChar::Null). The size() | - |
| 509 | function always returns the size of the whole string, including | - |
| 510 | embedded '\\0' characters. | - |
| 511 | | - |
| 512 | After a call to the resize() function, newly allocated characters | - |
| 513 | have undefined values. To set all the characters in the string to | - |
| 514 | a particular value, use the fill() function. | - |
| 515 | | - |
| 516 | QString provides dozens of overloads designed to simplify string | - |
| 517 | usage. For example, if you want to compare a QString with a string | - |
| 518 | literal, you can write code like this and it will work as expected: | - |
| 519 | | - |
| 520 | \snippet qstring/main.cpp 4 | - |
| 521 | | - |
| 522 | You can also pass string literals to functions that take QStrings | - |
| 523 | as arguments, invoking the QString(const char *) | - |
| 524 | constructor. Similarly, you can pass a QString to a function that | - |
| 525 | takes a \c{const char *} argument using the \l qPrintable() macro | - |
| 526 | which returns the given QString as a \c{const char *}. This is | - |
| 527 | equivalent to calling <QString>.toLocal8Bit().constData(). | - |
| 528 | | - |
| 529 | \section1 Manipulating String Data | - |
| 530 | | - |
| 531 | QString provides the following basic functions for modifying the | - |
| 532 | character data: append(), prepend(), insert(), replace(), and | - |
| 533 | remove(). For example: | - |
| 534 | | - |
| 535 | \snippet qstring/main.cpp 5 | - |
| 536 | | - |
| 537 | If you are building a QString gradually and know in advance | - |
| 538 | approximately how many characters the QString will contain, you | - |
| 539 | can call reserve(), asking QString to preallocate a certain amount | - |
| 540 | of memory. You can also call capacity() to find out how much | - |
| 541 | memory QString actually allocated. | - |
| 542 | | - |
| 543 | The replace() and remove() functions' first two arguments are the | - |
| 544 | position from which to start erasing and the number of characters | - |
| 545 | that should be erased. If you want to replace all occurrences of | - |
| 546 | a particular substring with another, use one of the two-parameter | - |
| 547 | replace() overloads. | - |
| 548 | | - |
| 549 | A frequent requirement is to remove whitespace characters from a | - |
| 550 | string ('\\n', '\\t', ' ', etc.). If you want to remove whitespace | - |
| 551 | from both ends of a QString, use the trimmed() function. If you | - |
| 552 | want to remove whitespace from both ends and replace multiple | - |
| 553 | consecutive whitespaces with a single space character within the | - |
| 554 | string, use simplified(). | - |
| 555 | | - |
| 556 | If you want to find all occurrences of a particular character or | - |
| 557 | substring in a QString, use the indexOf() or lastIndexOf() | - |
| 558 | functions. The former searches forward starting from a given index | - |
| 559 | position, the latter searches backward. Both return the index | - |
| 560 | position of the character or substring if they find it; otherwise, | - |
| 561 | they return -1. For example, here's a typical loop that finds all | - |
| 562 | occurrences of a particular substring: | - |
| 563 | | - |
| 564 | \snippet qstring/main.cpp 6 | - |
| 565 | | - |
| 566 | QString provides many functions for converting numbers into | - |
| 567 | strings and strings into numbers. See the arg() functions, the | - |
| 568 | setNum() functions, the number() static functions, and the | - |
| 569 | toInt(), toDouble(), and similar functions. | - |
| 570 | | - |
| 571 | To get an upper- or lowercase version of a string use toUpper() or | - |
| 572 | toLower(). | - |
| 573 | | - |
| 574 | Lists of strings are handled by the QStringList class. You can | - |
| 575 | split a string into a list of strings using the split() function, | - |
| 576 | and join a list of strings into a single string with an optional | - |
| 577 | separator using QStringList::join(). You can obtain a list of | - |
| 578 | strings from a string list that contain a particular substring or | - |
| 579 | that match a particular QRegExp using the QStringList::filter() | - |
| 580 | function. | - |
| 581 | | - |
| 582 | \section1 Querying String Data | - |
| 583 | | - |
| 584 | If you want to see if a QString starts or ends with a particular | - |
| 585 | substring use startsWith() or endsWith(). If you simply want to | - |
| 586 | check whether a QString contains a particular character or | - |
| 587 | substring, use the contains() function. If you want to find out | - |
| 588 | how many times a particular character or substring occurs in the | - |
| 589 | string, use count(). | - |
| 590 | | - |
| 591 | QStrings can be compared using overloaded operators such as \l | - |
| 592 | operator<(), \l operator<=(), \l operator==(), \l operator>=(), | - |
| 593 | and so on. Note that the comparison is based exclusively on the | - |
| 594 | numeric Unicode values of the characters. It is very fast, but is | - |
| 595 | not what a human would expect; the QString::localeAwareCompare() | - |
| 596 | function is a better choice for sorting user-interface strings. | - |
| 597 | | - |
| 598 | To obtain a pointer to the actual character data, call data() or | - |
| 599 | constData(). These functions return a pointer to the beginning of | - |
| 600 | the QChar data. The pointer is guaranteed to remain valid until a | - |
| 601 | non-const function is called on the QString. | - |
| 602 | | - |
| 603 | \section1 Converting Between 8-Bit Strings and Unicode Strings | - |
| 604 | | - |
| 605 | QString provides the following three functions that return a | - |
| 606 | \c{const char *} version of the string as QByteArray: toUtf8(), | - |
| 607 | toLatin1(), and toLocal8Bit(). | - |
| 608 | | - |
| 609 | \list | - |
| 610 | \li toLatin1() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. | - |
| 611 | \li toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a | - |
| 612 | superset of US-ASCII (ANSI X3.4-1986) that supports the entire | - |
| 613 | Unicode character set through multibyte sequences. | - |
| 614 | \li toLocal8Bit() returns an 8-bit string using the system's local | - |
| 615 | encoding. | - |
| 616 | \endlist | - |
| 617 | | - |
| 618 | To convert from one of these encodings, QString provides | - |
| 619 | fromLatin1(), fromUtf8(), and fromLocal8Bit(). Other | - |
| 620 | encodings are supported through the QTextCodec class. | - |
| 621 | | - |
| 622 | As mentioned above, QString provides a lot of functions and | - |
| 623 | operators that make it easy to interoperate with \c{const char *} | - |
| 624 | strings. But this functionality is a double-edged sword: It makes | - |
| 625 | QString more convenient to use if all strings are US-ASCII or | - |
| 626 | Latin-1, but there is always the risk that an implicit conversion | - |
| 627 | from or to \c{const char *} is done using the wrong 8-bit | - |
| 628 | encoding. To minimize these risks, you can turn off these implicit | - |
| 629 | conversions by defining the following two preprocessor symbols: | - |
| 630 | | - |
| 631 | \list | - |
| 632 | \li \c QT_NO_CAST_FROM_ASCII disables automatic conversions from | - |
| 633 | C string literals and pointers to Unicode. | - |
| 634 | \li \c QT_NO_CAST_TO_ASCII disables automatic conversion from QString | - |
| 635 | to C strings. | - |
| 636 | \endlist | - |
| 637 | | - |
| 638 | One way to define these preprocessor symbols globally for your | - |
| 639 | application is to add the following entry to your | - |
| 640 | \l{qmake Project Files}{qmake project file}: | - |
| 641 | | - |
| 642 | \snippet code/src_corelib_tools_qstring.cpp 0 | - |
| 643 | | - |
| 644 | You then need to explicitly call fromUtf8(), fromLatin1(), | - |
| 645 | or fromLocal8Bit() to construct a QString from an | - |
| 646 | 8-bit string, or use the lightweight QLatin1String class, for | - |
| 647 | example: | - |
| 648 | | - |
| 649 | \snippet code/src_corelib_tools_qstring.cpp 1 | - |
| 650 | | - |
| 651 | Similarly, you must call toLatin1(), toUtf8(), or | - |
| 652 | toLocal8Bit() explicitly to convert the QString to an 8-bit | - |
| 653 | string. (Other encodings are supported through the QTextCodec | - |
| 654 | class.) | - |
| 655 | | - |
| 656 | \table 100 % | - |
| 657 | \header | - |
| 658 | \li Note for C Programmers | - |
| 659 | | - |
| 660 | \row | - |
| 661 | \li | - |
| 662 | Due to C++'s type system and the fact that QString is | - |
| 663 | \l{implicitly shared}, QStrings may be treated like \c{int}s or | - |
| 664 | other basic types. For example: | - |
| 665 | | - |
| 666 | \snippet qstring/main.cpp 7 | - |
| 667 | | - |
| 668 | The \c result variable, is a normal variable allocated on the | - |
| 669 | stack. When \c return is called, and because we're returning by | - |
| 670 | value, the copy constructor is called and a copy of the string is | - |
| 671 | returned. No actual copying takes place thanks to the implicit | - |
| 672 | sharing. | - |
| 673 | | - |
| 674 | \endtable | - |
| 675 | | - |
| 676 | \section1 Distinction Between Null and Empty Strings | - |
| 677 | | - |
| 678 | For historical reasons, QString distinguishes between a null | - |
| 679 | string and an empty string. A \e null string is a string that is | - |
| 680 | initialized using QString's default constructor or by passing | - |
| 681 | (const char *)0 to the constructor. An \e empty string is any | - |
| 682 | string with size 0. A null string is always empty, but an empty | - |
| 683 | string isn't necessarily null: | - |
| 684 | | - |
| 685 | \snippet qstring/main.cpp 8 | - |
| 686 | | - |
| 687 | All functions except isNull() treat null strings the same as empty | - |
| 688 | strings. For example, toUtf8().constData() returns a pointer to a | - |
| 689 | '\\0' character for a null string (\e not a null pointer), and | - |
| 690 | QString() compares equal to QString(""). We recommend that you | - |
| 691 | always use the isEmpty() function and avoid isNull(). | - |
| 692 | | - |
| 693 | \section1 Argument Formats | - |
| 694 | | - |
| 695 | In member functions where an argument \e format can be specified | - |
| 696 | (e.g., arg(), number()), the argument \e format can be one of the | - |
| 697 | following: | - |
| 698 | | - |
| 699 | \table | - |
| 700 | \header \li Format \li Meaning | - |
| 701 | \row \li \c e \li format as [-]9.9e[+|-]999 | - |
| 702 | \row \li \c E \li format as [-]9.9E[+|-]999 | - |
| 703 | \row \li \c f \li format as [-]9.9 | - |
| 704 | \row \li \c g \li use \c e or \c f format, whichever is the most concise | - |
| 705 | \row \li \c G \li use \c E or \c f format, whichever is the most concise | - |
| 706 | \endtable | - |
| 707 | | - |
| 708 | A \e precision is also specified with the argument \e format. For | - |
| 709 | the 'e', 'E', and 'f' formats, the \e precision represents the | - |
| 710 | number of digits \e after the decimal point. For the 'g' and 'G' | - |
| 711 | formats, the \e precision represents the maximum number of | - |
| 712 | significant digits (trailing zeroes are omitted). | - |
| 713 | | - |
| 714 | \section1 More Efficient String Construction | - |
| 715 | | - |
| 716 | Many strings are known at compile time. But the trivial | - |
| 717 | constructor QString("Hello"), will copy the contents of the string, | - |
| 718 | treating the contents as Latin-1. To avoid this one can use the | - |
| 719 | QStringLiteral macro to directly create the required data at compile | - |
| 720 | time. Constructing a QString out of the literal does then not cause | - |
| 721 | any overhead at runtime. | - |
| 722 | | - |
| 723 | A slightly less efficient way is to use QLatin1String. This class wraps | - |
| 724 | a C string literal, precalculates it length at compile time and can | - |
| 725 | then be used for faster comparison with QStrings and conversion to | - |
| 726 | QStrings than a regular C string literal. | - |
| 727 | | - |
| 728 | Using the QString \c{'+'} operator, it is easy to construct a | - |
| 729 | complex string from multiple substrings. You will often write code | - |
| 730 | like this: | - |
| 731 | | - |
| 732 | \snippet qstring/stringbuilder.cpp 0 | - |
| 733 | | - |
| 734 | There is nothing wrong with either of these string constructions, | - |
| 735 | but there are a few hidden inefficiencies. Beginning with Qt 4.6, | - |
| 736 | you can eliminate them. | - |
| 737 | | - |
| 738 | First, multiple uses of the \c{'+'} operator usually means | - |
| 739 | multiple memory allocations. When concatenating \e{n} substrings, | - |
| 740 | where \e{n > 2}, there can be as many as \e{n - 1} calls to the | - |
| 741 | memory allocator. | - |
| 742 | | - |
| 743 | In 4.6, an internal template class \c{QStringBuilder} has been | - |
| 744 | added along with a few helper functions. This class is marked | - |
| 745 | internal and does not appear in the documentation, because you | - |
| 746 | aren't meant to instantiate it in your code. Its use will be | - |
| 747 | automatic, as described below. The class is found in | - |
| 748 | \c {src/corelib/tools/qstringbuilder.cpp} if you want to have a | - |
| 749 | look at it. | - |
| 750 | | - |
| 751 | \c{QStringBuilder} uses expression templates and reimplements the | - |
| 752 | \c{'%'} operator so that when you use \c{'%'} for string | - |
| 753 | concatenation instead of \c{'+'}, multiple substring | - |
| 754 | concatenations will be postponed until the final result is about | - |
| 755 | to be assigned to a QString. At this point, the amount of memory | - |
| 756 | required for the final result is known. The memory allocator is | - |
| 757 | then called \e{once} to get the required space, and the substrings | - |
| 758 | are copied into it one by one. | - |
| 759 | | - |
| 760 | Additional efficiency is gained by inlining and reduced reference | - |
| 761 | counting (the QString created from a \c{QStringBuilder} typically | - |
| 762 | has a ref count of 1, whereas QString::append() needs an extra | - |
| 763 | test). | - |
| 764 | | - |
| 765 | There are three ways you can access this improved method of string | - |
| 766 | construction. The straightforward way is to include | - |
| 767 | \c{QStringBuilder} wherever you want to use it, and use the | - |
| 768 | \c{'%'} operator instead of \c{'+'} when concatenating strings: | - |
| 769 | | - |
| 770 | \snippet qstring/stringbuilder.cpp 5 | - |
| 771 | | - |
| 772 | A more global approach which is the most convenient but | - |
| 773 | not entirely source compatible, is to this define in your | - |
| 774 | .pro file: | - |
| 775 | | - |
| 776 | \snippet qstring/stringbuilder.cpp 3 | - |
| 777 | | - |
| 778 | and the \c{'+'} will automatically be performed as the | - |
| 779 | \c{QStringBuilder} \c{'%'} everywhere. | - |
| 780 | | - |
| 781 | \sa fromRawData(), QChar, QLatin1String, QByteArray, QStringRef | - |
| 782 | */ | - |
| 783 | | - |
| 784 | /*! | - |
| 785 | \enum QString::SplitBehavior | - |
| 786 | | - |
| 787 | This enum specifies how the split() function should behave with | - |
| 788 | respect to empty strings. | - |
| 789 | | - |
| 790 | \value KeepEmptyParts If a field is empty, keep it in the result. | - |
| 791 | \value SkipEmptyParts If a field is empty, don't include it in the result. | - |
| 792 | | - |
| 793 | \sa split() | - |
| 794 | */ | - |
| 795 | | - |
| 796 | /*! \typedef QString::ConstIterator | - |
| 797 | | - |
| 798 | Qt-style synonym for QString::const_iterator. | - |
| 799 | */ | - |
| 800 | | - |
| 801 | /*! \typedef QString::Iterator | - |
| 802 | | - |
| 803 | Qt-style synonym for QString::iterator. | - |
| 804 | */ | - |
| 805 | | - |
| 806 | /*! \typedef QString::const_iterator | - |
| 807 | | - |
| 808 | The QString::const_iterator typedef provides an STL-style const | - |
| 809 | iterator for QString. | - |
| 810 | | - |
| 811 | \sa QString::iterator | - |
| 812 | */ | - |
| 813 | | - |
| 814 | /*! \typedef QString::iterator | - |
| 815 | | - |
| 816 | The QString::iterator typedef provides an STL-style non-const | - |
| 817 | iterator for QString. | - |
| 818 | | - |
| 819 | \sa QString::const_iterator | - |
| 820 | */ | - |
| 821 | | - |
| 822 | /*! | - |
| 823 | \typedef QString::const_reference | - |
| 824 | | - |
| 825 | The QString::const_reference typedef provides an STL-style | - |
| 826 | const reference for QString. | - |
| 827 | */ | - |
| 828 | /*! | - |
| 829 | \typedef QString::reference | - |
| 830 | | - |
| 831 | The QString::const_reference typedef provides an STL-style | - |
| 832 | reference for QString. | - |
| 833 | */ | - |
| 834 | /*! | - |
| 835 | \typedef QString::value_type | - |
| 836 | | - |
| 837 | The QString::const_reference typedef provides an STL-style | - |
| 838 | value type for QString. | - |
| 839 | */ | - |
| 840 | | - |
| 841 | /*! \fn QString::iterator QString::begin() | - |
| 842 | | - |
| 843 | Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in | - |
| 844 | the string. | - |
| 845 | | - |
| 846 | \sa constBegin(), end() | - |
| 847 | */ | - |
| 848 | | - |
| 849 | /*! \fn QString::const_iterator QString::begin() const | - |
| 850 | | - |
| 851 | \overload begin() | - |
| 852 | */ | - |
| 853 | | - |
| 854 | /*! \fn QString::const_iterator QString::cbegin() const | - |
| 855 | \since 5.0 | - |
| 856 | | - |
| 857 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character | - |
| 858 | in the string. | - |
| 859 | | - |
| 860 | \sa begin(), cend() | - |
| 861 | */ | - |
| 862 | | - |
| 863 | /*! \fn QString::const_iterator QString::constBegin() const | - |
| 864 | | - |
| 865 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character | - |
| 866 | in the string. | - |
| 867 | | - |
| 868 | \sa begin(), constEnd() | - |
| 869 | */ | - |
| 870 | | - |
| 871 | /*! \fn QString::iterator QString::end() | - |
| 872 | | - |
| 873 | Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary character | - |
| 874 | after the last character in the string. | - |
| 875 | | - |
| 876 | \sa begin(), constEnd() | - |
| 877 | */ | - |
| 878 | | - |
| 879 | /*! \fn QString::const_iterator QString::end() const | - |
| 880 | | - |
| 881 | \overload end() | - |
| 882 | */ | - |
| 883 | | - |
| 884 | /*! \fn QString::const_iterator QString::cend() const | - |
| 885 | \since 5.0 | - |
| 886 | | - |
| 887 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary | - |
| 888 | item after the last item in the list. | - |
| 889 | | - |
| 890 | \sa cbegin(), end() | - |
| 891 | */ | - |
| 892 | | - |
| 893 | /*! \fn QString::const_iterator QString::constEnd() const | - |
| 894 | | - |
| 895 | Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary | - |
| 896 | item after the last item in the list. | - |
| 897 | | - |
| 898 | \sa constBegin(), end() | - |
| 899 | */ | - |
| 900 | | - |
| 901 | /*! | - |
| 902 | \fn QString::QString() | - |
| 903 | | - |
| 904 | Constructs a null string. Null strings are also empty. | - |
| 905 | | - |
| 906 | \sa isEmpty() | - |
| 907 | */ | - |
| 908 | | - |
| 909 | /*! \fn QString::QString(const char *str) | - |
| 910 | | - |
| 911 | Constructs a string initialized with the 8-bit string \a str. The | - |
| 912 | given const char pointer is converted to Unicode using the | - |
| 913 | fromUtf8() function. | - |
| 914 | | - |
| 915 | You can disable this constructor by defining \c | - |
| 916 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 917 | can be useful if you want to ensure that all user-visible strings | - |
| 918 | go through QObject::tr(), for example. | - |
| 919 | | - |
| 920 | \sa fromLatin1(), fromLocal8Bit(), fromUtf8() | - |
| 921 | */ | - |
| 922 | | - |
| 923 | /*! \fn QString QString::fromStdString(const std::string &str) | - |
| 924 | | - |
| 925 | Returns a copy of the \a str string. The given string is converted | - |
| 926 | to Unicode using the fromUtf8() function. | - |
| 927 | | - |
| 928 | This constructor is only available if Qt is configured with STL | - |
| 929 | compatibility enabled. | - |
| 930 | | - |
| 931 | \sa fromLatin1(), fromLocal8Bit(), fromUtf8() | - |
| 932 | */ | - |
| 933 | | - |
| 934 | /*! \fn QString QString::fromStdWString(const std::wstring &str) | - |
| 935 | | - |
| 936 | Returns a copy of the \a str string. The given string is assumed | - |
| 937 | to be encoded in utf16 if the size of wchar_t is 2 bytes (e.g. on | - |
| 938 | windows) and ucs4 if the size of wchar_t is 4 bytes (most Unix | - |
| 939 | systems). | - |
| 940 | | - |
| 941 | \sa fromUtf16(), fromLatin1(), fromLocal8Bit(), fromUtf8(), fromUcs4() | - |
| 942 | */ | - |
| 943 | | - |
| 944 | /*! \fn QString QString::fromWCharArray(const wchar_t *string, int size) | - |
| 945 | \since 4.2 | - |
| 946 | | - |
| 947 | Returns a copy of the \a string, where the encoding of \a string depends on | - |
| 948 | the size of wchar. If wchar is 4 bytes, the \a string is interpreted as ucs-4, | - |
| 949 | if wchar is 2 bytes it is interpreted as ucs-2. | - |
| 950 | | - |
| 951 | If \a size is -1 (default), the \a string has to be 0 terminated. | - |
| 952 | | - |
| 953 | \sa fromUtf16(), fromLatin1(), fromLocal8Bit(), fromUtf8(), fromUcs4(), fromStdWString() | - |
| 954 | */ | - |
| 955 | | - |
| 956 | /*! \fn std::wstring QString::toStdWString() const | - |
| 957 | | - |
| 958 | Returns a std::wstring object with the data contained in this | - |
| 959 | QString. The std::wstring is encoded in utf16 on platforms where | - |
| 960 | wchar_t is 2 bytes wide (e.g. windows) and in ucs4 on platforms | - |
| 961 | where wchar_t is 4 bytes wide (most Unix systems). | - |
| 962 | | - |
| 963 | This operator is mostly useful to pass a QString to a function | - |
| 964 | that accepts a std::wstring object. | - |
| 965 | | - |
| 966 | \sa utf16(), toLatin1(), toUtf8(), toLocal8Bit() | - |
| 967 | */ | - |
| 968 | | - |
| 969 | // ### replace with QCharIterator | - |
| 970 | int QString::toUcs4_helper(const ushort *uc, int length, uint *out) | - |
| 971 | { | - |
| 972 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
| 973 | for (; i < length; ++i) { evaluated: i < length| yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
| 974 | uint u = uc[i]; executed (the execution status of this line is deduced): uint u = uc[i]; | - |
| 975 | if (QChar::isHighSurrogate(u) && i + 1 < length) { partially evaluated: QChar::isHighSurrogate(u)| no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: i + 1 < length | 0-5 |
| 976 | ushort low = uc[i+1]; never executed (the execution status of this line is deduced): ushort low = uc[i+1]; | - |
| 977 | if (QChar::isLowSurrogate(low)) { never evaluated: QChar::isLowSurrogate(low) | 0 |
| 978 | ++i; never executed (the execution status of this line is deduced): ++i; | - |
| 979 | u = QChar::surrogateToUcs4(u, low); never executed (the execution status of this line is deduced): u = QChar::surrogateToUcs4(u, low); | - |
| 980 | } | 0 |
| 981 | } | 0 |
| 982 | *out++ = u; executed (the execution status of this line is deduced): *out++ = u; | - |
| 983 | } executed: }Execution Count:5 | 5 |
| 984 | return i; executed: return i;Execution Count:1 | 1 |
| 985 | } | - |
| 986 | | - |
| 987 | /*! \fn int QString::toWCharArray(wchar_t *array) const | - |
| 988 | \since 4.2 | - |
| 989 | | - |
| 990 | Fills the \a array with the data contained in this QString object. | - |
| 991 | The array is encoded in utf16 on platforms where | - |
| 992 | wchar_t is 2 bytes wide (e.g. windows) and in ucs4 on platforms | - |
| 993 | where wchar_t is 4 bytes wide (most Unix systems). | - |
| 994 | | - |
| 995 | \a array has to be allocated by the caller and contain enough space to | - |
| 996 | hold the complete string (allocating the array with the same length as the | - |
| 997 | string is always sufficient). | - |
| 998 | | - |
| 999 | This function returns the actual length of the string in \a array. | - |
| 1000 | | - |
| 1001 | \note This function does not append a null character to the array. | - |
| 1002 | | - |
| 1003 | \sa utf16(), toUcs4(), toLatin1(), toUtf8(), toLocal8Bit(), toStdWString() | - |
| 1004 | */ | - |
| 1005 | | - |
| 1006 | /*! \fn QString::QString(const QString &other) | - |
| 1007 | | - |
| 1008 | Constructs a copy of \a other. | - |
| 1009 | | - |
| 1010 | This operation takes \l{constant time}, because QString is | - |
| 1011 | \l{implicitly shared}. This makes returning a QString from a | - |
| 1012 | function very fast. If a shared instance is modified, it will be | - |
| 1013 | copied (copy-on-write), and that takes \l{linear time}. | - |
| 1014 | | - |
| 1015 | \sa operator=() | - |
| 1016 | */ | - |
| 1017 | | - |
| 1018 | /*! | - |
| 1019 | Constructs a string initialized with the first \a size characters | - |
| 1020 | of the QChar array \a unicode. | - |
| 1021 | | - |
| 1022 | If \a unicode is 0, a null string is constructed. | - |
| 1023 | | - |
| 1024 | If \a size is negative, \a unicode is assumed to point to a nul-terminated | - |
| 1025 | array and its length is determined dynamically. The terminating | - |
| 1026 | nul-character is not considered part of the string. | - |
| 1027 | | - |
| 1028 | QString makes a deep copy of the string data. The unicode data is copied as | - |
| 1029 | is and the Byte Order Mark is preserved if present. | - |
| 1030 | | - |
| 1031 | \sa fromRawData() | - |
| 1032 | */ | - |
| 1033 | QString::QString(const QChar *unicode, int size) | - |
| 1034 | { | - |
| 1035 | if (!unicode) { evaluated: !unicode| yes Evaluation Count:3143 | yes Evaluation Count:13370496 |
| 3143-13370496 |
| 1036 | d = Data::sharedNull(); executed (the execution status of this line is deduced): d = Data::sharedNull(); | - |
| 1037 | } else { executed: }Execution Count:3143 | 3143 |
| 1038 | if (size < 0) { evaluated: size < 0| yes Evaluation Count:101017 | yes Evaluation Count:13269460 |
| 101017-13269460 |
| 1039 | size = 0; executed (the execution status of this line is deduced): size = 0; | - |
| 1040 | while (unicode[size] != 0) evaluated: unicode[size] != 0| yes Evaluation Count:2158999 | yes Evaluation Count:101017 |
| 101017-2158999 |
| 1041 | ++size; executed: ++size;Execution Count:2158999 | 2158999 |
| 1042 | } executed: }Execution Count:101017 | 101017 |
| 1043 | if (!size) { evaluated: !size| yes Evaluation Count:558939 | yes Evaluation Count:12811559 |
| 558939-12811559 |
| 1044 | d = Data::allocate(0); executed (the execution status of this line is deduced): d = Data::allocate(0); | - |
| 1045 | } else { executed: }Execution Count:558925 | 558925 |
| 1046 | d = Data::allocate(size + 1); executed (the execution status of this line is deduced): d = Data::allocate(size + 1); | - |
| 1047 | Q_CHECK_PTR(d); never executed: qBadAlloc(); executed: }Execution Count:12811776 partially evaluated: !(d)| no Evaluation Count:0 | yes Evaluation Count:12811818 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:12811759 |
| 0-12811818 |
| 1048 | d->size = size; executed (the execution status of this line is deduced): d->size = size; | - |
| 1049 | memcpy(d->data(), unicode, size * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(d->data(), unicode, size * sizeof(QChar)); | - |
| 1050 | d->data()[size] = '\0'; executed (the execution status of this line is deduced): d->data()[size] = '\0'; | - |
| 1051 | } executed: }Execution Count:12811751 | 12811751 |
| 1052 | } | - |
| 1053 | } | - |
| 1054 | | - |
| 1055 | /*! | - |
| 1056 | Constructs a string of the given \a size with every character set | - |
| 1057 | to \a ch. | - |
| 1058 | | - |
| 1059 | \sa fill() | - |
| 1060 | */ | - |
| 1061 | QString::QString(int size, QChar ch) | - |
| 1062 | { | - |
| 1063 | if (size <= 0) { evaluated: size <= 0| yes Evaluation Count:20756 | yes Evaluation Count:168912 |
| 20756-168912 |
| 1064 | d = Data::allocate(0); executed (the execution status of this line is deduced): d = Data::allocate(0); | - |
| 1065 | } else { executed: }Execution Count:20756 | 20756 |
| 1066 | d = Data::allocate(size + 1); executed (the execution status of this line is deduced): d = Data::allocate(size + 1); | - |
| 1067 | Q_CHECK_PTR(d); never executed: qBadAlloc(); executed: }Execution Count:168912 partially evaluated: !(d)| no Evaluation Count:0 | yes Evaluation Count:168912 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:168912 |
| 0-168912 |
| 1068 | d->size = size; executed (the execution status of this line is deduced): d->size = size; | - |
| 1069 | d->data()[size] = '\0'; executed (the execution status of this line is deduced): d->data()[size] = '\0'; | - |
| 1070 | ushort *i = d->data() + size; executed (the execution status of this line is deduced): ushort *i = d->data() + size; | - |
| 1071 | ushort *b = d->data(); executed (the execution status of this line is deduced): ushort *b = d->data(); | - |
| 1072 | const ushort value = ch.unicode(); executed (the execution status of this line is deduced): const ushort value = ch.unicode(); | - |
| 1073 | while (i != b) evaluated: i != b| yes Evaluation Count:342275 | yes Evaluation Count:168912 |
| 168912-342275 |
| 1074 | *--i = value; executed: *--i = value;Execution Count:342275 | 342275 |
| 1075 | } executed: }Execution Count:168912 | 168912 |
| 1076 | } | - |
| 1077 | | - |
| 1078 | /*! \fn QString::QString(int size, Qt::Initialization) | - |
| 1079 | \internal | - |
| 1080 | | - |
| 1081 | Constructs a string of the given \a size without initializing the | - |
| 1082 | characters. This is only used in \c QStringBuilder::toString(). | - |
| 1083 | */ | - |
| 1084 | QString::QString(int size, Qt::Initialization) | - |
| 1085 | { | - |
| 1086 | d = Data::allocate(size + 1); executed (the execution status of this line is deduced): d = Data::allocate(size + 1); | - |
| 1087 | Q_CHECK_PTR(d); never executed: qBadAlloc(); executed: }Execution Count:78893810 partially evaluated: !(d)| no Evaluation Count:0 | yes Evaluation Count:78893820 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:78893795 |
| 0-78893820 |
| 1088 | d->size = size; executed (the execution status of this line is deduced): d->size = size; | - |
| 1089 | d->data()[size] = '\0'; executed (the execution status of this line is deduced): d->data()[size] = '\0'; | - |
| 1090 | } executed: }Execution Count:78893799 | 78893799 |
| 1091 | | - |
| 1092 | /*! \fn QString::QString(QLatin1String str) | - |
| 1093 | | - |
| 1094 | Constructs a copy of the Latin-1 string \a str. | - |
| 1095 | | - |
| 1096 | \sa fromLatin1() | - |
| 1097 | */ | - |
| 1098 | | - |
| 1099 | /*! | - |
| 1100 | Constructs a string of size 1 containing the character \a ch. | - |
| 1101 | */ | - |
| 1102 | QString::QString(QChar ch) | - |
| 1103 | { | - |
| 1104 | d = Data::allocate(2); executed (the execution status of this line is deduced): d = Data::allocate(2); | - |
| 1105 | Q_CHECK_PTR(d); never executed: qBadAlloc(); executed: }Execution Count:2510083 partially evaluated: !(d)| no Evaluation Count:0 | yes Evaluation Count:2510084 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:2510084 |
| 0-2510084 |
| 1106 | d->size = 1; executed (the execution status of this line is deduced): d->size = 1; | - |
| 1107 | d->data()[0] = ch.unicode(); executed (the execution status of this line is deduced): d->data()[0] = ch.unicode(); | - |
| 1108 | d->data()[1] = '\0'; executed (the execution status of this line is deduced): d->data()[1] = '\0'; | - |
| 1109 | } executed: }Execution Count:2510083 | 2510083 |
| 1110 | | - |
| 1111 | /*! \fn QString::QString(const QByteArray &ba) | - |
| 1112 | | - |
| 1113 | Constructs a string initialized with the byte array \a ba. The | - |
| 1114 | given byte array is converted to Unicode using fromUtf8(). Stops | - |
| 1115 | copying at the first 0 character, otherwise copies the entire byte | - |
| 1116 | array. | - |
| 1117 | | - |
| 1118 | You can disable this constructor by defining \c | - |
| 1119 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 1120 | can be useful if you want to ensure that all user-visible strings | - |
| 1121 | go through QObject::tr(), for example. | - |
| 1122 | | - |
| 1123 | \sa fromLatin1(), fromLocal8Bit(), fromUtf8() | - |
| 1124 | */ | - |
| 1125 | | - |
| 1126 | /*! \fn QString::QString(const Null &) | - |
| 1127 | \internal | - |
| 1128 | */ | - |
| 1129 | | - |
| 1130 | /*! \fn QString &QString::operator=(const Null &) | - |
| 1131 | \internal | - |
| 1132 | */ | - |
| 1133 | | - |
| 1134 | /*! | - |
| 1135 | \fn QString::~QString() | - |
| 1136 | | - |
| 1137 | Destroys the string. | - |
| 1138 | */ | - |
| 1139 | | - |
| 1140 | | - |
| 1141 | /*! \fn void QString::swap(QString &other) | - |
| 1142 | \since 4.8 | - |
| 1143 | | - |
| 1144 | Swaps string \a other with this string. This operation is very fast and | - |
| 1145 | never fails. | - |
| 1146 | */ | - |
| 1147 | | - |
| 1148 | /*! \fn void QString::detach() | - |
| 1149 | | - |
| 1150 | \internal | - |
| 1151 | */ | - |
| 1152 | | - |
| 1153 | /*! \fn bool QString::isDetached() const | - |
| 1154 | | - |
| 1155 | \internal | - |
| 1156 | */ | - |
| 1157 | | - |
| 1158 | /*! \fn bool QString::isSharedWith(const QString &other) const | - |
| 1159 | | - |
| 1160 | \internal | - |
| 1161 | */ | - |
| 1162 | | - |
| 1163 | /*! | - |
| 1164 | Sets the size of the string to \a size characters. | - |
| 1165 | | - |
| 1166 | If \a size is greater than the current size, the string is | - |
| 1167 | extended to make it \a size characters long with the extra | - |
| 1168 | characters added to the end. The new characters are uninitialized. | - |
| 1169 | | - |
| 1170 | If \a size is less than the current size, characters are removed | - |
| 1171 | from the end. | - |
| 1172 | | - |
| 1173 | Example: | - |
| 1174 | | - |
| 1175 | \snippet qstring/main.cpp 45 | - |
| 1176 | | - |
| 1177 | If you want to append a certain number of identical characters to | - |
| 1178 | the string, use \l operator+=() as follows rather than resize(): | - |
| 1179 | | - |
| 1180 | \snippet qstring/main.cpp 46 | - |
| 1181 | | - |
| 1182 | If you want to expand the string so that it reaches a certain | - |
| 1183 | width and fill the new positions with a particular character, use | - |
| 1184 | the leftJustified() function: | - |
| 1185 | | - |
| 1186 | If \a size is negative, it is equivalent to passing zero. | - |
| 1187 | | - |
| 1188 | \snippet qstring/main.cpp 47 | - |
| 1189 | | - |
| 1190 | \sa truncate(), reserve() | - |
| 1191 | */ | - |
| 1192 | | - |
| 1193 | void QString::resize(int size) | - |
| 1194 | { | - |
| 1195 | if (size < 0) evaluated: size < 0| yes Evaluation Count:9 | yes Evaluation Count:105770619 |
| 9-105770619 |
| 1196 | size = 0; executed: size = 0;Execution Count:9 | 9 |
| 1197 | | - |
| 1198 | if (IS_RAW_DATA(d) && !d->ref.isShared() && size < d->size) { evaluated: ((d)->offset != sizeof(QStringData))| yes Evaluation Count:2 | yes Evaluation Count:105770583 |
partially evaluated: !d->ref.isShared()| yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: size < d->size| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-105770583 |
| 1199 | d->size = size; executed (the execution status of this line is deduced): d->size = size; | - |
| 1200 | return; executed: return;Execution Count:2 | 2 |
| 1201 | } | - |
| 1202 | | - |
| 1203 | if (size == 0 && !d->capacityReserved) { evaluated: size == 0| yes Evaluation Count:480855 | yes Evaluation Count:105289745 |
evaluated: !d->capacityReserved| yes Evaluation Count:21506 | yes Evaluation Count:459349 |
| 21506-105289745 |
| 1204 | Data *x = Data::allocate(0); executed (the execution status of this line is deduced): Data *x = Data::allocate(0); | - |
| 1205 | if (!d->ref.deref()) evaluated: !d->ref.deref()| yes Evaluation Count:8917 | yes Evaluation Count:12589 |
| 8917-12589 |
| 1206 | Data::deallocate(d); executed: Data::deallocate(d);Execution Count:8917 | 8917 |
| 1207 | d = x; executed (the execution status of this line is deduced): d = x; | - |
| 1208 | } else { executed: }Execution Count:21506 | 21506 |
| 1209 | if (d->ref.isShared() || uint(size) + 1u > d->alloc evaluated: d->ref.isShared()| yes Evaluation Count:743930 | yes Evaluation Count:105005228 |
evaluated: uint(size) + 1u > d->alloc| yes Evaluation Count:773677 | yes Evaluation Count:104231610 |
| 743930-105005228 |
| 1210 | || (!d->capacityReserved && size < d->size evaluated: !d->capacityReserved| yes Evaluation Count:103488302 | yes Evaluation Count:743417 |
evaluated: size < d->size| yes Evaluation Count:62049919 | yes Evaluation Count:41438380 |
| 743417-103488302 |
| 1211 | && uint(size) + 1u < uint(d->alloc >> 1))) evaluated: uint(size) + 1u < uint(d->alloc >> 1)| yes Evaluation Count:94531 | yes Evaluation Count:61955396 |
| 94531-61955396 |
| 1212 | reallocData(uint(size) + 1u, true); executed: reallocData(uint(size) + 1u, true);Execution Count:1612138 | 1612138 |
| 1213 | if (d->alloc) { partially evaluated: d->alloc| yes Evaluation Count:105749185 | no Evaluation Count:0 |
| 0-105749185 |
| 1214 | d->size = size; executed (the execution status of this line is deduced): d->size = size; | - |
| 1215 | d->data()[size] = '\0'; executed (the execution status of this line is deduced): d->data()[size] = '\0'; | - |
| 1216 | } executed: }Execution Count:105749184 | 105749184 |
| 1217 | } executed: }Execution Count:105749196 | 105749196 |
| 1218 | } | - |
| 1219 | | - |
| 1220 | /*! \fn int QString::capacity() const | - |
| 1221 | | - |
| 1222 | Returns the maximum number of characters that can be stored in | - |
| 1223 | the string without forcing a reallocation. | - |
| 1224 | | - |
| 1225 | The sole purpose of this function is to provide a means of fine | - |
| 1226 | tuning QString's memory usage. In general, you will rarely ever | - |
| 1227 | need to call this function. If you want to know how many | - |
| 1228 | characters are in the string, call size(). | - |
| 1229 | | - |
| 1230 | \sa reserve(), squeeze() | - |
| 1231 | */ | - |
| 1232 | | - |
| 1233 | /*! | - |
| 1234 | \fn void QString::reserve(int size) | - |
| 1235 | | - |
| 1236 | Attempts to allocate memory for at least \a size characters. If | - |
| 1237 | you know in advance how large the string will be, you can call | - |
| 1238 | this function, and if you resize the string often you are likely | - |
| 1239 | to get better performance. If \a size is an underestimate, the | - |
| 1240 | worst that will happen is that the QString will be a bit slower. | - |
| 1241 | | - |
| 1242 | The sole purpose of this function is to provide a means of fine | - |
| 1243 | tuning QString's memory usage. In general, you will rarely ever | - |
| 1244 | need to call this function. If you want to change the size of the | - |
| 1245 | string, call resize(). | - |
| 1246 | | - |
| 1247 | This function is useful for code that needs to build up a long | - |
| 1248 | string and wants to avoid repeated reallocation. In this example, | - |
| 1249 | we want to add to the string until some condition is true, and | - |
| 1250 | we're fairly sure that size is large enough to make a call to | - |
| 1251 | reserve() worthwhile: | - |
| 1252 | | - |
| 1253 | \snippet qstring/main.cpp 44 | - |
| 1254 | | - |
| 1255 | \sa squeeze(), capacity() | - |
| 1256 | */ | - |
| 1257 | | - |
| 1258 | /*! | - |
| 1259 | \fn void QString::squeeze() | - |
| 1260 | | - |
| 1261 | Releases any memory not required to store the character data. | - |
| 1262 | | - |
| 1263 | The sole purpose of this function is to provide a means of fine | - |
| 1264 | tuning QString's memory usage. In general, you will rarely ever | - |
| 1265 | need to call this function. | - |
| 1266 | | - |
| 1267 | \sa reserve(), capacity() | - |
| 1268 | */ | - |
| 1269 | | - |
| 1270 | void QString::reallocData(uint alloc, bool grow) | - |
| 1271 | { | - |
| 1272 | if (grow) evaluated: grow| yes Evaluation Count:3493417 | yes Evaluation Count:599703 |
| 599703-3493417 |
| 1273 | alloc = qAllocMore(alloc * sizeof(QChar), sizeof(Data)) / sizeof(QChar); executed: alloc = qAllocMore(alloc * sizeof(QChar), sizeof(Data)) / sizeof(QChar);Execution Count:3493416 | 3493416 |
| 1274 | | - |
| 1275 | if (d->ref.isShared() || IS_RAW_DATA(d)) { evaluated: d->ref.isShared()| yes Evaluation Count:1888219 | yes Evaluation Count:2204896 |
evaluated: ((d)->offset != sizeof(QStringData))| yes Evaluation Count:796 | yes Evaluation Count:2204105 |
| 796-2204896 |
| 1276 | Data::AllocationOptions allocOptions(d->capacityReserved ? Data::CapacityReserved : 0); executed (the execution status of this line is deduced): Data::AllocationOptions allocOptions(d->capacityReserved ? Data::CapacityReserved : 0); | - |
| 1277 | Data *x = Data::allocate(alloc, allocOptions); executed (the execution status of this line is deduced): Data *x = Data::allocate(alloc, allocOptions); | - |
| 1278 | Q_CHECK_PTR(x); never executed: qBadAlloc(); executed: }Execution Count:1889028 partially evaluated: !(x)| no Evaluation Count:0 | yes Evaluation Count:1889061 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:1889025 |
| 0-1889061 |
| 1279 | x->size = qMin(int(alloc) - 1, d->size); executed (the execution status of this line is deduced): x->size = qMin(int(alloc) - 1, d->size); | - |
| 1280 | ::memcpy(x->data(), d->data(), x->size * sizeof(QChar)); executed (the execution status of this line is deduced): ::memcpy(x->data(), d->data(), x->size * sizeof(QChar)); | - |
| 1281 | x->data()[x->size] = 0; executed (the execution status of this line is deduced): x->data()[x->size] = 0; | - |
| 1282 | if (!d->ref.deref()) evaluated: !d->ref.deref()| yes Evaluation Count:796 | yes Evaluation Count:1888258 |
| 796-1888258 |
| 1283 | Data::deallocate(d); executed: Data::deallocate(d);Execution Count:796 | 796 |
| 1284 | d = x; executed (the execution status of this line is deduced): d = x; | - |
| 1285 | } else { executed: }Execution Count:1889047 | 1889047 |
| 1286 | Data *p = static_cast<Data *>(::realloc(d, sizeof(Data) + alloc * sizeof(QChar))); executed (the execution status of this line is deduced): Data *p = static_cast<Data *>(::realloc(d, sizeof(Data) + alloc * sizeof(QChar))); | - |
| 1287 | Q_CHECK_PTR(p); never executed: qBadAlloc(); executed: }Execution Count:2204108 partially evaluated: !(p)| no Evaluation Count:0 | yes Evaluation Count:2204108 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:2204107 |
| 0-2204108 |
| 1288 | d = p; executed (the execution status of this line is deduced): d = p; | - |
| 1289 | d->alloc = alloc; executed (the execution status of this line is deduced): d->alloc = alloc; | - |
| 1290 | d->offset = sizeof(QStringData); executed (the execution status of this line is deduced): d->offset = sizeof(QStringData); | - |
| 1291 | } executed: }Execution Count:2204108 | 2204108 |
| 1292 | } | - |
| 1293 | | - |
| 1294 | void QString::expand(int i) | - |
| 1295 | { | - |
| 1296 | int sz = d->size; executed (the execution status of this line is deduced): int sz = d->size; | - |
| 1297 | resize(qMax(i + 1, sz)); executed (the execution status of this line is deduced): resize(qMax(i + 1, sz)); | - |
| 1298 | if (d->size - 1 > sz) { evaluated: d->size - 1 > sz| yes Evaluation Count:165945 | yes Evaluation Count:1353056 |
| 165945-1353056 |
| 1299 | ushort *n = d->data() + d->size - 1; executed (the execution status of this line is deduced): ushort *n = d->data() + d->size - 1; | - |
| 1300 | ushort *e = d->data() + sz; executed (the execution status of this line is deduced): ushort *e = d->data() + sz; | - |
| 1301 | while (n != e) evaluated: n != e| yes Evaluation Count:1380326 | yes Evaluation Count:165945 |
| 165945-1380326 |
| 1302 | * --n = ' '; executed: * --n = ' ';Execution Count:1380326 | 1380326 |
| 1303 | } executed: }Execution Count:165945 | 165945 |
| 1304 | } executed: }Execution Count:1519001 | 1519001 |
| 1305 | | - |
| 1306 | /*! \fn void QString::clear() | - |
| 1307 | | - |
| 1308 | Clears the contents of the string and makes it empty. | - |
| 1309 | | - |
| 1310 | \sa resize(), isEmpty() | - |
| 1311 | */ | - |
| 1312 | | - |
| 1313 | /*! \fn QString &QString::operator=(const QString &other) | - |
| 1314 | | - |
| 1315 | Assigns \a other to this string and returns a reference to this | - |
| 1316 | string. | - |
| 1317 | */ | - |
| 1318 | | - |
| 1319 | QString &QString::operator=(const QString &other) | - |
| 1320 | { | - |
| 1321 | other.d->ref.ref(); executed (the execution status of this line is deduced): other.d->ref.ref(); | - |
| 1322 | if (!d->ref.deref()) evaluated: !d->ref.deref()| yes Evaluation Count:739565 | yes Evaluation Count:5901735 |
| 739565-5901735 |
| 1323 | Data::deallocate(d); executed: Data::deallocate(d);Execution Count:739565 | 739565 |
| 1324 | d = other.d; executed (the execution status of this line is deduced): d = other.d; | - |
| 1325 | return *this; executed: return *this;Execution Count:6641159 | 6641159 |
| 1326 | } | - |
| 1327 | | - |
| 1328 | | - |
| 1329 | /*! \fn QString &QString::operator=(QLatin1String str) | - |
| 1330 | | - |
| 1331 | \overload operator=() | - |
| 1332 | | - |
| 1333 | Assigns the Latin-1 string \a str to this string. | - |
| 1334 | */ | - |
| 1335 | | - |
| 1336 | /*! \fn QString &QString::operator=(const QByteArray &ba) | - |
| 1337 | | - |
| 1338 | \overload operator=() | - |
| 1339 | | - |
| 1340 | Assigns \a ba to this string. The byte array is converted to Unicode | - |
| 1341 | using the fromUtf8() function. This function stops conversion at the | - |
| 1342 | first NUL character found, or the end of the \a ba byte array. | - |
| 1343 | | - |
| 1344 | You can disable this operator by defining \c | - |
| 1345 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 1346 | can be useful if you want to ensure that all user-visible strings | - |
| 1347 | go through QObject::tr(), for example. | - |
| 1348 | */ | - |
| 1349 | | - |
| 1350 | /*! \fn QString &QString::operator=(const char *str) | - |
| 1351 | | - |
| 1352 | \overload operator=() | - |
| 1353 | | - |
| 1354 | Assigns \a str to this string. The const char pointer is converted | - |
| 1355 | to Unicode using the fromUtf8() function. | - |
| 1356 | | - |
| 1357 | You can disable this operator by defining \c | - |
| 1358 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 1359 | can be useful if you want to ensure that all user-visible strings | - |
| 1360 | go through QObject::tr(), for example. | - |
| 1361 | */ | - |
| 1362 | | - |
| 1363 | /*! \fn QString &QString::operator=(char ch) | - |
| 1364 | | - |
| 1365 | \overload operator=() | - |
| 1366 | | - |
| 1367 | Assigns character \a ch to this string. Note that the character is | - |
| 1368 | converted to Unicode using the fromLatin1() function, unlike other 8-bit | - |
| 1369 | functions that operate on UTF-8 data. | - |
| 1370 | | - |
| 1371 | You can disable this operator by defining \c | - |
| 1372 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 1373 | can be useful if you want to ensure that all user-visible strings | - |
| 1374 | go through QObject::tr(), for example. | - |
| 1375 | */ | - |
| 1376 | | - |
| 1377 | /*! | - |
| 1378 | \overload operator=() | - |
| 1379 | | - |
| 1380 | Sets the string to contain the single character \a ch. | - |
| 1381 | */ | - |
| 1382 | QString &QString::operator=(QChar ch) | - |
| 1383 | { | - |
| 1384 | return operator=(QString(ch)); executed: return operator=(QString(ch));Execution Count:69542 | 69542 |
| 1385 | } | - |
| 1386 | | - |
| 1387 | /*! | - |
| 1388 | \fn QString& QString::insert(int position, const QString &str) | - |
| 1389 | | - |
| 1390 | Inserts the string \a str at the given index \a position and | - |
| 1391 | returns a reference to this string. | - |
| 1392 | | - |
| 1393 | Example: | - |
| 1394 | | - |
| 1395 | \snippet qstring/main.cpp 26 | - |
| 1396 | | - |
| 1397 | If the given \a position is greater than size(), the array is | - |
| 1398 | first extended using resize(). | - |
| 1399 | | - |
| 1400 | \sa append(), prepend(), replace(), remove() | - |
| 1401 | */ | - |
| 1402 | | - |
| 1403 | | - |
| 1404 | /*! | - |
| 1405 | \fn QString &QString::insert(int position, QLatin1String str) | - |
| 1406 | \overload insert() | - |
| 1407 | | - |
| 1408 | Inserts the Latin-1 string \a str at the given index \a position. | - |
| 1409 | */ | - |
| 1410 | QString &QString::insert(int i, QLatin1String str) | - |
| 1411 | { | - |
| 1412 | const uchar *s = (const uchar *)str.latin1(); executed (the execution status of this line is deduced): const uchar *s = (const uchar *)str.latin1(); | - |
| 1413 | if (i < 0 || !s || !(*s)) partially evaluated: i < 0| no Evaluation Count:0 | yes Evaluation Count:893 |
evaluated: !s| yes Evaluation Count:1 | yes Evaluation Count:892 |
evaluated: !(*s)| yes Evaluation Count:1 | yes Evaluation Count:891 |
| 0-893 |
| 1414 | return *this; executed: return *this;Execution Count:2 | 2 |
| 1415 | | - |
| 1416 | int len = str.size(); executed (the execution status of this line is deduced): int len = str.size(); | - |
| 1417 | expand(qMax(d->size, i) + len - 1); executed (the execution status of this line is deduced): expand(qMax(d->size, i) + len - 1); | - |
| 1418 | | - |
| 1419 | ::memmove(d->data() + i + len, d->data() + i, (d->size - i - len) * sizeof(QChar)); executed (the execution status of this line is deduced): ::memmove(d->data() + i + len, d->data() + i, (d->size - i - len) * sizeof(QChar)); | - |
| 1420 | for (int j = 0; j < len; ++j) evaluated: j < len| yes Evaluation Count:4771 | yes Evaluation Count:891 |
| 891-4771 |
| 1421 | d->data()[i + j] = s[j]; executed: d->data()[i + j] = s[j];Execution Count:4771 | 4771 |
| 1422 | return *this; executed: return *this;Execution Count:891 | 891 |
| 1423 | } | - |
| 1424 | | - |
| 1425 | /*! | - |
| 1426 | \fn QString& QString::insert(int position, const QChar *unicode, int size) | - |
| 1427 | \overload insert() | - |
| 1428 | | - |
| 1429 | Inserts the first \a size characters of the QChar array \a unicode | - |
| 1430 | at the given index \a position in the string. | - |
| 1431 | */ | - |
| 1432 | QString& QString::insert(int i, const QChar *unicode, int size) | - |
| 1433 | { | - |
| 1434 | if (i < 0 || size <= 0) partially evaluated: i < 0| no Evaluation Count:0 | yes Evaluation Count:244832 |
evaluated: size <= 0| yes Evaluation Count:76645 | yes Evaluation Count:168187 |
| 0-244832 |
| 1435 | return *this; executed: return *this;Execution Count:76645 | 76645 |
| 1436 | | - |
| 1437 | const ushort *s = (const ushort *)unicode; executed (the execution status of this line is deduced): const ushort *s = (const ushort *)unicode; | - |
| 1438 | if (s >= d->data() && s < d->data() + d->alloc) { evaluated: s >= d->data()| yes Evaluation Count:118169 | yes Evaluation Count:50018 |
evaluated: s < d->data() + d->alloc| yes Evaluation Count:3 | yes Evaluation Count:118166 |
| 3-118169 |
| 1439 | // Part of me - take a copy | - |
| 1440 | ushort *tmp = static_cast<ushort *>(::malloc(size * sizeof(QChar))); executed (the execution status of this line is deduced): ushort *tmp = static_cast<ushort *>(::malloc(size * sizeof(QChar))); | - |
| 1441 | Q_CHECK_PTR(tmp); never executed: qBadAlloc(); executed: }Execution Count:3 partially evaluated: !(tmp)| no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 1442 | memcpy(tmp, s, size * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(tmp, s, size * sizeof(QChar)); | - |
| 1443 | insert(i, reinterpret_cast<const QChar *>(tmp), size); executed (the execution status of this line is deduced): insert(i, reinterpret_cast<const QChar *>(tmp), size); | - |
| 1444 | ::free(tmp); executed (the execution status of this line is deduced): ::free(tmp); | - |
| 1445 | return *this; executed: return *this;Execution Count:3 | 3 |
| 1446 | } | - |
| 1447 | | - |
| 1448 | expand(qMax(d->size, i) + size - 1); executed (the execution status of this line is deduced): expand(qMax(d->size, i) + size - 1); | - |
| 1449 | | - |
| 1450 | ::memmove(d->data() + i + size, d->data() + i, (d->size - i - size) * sizeof(QChar)); executed (the execution status of this line is deduced): ::memmove(d->data() + i + size, d->data() + i, (d->size - i - size) * sizeof(QChar)); | - |
| 1451 | memcpy(d->data() + i, s, size * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(d->data() + i, s, size * sizeof(QChar)); | - |
| 1452 | return *this; executed: return *this;Execution Count:168184 | 168184 |
| 1453 | } | - |
| 1454 | | - |
| 1455 | /*! | - |
| 1456 | \fn QString& QString::insert(int position, QChar ch) | - |
| 1457 | \overload insert() | - |
| 1458 | | - |
| 1459 | Inserts \a ch at the given index \a position in the string. | - |
| 1460 | */ | - |
| 1461 | | - |
| 1462 | QString& QString::insert(int i, QChar ch) | - |
| 1463 | { | - |
| 1464 | if (i < 0) partially evaluated: i < 0| no Evaluation Count:0 | yes Evaluation Count:1340672 |
| 0-1340672 |
| 1465 | i += d->size; never executed: i += d->size; | 0 |
| 1466 | if (i < 0) partially evaluated: i < 0| no Evaluation Count:0 | yes Evaluation Count:1340672 |
| 0-1340672 |
| 1467 | return *this; never executed: return *this; | 0 |
| 1468 | expand(qMax(i, d->size)); executed (the execution status of this line is deduced): expand(qMax(i, d->size)); | - |
| 1469 | ::memmove(d->data() + i + 1, d->data() + i, (d->size - i - 1) * sizeof(QChar)); executed (the execution status of this line is deduced): ::memmove(d->data() + i + 1, d->data() + i, (d->size - i - 1) * sizeof(QChar)); | - |
| 1470 | d->data()[i] = ch.unicode(); executed (the execution status of this line is deduced): d->data()[i] = ch.unicode(); | - |
| 1471 | return *this; executed: return *this;Execution Count:1340672 | 1340672 |
| 1472 | } | - |
| 1473 | | - |
| 1474 | /*! | - |
| 1475 | Appends the string \a str onto the end of this string. | - |
| 1476 | | - |
| 1477 | Example: | - |
| 1478 | | - |
| 1479 | \snippet qstring/main.cpp 9 | - |
| 1480 | | - |
| 1481 | This is the same as using the insert() function: | - |
| 1482 | | - |
| 1483 | \snippet qstring/main.cpp 10 | - |
| 1484 | | - |
| 1485 | The append() function is typically very fast (\l{constant time}), | - |
| 1486 | because QString preallocates extra space at the end of the string | - |
| 1487 | data so it can grow without reallocating the entire string each | - |
| 1488 | time. | - |
| 1489 | | - |
| 1490 | \sa operator+=(), prepend(), insert() | - |
| 1491 | */ | - |
| 1492 | QString &QString::append(const QString &str) | - |
| 1493 | { | - |
| 1494 | if (str.d != Data::sharedNull()) { evaluated: str.d != Data::sharedNull()| yes Evaluation Count:43946159 | yes Evaluation Count:131573 |
| 131573-43946159 |
| 1495 | if (d == Data::sharedNull()) { evaluated: d == Data::sharedNull()| yes Evaluation Count:125151 | yes Evaluation Count:43821004 |
| 125151-43821004 |
| 1496 | operator=(str); executed (the execution status of this line is deduced): operator=(str); | - |
| 1497 | } else { executed: }Execution Count:125151 | 125151 |
| 1498 | if (d->ref.isShared() || uint(d->size + str.d->size) + 1u > d->alloc) evaluated: d->ref.isShared()| yes Evaluation Count:164557 | yes Evaluation Count:43656448 |
evaluated: uint(d->size + str.d->size) + 1u > d->alloc| yes Evaluation Count:468632 | yes Evaluation Count:43187825 |
| 164557-43656448 |
| 1499 | reallocData(uint(d->size + str.d->size) + 1u, true); executed: reallocData(uint(d->size + str.d->size) + 1u, true);Execution Count:633189 | 633189 |
| 1500 | memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar)); | - |
| 1501 | d->size += str.d->size; executed (the execution status of this line is deduced): d->size += str.d->size; | - |
| 1502 | d->data()[d->size] = '\0'; executed (the execution status of this line is deduced): d->data()[d->size] = '\0'; | - |
| 1503 | } executed: }Execution Count:43821009 | 43821009 |
| 1504 | } | - |
| 1505 | return *this; executed: return *this;Execution Count:44077734 | 44077734 |
| 1506 | } | - |
| 1507 | | - |
| 1508 | /*! | - |
| 1509 | \overload append() | - |
| 1510 | \since 5.0 | - |
| 1511 | | - |
| 1512 | Appends \a len characters from the QChar array \a str to this string. | - |
| 1513 | */ | - |
| 1514 | QString &QString::append(const QChar *str, int len) | - |
| 1515 | { | - |
| 1516 | if (str && len > 0) { evaluated: str| yes Evaluation Count:23059 | yes Evaluation Count:1 |
evaluated: len > 0| yes Evaluation Count:23057 | yes Evaluation Count:2 |
| 1-23059 |
| 1517 | if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) evaluated: d->ref.isShared()| yes Evaluation Count:1 | yes Evaluation Count:23056 |
evaluated: uint(d->size + len) + 1u > d->alloc| yes Evaluation Count:1 | yes Evaluation Count:23055 |
| 1-23056 |
| 1518 | reallocData(uint(d->size + len) + 1u, true); executed: reallocData(uint(d->size + len) + 1u, true);Execution Count:2 | 2 |
| 1519 | memcpy(d->data() + d->size, str, len * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(d->data() + d->size, str, len * sizeof(QChar)); | - |
| 1520 | d->size += len; executed (the execution status of this line is deduced): d->size += len; | - |
| 1521 | d->data()[d->size] = '\0'; executed (the execution status of this line is deduced): d->data()[d->size] = '\0'; | - |
| 1522 | } executed: }Execution Count:23057 | 23057 |
| 1523 | return *this; executed: return *this;Execution Count:23060 | 23060 |
| 1524 | } | - |
| 1525 | | - |
| 1526 | /*! | - |
| 1527 | \overload append() | - |
| 1528 | | - |
| 1529 | Appends the Latin-1 string \a str to this string. | - |
| 1530 | */ | - |
| 1531 | QString &QString::append(QLatin1String str) | - |
| 1532 | { | - |
| 1533 | const uchar *s = (const uchar *)str.latin1(); executed (the execution status of this line is deduced): const uchar *s = (const uchar *)str.latin1(); | - |
| 1534 | if (s) { evaluated: s| yes Evaluation Count:34384 | yes Evaluation Count:32 |
| 32-34384 |
| 1535 | int len = str.size(); executed (the execution status of this line is deduced): int len = str.size(); | - |
| 1536 | if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) evaluated: d->ref.isShared()| yes Evaluation Count:3162 | yes Evaluation Count:31223 |
evaluated: uint(d->size + len) + 1u > d->alloc| yes Evaluation Count:8111 | yes Evaluation Count:23111 |
| 3162-31223 |
| 1537 | reallocData(uint(d->size + len) + 1u, true); executed: reallocData(uint(d->size + len) + 1u, true);Execution Count:11273 | 11273 |
| 1538 | ushort *i = d->data() + d->size; executed (the execution status of this line is deduced): ushort *i = d->data() + d->size; | - |
| 1539 | while ((*i++ = *s++)) evaluated: (*i++ = *s++)| yes Evaluation Count:565913 | yes Evaluation Count:34392 |
| 34392-565913 |
| 1540 | ; executed: ;Execution Count:565913 | 565913 |
| 1541 | d->size += len; executed (the execution status of this line is deduced): d->size += len; | - |
| 1542 | } executed: }Execution Count:34391 | 34391 |
| 1543 | return *this; executed: return *this;Execution Count:34425 | 34425 |
| 1544 | } | - |
| 1545 | | - |
| 1546 | /*! \fn QString &QString::append(const QByteArray &ba) | - |
| 1547 | | - |
| 1548 | \overload append() | - |
| 1549 | | - |
| 1550 | Appends the byte array \a ba to this string. The given byte array | - |
| 1551 | is converted to Unicode using the fromUtf8() function. | - |
| 1552 | | - |
| 1553 | You can disable this function by defining \c QT_NO_CAST_FROM_ASCII | - |
| 1554 | when you compile your applications. This can be useful if you want | - |
| 1555 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 1556 | for example. | - |
| 1557 | */ | - |
| 1558 | | - |
| 1559 | /*! \fn QString &QString::append(const char *str) | - |
| 1560 | | - |
| 1561 | \overload append() | - |
| 1562 | | - |
| 1563 | Appends the string \a str to this string. The given const char | - |
| 1564 | pointer is converted to Unicode using the fromUtf8() function. | - |
| 1565 | | - |
| 1566 | You can disable this function by defining \c QT_NO_CAST_FROM_ASCII | - |
| 1567 | when you compile your applications. This can be useful if you want | - |
| 1568 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 1569 | for example. | - |
| 1570 | */ | - |
| 1571 | | - |
| 1572 | /*! | - |
| 1573 | \overload append() | - |
| 1574 | | - |
| 1575 | Appends the character \a ch to this string. | - |
| 1576 | */ | - |
| 1577 | QString &QString::append(QChar ch) | - |
| 1578 | { | - |
| 1579 | if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) evaluated: d->ref.isShared()| yes Evaluation Count:119174 | yes Evaluation Count:870934 |
evaluated: uint(d->size) + 2u > d->alloc| yes Evaluation Count:405489 | yes Evaluation Count:465445 |
| 119174-870934 |
| 1580 | reallocData(uint(d->size) + 2u, true); executed: reallocData(uint(d->size) + 2u, true);Execution Count:524663 | 524663 |
| 1581 | d->data()[d->size++] = ch.unicode(); executed (the execution status of this line is deduced): d->data()[d->size++] = ch.unicode(); | - |
| 1582 | d->data()[d->size] = '\0'; executed (the execution status of this line is deduced): d->data()[d->size] = '\0'; | - |
| 1583 | return *this; executed: return *this;Execution Count:990108 | 990108 |
| 1584 | } | - |
| 1585 | | - |
| 1586 | /*! \fn QString &QString::prepend(const QString &str) | - |
| 1587 | | - |
| 1588 | Prepends the string \a str to the beginning of this string and | - |
| 1589 | returns a reference to this string. | - |
| 1590 | | - |
| 1591 | Example: | - |
| 1592 | | - |
| 1593 | \snippet qstring/main.cpp 36 | - |
| 1594 | | - |
| 1595 | \sa append(), insert() | - |
| 1596 | */ | - |
| 1597 | | - |
| 1598 | /*! \fn QString &QString::prepend(QLatin1String str) | - |
| 1599 | | - |
| 1600 | \overload prepend() | - |
| 1601 | | - |
| 1602 | Prepends the Latin-1 string \a str to this string. | - |
| 1603 | */ | - |
| 1604 | | - |
| 1605 | /*! \fn QString &QString::prepend(const QByteArray &ba) | - |
| 1606 | | - |
| 1607 | \overload prepend() | - |
| 1608 | | - |
| 1609 | Prepends the byte array \a ba to this string. The byte array is | - |
| 1610 | converted to Unicode using the fromUtf8() function. | - |
| 1611 | | - |
| 1612 | You can disable this function by defining \c | - |
| 1613 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 1614 | can be useful if you want to ensure that all user-visible strings | - |
| 1615 | go through QObject::tr(), for example. | - |
| 1616 | */ | - |
| 1617 | | - |
| 1618 | /*! \fn QString &QString::prepend(const char *str) | - |
| 1619 | | - |
| 1620 | \overload prepend() | - |
| 1621 | | - |
| 1622 | Prepends the string \a str to this string. The const char pointer | - |
| 1623 | is converted to Unicode using the fromUtf8() function. | - |
| 1624 | | - |
| 1625 | You can disable this function by defining \c | - |
| 1626 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 1627 | can be useful if you want to ensure that all user-visible strings | - |
| 1628 | go through QObject::tr(), for example. | - |
| 1629 | */ | - |
| 1630 | | - |
| 1631 | /*! \fn QString &QString::prepend(QChar ch) | - |
| 1632 | | - |
| 1633 | \overload prepend() | - |
| 1634 | | - |
| 1635 | Prepends the character \a ch to this string. | - |
| 1636 | */ | - |
| 1637 | | - |
| 1638 | /*! | - |
| 1639 | \fn QString &QString::remove(int position, int n) | - |
| 1640 | | - |
| 1641 | Removes \a n characters from the string, starting at the given \a | - |
| 1642 | position index, and returns a reference to the string. | - |
| 1643 | | - |
| 1644 | If the specified \a position index is within the string, but \a | - |
| 1645 | position + \a n is beyond the end of the string, the string is | - |
| 1646 | truncated at the specified \a position. | - |
| 1647 | | - |
| 1648 | \snippet qstring/main.cpp 37 | - |
| 1649 | | - |
| 1650 | \sa insert(), replace() | - |
| 1651 | */ | - |
| 1652 | QString &QString::remove(int pos, int len) | - |
| 1653 | { | - |
| 1654 | if (pos < 0) // count from end of string partially evaluated: pos < 0| no Evaluation Count:0 | yes Evaluation Count:251257 |
| 0-251257 |
| 1655 | pos += d->size; never executed: pos += d->size; | 0 |
| 1656 | if (pos < 0 || pos >= d->size) { partially evaluated: pos < 0| no Evaluation Count:0 | yes Evaluation Count:251257 |
partially evaluated: pos >= d->size| no Evaluation Count:0 | yes Evaluation Count:251257 |
| 0-251257 |
| 1657 | // range problems | - |
| 1658 | } else if (len >= d->size - pos) { never executed: } evaluated: len >= d->size - pos| yes Evaluation Count:122647 | yes Evaluation Count:128610 |
| 0-128610 |
| 1659 | resize(pos); // truncate executed (the execution status of this line is deduced): resize(pos); | - |
| 1660 | } else if (len > 0) { executed: }Execution Count:122647 evaluated: len > 0| yes Evaluation Count:128609 | yes Evaluation Count:1 |
| 1-128609 |
| 1661 | detach(); executed (the execution status of this line is deduced): detach(); | - |
| 1662 | memmove(d->data() + pos, d->data() + pos + len, executed (the execution status of this line is deduced): memmove(d->data() + pos, d->data() + pos + len, | - |
| 1663 | (d->size - pos - len + 1) * sizeof(ushort)); executed (the execution status of this line is deduced): (d->size - pos - len + 1) * sizeof(ushort)); | - |
| 1664 | d->size -= len; executed (the execution status of this line is deduced): d->size -= len; | - |
| 1665 | } executed: }Execution Count:128609 | 128609 |
| 1666 | return *this; executed: return *this;Execution Count:251257 | 251257 |
| 1667 | } | - |
| 1668 | | - |
| 1669 | /*! | - |
| 1670 | Removes every occurrence of the given \a str string in this | - |
| 1671 | string, and returns a reference to this string. | - |
| 1672 | | - |
| 1673 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 1674 | case sensitive; otherwise the search is case insensitive. | - |
| 1675 | | - |
| 1676 | This is the same as \c replace(str, "", cs). | - |
| 1677 | | - |
| 1678 | \sa replace() | - |
| 1679 | */ | - |
| 1680 | QString &QString::remove(const QString &str, Qt::CaseSensitivity cs) | - |
| 1681 | { | - |
| 1682 | if (str.d->size) { evaluated: str.d->size| yes Evaluation Count:70 | yes Evaluation Count:4 |
| 4-70 |
| 1683 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
| 1684 | while ((i = indexOf(str, i, cs)) != -1) evaluated: (i = indexOf(str, i, cs)) != -1| yes Evaluation Count:24 | yes Evaluation Count:70 |
| 24-70 |
| 1685 | remove(i, str.d->size); executed: remove(i, str.d->size);Execution Count:24 | 24 |
| 1686 | } executed: }Execution Count:70 | 70 |
| 1687 | return *this; executed: return *this;Execution Count:74 | 74 |
| 1688 | } | - |
| 1689 | | - |
| 1690 | /*! | - |
| 1691 | Removes every occurrence of the character \a ch in this string, and | - |
| 1692 | returns a reference to this string. | - |
| 1693 | | - |
| 1694 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 1695 | sensitive; otherwise the search is case insensitive. | - |
| 1696 | | - |
| 1697 | Example: | - |
| 1698 | | - |
| 1699 | \snippet qstring/main.cpp 38 | - |
| 1700 | | - |
| 1701 | This is the same as \c replace(ch, "", cs). | - |
| 1702 | | - |
| 1703 | \sa replace() | - |
| 1704 | */ | - |
| 1705 | QString &QString::remove(QChar ch, Qt::CaseSensitivity cs) | - |
| 1706 | { | - |
| 1707 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
| 1708 | ushort c = ch.unicode(); executed (the execution status of this line is deduced): ushort c = ch.unicode(); | - |
| 1709 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:6001 | yes Evaluation Count:11 |
| 11-6001 |
| 1710 | while (i < d->size) evaluated: i < d->size| yes Evaluation Count:30710 | yes Evaluation Count:6001 |
| 6001-30710 |
| 1711 | if (d->data()[i] == ch) evaluated: d->data()[i] == ch| yes Evaluation Count:1419 | yes Evaluation Count:29291 |
| 1419-29291 |
| 1712 | remove(i, 1); executed: remove(i, 1);Execution Count:1419 | 1419 |
| 1713 | else | - |
| 1714 | i++; executed: i++;Execution Count:29291 | 29291 |
| 1715 | } else { executed: }Execution Count:6001 | 6001 |
| 1716 | c = foldCase(c); executed (the execution status of this line is deduced): c = foldCase(c); | - |
| 1717 | while (i < d->size) evaluated: i < d->size| yes Evaluation Count:36 | yes Evaluation Count:11 |
| 11-36 |
| 1718 | if (foldCase(d->data()[i]) == c) evaluated: foldCase(d->data()[i]) == c| yes Evaluation Count:14 | yes Evaluation Count:22 |
| 14-22 |
| 1719 | remove(i, 1); executed: remove(i, 1);Execution Count:14 | 14 |
| 1720 | else | - |
| 1721 | i++; executed: i++;Execution Count:22 | 22 |
| 1722 | } executed: }Execution Count:11 | 11 |
| 1723 | return *this; executed: return *this;Execution Count:6012 | 6012 |
| 1724 | } | - |
| 1725 | | - |
| 1726 | /*! | - |
| 1727 | \fn QString &QString::remove(const QRegExp &rx) | - |
| 1728 | | - |
| 1729 | Removes every occurrence of the regular expression \a rx in the | - |
| 1730 | string, and returns a reference to the string. For example: | - |
| 1731 | | - |
| 1732 | \snippet qstring/main.cpp 39 | - |
| 1733 | | - |
| 1734 | \sa indexOf(), lastIndexOf(), replace() | - |
| 1735 | */ | - |
| 1736 | | - |
| 1737 | /*! | - |
| 1738 | \fn QString &QString::remove(const QRegularExpression &re) | - |
| 1739 | \since 5.0 | - |
| 1740 | | - |
| 1741 | Removes every occurrence of the regular expression \a re in the | - |
| 1742 | string, and returns a reference to the string. For example: | - |
| 1743 | | - |
| 1744 | \snippet qstring/main.cpp 96 | - |
| 1745 | | - |
| 1746 | \sa indexOf(), lastIndexOf(), replace() | - |
| 1747 | */ | - |
| 1748 | | - |
| 1749 | /*! | - |
| 1750 | \fn QString &QString::replace(int position, int n, const QString &after) | - |
| 1751 | | - |
| 1752 | Replaces \a n characters beginning at index \a position with | - |
| 1753 | the string \a after and returns a reference to this string. | - |
| 1754 | | - |
| 1755 | \note If the specified \a position index is within the string, | - |
| 1756 | but \a position + \a n goes outside the strings range, | - |
| 1757 | then \a n will be adjusted to stop at the end of the string. | - |
| 1758 | | - |
| 1759 | Example: | - |
| 1760 | | - |
| 1761 | \snippet qstring/main.cpp 40 | - |
| 1762 | | - |
| 1763 | \sa insert(), remove() | - |
| 1764 | */ | - |
| 1765 | QString &QString::replace(int pos, int len, const QString &after) | - |
| 1766 | { | - |
| 1767 | QString copy = after; executed (the execution status of this line is deduced): QString copy = after; | - |
| 1768 | return replace(pos, len, copy.constData(), copy.length()); executed: return replace(pos, len, copy.constData(), copy.length());Execution Count:2015646 | 2015646 |
| 1769 | } | - |
| 1770 | | - |
| 1771 | /*! | - |
| 1772 | \fn QString &QString::replace(int position, int n, const QChar *unicode, int size) | - |
| 1773 | \overload replace() | - |
| 1774 | Replaces \a n characters beginning at index \a position with the | - |
| 1775 | first \a size characters of the QChar array \a unicode and returns a | - |
| 1776 | reference to this string. | - |
| 1777 | */ | - |
| 1778 | QString &QString::replace(int pos, int len, const QChar *unicode, int size) | - |
| 1779 | { | - |
| 1780 | if (pos < 0 || pos > d->size) partially evaluated: pos < 0| no Evaluation Count:0 | yes Evaluation Count:2197608 |
partially evaluated: pos > d->size| no Evaluation Count:0 | yes Evaluation Count:2197608 |
| 0-2197608 |
| 1781 | return *this; never executed: return *this; | 0 |
| 1782 | if (len > d->size - pos) evaluated: len > d->size - pos| yes Evaluation Count:25 | yes Evaluation Count:2197583 |
| 25-2197583 |
| 1783 | len = d->size - pos; executed: len = d->size - pos;Execution Count:25 | 25 |
| 1784 | | - |
| 1785 | uint index = pos; executed (the execution status of this line is deduced): uint index = pos; | - |
| 1786 | replace_helper(&index, 1, len, unicode, size); executed (the execution status of this line is deduced): replace_helper(&index, 1, len, unicode, size); | - |
| 1787 | return *this; executed: return *this;Execution Count:2197608 | 2197608 |
| 1788 | } | - |
| 1789 | | - |
| 1790 | /*! | - |
| 1791 | \fn QString &QString::replace(int position, int n, QChar after) | - |
| 1792 | \overload replace() | - |
| 1793 | | - |
| 1794 | Replaces \a n characters beginning at index \a position with the | - |
| 1795 | character \a after and returns a reference to this string. | - |
| 1796 | */ | - |
| 1797 | QString &QString::replace(int pos, int len, QChar after) | - |
| 1798 | { | - |
| 1799 | return replace(pos, len, &after, 1); executed: return replace(pos, len, &after, 1);Execution Count:9 | 9 |
| 1800 | } | - |
| 1801 | | - |
| 1802 | /*! | - |
| 1803 | \overload replace() | - |
| 1804 | Replaces every occurrence of the string \a before with the string \a | - |
| 1805 | after and returns a reference to this string. | - |
| 1806 | | - |
| 1807 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 1808 | sensitive; otherwise the search is case insensitive. | - |
| 1809 | | - |
| 1810 | Example: | - |
| 1811 | | - |
| 1812 | \snippet qstring/main.cpp 41 | - |
| 1813 | | - |
| 1814 | \note The replacement text is not rescanned after it is inserted. | - |
| 1815 | | - |
| 1816 | Example: | - |
| 1817 | | - |
| 1818 | \snippet qstring/main.cpp 86 | - |
| 1819 | */ | - |
| 1820 | QString &QString::replace(const QString &before, const QString &after, Qt::CaseSensitivity cs) | - |
| 1821 | { | - |
| 1822 | return replace(before.constData(), before.size(), after.constData(), after.size(), cs); executed: return replace(before.constData(), before.size(), after.constData(), after.size(), cs);Execution Count:157421 | 157421 |
| 1823 | } | - |
| 1824 | | - |
| 1825 | /*! | - |
| 1826 | \internal | - |
| 1827 | */ | - |
| 1828 | void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen) | - |
| 1829 | { | - |
| 1830 | // copy *after in case it lies inside our own d->data() area | - |
| 1831 | // (which we could possibly invalidate via a realloc or corrupt via memcpy operations.) | - |
| 1832 | QChar *afterBuffer = const_cast<QChar *>(after); executed (the execution status of this line is deduced): QChar *afterBuffer = const_cast<QChar *>(after); | - |
| 1833 | if (after >= reinterpret_cast<QChar *>(d->data()) && after < reinterpret_cast<QChar *>(d->data()) + d->size) { evaluated: after >= reinterpret_cast<QChar *>(d->data())| yes Evaluation Count:186199 | yes Evaluation Count:2013296 |
evaluated: after < reinterpret_cast<QChar *>(d->data()) + d->size| yes Evaluation Count:21 | yes Evaluation Count:186178 |
| 21-2013296 |
| 1834 | afterBuffer = static_cast<QChar *>(::malloc(alen*sizeof(QChar))); executed (the execution status of this line is deduced): afterBuffer = static_cast<QChar *>(::malloc(alen*sizeof(QChar))); | - |
| 1835 | Q_CHECK_PTR(afterBuffer); never executed: qBadAlloc(); executed: }Execution Count:21 partially evaluated: !(afterBuffer)| no Evaluation Count:0 | yes Evaluation Count:21 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
| 1836 | ::memcpy(afterBuffer, after, alen*sizeof(QChar)); executed (the execution status of this line is deduced): ::memcpy(afterBuffer, after, alen*sizeof(QChar)); | - |
| 1837 | } executed: }Execution Count:21 | 21 |
| 1838 | | - |
| 1839 | QT_TRY { | - |
| 1840 | if (blen == alen) { evaluated: blen == alen| yes Evaluation Count:2013152 | yes Evaluation Count:186343 |
| 186343-2013152 |
| 1841 | // replace in place | - |
| 1842 | detach(); executed (the execution status of this line is deduced): detach(); | - |
| 1843 | for (int i = 0; i < nIndices; ++i) evaluated: i < nIndices| yes Evaluation Count:2013158 | yes Evaluation Count:2013152 |
| 2013152-2013158 |
| 1844 | memcpy(d->data() + indices[i], afterBuffer, alen * sizeof(QChar)); executed: memcpy(d->data() + indices[i], afterBuffer, alen * sizeof(QChar));Execution Count:2013158 | 2013158 |
| 1845 | } else if (alen < blen) { executed: }Execution Count:2013152 evaluated: alen < blen| yes Evaluation Count:10628 | yes Evaluation Count:175715 |
| 10628-2013152 |
| 1846 | // replace from front | - |
| 1847 | detach(); executed (the execution status of this line is deduced): detach(); | - |
| 1848 | uint to = indices[0]; executed (the execution status of this line is deduced): uint to = indices[0]; | - |
| 1849 | if (alen) evaluated: alen| yes Evaluation Count:10598 | yes Evaluation Count:30 |
| 30-10598 |
| 1850 | memcpy(d->data()+to, after, alen*sizeof(QChar)); executed: memcpy(d->data()+to, after, alen*sizeof(QChar));Execution Count:10598 | 10598 |
| 1851 | to += alen; executed (the execution status of this line is deduced): to += alen; | - |
| 1852 | uint movestart = indices[0] + blen; executed (the execution status of this line is deduced): uint movestart = indices[0] + blen; | - |
| 1853 | for (int i = 1; i < nIndices; ++i) { evaluated: i < nIndices| yes Evaluation Count:337 | yes Evaluation Count:10628 |
| 337-10628 |
| 1854 | int msize = indices[i] - movestart; executed (the execution status of this line is deduced): int msize = indices[i] - movestart; | - |
| 1855 | if (msize > 0) { evaluated: msize > 0| yes Evaluation Count:335 | yes Evaluation Count:2 |
| 2-335 |
| 1856 | memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar)); executed (the execution status of this line is deduced): memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar)); | - |
| 1857 | to += msize; executed (the execution status of this line is deduced): to += msize; | - |
| 1858 | } executed: }Execution Count:335 | 335 |
| 1859 | if (alen) { evaluated: alen| yes Evaluation Count:332 | yes Evaluation Count:5 |
| 5-332 |
| 1860 | memcpy(d->data() + to, afterBuffer, alen*sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(d->data() + to, afterBuffer, alen*sizeof(QChar)); | - |
| 1861 | to += alen; executed (the execution status of this line is deduced): to += alen; | - |
| 1862 | } executed: }Execution Count:332 | 332 |
| 1863 | movestart = indices[i] + blen; executed (the execution status of this line is deduced): movestart = indices[i] + blen; | - |
| 1864 | } executed: }Execution Count:337 | 337 |
| 1865 | int msize = d->size - movestart; executed (the execution status of this line is deduced): int msize = d->size - movestart; | - |
| 1866 | if (msize > 0) evaluated: msize > 0| yes Evaluation Count:1189 | yes Evaluation Count:9439 |
| 1189-9439 |
| 1867 | memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar)); executed: memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar));Execution Count:1189 | 1189 |
| 1868 | resize(d->size - nIndices*(blen-alen)); executed (the execution status of this line is deduced): resize(d->size - nIndices*(blen-alen)); | - |
| 1869 | } else { executed: }Execution Count:10628 | 10628 |
| 1870 | // replace from back | - |
| 1871 | int adjust = nIndices*(alen-blen); executed (the execution status of this line is deduced): int adjust = nIndices*(alen-blen); | - |
| 1872 | int newLen = d->size + adjust; executed (the execution status of this line is deduced): int newLen = d->size + adjust; | - |
| 1873 | int moveend = d->size; executed (the execution status of this line is deduced): int moveend = d->size; | - |
| 1874 | resize(newLen); executed (the execution status of this line is deduced): resize(newLen); | - |
| 1875 | | - |
| 1876 | while (nIndices) { evaluated: nIndices| yes Evaluation Count:175805 | yes Evaluation Count:175715 |
| 175715-175805 |
| 1877 | --nIndices; executed (the execution status of this line is deduced): --nIndices; | - |
| 1878 | int movestart = indices[nIndices] + blen; executed (the execution status of this line is deduced): int movestart = indices[nIndices] + blen; | - |
| 1879 | int insertstart = indices[nIndices] + nIndices*(alen-blen); executed (the execution status of this line is deduced): int insertstart = indices[nIndices] + nIndices*(alen-blen); | - |
| 1880 | int moveto = insertstart + alen; executed (the execution status of this line is deduced): int moveto = insertstart + alen; | - |
| 1881 | memmove(d->data() + moveto, d->data() + movestart, executed (the execution status of this line is deduced): memmove(d->data() + moveto, d->data() + movestart, | - |
| 1882 | (moveend - movestart)*sizeof(QChar)); executed (the execution status of this line is deduced): (moveend - movestart)*sizeof(QChar)); | - |
| 1883 | memcpy(d->data() + insertstart, afterBuffer, alen*sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(d->data() + insertstart, afterBuffer, alen*sizeof(QChar)); | - |
| 1884 | moveend = movestart-blen; executed (the execution status of this line is deduced): moveend = movestart-blen; | - |
| 1885 | } executed: }Execution Count:175805 | 175805 |
| 1886 | } executed: }Execution Count:175715 | 175715 |
| 1887 | } QT_CATCH(const std::bad_alloc &) { | - |
| 1888 | if (afterBuffer != after) never evaluated: afterBuffer != after | 0 |
| 1889 | ::free(afterBuffer); never executed: ::free(afterBuffer); | 0 |
| 1890 | QT_RETHROW; | 0 |
| 1891 | } | - |
| 1892 | if (afterBuffer != after) evaluated: afterBuffer != after| yes Evaluation Count:21 | yes Evaluation Count:2199474 |
| 21-2199474 |
| 1893 | ::free(afterBuffer); executed: ::free(afterBuffer);Execution Count:21 | 21 |
| 1894 | } executed: }Execution Count:2199495 | 2199495 |
| 1895 | | - |
| 1896 | /*! | - |
| 1897 | \since 4.5 | - |
| 1898 | \overload replace() | - |
| 1899 | | - |
| 1900 | Replaces each occurrence in this string of the first \a blen | - |
| 1901 | characters of \a before with the first \a alen characters of \a | - |
| 1902 | after and returns a reference to this string. | - |
| 1903 | | - |
| 1904 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 1905 | sensitive; otherwise the search is case insensitive. | - |
| 1906 | */ | - |
| 1907 | QString &QString::replace(const QChar *before, int blen, | - |
| 1908 | const QChar *after, int alen, | - |
| 1909 | Qt::CaseSensitivity cs) | - |
| 1910 | { | - |
| 1911 | if (d->size == 0) { evaluated: d->size == 0| yes Evaluation Count:1213 | yes Evaluation Count:162368 |
| 1213-162368 |
| 1912 | if (blen) evaluated: blen| yes Evaluation Count:1207 | yes Evaluation Count:6 |
| 6-1207 |
| 1913 | return *this; executed: return *this;Execution Count:1207 | 1207 |
| 1914 | } else { executed: }Execution Count:6 | 6 |
| 1915 | if (cs == Qt::CaseSensitive && before == after && blen == alen) evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:162353 | yes Evaluation Count:15 |
evaluated: before == after| yes Evaluation Count:3 | yes Evaluation Count:162350 |
partially evaluated: blen == alen| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-162353 |
| 1916 | return *this; executed: return *this;Execution Count:3 | 3 |
| 1917 | } executed: }Execution Count:162365 | 162365 |
| 1918 | if (alen == 0 && blen == 0) evaluated: alen == 0| yes Evaluation Count:20 | yes Evaluation Count:162351 |
evaluated: blen == 0| yes Evaluation Count:3 | yes Evaluation Count:17 |
| 3-162351 |
| 1919 | return *this; executed: return *this;Execution Count:3 | 3 |
| 1920 | | - |
| 1921 | QStringMatcher matcher(before, blen, cs); executed (the execution status of this line is deduced): QStringMatcher matcher(before, blen, cs); | - |
| 1922 | | - |
| 1923 | int index = 0; executed (the execution status of this line is deduced): int index = 0; | - |
| 1924 | while (1) { partially evaluated: 1| yes Evaluation Count:162368 | no Evaluation Count:0 |
| 0-162368 |
| 1925 | uint indices[1024]; executed (the execution status of this line is deduced): uint indices[1024]; | - |
| 1926 | uint pos = 0; executed (the execution status of this line is deduced): uint pos = 0; | - |
| 1927 | while (pos < 1023) { partially evaluated: pos < 1023| yes Evaluation Count:164653 | no Evaluation Count:0 |
| 0-164653 |
| 1928 | index = matcher.indexIn(*this, index); executed (the execution status of this line is deduced): index = matcher.indexIn(*this, index); | - |
| 1929 | if (index == -1) evaluated: index == -1| yes Evaluation Count:162368 | yes Evaluation Count:2285 |
| 2285-162368 |
| 1930 | break; executed: break;Execution Count:162368 | 162368 |
| 1931 | indices[pos++] = index; executed (the execution status of this line is deduced): indices[pos++] = index; | - |
| 1932 | index += blen; executed (the execution status of this line is deduced): index += blen; | - |
| 1933 | // avoid infinite loop | - |
| 1934 | if (!blen) evaluated: !blen| yes Evaluation Count:10 | yes Evaluation Count:2275 |
| 10-2275 |
| 1935 | index++; executed: index++;Execution Count:10 | 10 |
| 1936 | } executed: }Execution Count:2285 | 2285 |
| 1937 | if (!pos) evaluated: !pos| yes Evaluation Count:160501 | yes Evaluation Count:1867 |
| 1867-160501 |
| 1938 | break; executed: break;Execution Count:160501 | 160501 |
| 1939 | | - |
| 1940 | replace_helper(indices, pos, blen, after, alen); executed (the execution status of this line is deduced): replace_helper(indices, pos, blen, after, alen); | - |
| 1941 | | - |
| 1942 | if (index == -1) partially evaluated: index == -1| yes Evaluation Count:1867 | no Evaluation Count:0 |
| 0-1867 |
| 1943 | break; executed: break;Execution Count:1867 | 1867 |
| 1944 | // index has to be adjusted in case we get back into the loop above. | - |
| 1945 | index += pos*(alen-blen); never executed (the execution status of this line is deduced): index += pos*(alen-blen); | - |
| 1946 | } | 0 |
| 1947 | | - |
| 1948 | return *this; executed: return *this;Execution Count:162368 | 162368 |
| 1949 | } | - |
| 1950 | | - |
| 1951 | /*! | - |
| 1952 | \overload replace() | - |
| 1953 | Replaces every occurrence of the character \a ch in the string with | - |
| 1954 | \a after and returns a reference to this string. | - |
| 1955 | | - |
| 1956 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 1957 | sensitive; otherwise the search is case insensitive. | - |
| 1958 | */ | - |
| 1959 | QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs) | - |
| 1960 | { | - |
| 1961 | if (after.d->size == 0) evaluated: after.d->size == 0| yes Evaluation Count:37 | yes Evaluation Count:2086 |
| 37-2086 |
| 1962 | return remove(ch, cs); executed: return remove(ch, cs);Execution Count:37 | 37 |
| 1963 | | - |
| 1964 | if (after.d->size == 1) evaluated: after.d->size == 1| yes Evaluation Count:22 | yes Evaluation Count:2064 |
| 22-2064 |
| 1965 | return replace(ch, after.d->data()[0], cs); executed: return replace(ch, after.d->data()[0], cs);Execution Count:22 | 22 |
| 1966 | | - |
| 1967 | if (d->size == 0) evaluated: d->size == 0| yes Evaluation Count:490 | yes Evaluation Count:1574 |
| 490-1574 |
| 1968 | return *this; executed: return *this;Execution Count:490 | 490 |
| 1969 | | - |
| 1970 | ushort cc = (cs == Qt::CaseSensitive ? ch.unicode() : ch.toCaseFolded().unicode()); evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:1570 | yes Evaluation Count:4 |
| 4-1570 |
| 1971 | | - |
| 1972 | int index = 0; executed (the execution status of this line is deduced): int index = 0; | - |
| 1973 | while (1) { partially evaluated: 1| yes Evaluation Count:1594 | no Evaluation Count:0 |
| 0-1594 |
| 1974 | uint indices[1024]; executed (the execution status of this line is deduced): uint indices[1024]; | - |
| 1975 | uint pos = 0; executed (the execution status of this line is deduced): uint pos = 0; | - |
| 1976 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:1587 | yes Evaluation Count:7 |
| 7-1587 |
| 1977 | while (pos < 1023 && index < d->size) { partially evaluated: pos < 1023| yes Evaluation Count:59844 | no Evaluation Count:0 |
evaluated: index < d->size| yes Evaluation Count:58257 | yes Evaluation Count:1587 |
| 0-59844 |
| 1978 | if (d->data()[index] == cc) evaluated: d->data()[index] == cc| yes Evaluation Count:27 | yes Evaluation Count:58230 |
| 27-58230 |
| 1979 | indices[pos++] = index; executed: indices[pos++] = index;Execution Count:27 | 27 |
| 1980 | index++; executed (the execution status of this line is deduced): index++; | - |
| 1981 | } executed: }Execution Count:58257 | 58257 |
| 1982 | } else { executed: }Execution Count:1587 | 1587 |
| 1983 | while (pos < 1023 && index < d->size) { partially evaluated: pos < 1023| yes Evaluation Count:29 | no Evaluation Count:0 |
evaluated: index < d->size| yes Evaluation Count:22 | yes Evaluation Count:7 |
| 0-29 |
| 1984 | if (QChar::toCaseFolded(d->data()[index]) == cc) evaluated: QChar::toCaseFolded(d->data()[index]) == cc| yes Evaluation Count:8 | yes Evaluation Count:14 |
| 8-14 |
| 1985 | indices[pos++] = index; executed: indices[pos++] = index;Execution Count:8 | 8 |
| 1986 | index++; executed (the execution status of this line is deduced): index++; | - |
| 1987 | } executed: }Execution Count:22 | 22 |
| 1988 | } executed: }Execution Count:7 | 7 |
| 1989 | if (!pos) evaluated: !pos| yes Evaluation Count:1574 | yes Evaluation Count:20 |
| 20-1574 |
| 1990 | break; executed: break;Execution Count:1574 | 1574 |
| 1991 | | - |
| 1992 | replace_helper(indices, pos, 1, after.constData(), after.d->size); executed (the execution status of this line is deduced): replace_helper(indices, pos, 1, after.constData(), after.d->size); | - |
| 1993 | | - |
| 1994 | if (index == -1) partially evaluated: index == -1| no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
| 1995 | break; | 0 |
| 1996 | // index has to be adjusted in case we get back into the loop above. | - |
| 1997 | index += pos*(after.d->size - 1); executed (the execution status of this line is deduced): index += pos*(after.d->size - 1); | - |
| 1998 | } executed: }Execution Count:20 | 20 |
| 1999 | return *this; executed: return *this;Execution Count:1574 | 1574 |
| 2000 | } | - |
| 2001 | | - |
| 2002 | /*! | - |
| 2003 | \overload replace() | - |
| 2004 | Replaces every occurrence of the character \a before with the | - |
| 2005 | character \a after and returns a reference to this string. | - |
| 2006 | | - |
| 2007 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2008 | sensitive; otherwise the search is case insensitive. | - |
| 2009 | */ | - |
| 2010 | QString& QString::replace(QChar before, QChar after, Qt::CaseSensitivity cs) | - |
| 2011 | { | - |
| 2012 | ushort a = after.unicode(); executed (the execution status of this line is deduced): ushort a = after.unicode(); | - |
| 2013 | ushort b = before.unicode(); executed (the execution status of this line is deduced): ushort b = before.unicode(); | - |
| 2014 | if (d->size) { evaluated: d->size| yes Evaluation Count:931949 | yes Evaluation Count:2 |
| 2-931949 |
| 2015 | detach(); executed (the execution status of this line is deduced): detach(); | - |
| 2016 | ushort *i = d->data(); executed (the execution status of this line is deduced): ushort *i = d->data(); | - |
| 2017 | const ushort *e = i + d->size; executed (the execution status of this line is deduced): const ushort *e = i + d->size; | - |
| 2018 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:931927 | yes Evaluation Count:22 |
| 22-931927 |
| 2019 | for (; i != e; ++i) evaluated: i != e| yes Evaluation Count:1935401 | yes Evaluation Count:931927 |
| 931927-1935401 |
| 2020 | if (*i == b) evaluated: *i == b| yes Evaluation Count:722 | yes Evaluation Count:1934679 |
| 722-1934679 |
| 2021 | *i = a; executed: *i = a;Execution Count:722 | 722 |
| 2022 | } else { executed: }Execution Count:931927 | 931927 |
| 2023 | b = foldCase(b); executed (the execution status of this line is deduced): b = foldCase(b); | - |
| 2024 | for (; i != e; ++i) evaluated: i != e| yes Evaluation Count:58 | yes Evaluation Count:22 |
| 22-58 |
| 2025 | if (foldCase(*i) == b) evaluated: foldCase(*i) == b| yes Evaluation Count:30 | yes Evaluation Count:28 |
| 28-30 |
| 2026 | *i = a; executed: *i = a;Execution Count:30 | 30 |
| 2027 | } executed: }Execution Count:22 | 22 |
| 2028 | } | - |
| 2029 | return *this; executed: return *this;Execution Count:931951 | 931951 |
| 2030 | } | - |
| 2031 | | - |
| 2032 | /*! | - |
| 2033 | \since 4.5 | - |
| 2034 | \overload replace() | - |
| 2035 | | - |
| 2036 | Replaces every occurrence of the string \a before with the string \a | - |
| 2037 | after and returns a reference to this string. | - |
| 2038 | | - |
| 2039 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2040 | sensitive; otherwise the search is case insensitive. | - |
| 2041 | | - |
| 2042 | \note The text is not rescanned after a replacement. | - |
| 2043 | */ | - |
| 2044 | QString &QString::replace(QLatin1String before, QLatin1String after, Qt::CaseSensitivity cs) | - |
| 2045 | { | - |
| 2046 | int alen = after.size(); executed (the execution status of this line is deduced): int alen = after.size(); | - |
| 2047 | QVarLengthArray<ushort> a(alen); executed (the execution status of this line is deduced): QVarLengthArray<ushort> a(alen); | - |
| 2048 | for (int i = 0; i < alen; ++i) evaluated: i < alen| yes Evaluation Count:1487 | yes Evaluation Count:528 |
| 528-1487 |
| 2049 | a[i] = (uchar)after.latin1()[i]; executed: a[i] = (uchar)after.latin1()[i];Execution Count:1487 | 1487 |
| 2050 | int blen = before.size(); executed (the execution status of this line is deduced): int blen = before.size(); | - |
| 2051 | QVarLengthArray<ushort> b(blen); executed (the execution status of this line is deduced): QVarLengthArray<ushort> b(blen); | - |
| 2052 | for (int i = 0; i < blen; ++i) evaluated: i < blen| yes Evaluation Count:2926 | yes Evaluation Count:528 |
| 528-2926 |
| 2053 | b[i] = (uchar)before.latin1()[i]; executed: b[i] = (uchar)before.latin1()[i];Execution Count:2926 | 2926 |
| 2054 | return replace((const QChar *)b.data(), blen, (const QChar *)a.data(), alen, cs); executed: return replace((const QChar *)b.data(), blen, (const QChar *)a.data(), alen, cs);Execution Count:528 | 528 |
| 2055 | } | - |
| 2056 | | - |
| 2057 | /*! | - |
| 2058 | \since 4.5 | - |
| 2059 | \overload replace() | - |
| 2060 | | - |
| 2061 | Replaces every occurrence of the string \a before with the string \a | - |
| 2062 | after and returns a reference to this string. | - |
| 2063 | | - |
| 2064 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2065 | sensitive; otherwise the search is case insensitive. | - |
| 2066 | | - |
| 2067 | \note The text is not rescanned after a replacement. | - |
| 2068 | */ | - |
| 2069 | QString &QString::replace(QLatin1String before, const QString &after, Qt::CaseSensitivity cs) | - |
| 2070 | { | - |
| 2071 | int blen = before.size(); executed (the execution status of this line is deduced): int blen = before.size(); | - |
| 2072 | QVarLengthArray<ushort> b(blen); executed (the execution status of this line is deduced): QVarLengthArray<ushort> b(blen); | - |
| 2073 | for (int i = 0; i < blen; ++i) evaluated: i < blen| yes Evaluation Count:258 | yes Evaluation Count:129 |
| 129-258 |
| 2074 | b[i] = (uchar)before.latin1()[i]; executed: b[i] = (uchar)before.latin1()[i];Execution Count:258 | 258 |
| 2075 | return replace((const QChar *)b.data(), blen, after.constData(), after.d->size, cs); executed: return replace((const QChar *)b.data(), blen, after.constData(), after.d->size, cs);Execution Count:129 | 129 |
| 2076 | } | - |
| 2077 | | - |
| 2078 | /*! | - |
| 2079 | \since 4.5 | - |
| 2080 | \overload replace() | - |
| 2081 | | - |
| 2082 | Replaces every occurrence of the string \a before with the string \a | - |
| 2083 | after and returns a reference to this string. | - |
| 2084 | | - |
| 2085 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2086 | sensitive; otherwise the search is case insensitive. | - |
| 2087 | | - |
| 2088 | \note The text is not rescanned after a replacement. | - |
| 2089 | */ | - |
| 2090 | QString &QString::replace(const QString &before, QLatin1String after, Qt::CaseSensitivity cs) | - |
| 2091 | { | - |
| 2092 | int alen = after.size(); never executed (the execution status of this line is deduced): int alen = after.size(); | - |
| 2093 | QVarLengthArray<ushort> a(alen); never executed (the execution status of this line is deduced): QVarLengthArray<ushort> a(alen); | - |
| 2094 | for (int i = 0; i < alen; ++i) never evaluated: i < alen | 0 |
| 2095 | a[i] = (uchar)after.latin1()[i]; never executed: a[i] = (uchar)after.latin1()[i]; | 0 |
| 2096 | return replace(before.constData(), before.d->size, (const QChar *)a.data(), alen, cs); never executed: return replace(before.constData(), before.d->size, (const QChar *)a.data(), alen, cs); | 0 |
| 2097 | } | - |
| 2098 | | - |
| 2099 | /*! | - |
| 2100 | \since 4.5 | - |
| 2101 | \overload replace() | - |
| 2102 | | - |
| 2103 | Replaces every occurrence of the character \a c with the string \a | - |
| 2104 | after and returns a reference to this string. | - |
| 2105 | | - |
| 2106 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2107 | sensitive; otherwise the search is case insensitive. | - |
| 2108 | | - |
| 2109 | \note The text is not rescanned after a replacement. | - |
| 2110 | */ | - |
| 2111 | QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs) | - |
| 2112 | { | - |
| 2113 | int alen = after.size(); executed (the execution status of this line is deduced): int alen = after.size(); | - |
| 2114 | QVarLengthArray<ushort> a(alen); executed (the execution status of this line is deduced): QVarLengthArray<ushort> a(alen); | - |
| 2115 | for (int i = 0; i < alen; ++i) evaluated: i < alen| yes Evaluation Count:14727 | yes Evaluation Count:5503 |
| 5503-14727 |
| 2116 | a[i] = (uchar)after.latin1()[i]; executed: a[i] = (uchar)after.latin1()[i];Execution Count:14727 | 14727 |
| 2117 | return replace(&c, 1, (const QChar *)a.data(), alen, cs); executed: return replace(&c, 1, (const QChar *)a.data(), alen, cs);Execution Count:5503 | 5503 |
| 2118 | } | - |
| 2119 | | - |
| 2120 | | - |
| 2121 | /*! | - |
| 2122 | \relates QString | - |
| 2123 | Returns true if string \a s1 is equal to string \a s2; otherwise | - |
| 2124 | returns false. | - |
| 2125 | | - |
| 2126 | The comparison is based exclusively on the numeric Unicode values of | - |
| 2127 | the characters and is very fast, but is not what a human would | - |
| 2128 | expect. Consider sorting user-interface strings with | - |
| 2129 | localeAwareCompare(). | - |
| 2130 | */ | - |
| 2131 | bool operator==(const QString &s1, const QString &s2) | - |
| 2132 | { | - |
| 2133 | if (s1.d->size != s2.d->size) evaluated: s1.d->size != s2.d->size| yes Evaluation Count:341015 | yes Evaluation Count:2205315 |
| 341015-2205315 |
| 2134 | return false; executed: return false;Execution Count:341015 | 341015 |
| 2135 | | - |
| 2136 | return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size); executed: return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size);Execution Count:2205313 | 2205313 |
| 2137 | } | - |
| 2138 | | - |
| 2139 | /*! | - |
| 2140 | \overload operator==() | - |
| 2141 | */ | - |
| 2142 | bool QString::operator==(QLatin1String other) const | - |
| 2143 | { | - |
| 2144 | if (d->size != other.size()) evaluated: d->size != other.size()| yes Evaluation Count:285300 | yes Evaluation Count:70731 |
| 70731-285300 |
| 2145 | return false; executed: return false;Execution Count:285300 | 285300 |
| 2146 | | - |
| 2147 | if (!other.size()) evaluated: !other.size()| yes Evaluation Count:7 | yes Evaluation Count:70726 |
| 7-70726 |
| 2148 | return isEmpty(); executed: return isEmpty();Execution Count:7 | 7 |
| 2149 | | - |
| 2150 | const ushort *uc = d->data(); executed (the execution status of this line is deduced): const ushort *uc = d->data(); | - |
| 2151 | const ushort *e = uc + d->size; executed (the execution status of this line is deduced): const ushort *e = uc + d->size; | - |
| 2152 | const uchar *c = (uchar *)other.latin1(); executed (the execution status of this line is deduced): const uchar *c = (uchar *)other.latin1(); | - |
| 2153 | | - |
| 2154 | while (uc < e) { evaluated: uc < e| yes Evaluation Count:376404 | yes Evaluation Count:55832 |
| 55832-376404 |
| 2155 | if (*uc != *c) evaluated: *uc != *c| yes Evaluation Count:14895 | yes Evaluation Count:361509 |
| 14895-361509 |
| 2156 | return false; executed: return false;Execution Count:14895 | 14895 |
| 2157 | ++uc; executed (the execution status of this line is deduced): ++uc; | - |
| 2158 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 2159 | } executed: }Execution Count:361511 | 361511 |
| 2160 | return true; executed: return true;Execution Count:55832 | 55832 |
| 2161 | } | - |
| 2162 | | - |
| 2163 | /*! \fn bool QString::operator==(const QByteArray &other) const | - |
| 2164 | | - |
| 2165 | \overload operator==() | - |
| 2166 | | - |
| 2167 | The \a other byte array is converted to a QString using the | - |
| 2168 | fromUtf8() function. This function stops conversion at the | - |
| 2169 | first NUL character found, or the end of the byte array. | - |
| 2170 | | - |
| 2171 | You can disable this operator by defining \c | - |
| 2172 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2173 | can be useful if you want to ensure that all user-visible strings | - |
| 2174 | go through QObject::tr(), for example. | - |
| 2175 | */ | - |
| 2176 | | - |
| 2177 | /*! \fn bool QString::operator==(const char *other) const | - |
| 2178 | | - |
| 2179 | \overload operator==() | - |
| 2180 | | - |
| 2181 | The \a other const char pointer is converted to a QString using | - |
| 2182 | the fromUtf8() function. | - |
| 2183 | | - |
| 2184 | You can disable this operator by defining \c | - |
| 2185 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2186 | can be useful if you want to ensure that all user-visible strings | - |
| 2187 | go through QObject::tr(), for example. | - |
| 2188 | */ | - |
| 2189 | | - |
| 2190 | /*! | - |
| 2191 | \relates QString | - |
| 2192 | Returns true if string \a s1 is lexically less than string | - |
| 2193 | \a s2; otherwise returns false. | - |
| 2194 | | - |
| 2195 | The comparison is based exclusively on the numeric Unicode values | - |
| 2196 | of the characters and is very fast, but is not what a human would | - |
| 2197 | expect. Consider sorting user-interface strings using the | - |
| 2198 | QString::localeAwareCompare() function. | - |
| 2199 | */ | - |
| 2200 | bool operator<(const QString &s1, const QString &s2) | - |
| 2201 | { | - |
| 2202 | return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0; executed: return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;Execution Count:567875 | 567875 |
| 2203 | } | - |
| 2204 | | - |
| 2205 | /*! | - |
| 2206 | \overload operator<() | - |
| 2207 | */ | - |
| 2208 | bool QString::operator<(QLatin1String other) const | - |
| 2209 | { | - |
| 2210 | const uchar *c = (uchar *) other.latin1(); executed (the execution status of this line is deduced): const uchar *c = (uchar *) other.latin1(); | - |
| 2211 | if (!c || *c == 0) evaluated: !c| yes Evaluation Count:5 | yes Evaluation Count:1920 |
evaluated: *c == 0| yes Evaluation Count:7 | yes Evaluation Count:1913 |
| 5-1920 |
| 2212 | return false; executed: return false;Execution Count:12 | 12 |
| 2213 | | - |
| 2214 | const ushort *uc = d->data(); executed (the execution status of this line is deduced): const ushort *uc = d->data(); | - |
| 2215 | const ushort *e = uc + qMin(d->size, other.size()); executed (the execution status of this line is deduced): const ushort *e = uc + qMin(d->size, other.size()); | - |
| 2216 | | - |
| 2217 | while (uc < e) { evaluated: uc < e| yes Evaluation Count:5360 | yes Evaluation Count:1862 |
| 1862-5360 |
| 2218 | if (*uc != *c) evaluated: *uc != *c| yes Evaluation Count:51 | yes Evaluation Count:5309 |
| 51-5309 |
| 2219 | break; executed: break;Execution Count:51 | 51 |
| 2220 | ++uc; executed (the execution status of this line is deduced): ++uc; | - |
| 2221 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 2222 | } executed: }Execution Count:5309 | 5309 |
| 2223 | return (uc == e ? d->size < other.size() : *uc < *c); executed: return (uc == e ? d->size < other.size() : *uc < *c);Execution Count:1913 | 1913 |
| 2224 | } | - |
| 2225 | | - |
| 2226 | /*! \fn bool QString::operator<(const QByteArray &other) const | - |
| 2227 | | - |
| 2228 | \overload operator<() | - |
| 2229 | | - |
| 2230 | The \a other byte array is converted to a QString using the | - |
| 2231 | fromUtf8() function. If any NUL characters ('\\0') are embedded | - |
| 2232 | in the byte array, they will be included in the transformation. | - |
| 2233 | | - |
| 2234 | You can disable this operator by defining \c | - |
| 2235 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2236 | can be useful if you want to ensure that all user-visible strings | - |
| 2237 | go through QObject::tr(), for example. | - |
| 2238 | */ | - |
| 2239 | | - |
| 2240 | /*! \fn bool QString::operator<(const char *other) const | - |
| 2241 | | - |
| 2242 | \overload operator<() | - |
| 2243 | | - |
| 2244 | The \a other const char pointer is converted to a QString using | - |
| 2245 | the fromUtf8() function. | - |
| 2246 | | - |
| 2247 | You can disable this operator by defining \c | - |
| 2248 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2249 | can be useful if you want to ensure that all user-visible strings | - |
| 2250 | go through QObject::tr(), for example. | - |
| 2251 | */ | - |
| 2252 | | - |
| 2253 | /*! \fn bool QString::operator<=(const QString &s1, const QString &s2) | - |
| 2254 | | - |
| 2255 | Returns true if string \a s1 is lexically less than or equal to | - |
| 2256 | string \a s2; otherwise returns false. | - |
| 2257 | | - |
| 2258 | The comparison is based exclusively on the numeric Unicode values | - |
| 2259 | of the characters and is very fast, but is not what a human would | - |
| 2260 | expect. Consider sorting user-interface strings with | - |
| 2261 | localeAwareCompare(). | - |
| 2262 | */ | - |
| 2263 | | - |
| 2264 | /*! \fn bool QString::operator<=(QLatin1String other) const | - |
| 2265 | | - |
| 2266 | \overload operator<=() | - |
| 2267 | */ | - |
| 2268 | | - |
| 2269 | /*! \fn bool QString::operator<=(const QByteArray &other) const | - |
| 2270 | | - |
| 2271 | \overload operator<=() | - |
| 2272 | | - |
| 2273 | The \a other byte array is converted to a QString using the | - |
| 2274 | fromUtf8() function. If any NUL characters ('\\0') are embedded | - |
| 2275 | in the byte array, they will be included in the transformation. | - |
| 2276 | | - |
| 2277 | You can disable this operator by defining \c | - |
| 2278 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2279 | can be useful if you want to ensure that all user-visible strings | - |
| 2280 | go through QObject::tr(), for example. | - |
| 2281 | */ | - |
| 2282 | | - |
| 2283 | /*! \fn bool QString::operator<=(const char *other) const | - |
| 2284 | | - |
| 2285 | \overload operator<=() | - |
| 2286 | | - |
| 2287 | The \a other const char pointer is converted to a QString using | - |
| 2288 | the fromUtf8() function. | - |
| 2289 | | - |
| 2290 | You can disable this operator by defining \c | - |
| 2291 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2292 | can be useful if you want to ensure that all user-visible strings | - |
| 2293 | go through QObject::tr(), for example. | - |
| 2294 | */ | - |
| 2295 | | - |
| 2296 | /*! \fn bool QString::operator>(const QString &s1, const QString &s2) | - |
| 2297 | | - |
| 2298 | Returns true if string \a s1 is lexically greater than string \a | - |
| 2299 | s2; otherwise returns false. | - |
| 2300 | | - |
| 2301 | The comparison is based exclusively on the numeric Unicode values | - |
| 2302 | of the characters and is very fast, but is not what a human would | - |
| 2303 | expect. Consider sorting user-interface strings with | - |
| 2304 | localeAwareCompare(). | - |
| 2305 | */ | - |
| 2306 | | - |
| 2307 | /*! | - |
| 2308 | \overload operator>() | - |
| 2309 | */ | - |
| 2310 | bool QString::operator>(QLatin1String other) const | - |
| 2311 | { | - |
| 2312 | const uchar *c = (uchar *) other.latin1(); executed (the execution status of this line is deduced): const uchar *c = (uchar *) other.latin1(); | - |
| 2313 | if (!c || *c == '\0') evaluated: !c| yes Evaluation Count:5 | yes Evaluation Count:72913 |
evaluated: *c == '\0'| yes Evaluation Count:13 | yes Evaluation Count:72900 |
| 5-72913 |
| 2314 | return !isEmpty(); executed: return !isEmpty();Execution Count:18 | 18 |
| 2315 | | - |
| 2316 | const ushort *uc = d->data(); executed (the execution status of this line is deduced): const ushort *uc = d->data(); | - |
| 2317 | const ushort *e = uc + qMin(d->size, other.size()); executed (the execution status of this line is deduced): const ushort *e = uc + qMin(d->size, other.size()); | - |
| 2318 | | - |
| 2319 | while (uc < e) { evaluated: uc < e| yes Evaluation Count:228038 | yes Evaluation Count:31383 |
| 31383-228038 |
| 2320 | if (*uc != *c) evaluated: *uc != *c| yes Evaluation Count:41517 | yes Evaluation Count:186521 |
| 41517-186521 |
| 2321 | break; executed: break;Execution Count:41517 | 41517 |
| 2322 | ++uc; executed (the execution status of this line is deduced): ++uc; | - |
| 2323 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 2324 | } executed: }Execution Count:186521 | 186521 |
| 2325 | return (uc == e) ? d->size > other.size() : *uc > *c; executed: return (uc == e) ? d->size > other.size() : *uc > *c;Execution Count:72900 | 72900 |
| 2326 | } | - |
| 2327 | | - |
| 2328 | /*! \fn bool QString::operator>(const QByteArray &other) const | - |
| 2329 | | - |
| 2330 | \overload operator>() | - |
| 2331 | | - |
| 2332 | The \a other byte array is converted to a QString using the | - |
| 2333 | fromUtf8() function. If any NUL characters ('\\0') are embedded | - |
| 2334 | in the byte array, they will be included in the transformation. | - |
| 2335 | | - |
| 2336 | You can disable this operator by defining \c | - |
| 2337 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2338 | can be useful if you want to ensure that all user-visible strings | - |
| 2339 | go through QObject::tr(), for example. | - |
| 2340 | */ | - |
| 2341 | | - |
| 2342 | /*! \fn bool QString::operator>(const char *other) const | - |
| 2343 | | - |
| 2344 | \overload operator>() | - |
| 2345 | | - |
| 2346 | The \a other const char pointer is converted to a QString using | - |
| 2347 | the fromUtf8() function. | - |
| 2348 | | - |
| 2349 | You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII | - |
| 2350 | when you compile your applications. This can be useful if you want | - |
| 2351 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 2352 | for example. | - |
| 2353 | */ | - |
| 2354 | | - |
| 2355 | /*! \fn bool operator>=(const QString &s1, const QString &s2) | - |
| 2356 | \relates QString | - |
| 2357 | | - |
| 2358 | Returns true if string \a s1 is lexically greater than or equal to | - |
| 2359 | string \a s2; otherwise returns false. | - |
| 2360 | | - |
| 2361 | The comparison is based exclusively on the numeric Unicode values | - |
| 2362 | of the characters and is very fast, but is not what a human would | - |
| 2363 | expect. Consider sorting user-interface strings with | - |
| 2364 | localeAwareCompare(). | - |
| 2365 | */ | - |
| 2366 | | - |
| 2367 | /*! \fn bool QString::operator>=(QLatin1String other) const | - |
| 2368 | | - |
| 2369 | \overload operator>=() | - |
| 2370 | */ | - |
| 2371 | | - |
| 2372 | /*! \fn bool QString::operator>=(const QByteArray &other) const | - |
| 2373 | | - |
| 2374 | \overload operator>=() | - |
| 2375 | | - |
| 2376 | The \a other byte array is converted to a QString using the | - |
| 2377 | fromUtf8() function. If any NUL characters ('\\0') are embedded in | - |
| 2378 | the byte array, they will be included in the transformation. | - |
| 2379 | | - |
| 2380 | You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII | - |
| 2381 | when you compile your applications. This can be useful if you want | - |
| 2382 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 2383 | for example. | - |
| 2384 | */ | - |
| 2385 | | - |
| 2386 | /*! \fn bool QString::operator>=(const char *other) const | - |
| 2387 | | - |
| 2388 | \overload operator>=() | - |
| 2389 | | - |
| 2390 | The \a other const char pointer is converted to a QString using | - |
| 2391 | the fromUtf8() function. | - |
| 2392 | | - |
| 2393 | You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII | - |
| 2394 | when you compile your applications. This can be useful if you want | - |
| 2395 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 2396 | for example. | - |
| 2397 | */ | - |
| 2398 | | - |
| 2399 | /*! \fn bool operator!=(const QString &s1, const QString &s2) | - |
| 2400 | \relates QString | - |
| 2401 | | - |
| 2402 | Returns true if string \a s1 is not equal to string \a s2; | - |
| 2403 | otherwise returns false. | - |
| 2404 | | - |
| 2405 | The comparison is based exclusively on the numeric Unicode values | - |
| 2406 | of the characters and is very fast, but is not what a human would | - |
| 2407 | expect. Consider sorting user-interface strings with | - |
| 2408 | localeAwareCompare(). | - |
| 2409 | */ | - |
| 2410 | | - |
| 2411 | /*! \fn bool QString::operator!=(QLatin1String other) const | - |
| 2412 | | - |
| 2413 | \overload operator!=() | - |
| 2414 | */ | - |
| 2415 | | - |
| 2416 | /*! \fn bool QString::operator!=(const QByteArray &other) const | - |
| 2417 | | - |
| 2418 | \overload operator!=() | - |
| 2419 | | - |
| 2420 | The \a other byte array is converted to a QString using the | - |
| 2421 | fromUtf8() function. If any NUL characters ('\\0') are embedded | - |
| 2422 | in the byte array, they will be included in the transformation. | - |
| 2423 | | - |
| 2424 | You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII | - |
| 2425 | when you compile your applications. This can be useful if you want | - |
| 2426 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 2427 | for example. | - |
| 2428 | */ | - |
| 2429 | | - |
| 2430 | /*! \fn bool QString::operator!=(const char *other) const | - |
| 2431 | | - |
| 2432 | \overload operator!=() | - |
| 2433 | | - |
| 2434 | The \a other const char pointer is converted to a QString using | - |
| 2435 | the fromUtf8() function. | - |
| 2436 | | - |
| 2437 | You can disable this operator by defining \c | - |
| 2438 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 2439 | can be useful if you want to ensure that all user-visible strings | - |
| 2440 | go through QObject::tr(), for example. | - |
| 2441 | */ | - |
| 2442 | | - |
| 2443 | /*! | - |
| 2444 | Returns the index position of the first occurrence of the string \a | - |
| 2445 | str in this string, searching forward from index position \a | - |
| 2446 | from. Returns -1 if \a str is not found. | - |
| 2447 | | - |
| 2448 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2449 | sensitive; otherwise the search is case insensitive. | - |
| 2450 | | - |
| 2451 | Example: | - |
| 2452 | | - |
| 2453 | \snippet qstring/main.cpp 24 | - |
| 2454 | | - |
| 2455 | If \a from is -1, the search starts at the last character; if it is | - |
| 2456 | -2, at the next to last character and so on. | - |
| 2457 | | - |
| 2458 | \sa lastIndexOf(), contains(), count() | - |
| 2459 | */ | - |
| 2460 | int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - |
| 2461 | { | - |
| 2462 | return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); executed: return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs);Execution Count:54534 | 54534 |
| 2463 | } | - |
| 2464 | | - |
| 2465 | /*! | - |
| 2466 | \since 4.5 | - |
| 2467 | Returns the index position of the first occurrence of the string \a | - |
| 2468 | str in this string, searching forward from index position \a | - |
| 2469 | from. Returns -1 if \a str is not found. | - |
| 2470 | | - |
| 2471 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2472 | sensitive; otherwise the search is case insensitive. | - |
| 2473 | | - |
| 2474 | Example: | - |
| 2475 | | - |
| 2476 | \snippet qstring/main.cpp 24 | - |
| 2477 | | - |
| 2478 | If \a from is -1, the search starts at the last character; if it is | - |
| 2479 | -2, at the next to last character and so on. | - |
| 2480 | | - |
| 2481 | \sa lastIndexOf(), contains(), count() | - |
| 2482 | */ | - |
| 2483 | | - |
| 2484 | int QString::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - |
| 2485 | { | - |
| 2486 | return qt_find_latin1_string(unicode(), size(), str, from, cs); executed: return qt_find_latin1_string(unicode(), size(), str, from, cs);Execution Count:2528 | 2528 |
| 2487 | } | - |
| 2488 | | - |
| 2489 | int qFindString( | - |
| 2490 | const QChar *haystack0, int haystackLen, int from, | - |
| 2491 | const QChar *needle0, int needleLen, Qt::CaseSensitivity cs) | - |
| 2492 | { | - |
| 2493 | const int l = haystackLen; executed (the execution status of this line is deduced): const int l = haystackLen; | - |
| 2494 | const int sl = needleLen; executed (the execution status of this line is deduced): const int sl = needleLen; | - |
| 2495 | if (from < 0) partially evaluated: from < 0| no Evaluation Count:0 | yes Evaluation Count:198647 |
| 0-198647 |
| 2496 | from += l; never executed: from += l; | 0 |
| 2497 | if (uint(sl + from) > (uint)l) evaluated: uint(sl + from) > (uint)l| yes Evaluation Count:53520 | yes Evaluation Count:145127 |
| 53520-145127 |
| 2498 | return -1; executed: return -1;Execution Count:53520 | 53520 |
| 2499 | if (!sl) evaluated: !sl| yes Evaluation Count:337 | yes Evaluation Count:144790 |
| 337-144790 |
| 2500 | return from; executed: return from;Execution Count:337 | 337 |
| 2501 | if (!l) partially evaluated: !l| no Evaluation Count:0 | yes Evaluation Count:144790 |
| 0-144790 |
| 2502 | return -1; never executed: return -1; | 0 |
| 2503 | | - |
| 2504 | if (sl == 1) evaluated: sl == 1| yes Evaluation Count:127178 | yes Evaluation Count:17612 |
| 17612-127178 |
| 2505 | return findChar(haystack0, haystackLen, needle0[0], from, cs); executed: return findChar(haystack0, haystackLen, needle0[0], from, cs);Execution Count:127178 | 127178 |
| 2506 | | - |
| 2507 | /* | - |
| 2508 | We use the Boyer-Moore algorithm in cases where the overhead | - |
| 2509 | for the skip table should pay off, otherwise we use a simple | - |
| 2510 | hash function. | - |
| 2511 | */ | - |
| 2512 | if (l > 500 && sl > 5) evaluated: l > 500| yes Evaluation Count:235 | yes Evaluation Count:17377 |
evaluated: sl > 5| yes Evaluation Count:215 | yes Evaluation Count:20 |
| 20-17377 |
| 2513 | return qFindStringBoyerMoore(haystack0, haystackLen, from, executed: return qFindStringBoyerMoore(haystack0, haystackLen, from, needle0, needleLen, cs);Execution Count:215 | 215 |
| 2514 | needle0, needleLen, cs); executed: return qFindStringBoyerMoore(haystack0, haystackLen, from, needle0, needleLen, cs);Execution Count:215 | 215 |
| 2515 | | - |
| 2516 | /* | - |
| 2517 | We use some hashing for efficiency's sake. Instead of | - |
| 2518 | comparing strings, we compare the hash value of str with that | - |
| 2519 | of a part of this QString. Only if that matches, we call | - |
| 2520 | ucstrncmp() or ucstrnicmp(). | - |
| 2521 | */ | - |
| 2522 | const ushort *needle = (const ushort *)needle0; executed (the execution status of this line is deduced): const ushort *needle = (const ushort *)needle0; | - |
| 2523 | const ushort *haystack = (const ushort *)haystack0 + from; executed (the execution status of this line is deduced): const ushort *haystack = (const ushort *)haystack0 + from; | - |
| 2524 | const ushort *end = (const ushort *)haystack0 + (l-sl); executed (the execution status of this line is deduced): const ushort *end = (const ushort *)haystack0 + (l-sl); | - |
| 2525 | const int sl_minus_1 = sl-1; executed (the execution status of this line is deduced): const int sl_minus_1 = sl-1; | - |
| 2526 | int hashNeedle = 0, hashHaystack = 0, idx; executed (the execution status of this line is deduced): int hashNeedle = 0, hashHaystack = 0, idx; | - |
| 2527 | | - |
| 2528 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:14608 | yes Evaluation Count:2789 |
| 2789-14608 |
| 2529 | for (idx = 0; idx < sl; ++idx) { evaluated: idx < sl| yes Evaluation Count:85783 | yes Evaluation Count:14608 |
| 14608-85783 |
| 2530 | hashNeedle = ((hashNeedle<<1) + needle[idx]); executed (the execution status of this line is deduced): hashNeedle = ((hashNeedle<<1) + needle[idx]); | - |
| 2531 | hashHaystack = ((hashHaystack<<1) + haystack[idx]); executed (the execution status of this line is deduced): hashHaystack = ((hashHaystack<<1) + haystack[idx]); | - |
| 2532 | } executed: }Execution Count:85783 | 85783 |
| 2533 | hashHaystack -= haystack[sl_minus_1]; executed (the execution status of this line is deduced): hashHaystack -= haystack[sl_minus_1]; | - |
| 2534 | | - |
| 2535 | while (haystack <= end) { evaluated: haystack <= end| yes Evaluation Count:188199 | yes Evaluation Count:11548 |
| 11548-188199 |
| 2536 | hashHaystack += haystack[sl_minus_1]; executed (the execution status of this line is deduced): hashHaystack += haystack[sl_minus_1]; | - |
| 2537 | if (hashHaystack == hashNeedle evaluated: hashHaystack == hashNeedle| yes Evaluation Count:3134 | yes Evaluation Count:185065 |
| 3134-185065 |
| 2538 | && ucstrncmp((const QChar *)needle, (const QChar *)haystack, sl) == 0) evaluated: ucstrncmp((const QChar *)needle, (const QChar *)haystack, sl) == 0| yes Evaluation Count:3060 | yes Evaluation Count:74 |
| 74-3060 |
| 2539 | return haystack - (const ushort *)haystack0; executed: return haystack - (const ushort *)haystack0;Execution Count:3060 | 3060 |
| 2540 | | - |
| 2541 | REHASH(*haystack); executed: hashHaystack -= (*haystack) << sl_minus_1;Execution Count:184006 evaluated: sl_minus_1 < (int)sizeof(int) * 8| yes Evaluation Count:184006 | yes Evaluation Count:1133 |
| 1133-184006 |
| 2542 | ++haystack; executed (the execution status of this line is deduced): ++haystack; | - |
| 2543 | } executed: }Execution Count:185139 | 185139 |
| 2544 | } else { executed: }Execution Count:11548 | 11548 |
| 2545 | const ushort *haystack_start = (const ushort *)haystack0; executed (the execution status of this line is deduced): const ushort *haystack_start = (const ushort *)haystack0; | - |
| 2546 | for (idx = 0; idx < sl; ++idx) { evaluated: idx < sl| yes Evaluation Count:11210 | yes Evaluation Count:2789 |
| 2789-11210 |
| 2547 | hashNeedle = (hashNeedle<<1) + foldCase(needle + idx, needle); executed (the execution status of this line is deduced): hashNeedle = (hashNeedle<<1) + foldCase(needle + idx, needle); | - |
| 2548 | hashHaystack = (hashHaystack<<1) + foldCase(haystack + idx, haystack_start); executed (the execution status of this line is deduced): hashHaystack = (hashHaystack<<1) + foldCase(haystack + idx, haystack_start); | - |
| 2549 | } executed: }Execution Count:11210 | 11210 |
| 2550 | hashHaystack -= foldCase(haystack + sl_minus_1, haystack_start); executed (the execution status of this line is deduced): hashHaystack -= foldCase(haystack + sl_minus_1, haystack_start); | - |
| 2551 | | - |
| 2552 | while (haystack <= end) { evaluated: haystack <= end| yes Evaluation Count:9870 | yes Evaluation Count:1694 |
| 1694-9870 |
| 2553 | hashHaystack += foldCase(haystack + sl_minus_1, haystack_start); executed (the execution status of this line is deduced): hashHaystack += foldCase(haystack + sl_minus_1, haystack_start); | - |
| 2554 | if (hashHaystack == hashNeedle && ucstrnicmp(needle, haystack, sl) == 0) evaluated: hashHaystack == hashNeedle| yes Evaluation Count:1105 | yes Evaluation Count:8765 |
evaluated: ucstrnicmp(needle, haystack, sl) == 0| yes Evaluation Count:1095 | yes Evaluation Count:10 |
| 10-8765 |
| 2555 | return haystack - (const ushort *)haystack0; executed: return haystack - (const ushort *)haystack0;Execution Count:1095 | 1095 |
| 2556 | | - |
| 2557 | REHASH(foldCase(haystack, haystack_start)); executed: hashHaystack -= (foldCase(haystack, haystack_start)) << sl_minus_1;Execution Count:8590 evaluated: sl_minus_1 < (int)sizeof(int) * 8| yes Evaluation Count:8590 | yes Evaluation Count:185 |
| 185-8590 |
| 2558 | ++haystack; executed (the execution status of this line is deduced): ++haystack; | - |
| 2559 | } executed: }Execution Count:8775 | 8775 |
| 2560 | } executed: }Execution Count:1694 | 1694 |
| 2561 | return -1; executed: return -1;Execution Count:13242 | 13242 |
| 2562 | } | - |
| 2563 | | - |
| 2564 | /*! | - |
| 2565 | \overload indexOf() | - |
| 2566 | | - |
| 2567 | Returns the index position of the first occurrence of the | - |
| 2568 | character \a ch in the string, searching forward from index | - |
| 2569 | position \a from. Returns -1 if \a ch could not be found. | - |
| 2570 | */ | - |
| 2571 | int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - |
| 2572 | { | - |
| 2573 | return findChar(unicode(), length(), ch, from, cs); executed: return findChar(unicode(), length(), ch, from, cs);Execution Count:158057 | 158057 |
| 2574 | } | - |
| 2575 | | - |
| 2576 | /*! | - |
| 2577 | \since 4.8 | - |
| 2578 | | - |
| 2579 | \overload indexOf() | - |
| 2580 | | - |
| 2581 | Returns the index position of the first occurrence of the string | - |
| 2582 | reference \a str in this string, searching forward from index | - |
| 2583 | position \a from. Returns -1 if \a str is not found. | - |
| 2584 | | - |
| 2585 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2586 | sensitive; otherwise the search is case insensitive. | - |
| 2587 | */ | - |
| 2588 | int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - |
| 2589 | { | - |
| 2590 | return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); executed: return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs);Execution Count:392 | 392 |
| 2591 | } | - |
| 2592 | | - |
| 2593 | static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs) | - |
| 2594 | { | - |
| 2595 | /* | - |
| 2596 | See indexOf() for explanations. | - |
| 2597 | */ | - |
| 2598 | | - |
| 2599 | const ushort *end = haystack; executed (the execution status of this line is deduced): const ushort *end = haystack; | - |
| 2600 | haystack += from; executed (the execution status of this line is deduced): haystack += from; | - |
| 2601 | const int sl_minus_1 = sl-1; executed (the execution status of this line is deduced): const int sl_minus_1 = sl-1; | - |
| 2602 | const ushort *n = needle+sl_minus_1; executed (the execution status of this line is deduced): const ushort *n = needle+sl_minus_1; | - |
| 2603 | const ushort *h = haystack+sl_minus_1; executed (the execution status of this line is deduced): const ushort *h = haystack+sl_minus_1; | - |
| 2604 | int hashNeedle = 0, hashHaystack = 0, idx; executed (the execution status of this line is deduced): int hashNeedle = 0, hashHaystack = 0, idx; | - |
| 2605 | | - |
| 2606 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:78 | yes Evaluation Count:98 |
| 78-98 |
| 2607 | for (idx = 0; idx < sl; ++idx) { evaluated: idx < sl| yes Evaluation Count:1042 | yes Evaluation Count:78 |
| 78-1042 |
| 2608 | hashNeedle = ((hashNeedle<<1) + *(n-idx)); executed (the execution status of this line is deduced): hashNeedle = ((hashNeedle<<1) + *(n-idx)); | - |
| 2609 | hashHaystack = ((hashHaystack<<1) + *(h-idx)); executed (the execution status of this line is deduced): hashHaystack = ((hashHaystack<<1) + *(h-idx)); | - |
| 2610 | } executed: }Execution Count:1042 | 1042 |
| 2611 | hashHaystack -= *haystack; executed (the execution status of this line is deduced): hashHaystack -= *haystack; | - |
| 2612 | | - |
| 2613 | while (haystack >= end) { evaluated: haystack >= end| yes Evaluation Count:653 | yes Evaluation Count:17 |
| 17-653 |
| 2614 | hashHaystack += *haystack; executed (the execution status of this line is deduced): hashHaystack += *haystack; | - |
| 2615 | if (hashHaystack == hashNeedle evaluated: hashHaystack == hashNeedle| yes Evaluation Count:65 | yes Evaluation Count:588 |
| 65-588 |
| 2616 | && ucstrncmp((const QChar *)needle, (const QChar *)haystack, sl) == 0) evaluated: ucstrncmp((const QChar *)needle, (const QChar *)haystack, sl) == 0| yes Evaluation Count:61 | yes Evaluation Count:4 |
| 4-61 |
| 2617 | return haystack - end; executed: return haystack - end;Execution Count:61 | 61 |
| 2618 | --haystack; executed (the execution status of this line is deduced): --haystack; | - |
| 2619 | REHASH(haystack[sl]); executed: hashHaystack -= (haystack[sl]) << sl_minus_1;Execution Count:456 evaluated: sl_minus_1 < (int)sizeof(int) * 8| yes Evaluation Count:456 | yes Evaluation Count:136 |
| 136-456 |
| 2620 | } executed: }Execution Count:592 | 592 |
| 2621 | } else { executed: }Execution Count:17 | 17 |
| 2622 | for (idx = 0; idx < sl; ++idx) { evaluated: idx < sl| yes Evaluation Count:1086 | yes Evaluation Count:98 |
| 98-1086 |
| 2623 | hashNeedle = ((hashNeedle<<1) + foldCase(n-idx, needle)); executed (the execution status of this line is deduced): hashNeedle = ((hashNeedle<<1) + foldCase(n-idx, needle)); | - |
| 2624 | hashHaystack = ((hashHaystack<<1) + foldCase(h-idx, end)); executed (the execution status of this line is deduced): hashHaystack = ((hashHaystack<<1) + foldCase(h-idx, end)); | - |
| 2625 | } executed: }Execution Count:1086 | 1086 |
| 2626 | hashHaystack -= foldCase(haystack, end); executed (the execution status of this line is deduced): hashHaystack -= foldCase(haystack, end); | - |
| 2627 | | - |
| 2628 | while (haystack >= end) { evaluated: haystack >= end| yes Evaluation Count:649 | yes Evaluation Count:37 |
| 37-649 |
| 2629 | hashHaystack += foldCase(haystack, end); executed (the execution status of this line is deduced): hashHaystack += foldCase(haystack, end); | - |
| 2630 | if (hashHaystack == hashNeedle && ucstrnicmp(needle, haystack, sl) == 0) evaluated: hashHaystack == hashNeedle| yes Evaluation Count:65 | yes Evaluation Count:584 |
evaluated: ucstrnicmp(needle, haystack, sl) == 0| yes Evaluation Count:61 | yes Evaluation Count:4 |
| 4-584 |
| 2631 | return haystack - end; executed: return haystack - end;Execution Count:61 | 61 |
| 2632 | --haystack; executed (the execution status of this line is deduced): --haystack; | - |
| 2633 | REHASH(foldCase(haystack + sl, end)); executed: hashHaystack -= (foldCase(haystack + sl, end)) << sl_minus_1;Execution Count:452 evaluated: sl_minus_1 < (int)sizeof(int) * 8| yes Evaluation Count:452 | yes Evaluation Count:136 |
| 136-452 |
| 2634 | } executed: }Execution Count:588 | 588 |
| 2635 | } executed: }Execution Count:37 | 37 |
| 2636 | return -1; executed: return -1;Execution Count:54 | 54 |
| 2637 | } | - |
| 2638 | | - |
| 2639 | /*! | - |
| 2640 | Returns the index position of the last occurrence of the string \a | - |
| 2641 | str in this string, searching backward from index position \a | - |
| 2642 | from. If \a from is -1 (default), the search starts at the last | - |
| 2643 | character; if \a from is -2, at the next to last character and so | - |
| 2644 | on. Returns -1 if \a str is not found. | - |
| 2645 | | - |
| 2646 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2647 | sensitive; otherwise the search is case insensitive. | - |
| 2648 | | - |
| 2649 | Example: | - |
| 2650 | | - |
| 2651 | \snippet qstring/main.cpp 29 | - |
| 2652 | | - |
| 2653 | \sa indexOf(), contains(), count() | - |
| 2654 | */ | - |
| 2655 | int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - |
| 2656 | { | - |
| 2657 | const int sl = str.d->size; executed (the execution status of this line is deduced): const int sl = str.d->size; | - |
| 2658 | if (sl == 1) evaluated: sl == 1| yes Evaluation Count:3220 | yes Evaluation Count:83 |
| 83-3220 |
| 2659 | return lastIndexOf(QChar(str.d->data()[0]), from, cs); executed: return lastIndexOf(QChar(str.d->data()[0]), from, cs);Execution Count:3220 | 3220 |
| 2660 | | - |
| 2661 | const int l = d->size; executed (the execution status of this line is deduced): const int l = d->size; | - |
| 2662 | if (from < 0) evaluated: from < 0| yes Evaluation Count:60 | yes Evaluation Count:23 |
| 23-60 |
| 2663 | from += l; executed: from += l;Execution Count:60 | 60 |
| 2664 | int delta = l-sl; executed (the execution status of this line is deduced): int delta = l-sl; | - |
| 2665 | if (from == l && sl == 0) evaluated: from == l| yes Evaluation Count:6 | yes Evaluation Count:77 |
evaluated: sl == 0| yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3-77 |
| 2666 | return from; executed: return from;Execution Count:3 | 3 |
| 2667 | if (from < 0 || from >= l || delta < 0) evaluated: from < 0| yes Evaluation Count:10 | yes Evaluation Count:70 |
evaluated: from >= l| yes Evaluation Count:6 | yes Evaluation Count:64 |
evaluated: delta < 0| yes Evaluation Count:9 | yes Evaluation Count:55 |
| 6-70 |
| 2668 | return -1; executed: return -1;Execution Count:25 | 25 |
| 2669 | if (from > delta) evaluated: from > delta| yes Evaluation Count:38 | yes Evaluation Count:17 |
| 17-38 |
| 2670 | from = delta; executed: from = delta;Execution Count:38 | 38 |
| 2671 | | - |
| 2672 | return lastIndexOfHelper(d->data(), from, str.d->data(), str.d->size, cs); executed: return lastIndexOfHelper(d->data(), from, str.d->data(), str.d->size, cs);Execution Count:55 | 55 |
| 2673 | } | - |
| 2674 | | - |
| 2675 | /*! | - |
| 2676 | \since 4.5 | - |
| 2677 | \overload lastIndexOf() | - |
| 2678 | | - |
| 2679 | Returns the index position of the last occurrence of the string \a | - |
| 2680 | str in this string, searching backward from index position \a | - |
| 2681 | from. If \a from is -1 (default), the search starts at the last | - |
| 2682 | character; if \a from is -2, at the next to last character and so | - |
| 2683 | on. Returns -1 if \a str is not found. | - |
| 2684 | | - |
| 2685 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2686 | sensitive; otherwise the search is case insensitive. | - |
| 2687 | | - |
| 2688 | Example: | - |
| 2689 | | - |
| 2690 | \snippet qstring/main.cpp 29 | - |
| 2691 | | - |
| 2692 | \sa indexOf(), contains(), count() | - |
| 2693 | */ | - |
| 2694 | int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - |
| 2695 | { | - |
| 2696 | const int sl = str.size(); executed (the execution status of this line is deduced): const int sl = str.size(); | - |
| 2697 | if (sl == 1) evaluated: sl == 1| yes Evaluation Count:4 | yes Evaluation Count:13 |
| 4-13 |
| 2698 | return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs); executed: return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);Execution Count:4 | 4 |
| 2699 | | - |
| 2700 | const int l = d->size; executed (the execution status of this line is deduced): const int l = d->size; | - |
| 2701 | if (from < 0) partially evaluated: from < 0| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 2702 | from += l; never executed: from += l; | 0 |
| 2703 | int delta = l-sl; executed (the execution status of this line is deduced): int delta = l-sl; | - |
| 2704 | if (from == l && sl == 0) partially evaluated: from == l| no Evaluation Count:0 | yes Evaluation Count:13 |
never evaluated: sl == 0 | 0-13 |
| 2705 | return from; never executed: return from; | 0 |
| 2706 | if (from < 0 || from >= l || delta < 0) partially evaluated: from < 0| no Evaluation Count:0 | yes Evaluation Count:13 |
partially evaluated: from >= l| no Evaluation Count:0 | yes Evaluation Count:13 |
partially evaluated: delta < 0| no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
| 2707 | return -1; never executed: return -1; | 0 |
| 2708 | if (from > delta) partially evaluated: from > delta| yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
| 2709 | from = delta; executed: from = delta;Execution Count:13 | 13 |
| 2710 | | - |
| 2711 | QVarLengthArray<ushort> s(sl); executed (the execution status of this line is deduced): QVarLengthArray<ushort> s(sl); | - |
| 2712 | for (int i = 0; i < sl; ++i) evaluated: i < sl| yes Evaluation Count:39 | yes Evaluation Count:13 |
| 13-39 |
| 2713 | s[i] = str.latin1()[i]; executed: s[i] = str.latin1()[i];Execution Count:39 | 39 |
| 2714 | | - |
| 2715 | return lastIndexOfHelper(d->data(), from, s.data(), sl, cs); executed: return lastIndexOfHelper(d->data(), from, s.data(), sl, cs);Execution Count:13 | 13 |
| 2716 | } | - |
| 2717 | | - |
| 2718 | /*! | - |
| 2719 | \overload lastIndexOf() | - |
| 2720 | | - |
| 2721 | Returns the index position of the last occurrence of the character | - |
| 2722 | \a ch, searching backward from position \a from. | - |
| 2723 | */ | - |
| 2724 | int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - |
| 2725 | { | - |
| 2726 | return qt_last_index_of(unicode(), size(), ch, from, cs); executed: return qt_last_index_of(unicode(), size(), ch, from, cs);Execution Count:26094 | 26094 |
| 2727 | } | - |
| 2728 | | - |
| 2729 | /*! | - |
| 2730 | \since 4.8 | - |
| 2731 | \overload lastIndexOf() | - |
| 2732 | | - |
| 2733 | Returns the index position of the last occurrence of the string | - |
| 2734 | reference \a str in this string, searching backward from index | - |
| 2735 | position \a from. If \a from is -1 (default), the search starts at | - |
| 2736 | the last character; if \a from is -2, at the next to last character | - |
| 2737 | and so on. Returns -1 if \a str is not found. | - |
| 2738 | | - |
| 2739 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 2740 | sensitive; otherwise the search is case insensitive. | - |
| 2741 | | - |
| 2742 | \sa indexOf(), contains(), count() | - |
| 2743 | */ | - |
| 2744 | int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - |
| 2745 | { | - |
| 2746 | const int sl = str.size(); executed (the execution status of this line is deduced): const int sl = str.size(); | - |
| 2747 | if (sl == 1) evaluated: sl == 1| yes Evaluation Count:86 | yes Evaluation Count:62 |
| 62-86 |
| 2748 | return lastIndexOf(str.at(0), from, cs); executed: return lastIndexOf(str.at(0), from, cs);Execution Count:86 | 86 |
| 2749 | | - |
| 2750 | const int l = d->size; executed (the execution status of this line is deduced): const int l = d->size; | - |
| 2751 | if (from < 0) evaluated: from < 0| yes Evaluation Count:48 | yes Evaluation Count:14 |
| 14-48 |
| 2752 | from += l; executed: from += l;Execution Count:48 | 48 |
| 2753 | int delta = l - sl; executed (the execution status of this line is deduced): int delta = l - sl; | - |
| 2754 | if (from == l && sl == 0) evaluated: from == l| yes Evaluation Count:4 | yes Evaluation Count:58 |
evaluated: sl == 0| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2-58 |
| 2755 | return from; executed: return from;Execution Count:2 | 2 |
| 2756 | if (from < 0 || from >= l || delta < 0) evaluated: from < 0| yes Evaluation Count:8 | yes Evaluation Count:52 |
evaluated: from >= l| yes Evaluation Count:4 | yes Evaluation Count:48 |
evaluated: delta < 0| yes Evaluation Count:8 | yes Evaluation Count:40 |
| 4-52 |
| 2757 | return -1; executed: return -1;Execution Count:20 | 20 |
| 2758 | if (from > delta) evaluated: from > delta| yes Evaluation Count:30 | yes Evaluation Count:10 |
| 10-30 |
| 2759 | from = delta; executed: from = delta;Execution Count:30 | 30 |
| 2760 | | - |
| 2761 | return lastIndexOfHelper(d->data(), from, reinterpret_cast<const ushort*>(str.unicode()), executed: return lastIndexOfHelper(d->data(), from, reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);Execution Count:40 | 40 |
| 2762 | str.size(), cs); executed: return lastIndexOfHelper(d->data(), from, reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);Execution Count:40 | 40 |
| 2763 | } | - |
| 2764 | | - |
| 2765 | #ifndef QT_NO_REGEXP | - |
| 2766 | struct QStringCapture | - |
| 2767 | { | - |
| 2768 | int pos; | - |
| 2769 | int len; | - |
| 2770 | int no; | - |
| 2771 | }; | - |
| 2772 | | - |
| 2773 | /*! | - |
| 2774 | \overload replace() | - |
| 2775 | | - |
| 2776 | Replaces every occurrence of the regular expression \a rx in the | - |
| 2777 | string with \a after. Returns a reference to the string. For | - |
| 2778 | example: | - |
| 2779 | | - |
| 2780 | \snippet qstring/main.cpp 42 | - |
| 2781 | | - |
| 2782 | For regular expressions containing \l{capturing parentheses}, | - |
| 2783 | occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced | - |
| 2784 | with \a{rx}.cap(1), cap(2), ... | - |
| 2785 | | - |
| 2786 | \snippet qstring/main.cpp 43 | - |
| 2787 | | - |
| 2788 | \sa indexOf(), lastIndexOf(), remove(), QRegExp::cap() | - |
| 2789 | */ | - |
| 2790 | QString& QString::replace(const QRegExp &rx, const QString &after) | - |
| 2791 | { | - |
| 2792 | QRegExp rx2(rx); executed (the execution status of this line is deduced): QRegExp rx2(rx); | - |
| 2793 | | - |
| 2794 | if (isEmpty() && rx2.indexIn(*this) == -1) evaluated: isEmpty()| yes Evaluation Count:51964 | yes Evaluation Count:83451 |
evaluated: rx2.indexIn(*this) == -1| yes Evaluation Count:51946 | yes Evaluation Count:18 |
| 18-83451 |
| 2795 | return *this; executed: return *this;Execution Count:51946 | 51946 |
| 2796 | | - |
| 2797 | reallocData(uint(d->size) + 1u); executed (the execution status of this line is deduced): reallocData(uint(d->size) + 1u); | - |
| 2798 | | - |
| 2799 | int index = 0; executed (the execution status of this line is deduced): int index = 0; | - |
| 2800 | int numCaptures = rx2.captureCount(); executed (the execution status of this line is deduced): int numCaptures = rx2.captureCount(); | - |
| 2801 | int al = after.length(); executed (the execution status of this line is deduced): int al = after.length(); | - |
| 2802 | QRegExp::CaretMode caretMode = QRegExp::CaretAtZero; executed (the execution status of this line is deduced): QRegExp::CaretMode caretMode = QRegExp::CaretAtZero; | - |
| 2803 | | - |
| 2804 | if (numCaptures > 0) { evaluated: numCaptures > 0| yes Evaluation Count:19 | yes Evaluation Count:83450 |
| 19-83450 |
| 2805 | const QChar *uc = after.unicode(); executed (the execution status of this line is deduced): const QChar *uc = after.unicode(); | - |
| 2806 | int numBackRefs = 0; executed (the execution status of this line is deduced): int numBackRefs = 0; | - |
| 2807 | | - |
| 2808 | for (int i = 0; i < al - 1; i++) { evaluated: i < al - 1| yes Evaluation Count:141 | yes Evaluation Count:19 |
| 19-141 |
| 2809 | if (uc[i] == QLatin1Char('\\')) { evaluated: uc[i] == QLatin1Char('\\')| yes Evaluation Count:56 | yes Evaluation Count:85 |
| 56-85 |
| 2810 | int no = uc[i + 1].digitValue(); executed (the execution status of this line is deduced): int no = uc[i + 1].digitValue(); | - |
| 2811 | if (no > 0 && no <= numCaptures) evaluated: no > 0| yes Evaluation Count:52 | yes Evaluation Count:4 |
evaluated: no <= numCaptures| yes Evaluation Count:50 | yes Evaluation Count:2 |
| 2-52 |
| 2812 | numBackRefs++; executed: numBackRefs++;Execution Count:50 | 50 |
| 2813 | } executed: }Execution Count:56 | 56 |
| 2814 | } executed: }Execution Count:141 | 141 |
| 2815 | | - |
| 2816 | /* | - |
| 2817 | This is the harder case where we have back-references. | - |
| 2818 | */ | - |
| 2819 | if (numBackRefs > 0) { evaluated: numBackRefs > 0| yes Evaluation Count:13 | yes Evaluation Count:6 |
| 6-13 |
| 2820 | QVarLengthArray<QStringCapture, 16> captures(numBackRefs); executed (the execution status of this line is deduced): QVarLengthArray<QStringCapture, 16> captures(numBackRefs); | - |
| 2821 | int j = 0; executed (the execution status of this line is deduced): int j = 0; | - |
| 2822 | | - |
| 2823 | for (int i = 0; i < al - 1; i++) { evaluated: i < al - 1| yes Evaluation Count:132 | yes Evaluation Count:13 |
| 13-132 |
| 2824 | if (uc[i] == QLatin1Char('\\')) { evaluated: uc[i] == QLatin1Char('\\')| yes Evaluation Count:52 | yes Evaluation Count:80 |
| 52-80 |
| 2825 | int no = uc[i + 1].digitValue(); executed (the execution status of this line is deduced): int no = uc[i + 1].digitValue(); | - |
| 2826 | if (no > 0 && no <= numCaptures) { evaluated: no > 0| yes Evaluation Count:51 | yes Evaluation Count:1 |
evaluated: no <= numCaptures| yes Evaluation Count:50 | yes Evaluation Count:1 |
| 1-51 |
| 2827 | QStringCapture capture; executed (the execution status of this line is deduced): QStringCapture capture; | - |
| 2828 | capture.pos = i; executed (the execution status of this line is deduced): capture.pos = i; | - |
| 2829 | capture.len = 2; executed (the execution status of this line is deduced): capture.len = 2; | - |
| 2830 | | - |
| 2831 | if (i < al - 2) { evaluated: i < al - 2| yes Evaluation Count:44 | yes Evaluation Count:6 |
| 6-44 |
| 2832 | int secondDigit = uc[i + 2].digitValue(); executed (the execution status of this line is deduced): int secondDigit = uc[i + 2].digitValue(); | - |
| 2833 | if (secondDigit != -1 && ((no * 10) + secondDigit) <= numCaptures) { evaluated: secondDigit != -1| yes Evaluation Count:28 | yes Evaluation Count:16 |
evaluated: ((no * 10) + secondDigit) <= numCaptures| yes Evaluation Count:6 | yes Evaluation Count:22 |
| 6-28 |
| 2834 | no = (no * 10) + secondDigit; executed (the execution status of this line is deduced): no = (no * 10) + secondDigit; | - |
| 2835 | ++capture.len; executed (the execution status of this line is deduced): ++capture.len; | - |
| 2836 | } executed: }Execution Count:6 | 6 |
| 2837 | } executed: }Execution Count:44 | 44 |
| 2838 | | - |
| 2839 | capture.no = no; executed (the execution status of this line is deduced): capture.no = no; | - |
| 2840 | captures[j++] = capture; executed (the execution status of this line is deduced): captures[j++] = capture; | - |
| 2841 | } executed: }Execution Count:50 | 50 |
| 2842 | } executed: }Execution Count:52 | 52 |
| 2843 | } executed: }Execution Count:132 | 132 |
| 2844 | | - |
| 2845 | while (index <= length()) { partially evaluated: index <= length()| yes Evaluation Count:35 | no Evaluation Count:0 |
| 0-35 |
| 2846 | index = rx2.indexIn(*this, index, caretMode); executed (the execution status of this line is deduced): index = rx2.indexIn(*this, index, caretMode); | - |
| 2847 | if (index == -1) evaluated: index == -1| yes Evaluation Count:13 | yes Evaluation Count:22 |
| 13-22 |
| 2848 | break; executed: break;Execution Count:13 | 13 |
| 2849 | | - |
| 2850 | QString after2(after); executed (the execution status of this line is deduced): QString after2(after); | - |
| 2851 | for (j = numBackRefs - 1; j >= 0; j--) { evaluated: j >= 0| yes Evaluation Count:58 | yes Evaluation Count:22 |
| 22-58 |
| 2852 | const QStringCapture &capture = captures[j]; executed (the execution status of this line is deduced): const QStringCapture &capture = captures[j]; | - |
| 2853 | after2.replace(capture.pos, capture.len, rx2.cap(capture.no)); executed (the execution status of this line is deduced): after2.replace(capture.pos, capture.len, rx2.cap(capture.no)); | - |
| 2854 | } executed: }Execution Count:58 | 58 |
| 2855 | | - |
| 2856 | replace(index, rx2.matchedLength(), after2); executed (the execution status of this line is deduced): replace(index, rx2.matchedLength(), after2); | - |
| 2857 | index += after2.length(); executed (the execution status of this line is deduced): index += after2.length(); | - |
| 2858 | | - |
| 2859 | // avoid infinite loop on 0-length matches (e.g., QRegExp("[a-z]*")) | - |
| 2860 | if (rx2.matchedLength() == 0) partially evaluated: rx2.matchedLength() == 0| no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
| 2861 | ++index; | 0 |
| 2862 | | - |
| 2863 | caretMode = QRegExp::CaretWontMatch; executed (the execution status of this line is deduced): caretMode = QRegExp::CaretWontMatch; | - |
| 2864 | } executed: }Execution Count:22 | 22 |
| 2865 | return *this; executed: return *this;Execution Count:13 | 13 |
| 2866 | } | - |
| 2867 | } executed: }Execution Count:6 | 6 |
| 2868 | | - |
| 2869 | /* | - |
| 2870 | This is the simple and optimized case where we don't have | - |
| 2871 | back-references. | - |
| 2872 | */ | - |
| 2873 | while (index != -1) { evaluated: index != -1| yes Evaluation Count:83456 | yes Evaluation Count:1101 |
| 1101-83456 |
| 2874 | struct { executed (the execution status of this line is deduced): struct { | - |
| 2875 | int pos; executed (the execution status of this line is deduced): int pos; | - |
| 2876 | int length; executed (the execution status of this line is deduced): int length; | - |
| 2877 | } replacements[2048]; executed (the execution status of this line is deduced): } replacements[2048]; | - |
| 2878 | | - |
| 2879 | int pos = 0; executed (the execution status of this line is deduced): int pos = 0; | - |
| 2880 | int adjust = 0; executed (the execution status of this line is deduced): int adjust = 0; | - |
| 2881 | while (pos < 2047) { partially evaluated: pos < 2047| yes Evaluation Count:84789 | no Evaluation Count:0 |
| 0-84789 |
| 2882 | index = rx2.indexIn(*this, index, caretMode); executed (the execution status of this line is deduced): index = rx2.indexIn(*this, index, caretMode); | - |
| 2883 | if (index == -1) evaluated: index == -1| yes Evaluation Count:83456 | yes Evaluation Count:1333 |
| 1333-83456 |
| 2884 | break; executed: break;Execution Count:83456 | 83456 |
| 2885 | int ml = rx2.matchedLength(); executed (the execution status of this line is deduced): int ml = rx2.matchedLength(); | - |
| 2886 | replacements[pos].pos = index; executed (the execution status of this line is deduced): replacements[pos].pos = index; | - |
| 2887 | replacements[pos++].length = ml; executed (the execution status of this line is deduced): replacements[pos++].length = ml; | - |
| 2888 | index += ml; executed (the execution status of this line is deduced): index += ml; | - |
| 2889 | adjust += al - ml; executed (the execution status of this line is deduced): adjust += al - ml; | - |
| 2890 | // avoid infinite loop | - |
| 2891 | if (!ml) evaluated: !ml| yes Evaluation Count:46 | yes Evaluation Count:1287 |
| 46-1287 |
| 2892 | index++; executed: index++;Execution Count:46 | 46 |
| 2893 | } executed: }Execution Count:1333 | 1333 |
| 2894 | if (!pos) evaluated: !pos| yes Evaluation Count:82355 | yes Evaluation Count:1101 |
| 1101-82355 |
| 2895 | break; executed: break;Execution Count:82355 | 82355 |
| 2896 | replacements[pos].pos = d->size; executed (the execution status of this line is deduced): replacements[pos].pos = d->size; | - |
| 2897 | int newlen = d->size + adjust; executed (the execution status of this line is deduced): int newlen = d->size + adjust; | - |
| 2898 | | - |
| 2899 | // to continue searching at the right position after we did | - |
| 2900 | // the first round of replacements | - |
| 2901 | if (index != -1) partially evaluated: index != -1| no Evaluation Count:0 | yes Evaluation Count:1101 |
| 0-1101 |
| 2902 | index += adjust; never executed: index += adjust; | 0 |
| 2903 | QString newstring; executed (the execution status of this line is deduced): QString newstring; | - |
| 2904 | newstring.reserve(newlen + 1); executed (the execution status of this line is deduced): newstring.reserve(newlen + 1); | - |
| 2905 | QChar *newuc = newstring.data(); executed (the execution status of this line is deduced): QChar *newuc = newstring.data(); | - |
| 2906 | QChar *uc = newuc; executed (the execution status of this line is deduced): QChar *uc = newuc; | - |
| 2907 | int copystart = 0; executed (the execution status of this line is deduced): int copystart = 0; | - |
| 2908 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
| 2909 | while (i < pos) { evaluated: i < pos| yes Evaluation Count:1333 | yes Evaluation Count:1101 |
| 1101-1333 |
| 2910 | int copyend = replacements[i].pos; executed (the execution status of this line is deduced): int copyend = replacements[i].pos; | - |
| 2911 | int size = copyend - copystart; executed (the execution status of this line is deduced): int size = copyend - copystart; | - |
| 2912 | memcpy(uc, d->data() + copystart, size * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(uc, d->data() + copystart, size * sizeof(QChar)); | - |
| 2913 | uc += size; executed (the execution status of this line is deduced): uc += size; | - |
| 2914 | memcpy(uc, after.d->data(), al * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(uc, after.d->data(), al * sizeof(QChar)); | - |
| 2915 | uc += al; executed (the execution status of this line is deduced): uc += al; | - |
| 2916 | copystart = copyend + replacements[i].length; executed (the execution status of this line is deduced): copystart = copyend + replacements[i].length; | - |
| 2917 | i++; executed (the execution status of this line is deduced): i++; | - |
| 2918 | } executed: }Execution Count:1333 | 1333 |
| 2919 | memcpy(uc, d->data() + copystart, (d->size - copystart) * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(uc, d->data() + copystart, (d->size - copystart) * sizeof(QChar)); | - |
| 2920 | newstring.resize(newlen); executed (the execution status of this line is deduced): newstring.resize(newlen); | - |
| 2921 | *this = newstring; executed (the execution status of this line is deduced): *this = newstring; | - |
| 2922 | caretMode = QRegExp::CaretWontMatch; executed (the execution status of this line is deduced): caretMode = QRegExp::CaretWontMatch; | - |
| 2923 | } executed: }Execution Count:1101 | 1101 |
| 2924 | return *this; executed: return *this;Execution Count:83456 | 83456 |
| 2925 | } | - |
| 2926 | #endif | - |
| 2927 | | - |
| 2928 | #ifndef QT_NO_REGEXP | - |
| 2929 | #ifndef QT_BOOTSTRAPPED | - |
| 2930 | /*! | - |
| 2931 | \overload replace() | - |
| 2932 | \since 5.0 | - |
| 2933 | | - |
| 2934 | Replaces every occurrence of the regular expression \a re in the | - |
| 2935 | string with \a after. Returns a reference to the string. For | - |
| 2936 | example: | - |
| 2937 | | - |
| 2938 | \snippet qstring/main.cpp 87 | - |
| 2939 | | - |
| 2940 | For regular expressions containing capturing groups, | - |
| 2941 | occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced | - |
| 2942 | with the string captured by the corresponding capturing group. | - |
| 2943 | | - |
| 2944 | \snippet qstring/main.cpp 88 | - |
| 2945 | | - |
| 2946 | \sa indexOf(), lastIndexOf(), remove(), QRegularExpression, QRegularExpressionMatch | - |
| 2947 | */ | - |
| 2948 | QString &QString::replace(const QRegularExpression &re, const QString &after) | - |
| 2949 | { | - |
| 2950 | if (!re.isValid()) { evaluated: !re.isValid()| yes Evaluation Count:2 | yes Evaluation Count:33 |
| 2-33 |
| 2951 | qWarning("QString::replace: invalid QRegularExpression object"); executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 2951, __PRETTY_FUNCTION__).warning("QString::replace: invalid QRegularExpression object"); | - |
| 2952 | return *this; executed: return *this;Execution Count:2 | 2 |
| 2953 | } | - |
| 2954 | | - |
| 2955 | const QString copy(*this); executed (the execution status of this line is deduced): const QString copy(*this); | - |
| 2956 | QRegularExpressionMatchIterator iterator = re.globalMatch(copy); executed (the execution status of this line is deduced): QRegularExpressionMatchIterator iterator = re.globalMatch(copy); | - |
| 2957 | if (!iterator.hasNext()) // no matches at all evaluated: !iterator.hasNext()| yes Evaluation Count:12 | yes Evaluation Count:21 |
| 12-21 |
| 2958 | return *this; executed: return *this;Execution Count:12 | 12 |
| 2959 | | - |
| 2960 | reallocData(uint(d->size) + 1u); executed (the execution status of this line is deduced): reallocData(uint(d->size) + 1u); | - |
| 2961 | | - |
| 2962 | int numCaptures = re.captureCount(); executed (the execution status of this line is deduced): int numCaptures = re.captureCount(); | - |
| 2963 | | - |
| 2964 | // 1. build the backreferences vector, holding where the backreferences | - |
| 2965 | // are in the replacement string | - |
| 2966 | QVector<QStringCapture> backReferences; executed (the execution status of this line is deduced): QVector<QStringCapture> backReferences; | - |
| 2967 | const int al = after.length(); executed (the execution status of this line is deduced): const int al = after.length(); | - |
| 2968 | const QChar *ac = after.unicode(); executed (the execution status of this line is deduced): const QChar *ac = after.unicode(); | - |
| 2969 | | - |
| 2970 | for (int i = 0; i < al - 1; i++) { evaluated: i < al - 1| yes Evaluation Count:138 | yes Evaluation Count:21 |
| 21-138 |
| 2971 | if (ac[i] == QLatin1Char('\\')) { evaluated: ac[i] == QLatin1Char('\\')| yes Evaluation Count:55 | yes Evaluation Count:83 |
| 55-83 |
| 2972 | int no = ac[i + 1].digitValue(); executed (the execution status of this line is deduced): int no = ac[i + 1].digitValue(); | - |
| 2973 | if (no > 0 && no <= numCaptures) { evaluated: no > 0| yes Evaluation Count:51 | yes Evaluation Count:4 |
evaluated: no <= numCaptures| yes Evaluation Count:48 | yes Evaluation Count:3 |
| 3-51 |
| 2974 | QStringCapture backReference; executed (the execution status of this line is deduced): QStringCapture backReference; | - |
| 2975 | backReference.pos = i; executed (the execution status of this line is deduced): backReference.pos = i; | - |
| 2976 | backReference.len = 2; executed (the execution status of this line is deduced): backReference.len = 2; | - |
| 2977 | | - |
| 2978 | if (i < al - 2) { evaluated: i < al - 2| yes Evaluation Count:43 | yes Evaluation Count:5 |
| 5-43 |
| 2979 | int secondDigit = ac[i + 2].digitValue(); executed (the execution status of this line is deduced): int secondDigit = ac[i + 2].digitValue(); | - |
| 2980 | if (secondDigit != -1 && ((no * 10) + secondDigit) <= numCaptures) { evaluated: secondDigit != -1| yes Evaluation Count:28 | yes Evaluation Count:15 |
evaluated: ((no * 10) + secondDigit) <= numCaptures| yes Evaluation Count:6 | yes Evaluation Count:22 |
| 6-28 |
| 2981 | no = (no * 10) + secondDigit; executed (the execution status of this line is deduced): no = (no * 10) + secondDigit; | - |
| 2982 | ++backReference.len; executed (the execution status of this line is deduced): ++backReference.len; | - |
| 2983 | } executed: }Execution Count:6 | 6 |
| 2984 | } executed: }Execution Count:43 | 43 |
| 2985 | | - |
| 2986 | backReference.no = no; executed (the execution status of this line is deduced): backReference.no = no; | - |
| 2987 | backReferences.append(backReference); executed (the execution status of this line is deduced): backReferences.append(backReference); | - |
| 2988 | } executed: }Execution Count:48 | 48 |
| 2989 | } executed: }Execution Count:55 | 55 |
| 2990 | } executed: }Execution Count:138 | 138 |
| 2991 | | - |
| 2992 | // 2. iterate on the matches. For every match, copy in chunks | - |
| 2993 | // - the part before the match | - |
| 2994 | // - the after string, with the proper replacements for the backreferences | - |
| 2995 | | - |
| 2996 | int newLength = 0; // length of the new string, with all the replacements executed (the execution status of this line is deduced): int newLength = 0; | - |
| 2997 | int lastEnd = 0; executed (the execution status of this line is deduced): int lastEnd = 0; | - |
| 2998 | QVector<QStringRef> chunks; executed (the execution status of this line is deduced): QVector<QStringRef> chunks; | - |
| 2999 | while (iterator.hasNext()) { evaluated: iterator.hasNext()| yes Evaluation Count:38 | yes Evaluation Count:21 |
| 21-38 |
| 3000 | QRegularExpressionMatch match = iterator.next(); executed (the execution status of this line is deduced): QRegularExpressionMatch match = iterator.next(); | - |
| 3001 | int len; executed (the execution status of this line is deduced): int len; | - |
| 3002 | // add the part before the match | - |
| 3003 | len = match.capturedStart() - lastEnd; executed (the execution status of this line is deduced): len = match.capturedStart() - lastEnd; | - |
| 3004 | if (len > 0) { evaluated: len > 0| yes Evaluation Count:4 | yes Evaluation Count:34 |
| 4-34 |
| 3005 | chunks << copy.midRef(lastEnd, len); executed (the execution status of this line is deduced): chunks << copy.midRef(lastEnd, len); | - |
| 3006 | newLength += len; executed (the execution status of this line is deduced): newLength += len; | - |
| 3007 | } executed: }Execution Count:4 | 4 |
| 3008 | | - |
| 3009 | lastEnd = 0; executed (the execution status of this line is deduced): lastEnd = 0; | - |
| 3010 | // add the after string, with replacements for the backreferences | - |
| 3011 | foreach (const QStringCapture &backReference, backReferences) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(backReferences)> _container_(backReferences); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QStringCapture &backReference = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 3012 | // part of "after" before the backreference | - |
| 3013 | len = backReference.pos - lastEnd; executed (the execution status of this line is deduced): len = backReference.pos - lastEnd; | - |
| 3014 | if (len > 0) { evaluated: len > 0| yes Evaluation Count:28 | yes Evaluation Count:30 |
| 28-30 |
| 3015 | chunks << after.midRef(lastEnd, len); executed (the execution status of this line is deduced): chunks << after.midRef(lastEnd, len); | - |
| 3016 | newLength += len; executed (the execution status of this line is deduced): newLength += len; | - |
| 3017 | } executed: }Execution Count:28 | 28 |
| 3018 | | - |
| 3019 | // backreference itself | - |
| 3020 | len = match.capturedLength(backReference.no); executed (the execution status of this line is deduced): len = match.capturedLength(backReference.no); | - |
| 3021 | if (len > 0) { evaluated: len > 0| yes Evaluation Count:57 | yes Evaluation Count:1 |
| 1-57 |
| 3022 | chunks << copy.midRef(match.capturedStart(backReference.no), len); executed (the execution status of this line is deduced): chunks << copy.midRef(match.capturedStart(backReference.no), len); | - |
| 3023 | newLength += len; executed (the execution status of this line is deduced): newLength += len; | - |
| 3024 | } executed: }Execution Count:57 | 57 |
| 3025 | | - |
| 3026 | lastEnd = backReference.pos + backReference.len; executed (the execution status of this line is deduced): lastEnd = backReference.pos + backReference.len; | - |
| 3027 | } executed: }Execution Count:58 | 58 |
| 3028 | | - |
| 3029 | // add the last part of the after string | - |
| 3030 | len = after.length() - lastEnd; executed (the execution status of this line is deduced): len = after.length() - lastEnd; | - |
| 3031 | if (len > 0) { evaluated: len > 0| yes Evaluation Count:27 | yes Evaluation Count:11 |
| 11-27 |
| 3032 | chunks << after.midRef(lastEnd, len); executed (the execution status of this line is deduced): chunks << after.midRef(lastEnd, len); | - |
| 3033 | newLength += len; executed (the execution status of this line is deduced): newLength += len; | - |
| 3034 | } executed: }Execution Count:27 | 27 |
| 3035 | | - |
| 3036 | lastEnd = match.capturedEnd(); executed (the execution status of this line is deduced): lastEnd = match.capturedEnd(); | - |
| 3037 | } executed: }Execution Count:38 | 38 |
| 3038 | | - |
| 3039 | // 3. trailing string after the last match | - |
| 3040 | if (copy.length() > lastEnd) { evaluated: copy.length() > lastEnd| yes Evaluation Count:7 | yes Evaluation Count:14 |
| 7-14 |
| 3041 | chunks << copy.midRef(lastEnd); executed (the execution status of this line is deduced): chunks << copy.midRef(lastEnd); | - |
| 3042 | newLength += copy.length() - lastEnd; executed (the execution status of this line is deduced): newLength += copy.length() - lastEnd; | - |
| 3043 | } executed: }Execution Count:7 | 7 |
| 3044 | | - |
| 3045 | // 4. assemble the chunks together | - |
| 3046 | resize(newLength); executed (the execution status of this line is deduced): resize(newLength); | - |
| 3047 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
| 3048 | QChar *uc = data(); executed (the execution status of this line is deduced): QChar *uc = data(); | - |
| 3049 | foreach (const QStringRef &chunk, chunks) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(chunks)> _container_(chunks); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QStringRef &chunk = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 3050 | int len = chunk.length(); executed (the execution status of this line is deduced): int len = chunk.length(); | - |
| 3051 | memcpy(uc + i, chunk.unicode(), len * sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(uc + i, chunk.unicode(), len * sizeof(QChar)); | - |
| 3052 | i += len; executed (the execution status of this line is deduced): i += len; | - |
| 3053 | } executed: }Execution Count:123 | 123 |
| 3054 | | - |
| 3055 | return *this; executed: return *this;Execution Count:21 | 21 |
| 3056 | } | - |
| 3057 | #endif // QT_BOOTSTRAPPED | - |
| 3058 | #endif // QT_NO_REGEXP | - |
| 3059 | | - |
| 3060 | /*! | - |
| 3061 | Returns the number of (potentially overlapping) occurrences of | - |
| 3062 | the string \a str in this string. | - |
| 3063 | | - |
| 3064 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 3065 | case sensitive; otherwise the search is case insensitive. | - |
| 3066 | | - |
| 3067 | \sa contains(), indexOf() | - |
| 3068 | */ | - |
| 3069 | | - |
| 3070 | int QString::count(const QString &str, Qt::CaseSensitivity cs) const | - |
| 3071 | { | - |
| 3072 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); executed: return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);Execution Count:12 | 12 |
| 3073 | } | - |
| 3074 | | - |
| 3075 | /*! | - |
| 3076 | \overload count() | - |
| 3077 | | - |
| 3078 | Returns the number of occurrences of character \a ch in the string. | - |
| 3079 | */ | - |
| 3080 | | - |
| 3081 | int QString::count(QChar ch, Qt::CaseSensitivity cs) const | - |
| 3082 | { | - |
| 3083 | return qt_string_count(unicode(), size(), ch, cs); executed: return qt_string_count(unicode(), size(), ch, cs);Execution Count:3589 | 3589 |
| 3084 | } | - |
| 3085 | | - |
| 3086 | /*! | - |
| 3087 | \since 4.8 | - |
| 3088 | \overload count() | - |
| 3089 | Returns the number of (potentially overlapping) occurrences of the | - |
| 3090 | string reference \a str in this string. | - |
| 3091 | | - |
| 3092 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 3093 | case sensitive; otherwise the search is case insensitive. | - |
| 3094 | | - |
| 3095 | \sa contains(), indexOf() | - |
| 3096 | */ | - |
| 3097 | int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const | - |
| 3098 | { | - |
| 3099 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); executed: return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);Execution Count:4 | 4 |
| 3100 | } | - |
| 3101 | | - |
| 3102 | | - |
| 3103 | /*! \fn bool QString::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 3104 | | - |
| 3105 | Returns true if this string contains an occurrence of the string | - |
| 3106 | \a str; otherwise returns false. | - |
| 3107 | | - |
| 3108 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 3109 | case sensitive; otherwise the search is case insensitive. | - |
| 3110 | | - |
| 3111 | Example: | - |
| 3112 | \snippet qstring/main.cpp 17 | - |
| 3113 | | - |
| 3114 | \sa indexOf(), count() | - |
| 3115 | */ | - |
| 3116 | | - |
| 3117 | /*! \fn bool QString::contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 3118 | | - |
| 3119 | \overload contains() | - |
| 3120 | | - |
| 3121 | Returns true if this string contains an occurrence of the | - |
| 3122 | character \a ch; otherwise returns false. | - |
| 3123 | */ | - |
| 3124 | | - |
| 3125 | /*! \fn bool QString::contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 3126 | \since 4.8 | - |
| 3127 | | - |
| 3128 | Returns true if this string contains an occurrence of the string | - |
| 3129 | reference \a str; otherwise returns false. | - |
| 3130 | | - |
| 3131 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 3132 | case sensitive; otherwise the search is case insensitive. | - |
| 3133 | | - |
| 3134 | \sa indexOf(), count() | - |
| 3135 | */ | - |
| 3136 | | - |
| 3137 | /*! \fn bool QString::contains(const QRegExp &rx) const | - |
| 3138 | | - |
| 3139 | \overload contains() | - |
| 3140 | | - |
| 3141 | Returns true if the regular expression \a rx matches somewhere in | - |
| 3142 | this string; otherwise returns false. | - |
| 3143 | */ | - |
| 3144 | | - |
| 3145 | /*! \fn bool QString::contains(QRegExp &rx) const | - |
| 3146 | \overload contains() | - |
| 3147 | \since 4.5 | - |
| 3148 | | - |
| 3149 | Returns true if the regular expression \a rx matches somewhere in | - |
| 3150 | this string; otherwise returns false. | - |
| 3151 | | - |
| 3152 | If there is a match, the \a rx regular expression will contain the | - |
| 3153 | matched captures (see QRegExp::matchedLength, QRegExp::cap). | - |
| 3154 | */ | - |
| 3155 | | - |
| 3156 | #ifndef QT_NO_REGEXP | - |
| 3157 | /*! | - |
| 3158 | \overload indexOf() | - |
| 3159 | | - |
| 3160 | Returns the index position of the first match of the regular | - |
| 3161 | expression \a rx in the string, searching forward from index | - |
| 3162 | position \a from. Returns -1 if \a rx didn't match anywhere. | - |
| 3163 | | - |
| 3164 | Example: | - |
| 3165 | | - |
| 3166 | \snippet qstring/main.cpp 25 | - |
| 3167 | */ | - |
| 3168 | int QString::indexOf(const QRegExp& rx, int from) const | - |
| 3169 | { | - |
| 3170 | QRegExp rx2(rx); executed (the execution status of this line is deduced): QRegExp rx2(rx); | - |
| 3171 | return rx2.indexIn(*this, from); executed: return rx2.indexIn(*this, from);Execution Count:20294 | 20294 |
| 3172 | } | - |
| 3173 | | - |
| 3174 | /*! | - |
| 3175 | \overload indexOf() | - |
| 3176 | \since 4.5 | - |
| 3177 | | - |
| 3178 | Returns the index position of the first match of the regular | - |
| 3179 | expression \a rx in the string, searching forward from index | - |
| 3180 | position \a from. Returns -1 if \a rx didn't match anywhere. | - |
| 3181 | | - |
| 3182 | If there is a match, the \a rx regular expression will contain the | - |
| 3183 | matched captures (see QRegExp::matchedLength, QRegExp::cap). | - |
| 3184 | | - |
| 3185 | Example: | - |
| 3186 | | - |
| 3187 | \snippet qstring/main.cpp 25 | - |
| 3188 | */ | - |
| 3189 | int QString::indexOf(QRegExp& rx, int from) const | - |
| 3190 | { | - |
| 3191 | return rx.indexIn(*this, from); executed: return rx.indexIn(*this, from);Execution Count:372 | 372 |
| 3192 | } | - |
| 3193 | | - |
| 3194 | /*! | - |
| 3195 | \overload lastIndexOf() | - |
| 3196 | | - |
| 3197 | Returns the index position of the last match of the regular | - |
| 3198 | expression \a rx in the string, searching backward from index | - |
| 3199 | position \a from. Returns -1 if \a rx didn't match anywhere. | - |
| 3200 | | - |
| 3201 | Example: | - |
| 3202 | | - |
| 3203 | \snippet qstring/main.cpp 30 | - |
| 3204 | */ | - |
| 3205 | int QString::lastIndexOf(const QRegExp& rx, int from) const | - |
| 3206 | { | - |
| 3207 | QRegExp rx2(rx); executed (the execution status of this line is deduced): QRegExp rx2(rx); | - |
| 3208 | return rx2.lastIndexIn(*this, from); executed: return rx2.lastIndexIn(*this, from);Execution Count:36 | 36 |
| 3209 | } | - |
| 3210 | | - |
| 3211 | /*! | - |
| 3212 | \overload lastIndexOf() | - |
| 3213 | \since 4.5 | - |
| 3214 | | - |
| 3215 | Returns the index position of the last match of the regular | - |
| 3216 | expression \a rx in the string, searching backward from index | - |
| 3217 | position \a from. Returns -1 if \a rx didn't match anywhere. | - |
| 3218 | | - |
| 3219 | If there is a match, the \a rx regular expression will contain the | - |
| 3220 | matched captures (see QRegExp::matchedLength, QRegExp::cap). | - |
| 3221 | | - |
| 3222 | Example: | - |
| 3223 | | - |
| 3224 | \snippet qstring/main.cpp 30 | - |
| 3225 | */ | - |
| 3226 | int QString::lastIndexOf(QRegExp& rx, int from) const | - |
| 3227 | { | - |
| 3228 | return rx.lastIndexIn(*this, from); executed: return rx.lastIndexIn(*this, from);Execution Count:36 | 36 |
| 3229 | } | - |
| 3230 | | - |
| 3231 | /*! | - |
| 3232 | \overload count() | - |
| 3233 | | - |
| 3234 | Returns the number of times the regular expression \a rx matches | - |
| 3235 | in the string. | - |
| 3236 | | - |
| 3237 | This function counts overlapping matches, so in the example | - |
| 3238 | below, there are four instances of "ana" or "ama": | - |
| 3239 | | - |
| 3240 | \snippet qstring/main.cpp 18 | - |
| 3241 | | - |
| 3242 | */ | - |
| 3243 | int QString::count(const QRegExp& rx) const | - |
| 3244 | { | - |
| 3245 | QRegExp rx2(rx); executed (the execution status of this line is deduced): QRegExp rx2(rx); | - |
| 3246 | int count = 0; executed (the execution status of this line is deduced): int count = 0; | - |
| 3247 | int index = -1; executed (the execution status of this line is deduced): int index = -1; | - |
| 3248 | int len = length(); executed (the execution status of this line is deduced): int len = length(); | - |
| 3249 | while (index < len - 1) { // count overlapping matches partially evaluated: index < len - 1| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 3250 | index = rx2.indexIn(*this, index + 1); executed (the execution status of this line is deduced): index = rx2.indexIn(*this, index + 1); | - |
| 3251 | if (index == -1) evaluated: index == -1| yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
| 3252 | break; executed: break;Execution Count:2 | 2 |
| 3253 | count++; executed (the execution status of this line is deduced): count++; | - |
| 3254 | } executed: }Execution Count:3 | 3 |
| 3255 | return count; executed: return count;Execution Count:2 | 2 |
| 3256 | } | - |
| 3257 | #endif // QT_NO_REGEXP | - |
| 3258 | | - |
| 3259 | #ifndef QT_NO_REGEXP | - |
| 3260 | #ifndef QT_BOOTSTRAPPED | - |
| 3261 | /*! | - |
| 3262 | \overload indexOf() | - |
| 3263 | \since 5.0 | - |
| 3264 | | - |
| 3265 | Returns the index position of the first match of the regular | - |
| 3266 | expression \a re in the string, searching forward from index | - |
| 3267 | position \a from. Returns -1 if \a re didn't match anywhere. | - |
| 3268 | | - |
| 3269 | Example: | - |
| 3270 | | - |
| 3271 | \snippet qstring/main.cpp 93 | - |
| 3272 | */ | - |
| 3273 | int QString::indexOf(const QRegularExpression& re, int from) const | - |
| 3274 | { | - |
| 3275 | if (!re.isValid()) { partially evaluated: !re.isValid()| no Evaluation Count:0 | yes Evaluation Count:64 |
| 0-64 |
| 3276 | qWarning("QString::indexOf: invalid QRegularExpression object"); never executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 3276, __PRETTY_FUNCTION__).warning("QString::indexOf: invalid QRegularExpression object"); | - |
| 3277 | return -1; never executed: return -1; | 0 |
| 3278 | } | - |
| 3279 | | - |
| 3280 | QRegularExpressionMatch match = re.match(*this, from); executed (the execution status of this line is deduced): QRegularExpressionMatch match = re.match(*this, from); | - |
| 3281 | if (match.hasMatch()) evaluated: match.hasMatch()| yes Evaluation Count:33 | yes Evaluation Count:31 |
| 31-33 |
| 3282 | return match.capturedStart(); executed: return match.capturedStart();Execution Count:33 | 33 |
| 3283 | | - |
| 3284 | return -1; executed: return -1;Execution Count:31 | 31 |
| 3285 | } | - |
| 3286 | | - |
| 3287 | /*! | - |
| 3288 | \overload lastIndexOf() | - |
| 3289 | \since 5.0 | - |
| 3290 | | - |
| 3291 | Returns the index position of the last match of the regular | - |
| 3292 | expression \a re in the string, which starts before the index | - |
| 3293 | position \a from. Returns -1 if \a re didn't match anywhere. | - |
| 3294 | | - |
| 3295 | Example: | - |
| 3296 | | - |
| 3297 | \snippet qstring/main.cpp 94 | - |
| 3298 | */ | - |
| 3299 | int QString::lastIndexOf(const QRegularExpression &re, int from) const | - |
| 3300 | { | - |
| 3301 | if (!re.isValid()) { evaluated: !re.isValid()| yes Evaluation Count:1 | yes Evaluation Count:18 |
| 1-18 |
| 3302 | qWarning("QString::lastIndexOf: invalid QRegularExpression object"); executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 3302, __PRETTY_FUNCTION__).warning("QString::lastIndexOf: invalid QRegularExpression object"); | - |
| 3303 | return -1; executed: return -1;Execution Count:1 | 1 |
| 3304 | } | - |
| 3305 | | - |
| 3306 | int endpos = (from < 0) ? (size() + from + 1) : (from + 1); evaluated: (from < 0)| yes Evaluation Count:6 | yes Evaluation Count:12 |
| 6-12 |
| 3307 | | - |
| 3308 | QRegularExpressionMatchIterator iterator = re.globalMatch(*this); executed (the execution status of this line is deduced): QRegularExpressionMatchIterator iterator = re.globalMatch(*this); | - |
| 3309 | int lastIndex = -1; executed (the execution status of this line is deduced): int lastIndex = -1; | - |
| 3310 | while (iterator.hasNext()) { evaluated: iterator.hasNext()| yes Evaluation Count:34 | yes Evaluation Count:13 |
| 13-34 |
| 3311 | QRegularExpressionMatch match = iterator.next(); executed (the execution status of this line is deduced): QRegularExpressionMatch match = iterator.next(); | - |
| 3312 | int start = match.capturedStart(); executed (the execution status of this line is deduced): int start = match.capturedStart(); | - |
| 3313 | if (start < endpos) evaluated: start < endpos| yes Evaluation Count:29 | yes Evaluation Count:5 |
| 5-29 |
| 3314 | lastIndex = start; executed: lastIndex = start;Execution Count:29 | 29 |
| 3315 | else | - |
| 3316 | break; executed: break;Execution Count:5 | 5 |
| 3317 | } | - |
| 3318 | | - |
| 3319 | return lastIndex; executed: return lastIndex;Execution Count:18 | 18 |
| 3320 | } | - |
| 3321 | | - |
| 3322 | /*! \overload contains() | - |
| 3323 | \since 5.0 | - |
| 3324 | | - |
| 3325 | Returns true if the regular expression \a re matches somewhere in | - |
| 3326 | this string; otherwise returns false. | - |
| 3327 | */ | - |
| 3328 | bool QString::contains(const QRegularExpression &re) const | - |
| 3329 | { | - |
| 3330 | if (!re.isValid()) { evaluated: !re.isValid()| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 3331 | qWarning("QString::contains: invalid QRegularExpression object"); executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 3331, __PRETTY_FUNCTION__).warning("QString::contains: invalid QRegularExpression object"); | - |
| 3332 | return false; executed: return false;Execution Count:1 | 1 |
| 3333 | } | - |
| 3334 | QRegularExpressionMatch match = re.match(*this); executed (the execution status of this line is deduced): QRegularExpressionMatch match = re.match(*this); | - |
| 3335 | return match.hasMatch(); executed: return match.hasMatch();Execution Count:5 | 5 |
| 3336 | } | - |
| 3337 | | - |
| 3338 | /*! | - |
| 3339 | \overload count() | - |
| 3340 | \since 5.0 | - |
| 3341 | | - |
| 3342 | Returns the number of times the regular expression \a re matches | - |
| 3343 | in the string. | - |
| 3344 | | - |
| 3345 | This function counts overlapping matches, so in the example | - |
| 3346 | below, there are four instances of "ana" or "ama": | - |
| 3347 | | - |
| 3348 | \snippet qstring/main.cpp 95 | - |
| 3349 | */ | - |
| 3350 | int QString::count(const QRegularExpression &re) const | - |
| 3351 | { | - |
| 3352 | if (!re.isValid()) { evaluated: !re.isValid()| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 3353 | qWarning("QString::count: invalid QRegularExpression object"); executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 3353, __PRETTY_FUNCTION__).warning("QString::count: invalid QRegularExpression object"); | - |
| 3354 | return 0; executed: return 0;Execution Count:1 | 1 |
| 3355 | } | - |
| 3356 | int count = 0; executed (the execution status of this line is deduced): int count = 0; | - |
| 3357 | int index = -1; executed (the execution status of this line is deduced): int index = -1; | - |
| 3358 | int len = length(); executed (the execution status of this line is deduced): int len = length(); | - |
| 3359 | while (index < len - 1) { partially evaluated: index < len - 1| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 3360 | QRegularExpressionMatch match = re.match(*this, index + 1); executed (the execution status of this line is deduced): QRegularExpressionMatch match = re.match(*this, index + 1); | - |
| 3361 | if (!match.hasMatch()) evaluated: !match.hasMatch()| yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
| 3362 | break; executed: break;Execution Count:2 | 2 |
| 3363 | index = match.capturedStart(); executed (the execution status of this line is deduced): index = match.capturedStart(); | - |
| 3364 | count++; executed (the execution status of this line is deduced): count++; | - |
| 3365 | } executed: }Execution Count:3 | 3 |
| 3366 | return count; executed: return count;Execution Count:2 | 2 |
| 3367 | } | - |
| 3368 | #endif // QT_BOOTSTRAPPED | - |
| 3369 | #endif // QT_NO_REGEXP | - |
| 3370 | | - |
| 3371 | /*! \fn int QString::count() const | - |
| 3372 | | - |
| 3373 | \overload count() | - |
| 3374 | | - |
| 3375 | Same as size(). | - |
| 3376 | */ | - |
| 3377 | | - |
| 3378 | | - |
| 3379 | /*! | - |
| 3380 | \enum QString::SectionFlag | - |
| 3381 | | - |
| 3382 | This enum specifies flags that can be used to affect various | - |
| 3383 | aspects of the section() function's behavior with respect to | - |
| 3384 | separators and empty fields. | - |
| 3385 | | - |
| 3386 | \value SectionDefault Empty fields are counted, leading and | - |
| 3387 | trailing separators are not included, and the separator is | - |
| 3388 | compared case sensitively. | - |
| 3389 | | - |
| 3390 | \value SectionSkipEmpty Treat empty fields as if they don't exist, | - |
| 3391 | i.e. they are not considered as far as \e start and \e end are | - |
| 3392 | concerned. | - |
| 3393 | | - |
| 3394 | \value SectionIncludeLeadingSep Include the leading separator (if | - |
| 3395 | any) in the result string. | - |
| 3396 | | - |
| 3397 | \value SectionIncludeTrailingSep Include the trailing separator | - |
| 3398 | (if any) in the result string. | - |
| 3399 | | - |
| 3400 | \value SectionCaseInsensitiveSeps Compare the separator | - |
| 3401 | case-insensitively. | - |
| 3402 | | - |
| 3403 | \sa section() | - |
| 3404 | */ | - |
| 3405 | | - |
| 3406 | /*! | - |
| 3407 | \fn QString QString::section(QChar sep, int start, int end = -1, SectionFlags flags) const | - |
| 3408 | | - |
| 3409 | This function returns a section of the string. | - |
| 3410 | | - |
| 3411 | This string is treated as a sequence of fields separated by the | - |
| 3412 | character, \a sep. The returned string consists of the fields from | - |
| 3413 | position \a start to position \a end inclusive. If \a end is not | - |
| 3414 | specified, all fields from position \a start to the end of the | - |
| 3415 | string are included. Fields are numbered 0, 1, 2, etc., counting | - |
| 3416 | from the left, and -1, -2, etc., counting from right to left. | - |
| 3417 | | - |
| 3418 | The \a flags argument can be used to affect some aspects of the | - |
| 3419 | function's behavior, e.g. whether to be case sensitive, whether | - |
| 3420 | to skip empty fields and how to deal with leading and trailing | - |
| 3421 | separators; see \l{SectionFlags}. | - |
| 3422 | | - |
| 3423 | \snippet qstring/main.cpp 52 | - |
| 3424 | | - |
| 3425 | If \a start or \a end is negative, we count fields from the right | - |
| 3426 | of the string, the right-most field being -1, the one from | - |
| 3427 | right-most field being -2, and so on. | - |
| 3428 | | - |
| 3429 | \snippet qstring/main.cpp 53 | - |
| 3430 | | - |
| 3431 | \sa split() | - |
| 3432 | */ | - |
| 3433 | | - |
| 3434 | /*! | - |
| 3435 | \overload section() | - |
| 3436 | | - |
| 3437 | \snippet qstring/main.cpp 51 | - |
| 3438 | \snippet qstring/main.cpp 54 | - |
| 3439 | | - |
| 3440 | \sa split() | - |
| 3441 | */ | - |
| 3442 | | - |
| 3443 | QString QString::section(const QString &sep, int start, int end, SectionFlags flags) const | - |
| 3444 | { | - |
| 3445 | QStringList sections = split(sep, KeepEmptyParts, executed (the execution status of this line is deduced): QStringList sections = split(sep, KeepEmptyParts, | - |
| 3446 | (flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive : Qt::CaseSensitive); executed (the execution status of this line is deduced): (flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive : Qt::CaseSensitive); | - |
| 3447 | if (sections.isEmpty()) partially evaluated: sections.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:1999 |
| 0-1999 |
| 3448 | return QString(); never executed: return QString(); | 0 |
| 3449 | if (!(flags & SectionSkipEmpty)) { evaluated: !(flags & SectionSkipEmpty)| yes Evaluation Count:200 | yes Evaluation Count:1799 |
| 200-1799 |
| 3450 | if (start < 0) evaluated: start < 0| yes Evaluation Count:185 | yes Evaluation Count:15 |
| 15-185 |
| 3451 | start += sections.count(); executed: start += sections.count();Execution Count:185 | 185 |
| 3452 | if (end < 0) evaluated: end < 0| yes Evaluation Count:187 | yes Evaluation Count:13 |
| 13-187 |
| 3453 | end += sections.count(); executed: end += sections.count();Execution Count:187 | 187 |
| 3454 | } else { executed: }Execution Count:200 | 200 |
| 3455 | int skip = 0; executed (the execution status of this line is deduced): int skip = 0; | - |
| 3456 | for (int k=0; k<sections.size(); ++k) { evaluated: k<sections.size()| yes Evaluation Count:14488 | yes Evaluation Count:1799 |
| 1799-14488 |
| 3457 | if (sections.at(k).isEmpty()) evaluated: sections.at(k).isEmpty()| yes Evaluation Count:1914 | yes Evaluation Count:12574 |
| 1914-12574 |
| 3458 | skip++; executed: skip++;Execution Count:1914 | 1914 |
| 3459 | } executed: }Execution Count:14488 | 14488 |
| 3460 | if (start < 0) partially evaluated: start < 0| no Evaluation Count:0 | yes Evaluation Count:1799 |
| 0-1799 |
| 3461 | start += sections.count() - skip; never executed: start += sections.count() - skip; | 0 |
| 3462 | if (end < 0) evaluated: end < 0| yes Evaluation Count:1792 | yes Evaluation Count:7 |
| 7-1792 |
| 3463 | end += sections.count() - skip; executed: end += sections.count() - skip;Execution Count:1792 | 1792 |
| 3464 | } executed: }Execution Count:1799 | 1799 |
| 3465 | int x = 0; executed (the execution status of this line is deduced): int x = 0; | - |
| 3466 | QString ret; executed (the execution status of this line is deduced): QString ret; | - |
| 3467 | int first_i = start, last_i = end; executed (the execution status of this line is deduced): int first_i = start, last_i = end; | - |
| 3468 | for (int i = 0; x <= end && i < sections.size(); ++i) { evaluated: x <= end| yes Evaluation Count:12862 | yes Evaluation Count:1999 |
partially evaluated: i < sections.size()| yes Evaluation Count:12862 | no Evaluation Count:0 |
| 0-12862 |
| 3469 | QString section = sections.at(i); executed (the execution status of this line is deduced): QString section = sections.at(i); | - |
| 3470 | const bool empty = section.isEmpty(); executed (the execution status of this line is deduced): const bool empty = section.isEmpty(); | - |
| 3471 | if (x >= start) { evaluated: x >= start| yes Evaluation Count:2037 | yes Evaluation Count:10825 |
| 2037-10825 |
| 3472 | if(x == start) evaluated: x == start| yes Evaluation Count:2022 | yes Evaluation Count:15 |
| 15-2022 |
| 3473 | first_i = i; executed: first_i = i;Execution Count:2022 | 2022 |
| 3474 | if(x == end) evaluated: x == end| yes Evaluation Count:2022 | yes Evaluation Count:15 |
| 15-2022 |
| 3475 | last_i = i; executed: last_i = i;Execution Count:2022 | 2022 |
| 3476 | if(x > start) evaluated: x > start| yes Evaluation Count:15 | yes Evaluation Count:2022 |
| 15-2022 |
| 3477 | ret += sep; executed: ret += sep;Execution Count:15 | 15 |
| 3478 | ret += section; executed (the execution status of this line is deduced): ret += section; | - |
| 3479 | } executed: }Execution Count:2037 | 2037 |
| 3480 | if (!empty || !(flags & SectionSkipEmpty)) evaluated: !empty| yes Evaluation Count:12788 | yes Evaluation Count:74 |
evaluated: !(flags & SectionSkipEmpty)| yes Evaluation Count:12 | yes Evaluation Count:62 |
| 12-12788 |
| 3481 | x++; executed: x++;Execution Count:12800 | 12800 |
| 3482 | } executed: }Execution Count:12862 | 12862 |
| 3483 | if((flags & SectionIncludeLeadingSep) && first_i) evaluated: (flags & SectionIncludeLeadingSep)| yes Evaluation Count:11 | yes Evaluation Count:1988 |
evaluated: first_i| yes Evaluation Count:7 | yes Evaluation Count:4 |
| 4-1988 |
| 3484 | ret.prepend(sep); executed: ret.prepend(sep);Execution Count:7 | 7 |
| 3485 | if((flags & SectionIncludeTrailingSep) && last_i < sections.size()-1) evaluated: (flags & SectionIncludeTrailingSep)| yes Evaluation Count:8 | yes Evaluation Count:1991 |
evaluated: last_i < sections.size()-1| yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-1991 |
| 3486 | ret += sep; executed: ret += sep;Execution Count:6 | 6 |
| 3487 | return ret; executed: return ret;Execution Count:1999 | 1999 |
| 3488 | } | - |
| 3489 | | - |
| 3490 | #ifndef QT_NO_REGEXP | - |
| 3491 | class qt_section_chunk { | - |
| 3492 | public: | - |
| 3493 | qt_section_chunk(int l, QString s) { length = l; string = s; } executed: }Execution Count:582 | 582 |
| 3494 | int length; | - |
| 3495 | QString string; | - |
| 3496 | }; | - |
| 3497 | | - |
| 3498 | static QString extractSections(const QList<qt_section_chunk> §ions, | - |
| 3499 | int start, | - |
| 3500 | int end, | - |
| 3501 | QString::SectionFlags flags) | - |
| 3502 | { | - |
| 3503 | if (start < 0) evaluated: start < 0| yes Evaluation Count:4 | yes Evaluation Count:70 |
| 4-70 |
| 3504 | start += sections.count(); executed: start += sections.count();Execution Count:4 | 4 |
| 3505 | if (end < 0) evaluated: end < 0| yes Evaluation Count:10 | yes Evaluation Count:64 |
| 10-64 |
| 3506 | end += sections.count(); executed: end += sections.count();Execution Count:10 | 10 |
| 3507 | | - |
| 3508 | QString ret; executed (the execution status of this line is deduced): QString ret; | - |
| 3509 | int x = 0; executed (the execution status of this line is deduced): int x = 0; | - |
| 3510 | int first_i = start, last_i = end; executed (the execution status of this line is deduced): int first_i = start, last_i = end; | - |
| 3511 | for (int i = 0; x <= end && i < sections.size(); ++i) { evaluated: x <= end| yes Evaluation Count:344 | yes Evaluation Count:72 |
evaluated: i < sections.size()| yes Evaluation Count:342 | yes Evaluation Count:2 |
| 2-344 |
| 3512 | const qt_section_chunk §ion = sections.at(i); executed (the execution status of this line is deduced): const qt_section_chunk §ion = sections.at(i); | - |
| 3513 | const bool empty = (section.length == section.string.length()); executed (the execution status of this line is deduced): const bool empty = (section.length == section.string.length()); | - |
| 3514 | if (x >= start) { evaluated: x >= start| yes Evaluation Count:170 | yes Evaluation Count:172 |
| 170-172 |
| 3515 | if (x == start) evaluated: x == start| yes Evaluation Count:118 | yes Evaluation Count:52 |
| 52-118 |
| 3516 | first_i = i; executed: first_i = i;Execution Count:118 | 118 |
| 3517 | if (x == end) evaluated: x == end| yes Evaluation Count:118 | yes Evaluation Count:52 |
| 52-118 |
| 3518 | last_i = i; executed: last_i = i;Execution Count:118 | 118 |
| 3519 | if (x != start) evaluated: x != start| yes Evaluation Count:52 | yes Evaluation Count:118 |
| 52-118 |
| 3520 | ret += section.string; executed: ret += section.string;Execution Count:52 | 52 |
| 3521 | else | - |
| 3522 | ret += section.string.mid(section.length); executed: ret += section.string.mid(section.length);Execution Count:118 | 118 |
| 3523 | } | - |
| 3524 | if (!empty || !(flags & QString::SectionSkipEmpty)) evaluated: !empty| yes Evaluation Count:170 | yes Evaluation Count:172 |
evaluated: !(flags & QString::SectionSkipEmpty)| yes Evaluation Count:48 | yes Evaluation Count:124 |
| 48-172 |
| 3525 | x++; executed: x++;Execution Count:218 | 218 |
| 3526 | } executed: }Execution Count:342 | 342 |
| 3527 | | - |
| 3528 | if ((flags & QString::SectionIncludeLeadingSep) && first_i < sections.size()) { evaluated: (flags & QString::SectionIncludeLeadingSep)| yes Evaluation Count:44 | yes Evaluation Count:30 |
evaluated: first_i < sections.size()| yes Evaluation Count:42 | yes Evaluation Count:2 |
| 2-44 |
| 3529 | const qt_section_chunk §ion = sections.at(first_i); executed (the execution status of this line is deduced): const qt_section_chunk §ion = sections.at(first_i); | - |
| 3530 | ret.prepend(section.string.left(section.length)); executed (the execution status of this line is deduced): ret.prepend(section.string.left(section.length)); | - |
| 3531 | } executed: }Execution Count:42 | 42 |
| 3532 | | - |
| 3533 | if ((flags & QString::SectionIncludeTrailingSep) && last_i+1 <= sections.size()-1) { evaluated: (flags & QString::SectionIncludeTrailingSep)| yes Evaluation Count:30 | yes Evaluation Count:44 |
evaluated: last_i+1 <= sections.size()-1| yes Evaluation Count:24 | yes Evaluation Count:6 |
| 6-44 |
| 3534 | const qt_section_chunk §ion = sections.at(last_i+1); executed (the execution status of this line is deduced): const qt_section_chunk §ion = sections.at(last_i+1); | - |
| 3535 | ret += section.string.left(section.length); executed (the execution status of this line is deduced): ret += section.string.left(section.length); | - |
| 3536 | } executed: }Execution Count:24 | 24 |
| 3537 | | - |
| 3538 | return ret; executed: return ret;Execution Count:74 | 74 |
| 3539 | } | - |
| 3540 | | - |
| 3541 | /*! | - |
| 3542 | \overload section() | - |
| 3543 | | - |
| 3544 | This string is treated as a sequence of fields separated by the | - |
| 3545 | regular expression, \a reg. | - |
| 3546 | | - |
| 3547 | \snippet qstring/main.cpp 55 | - |
| 3548 | | - |
| 3549 | \warning Using this QRegExp version is much more expensive than | - |
| 3550 | the overloaded string and character versions. | - |
| 3551 | | - |
| 3552 | \sa split(), simplified() | - |
| 3553 | */ | - |
| 3554 | QString QString::section(const QRegExp ®, int start, int end, SectionFlags flags) const | - |
| 3555 | { | - |
| 3556 | const QChar *uc = unicode(); executed (the execution status of this line is deduced): const QChar *uc = unicode(); | - |
| 3557 | if(!uc) partially evaluated: !uc| no Evaluation Count:0 | yes Evaluation Count:37 |
| 0-37 |
| 3558 | return QString(); never executed: return QString(); | 0 |
| 3559 | | - |
| 3560 | QRegExp sep(reg); executed (the execution status of this line is deduced): QRegExp sep(reg); | - |
| 3561 | sep.setCaseSensitivity((flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive executed (the execution status of this line is deduced): sep.setCaseSensitivity((flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive | - |
| 3562 | : Qt::CaseSensitive); executed (the execution status of this line is deduced): : Qt::CaseSensitive); | - |
| 3563 | | - |
| 3564 | QList<qt_section_chunk> sections; executed (the execution status of this line is deduced): QList<qt_section_chunk> sections; | - |
| 3565 | int n = length(), m = 0, last_m = 0, last_len = 0; executed (the execution status of this line is deduced): int n = length(), m = 0, last_m = 0, last_len = 0; | - |
| 3566 | while ((m = sep.indexIn(*this, m)) != -1) { evaluated: (m = sep.indexIn(*this, m)) != -1| yes Evaluation Count:254 | yes Evaluation Count:37 |
| 37-254 |
| 3567 | sections.append(qt_section_chunk(last_len, QString(uc + last_m, m - last_m))); executed (the execution status of this line is deduced): sections.append(qt_section_chunk(last_len, QString(uc + last_m, m - last_m))); | - |
| 3568 | last_m = m; executed (the execution status of this line is deduced): last_m = m; | - |
| 3569 | last_len = sep.matchedLength(); executed (the execution status of this line is deduced): last_len = sep.matchedLength(); | - |
| 3570 | m += qMax(sep.matchedLength(), 1); executed (the execution status of this line is deduced): m += qMax(sep.matchedLength(), 1); | - |
| 3571 | } executed: }Execution Count:254 | 254 |
| 3572 | sections.append(qt_section_chunk(last_len, QString(uc + last_m, n - last_m))); executed (the execution status of this line is deduced): sections.append(qt_section_chunk(last_len, QString(uc + last_m, n - last_m))); | - |
| 3573 | | - |
| 3574 | return extractSections(sections, start, end, flags); executed: return extractSections(sections, start, end, flags);Execution Count:37 | 37 |
| 3575 | } | - |
| 3576 | #endif | - |
| 3577 | | - |
| 3578 | #ifndef QT_NO_REGEXP | - |
| 3579 | #ifndef QT_BOOTSTRAPPED | - |
| 3580 | /*! | - |
| 3581 | \overload section() | - |
| 3582 | \since 5.0 | - |
| 3583 | | - |
| 3584 | This string is treated as a sequence of fields separated by the | - |
| 3585 | regular expression, \a re. | - |
| 3586 | | - |
| 3587 | \snippet qstring/main.cpp 89 | - |
| 3588 | | - |
| 3589 | \warning Using this QRegularExpression version is much more expensive than | - |
| 3590 | the overloaded string and character versions. | - |
| 3591 | | - |
| 3592 | \sa split(), simplified() | - |
| 3593 | */ | - |
| 3594 | QString QString::section(const QRegularExpression &re, int start, int end, SectionFlags flags) const | - |
| 3595 | { | - |
| 3596 | if (!re.isValid()) { partially evaluated: !re.isValid()| no Evaluation Count:0 | yes Evaluation Count:37 |
| 0-37 |
| 3597 | qWarning("QString::section: invalid QRegularExpression object"); never executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 3597, __PRETTY_FUNCTION__).warning("QString::section: invalid QRegularExpression object"); | - |
| 3598 | return QString(); never executed: return QString(); | 0 |
| 3599 | } | - |
| 3600 | | - |
| 3601 | const QChar *uc = unicode(); executed (the execution status of this line is deduced): const QChar *uc = unicode(); | - |
| 3602 | if (!uc) partially evaluated: !uc| no Evaluation Count:0 | yes Evaluation Count:37 |
| 0-37 |
| 3603 | return QString(); never executed: return QString(); | 0 |
| 3604 | | - |
| 3605 | QRegularExpression sep(re); executed (the execution status of this line is deduced): QRegularExpression sep(re); | - |
| 3606 | if (flags & SectionCaseInsensitiveSeps) evaluated: flags & SectionCaseInsensitiveSeps| yes Evaluation Count:1 | yes Evaluation Count:36 |
| 1-36 |
| 3607 | sep.setPatternOptions(sep.patternOptions() | QRegularExpression::CaseInsensitiveOption); executed: sep.setPatternOptions(sep.patternOptions() | QRegularExpression::CaseInsensitiveOption);Execution Count:1 | 1 |
| 3608 | | - |
| 3609 | QList<qt_section_chunk> sections; executed (the execution status of this line is deduced): QList<qt_section_chunk> sections; | - |
| 3610 | int n = length(), m = 0, last_m = 0, last_len = 0; executed (the execution status of this line is deduced): int n = length(), m = 0, last_m = 0, last_len = 0; | - |
| 3611 | QRegularExpressionMatchIterator iterator = sep.globalMatch(*this); executed (the execution status of this line is deduced): QRegularExpressionMatchIterator iterator = sep.globalMatch(*this); | - |
| 3612 | while (iterator.hasNext()) { evaluated: iterator.hasNext()| yes Evaluation Count:254 | yes Evaluation Count:37 |
| 37-254 |
| 3613 | QRegularExpressionMatch match = iterator.next(); executed (the execution status of this line is deduced): QRegularExpressionMatch match = iterator.next(); | - |
| 3614 | m = match.capturedStart(); executed (the execution status of this line is deduced): m = match.capturedStart(); | - |
| 3615 | sections.append(qt_section_chunk(last_len, QString(uc + last_m, m - last_m))); executed (the execution status of this line is deduced): sections.append(qt_section_chunk(last_len, QString(uc + last_m, m - last_m))); | - |
| 3616 | last_m = m; executed (the execution status of this line is deduced): last_m = m; | - |
| 3617 | last_len = match.capturedLength(); executed (the execution status of this line is deduced): last_len = match.capturedLength(); | - |
| 3618 | } executed: }Execution Count:254 | 254 |
| 3619 | sections.append(qt_section_chunk(last_len, QString(uc + last_m, n - last_m))); executed (the execution status of this line is deduced): sections.append(qt_section_chunk(last_len, QString(uc + last_m, n - last_m))); | - |
| 3620 | | - |
| 3621 | return extractSections(sections, start, end, flags); executed: return extractSections(sections, start, end, flags);Execution Count:37 | 37 |
| 3622 | } | - |
| 3623 | #endif // QT_BOOTSTRAPPED | - |
| 3624 | #endif // QT_NO_REGEXP | - |
| 3625 | | - |
| 3626 | /*! | - |
| 3627 | Returns a substring that contains the \a n leftmost characters | - |
| 3628 | of the string. | - |
| 3629 | | - |
| 3630 | The entire string is returned if \a n is greater than size() or | - |
| 3631 | less than zero. | - |
| 3632 | | - |
| 3633 | \snippet qstring/main.cpp 31 | - |
| 3634 | | - |
| 3635 | \sa right(), mid(), startsWith() | - |
| 3636 | */ | - |
| 3637 | QString QString::left(int n) const | - |
| 3638 | { | - |
| 3639 | if (n >= d->size || n < 0) evaluated: n >= d->size| yes Evaluation Count:83284 | yes Evaluation Count:27010 |
evaluated: n < 0| yes Evaluation Count:232 | yes Evaluation Count:26785 |
| 232-83284 |
| 3640 | return *this; executed: return *this;Execution Count:83516 | 83516 |
| 3641 | return QString((const QChar*) d->data(), n); executed: return QString((const QChar*) d->data(), n);Execution Count:26783 | 26783 |
| 3642 | } | - |
| 3643 | | - |
| 3644 | /*! | - |
| 3645 | Returns a substring that contains the \a n rightmost characters | - |
| 3646 | of the string. | - |
| 3647 | | - |
| 3648 | The entire string is returned if \a n is greater than size() or | - |
| 3649 | less than zero. | - |
| 3650 | | - |
| 3651 | \snippet qstring/main.cpp 48 | - |
| 3652 | | - |
| 3653 | \sa left(), mid(), endsWith() | - |
| 3654 | */ | - |
| 3655 | QString QString::right(int n) const | - |
| 3656 | { | - |
| 3657 | if (n >= d->size || n < 0) evaluated: n >= d->size| yes Evaluation Count:63 | yes Evaluation Count:3356 |
evaluated: n < 0| yes Evaluation Count:1 | yes Evaluation Count:3355 |
| 1-3356 |
| 3658 | return *this; executed: return *this;Execution Count:64 | 64 |
| 3659 | return QString((const QChar*) d->data() + d->size - n, n); executed: return QString((const QChar*) d->data() + d->size - n, n);Execution Count:3355 | 3355 |
| 3660 | } | - |
| 3661 | | - |
| 3662 | /*! | - |
| 3663 | Returns a string that contains \a n characters of this string, | - |
| 3664 | starting at the specified \a position index. | - |
| 3665 | | - |
| 3666 | Returns a null string if the \a position index exceeds the | - |
| 3667 | length of the string. If there are less than \a n characters | - |
| 3668 | available in the string starting at the given \a position, or if | - |
| 3669 | \a n is -1 (default), the function returns all characters that | - |
| 3670 | are available from the specified \a position. | - |
| 3671 | | - |
| 3672 | Example: | - |
| 3673 | | - |
| 3674 | \snippet qstring/main.cpp 34 | - |
| 3675 | | - |
| 3676 | \sa left(), right() | - |
| 3677 | */ | - |
| 3678 | | - |
| 3679 | QString QString::mid(int position, int n) const | - |
| 3680 | { | - |
| 3681 | if (position > d->size) evaluated: position > d->size| yes Evaluation Count:12142 | yes Evaluation Count:534136 |
| 12142-534136 |
| 3682 | return QString(); executed: return QString();Execution Count:12142 | 12142 |
| 3683 | if (position < 0) { evaluated: position < 0| yes Evaluation Count:34 | yes Evaluation Count:534102 |
| 34-534102 |
| 3684 | if (n < 0 || n + position >= d->size) evaluated: n < 0| yes Evaluation Count:7 | yes Evaluation Count:27 |
evaluated: n + position >= d->size| yes Evaluation Count:12 | yes Evaluation Count:15 |
| 7-27 |
| 3685 | return *this; executed: return *this;Execution Count:19 | 19 |
| 3686 | if (n + position <= 0) evaluated: n + position <= 0| yes Evaluation Count:11 | yes Evaluation Count:4 |
| 4-11 |
| 3687 | return QString(); executed: return QString();Execution Count:11 | 11 |
| 3688 | | - |
| 3689 | n += position; executed (the execution status of this line is deduced): n += position; | - |
| 3690 | position = 0; executed (the execution status of this line is deduced): position = 0; | - |
| 3691 | } else if (n < 0 || n > d->size - position) executed: }Execution Count:4 evaluated: n < 0| yes Evaluation Count:353756 | yes Evaluation Count:180367 |
evaluated: n > d->size - position| yes Evaluation Count:474 | yes Evaluation Count:179925 |
| 4-353756 |
| 3692 | n = d->size - position; executed: n = d->size - position;Execution Count:354231 | 354231 |
| 3693 | if (position == 0 && n == d->size) evaluated: position == 0| yes Evaluation Count:121561 | yes Evaluation Count:412582 |
evaluated: n == d->size| yes Evaluation Count:97684 | yes Evaluation Count:23879 |
| 23879-412582 |
| 3694 | return *this; executed: return *this;Execution Count:97679 | 97679 |
| 3695 | return QString((const QChar*) d->data() + position, n); executed: return QString((const QChar*) d->data() + position, n);Execution Count:436452 | 436452 |
| 3696 | } | - |
| 3697 | | - |
| 3698 | /*! | - |
| 3699 | Returns true if the string starts with \a s; otherwise returns | - |
| 3700 | false. | - |
| 3701 | | - |
| 3702 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 3703 | case sensitive; otherwise the search is case insensitive. | - |
| 3704 | | - |
| 3705 | \snippet qstring/main.cpp 65 | - |
| 3706 | | - |
| 3707 | \sa endsWith() | - |
| 3708 | */ | - |
| 3709 | bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const | - |
| 3710 | { | - |
| 3711 | return qt_starts_with(isNull() ? 0 : unicode(), size(), executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:72040 | 72040 |
| 3712 | s.isNull() ? 0 : s.unicode(), s.size(), cs); executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:72040 | 72040 |
| 3713 | } | - |
| 3714 | | - |
| 3715 | /*! | - |
| 3716 | \overload startsWith() | - |
| 3717 | */ | - |
| 3718 | bool QString::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const | - |
| 3719 | { | - |
| 3720 | return qt_starts_with(isNull() ? 0 : unicode(), size(), s, cs); executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), s, cs);Execution Count:666288 | 666288 |
| 3721 | } | - |
| 3722 | | - |
| 3723 | /*! | - |
| 3724 | \overload startsWith() | - |
| 3725 | | - |
| 3726 | Returns true if the string starts with \a c; otherwise returns | - |
| 3727 | false. | - |
| 3728 | */ | - |
| 3729 | bool QString::startsWith(QChar c, Qt::CaseSensitivity cs) const | - |
| 3730 | { | - |
| 3731 | return d->size executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[0] == c : foldCase(d->data()[0]) == foldCase(c.unicode()));Execution Count:73747 | 73747 |
| 3732 | && (cs == Qt::CaseSensitive executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[0] == c : foldCase(d->data()[0]) == foldCase(c.unicode()));Execution Count:73747 | 73747 |
| 3733 | ? d->data()[0] == c executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[0] == c : foldCase(d->data()[0]) == foldCase(c.unicode()));Execution Count:73747 | 73747 |
| 3734 | : foldCase(d->data()[0]) == foldCase(c.unicode())); executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[0] == c : foldCase(d->data()[0]) == foldCase(c.unicode()));Execution Count:73747 | 73747 |
| 3735 | } | - |
| 3736 | | - |
| 3737 | /*! | - |
| 3738 | \since 4.8 | - |
| 3739 | \overload | - |
| 3740 | Returns true if the string starts with the string reference \a s; | - |
| 3741 | otherwise returns false. | - |
| 3742 | | - |
| 3743 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 3744 | sensitive; otherwise the search is case insensitive. | - |
| 3745 | | - |
| 3746 | \sa endsWith() | - |
| 3747 | */ | - |
| 3748 | bool QString::startsWith(const QStringRef &s, Qt::CaseSensitivity cs) const | - |
| 3749 | { | - |
| 3750 | return qt_starts_with(isNull() ? 0 : unicode(), size(), executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:4 | 4 |
| 3751 | s.isNull() ? 0 : s.unicode(), s.size(), cs); executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:4 | 4 |
| 3752 | } | - |
| 3753 | | - |
| 3754 | /*! | - |
| 3755 | Returns true if the string ends with \a s; otherwise returns | - |
| 3756 | false. | - |
| 3757 | | - |
| 3758 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 3759 | sensitive; otherwise the search is case insensitive. | - |
| 3760 | | - |
| 3761 | \snippet qstring/main.cpp 20 | - |
| 3762 | | - |
| 3763 | \sa startsWith() | - |
| 3764 | */ | - |
| 3765 | bool QString::endsWith(const QString& s, Qt::CaseSensitivity cs) const | - |
| 3766 | { | - |
| 3767 | return qt_ends_with(isNull() ? 0 : unicode(), size(), executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:3459 | 3459 |
| 3768 | s.isNull() ? 0 : s.unicode(), s.size(), cs); executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:3459 | 3459 |
| 3769 | } | - |
| 3770 | | - |
| 3771 | /*! | - |
| 3772 | \since 4.8 | - |
| 3773 | \overload endsWith() | - |
| 3774 | Returns true if the string ends with the string reference \a s; | - |
| 3775 | otherwise returns false. | - |
| 3776 | | - |
| 3777 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 3778 | sensitive; otherwise the search is case insensitive. | - |
| 3779 | | - |
| 3780 | \sa startsWith() | - |
| 3781 | */ | - |
| 3782 | bool QString::endsWith(const QStringRef &s, Qt::CaseSensitivity cs) const | - |
| 3783 | { | - |
| 3784 | return qt_ends_with(isNull() ? 0 : unicode(), size(), executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:6 | 6 |
| 3785 | s.isNull() ? 0 : s.unicode(), s.size(), cs); executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), s.isNull() ? 0 : s.unicode(), s.size(), cs);Execution Count:6 | 6 |
| 3786 | } | - |
| 3787 | | - |
| 3788 | | - |
| 3789 | /*! | - |
| 3790 | \overload endsWith() | - |
| 3791 | */ | - |
| 3792 | bool QString::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const | - |
| 3793 | { | - |
| 3794 | return qt_ends_with(isNull() ? 0 : unicode(), size(), s, cs); executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), s, cs);Execution Count:5538 | 5538 |
| 3795 | } | - |
| 3796 | | - |
| 3797 | /*! | - |
| 3798 | Returns true if the string ends with \a c; otherwise returns | - |
| 3799 | false. | - |
| 3800 | | - |
| 3801 | \overload endsWith() | - |
| 3802 | */ | - |
| 3803 | bool QString::endsWith(QChar c, Qt::CaseSensitivity cs) const | - |
| 3804 | { | - |
| 3805 | return d->size executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[d->size - 1] == c : foldCase(d->data()[d->size - 1]) == foldCase(c.unicode()));Execution Count:35119 | 35119 |
| 3806 | && (cs == Qt::CaseSensitive executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[d->size - 1] == c : foldCase(d->data()[d->size - 1]) == foldCase(c.unicode()));Execution Count:35119 | 35119 |
| 3807 | ? d->data()[d->size - 1] == c executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[d->size - 1] == c : foldCase(d->data()[d->size - 1]) == foldCase(c.unicode()));Execution Count:35119 | 35119 |
| 3808 | : foldCase(d->data()[d->size - 1]) == foldCase(c.unicode())); executed: return d->size && (cs == Qt::CaseSensitive ? d->data()[d->size - 1] == c : foldCase(d->data()[d->size - 1]) == foldCase(c.unicode()));Execution Count:35119 | 35119 |
| 3809 | } | - |
| 3810 | | - |
| 3811 | | - |
| 3812 | #if defined(__SSE2__) | - |
| 3813 | static inline __m128i mergeQuestionMarks(__m128i chunk) | - |
| 3814 | { | - |
| 3815 | const __m128i questionMark = _mm_set1_epi16('?'); executed (the execution status of this line is deduced): const __m128i questionMark = _mm_set1_epi16('?'); | - |
| 3816 | | - |
| 3817 | # ifdef __SSE4_2__ | - |
| 3818 | // compare the unsigned shorts for the range 0x0100-0xFFFF | - |
| 3819 | // note on the use of _mm_cmpestrm: | - |
| 3820 | // The MSDN documentation online (http://technet.microsoft.com/en-us/library/bb514080.aspx) | - |
| 3821 | // says for range search the following: | - |
| 3822 | // For each character c in a, determine whether b0 <= c <= b1 or b2 <= c <= b3 | - |
| 3823 | // | - |
| 3824 | // However, all examples on the Internet, including from Intel | - |
| 3825 | // (see http://software.intel.com/en-us/articles/xml-parsing-accelerator-with-intel-streaming-simd-extensions-4-intel-sse4/) | - |
| 3826 | // put the range to be searched first | - |
| 3827 | // | - |
| 3828 | // Disassembly and instruction-level debugging with GCC and ICC show | - |
| 3829 | // that they are doing the right thing. Inverting the arguments in the | - |
| 3830 | // instruction does cause a bunch of test failures. | - |
| 3831 | | - |
| 3832 | const int mode = _SIDD_UWORD_OPS | _SIDD_CMP_RANGES | _SIDD_UNIT_MASK; | - |
| 3833 | const __m128i rangeMatch = _mm_cvtsi32_si128(0xffff0100); | - |
| 3834 | const __m128i offLimitMask = _mm_cmpestrm(rangeMatch, 2, chunk, 8, mode); | - |
| 3835 | | - |
| 3836 | // replace the non-Latin 1 characters in the chunk with question marks | - |
| 3837 | chunk = _mm_blendv_epi8(chunk, questionMark, offLimitMask); | - |
| 3838 | # else | - |
| 3839 | // SSE has no compare instruction for unsigned comparison. | - |
| 3840 | // The variables must be shiffted + 0x8000 to be compared | - |
| 3841 | const __m128i signedBitOffset = _mm_set1_epi16(0x8000); executed (the execution status of this line is deduced): const __m128i signedBitOffset = _mm_set1_epi16(0x8000); | - |
| 3842 | const __m128i thresholdMask = _mm_set1_epi16(0xff + 0x8000); executed (the execution status of this line is deduced): const __m128i thresholdMask = _mm_set1_epi16(0xff + 0x8000); | - |
| 3843 | | - |
| 3844 | const __m128i signedChunk = _mm_add_epi16(chunk, signedBitOffset); executed (the execution status of this line is deduced): const __m128i signedChunk = _mm_add_epi16(chunk, signedBitOffset); | - |
| 3845 | const __m128i offLimitMask = _mm_cmpgt_epi16(signedChunk, thresholdMask); executed (the execution status of this line is deduced): const __m128i offLimitMask = _mm_cmpgt_epi16(signedChunk, thresholdMask); | - |
| 3846 | | - |
| 3847 | # ifdef __SSE4_1__ | - |
| 3848 | // replace the non-Latin 1 characters in the chunk with question marks | - |
| 3849 | chunk = _mm_blendv_epi8(chunk, questionMark, offLimitMask); | - |
| 3850 | # else | - |
| 3851 | // offLimitQuestionMark contains '?' for each 16 bits that was off-limit | - |
| 3852 | // the 16 bits that were correct contains zeros | - |
| 3853 | const __m128i offLimitQuestionMark = _mm_and_si128(offLimitMask, questionMark); executed (the execution status of this line is deduced): const __m128i offLimitQuestionMark = _mm_and_si128(offLimitMask, questionMark); | - |
| 3854 | | - |
| 3855 | // correctBytes contains the bytes that were in limit | - |
| 3856 | // the 16 bits that were off limits contains zeros | - |
| 3857 | const __m128i correctBytes = _mm_andnot_si128(offLimitMask, chunk); executed (the execution status of this line is deduced): const __m128i correctBytes = _mm_andnot_si128(offLimitMask, chunk); | - |
| 3858 | | - |
| 3859 | // merge offLimitQuestionMark and correctBytes to have the result | - |
| 3860 | chunk = _mm_or_si128(correctBytes, offLimitQuestionMark); executed (the execution status of this line is deduced): chunk = _mm_or_si128(correctBytes, offLimitQuestionMark); | - |
| 3861 | # endif | - |
| 3862 | # endif | - |
| 3863 | return chunk; executed: return chunk;Execution Count:8809444 | 8809444 |
| 3864 | } | - |
| 3865 | #endif | - |
| 3866 | | - |
| 3867 | static QByteArray toLatin1_helper(const QChar *data, int length) | - |
| 3868 | { | - |
| 3869 | QByteArray ba; executed (the execution status of this line is deduced): QByteArray ba; | - |
| 3870 | if (length) { evaluated: length| yes Evaluation Count:18649589 | yes Evaluation Count:86475 |
| 86475-18649589 |
| 3871 | ba.resize(length); executed (the execution status of this line is deduced): ba.resize(length); | - |
| 3872 | const ushort *src = reinterpret_cast<const ushort *>(data); executed (the execution status of this line is deduced): const ushort *src = reinterpret_cast<const ushort *>(data); | - |
| 3873 | uchar *dst = (uchar*) ba.data(); executed (the execution status of this line is deduced): uchar *dst = (uchar*) ba.data(); | - |
| 3874 | #if defined(__SSE2__) | - |
| 3875 | if (length >= 16) { evaluated: length >= 16| yes Evaluation Count:1383261 | yes Evaluation Count:17266336 |
| 1383261-17266336 |
| 3876 | const int chunkCount = length >> 4; // divided by 16 executed (the execution status of this line is deduced): const int chunkCount = length >> 4; | - |
| 3877 | | - |
| 3878 | for (int i = 0; i < chunkCount; ++i) { evaluated: i < chunkCount| yes Evaluation Count:4404724 | yes Evaluation Count:1383263 |
| 1383263-4404724 |
| 3879 | __m128i chunk1 = _mm_loadu_si128((__m128i*)src); // load executed (the execution status of this line is deduced): __m128i chunk1 = _mm_loadu_si128((__m128i*)src); | - |
| 3880 | chunk1 = mergeQuestionMarks(chunk1); executed (the execution status of this line is deduced): chunk1 = mergeQuestionMarks(chunk1); | - |
| 3881 | src += 8; executed (the execution status of this line is deduced): src += 8; | - |
| 3882 | | - |
| 3883 | __m128i chunk2 = _mm_loadu_si128((__m128i*)src); // load executed (the execution status of this line is deduced): __m128i chunk2 = _mm_loadu_si128((__m128i*)src); | - |
| 3884 | chunk2 = mergeQuestionMarks(chunk2); executed (the execution status of this line is deduced): chunk2 = mergeQuestionMarks(chunk2); | - |
| 3885 | src += 8; executed (the execution status of this line is deduced): src += 8; | - |
| 3886 | | - |
| 3887 | // pack the two vector to 16 x 8bits elements | - |
| 3888 | const __m128i result = _mm_packus_epi16(chunk1, chunk2); executed (the execution status of this line is deduced): const __m128i result = _mm_packus_epi16(chunk1, chunk2); | - |
| 3889 | | - |
| 3890 | _mm_storeu_si128((__m128i*)dst, result); // store executed (the execution status of this line is deduced): _mm_storeu_si128((__m128i*)dst, result); | - |
| 3891 | dst += 16; executed (the execution status of this line is deduced): dst += 16; | - |
| 3892 | } executed: }Execution Count:4404723 | 4404723 |
| 3893 | length = length % 16; executed (the execution status of this line is deduced): length = length % 16; | - |
| 3894 | } executed: }Execution Count:1383263 | 1383263 |
| 3895 | #elif defined(__ARM_NEON__) | - |
| 3896 | // Refer to the documentation of the SSE2 implementation | - |
| 3897 | // this use eactly the same method as for SSE except: | - |
| 3898 | // 1) neon has unsigned comparison | - |
| 3899 | // 2) packing is done to 64 bits (8 x 8bits component). | - |
| 3900 | if (length >= 16) { | - |
| 3901 | const int chunkCount = length >> 3; // divided by 8 | - |
| 3902 | const uint16x8_t questionMark = vdupq_n_u16('?'); // set | - |
| 3903 | const uint16x8_t thresholdMask = vdupq_n_u16(0xff); // set | - |
| 3904 | for (int i = 0; i < chunkCount; ++i) { | - |
| 3905 | uint16x8_t chunk = vld1q_u16((uint16_t *)src); // load | - |
| 3906 | src += 8; | - |
| 3907 | | - |
| 3908 | const uint16x8_t offLimitMask = vcgtq_u16(chunk, thresholdMask); // chunk > thresholdMask | - |
| 3909 | const uint16x8_t offLimitQuestionMark = vandq_u16(offLimitMask, questionMark); // offLimitMask & questionMark | - |
| 3910 | const uint16x8_t correctBytes = vbicq_u16(chunk, offLimitMask); // !offLimitMask & chunk | - |
| 3911 | chunk = vorrq_u16(correctBytes, offLimitQuestionMark); // correctBytes | offLimitQuestionMark | - |
| 3912 | const uint8x8_t result = vmovn_u16(chunk); // narrowing move->packing | - |
| 3913 | vst1_u8(dst, result); // store | - |
| 3914 | dst += 8; | - |
| 3915 | } | - |
| 3916 | length = length % 8; | - |
| 3917 | } | - |
| 3918 | #endif | - |
| 3919 | while (length--) { evaluated: length--| yes Evaluation Count:35448116 | yes Evaluation Count:18649587 |
| 18649587-35448116 |
| 3920 | *dst++ = (*src>0xff) ? '?' : (uchar) *src; evaluated: (*src>0xff)| yes Evaluation Count:2598 | yes Evaluation Count:35445518 |
| 2598-35445518 |
| 3921 | ++src; executed (the execution status of this line is deduced): ++src; | - |
| 3922 | } executed: }Execution Count:35448118 | 35448118 |
| 3923 | } executed: }Execution Count:18649590 | 18649590 |
| 3924 | return ba; executed: return ba;Execution Count:18736065 | 18736065 |
| 3925 | } | - |
| 3926 | | - |
| 3927 | /*! | - |
| 3928 | Returns a Latin-1 representation of the string as a QByteArray. | - |
| 3929 | | - |
| 3930 | The returned byte array is undefined if the string contains non-Latin1 | - |
| 3931 | characters. Those characters may be suppressed or replaced with a | - |
| 3932 | question mark. | - |
| 3933 | | - |
| 3934 | \sa fromLatin1(), toUtf8(), toLocal8Bit(), QTextCodec | - |
| 3935 | */ | - |
| 3936 | QByteArray QString::toLatin1() const | - |
| 3937 | { | - |
| 3938 | return toLatin1_helper(unicode(), length()); executed: return toLatin1_helper(unicode(), length());Execution Count:18736048 | 18736048 |
| 3939 | } | - |
| 3940 | | - |
| 3941 | /*! | - |
| 3942 | \fn QByteArray QString::toAscii() const | - |
| 3943 | \deprecated | - |
| 3944 | Returns an 8-bit representation of the string as a QByteArray. | - |
| 3945 | | - |
| 3946 | This function does the same as toLatin1(). | - |
| 3947 | | - |
| 3948 | Note that, despite the name, this function does not necessarily return an US-ASCII | - |
| 3949 | (ANSI X3.4-1986) string and its result may not be US-ASCII compatible. | - |
| 3950 | | - |
| 3951 | \sa fromAscii(), toLatin1(), toUtf8(), toLocal8Bit(), QTextCodec | - |
| 3952 | */ | - |
| 3953 | | - |
| 3954 | #if !defined(Q_OS_MAC) && defined(Q_OS_UNIX) && !defined(QT_USE_ICU) | - |
| 3955 | static QByteArray toLocal8Bit_helper(const QChar *data, int length) | - |
| 3956 | { | - |
| 3957 | #ifndef QT_NO_TEXTCODEC | - |
| 3958 | QTextCodec *localeCodec = QTextCodec::codecForLocale(); | - |
| 3959 | if (localeCodec) | - |
| 3960 | return localeCodec->fromUnicode(data, length); | - |
| 3961 | #endif // QT_NO_TEXTCODEC | - |
| 3962 | return toLatin1_helper(data, length); | - |
| 3963 | } | - |
| 3964 | #endif | - |
| 3965 | | - |
| 3966 | /*! | - |
| 3967 | Returns the local 8-bit representation of the string as a | - |
| 3968 | QByteArray. The returned byte array is undefined if the string | - |
| 3969 | contains characters not supported by the local 8-bit encoding. | - |
| 3970 | | - |
| 3971 | QTextCodec::codecForLocale() is used to perform the conversion from | - |
| 3972 | Unicode. If the locale encoding could not be determined, this function | - |
| 3973 | does the same as toLatin1(). | - |
| 3974 | | - |
| 3975 | If this string contains any characters that cannot be encoded in the | - |
| 3976 | locale, the returned byte array is undefined. Those characters may be | - |
| 3977 | suppressed or replaced by another. | - |
| 3978 | | - |
| 3979 | \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec | - |
| 3980 | */ | - |
| 3981 | QByteArray QString::toLocal8Bit() const | - |
| 3982 | { | - |
| 3983 | #ifndef QT_NO_TEXTCODEC | - |
| 3984 | QTextCodec *localeCodec = QTextCodec::codecForLocale(); executed (the execution status of this line is deduced): QTextCodec *localeCodec = QTextCodec::codecForLocale(); | - |
| 3985 | if (localeCodec) partially evaluated: localeCodec| yes Evaluation Count:272820 | no Evaluation Count:0 |
| 0-272820 |
| 3986 | return localeCodec->fromUnicode(*this); executed: return localeCodec->fromUnicode(*this);Execution Count:272820 | 272820 |
| 3987 | #endif // QT_NO_TEXTCODEC | - |
| 3988 | return toLatin1(); never executed: return toLatin1(); | 0 |
| 3989 | } | - |
| 3990 | | - |
| 3991 | /*! | - |
| 3992 | Returns a UTF-8 representation of the string as a QByteArray. | - |
| 3993 | | - |
| 3994 | UTF-8 is a Unicode codec and can represent all characters in a Unicode | - |
| 3995 | string like QString. | - |
| 3996 | | - |
| 3997 | However, in the Unicode range, there are certain codepoints that are not | - |
| 3998 | considered characters. The Unicode standard reserves the last two | - |
| 3999 | codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, | - |
| 4000 | U+2FFFE, etc.), as well as 32 codepoints in the range U+FDD0..U+FDEF, | - |
| 4001 | inclusive, as non-characters. If any of those appear in the string, they | - |
| 4002 | may be discarded and will not appear in the UTF-8 representation, or they | - |
| 4003 | may be replaced by one or more replacement characters. | - |
| 4004 | | - |
| 4005 | \sa fromUtf8(), toLatin1(), toLocal8Bit(), QTextCodec | - |
| 4006 | */ | - |
| 4007 | QByteArray QString::toUtf8() const | - |
| 4008 | { | - |
| 4009 | if (isNull()) evaluated: isNull()| yes Evaluation Count:179 | yes Evaluation Count:25162 |
| 179-25162 |
| 4010 | return QByteArray(); executed: return QByteArray();Execution Count:179 | 179 |
| 4011 | | - |
| 4012 | return QUtf8::convertFromUnicode(constData(), length(), 0); executed: return QUtf8::convertFromUnicode(constData(), length(), 0);Execution Count:25162 | 25162 |
| 4013 | } | - |
| 4014 | | - |
| 4015 | /*! | - |
| 4016 | \since 4.2 | - |
| 4017 | | - |
| 4018 | Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>. | - |
| 4019 | | - |
| 4020 | UCS-4 is a Unicode codec and is lossless. All characters from this string | - |
| 4021 | can be encoded in UCS-4. The vector is not null terminated. | - |
| 4022 | | - |
| 4023 | \sa fromUtf8(), toUtf8(), toLatin1(), toLocal8Bit(), QTextCodec, fromUcs4(), toWCharArray() | - |
| 4024 | */ | - |
| 4025 | QVector<uint> QString::toUcs4() const | - |
| 4026 | { | - |
| 4027 | QVector<uint> v(length()); never executed (the execution status of this line is deduced): QVector<uint> v(length()); | - |
| 4028 | uint *a = v.data(); never executed (the execution status of this line is deduced): uint *a = v.data(); | - |
| 4029 | int len = toUcs4_helper(d->data(), length(), a); never executed (the execution status of this line is deduced): int len = toUcs4_helper(d->data(), length(), a); | - |
| 4030 | v.resize(len); never executed (the execution status of this line is deduced): v.resize(len); | - |
| 4031 | return v; never executed: return v; | 0 |
| 4032 | } | - |
| 4033 | | - |
| 4034 | QString::Data *QString::fromLatin1_helper(const char *str, int size) | - |
| 4035 | { | - |
| 4036 | Data *d; executed (the execution status of this line is deduced): Data *d; | - |
| 4037 | if (!str) { evaluated: !str| yes Evaluation Count:21 | yes Evaluation Count:5179272 |
| 21-5179272 |
| 4038 | d = Data::sharedNull(); executed (the execution status of this line is deduced): d = Data::sharedNull(); | - |
| 4039 | } else if (size == 0 || (!*str && size < 0)) { executed: }Execution Count:21 evaluated: size == 0| yes Evaluation Count:51005 | yes Evaluation Count:5128267 |
evaluated: !*str| yes Evaluation Count:315 | yes Evaluation Count:5127952 |
partially evaluated: size < 0| no Evaluation Count:0 | yes Evaluation Count:315 |
| 0-5128267 |
| 4040 | d = Data::allocate(0); executed (the execution status of this line is deduced): d = Data::allocate(0); | - |
| 4041 | } else { executed: }Execution Count:51005 | 51005 |
| 4042 | if (size < 0) partially evaluated: size < 0| no Evaluation Count:0 | yes Evaluation Count:5128268 |
| 0-5128268 |
| 4043 | size = qstrlen(str); never executed: size = qstrlen(str); | 0 |
| 4044 | d = Data::allocate(size + 1); executed (the execution status of this line is deduced): d = Data::allocate(size + 1); | - |
| 4045 | Q_CHECK_PTR(d); never executed: qBadAlloc(); executed: }Execution Count:5128267 partially evaluated: !(d)| no Evaluation Count:0 | yes Evaluation Count:5128269 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:5128267 |
| 0-5128269 |
| 4046 | d->size = size; executed (the execution status of this line is deduced): d->size = size; | - |
| 4047 | d->data()[size] = '\0'; executed (the execution status of this line is deduced): d->data()[size] = '\0'; | - |
| 4048 | ushort *dst = d->data(); executed (the execution status of this line is deduced): ushort *dst = d->data(); | - |
| 4049 | /* SIMD: | - |
| 4050 | * Unpacking with SSE has been shown to improve performance on recent CPUs | - |
| 4051 | * The same method gives no improvement with NEON. | - |
| 4052 | */ | - |
| 4053 | #if defined(__SSE2__) | - |
| 4054 | if (size >= 16) { evaluated: size >= 16| yes Evaluation Count:835959 | yes Evaluation Count:4292309 |
| 835959-4292309 |
| 4055 | int chunkCount = size >> 4; // divided by 16 executed (the execution status of this line is deduced): int chunkCount = size >> 4; | - |
| 4056 | const __m128i nullMask = _mm_set1_epi32(0); executed (the execution status of this line is deduced): const __m128i nullMask = _mm_set1_epi32(0); | - |
| 4057 | for (int i = 0; i < chunkCount; ++i) { evaluated: i < chunkCount| yes Evaluation Count:2470441 | yes Evaluation Count:835959 |
| 835959-2470441 |
| 4058 | const __m128i chunk = _mm_loadu_si128((__m128i*)str); // load executed (the execution status of this line is deduced): const __m128i chunk = _mm_loadu_si128((__m128i*)str); | - |
| 4059 | str += 16; executed (the execution status of this line is deduced): str += 16; | - |
| 4060 | | - |
| 4061 | // unpack the first 8 bytes, padding with zeros | - |
| 4062 | const __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullMask); executed (the execution status of this line is deduced): const __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullMask); | - |
| 4063 | _mm_storeu_si128((__m128i*)dst, firstHalf); // store executed (the execution status of this line is deduced): _mm_storeu_si128((__m128i*)dst, firstHalf); | - |
| 4064 | dst += 8; executed (the execution status of this line is deduced): dst += 8; | - |
| 4065 | | - |
| 4066 | // unpack the last 8 bytes, padding with zeros | - |
| 4067 | const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask); executed (the execution status of this line is deduced): const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask); | - |
| 4068 | _mm_storeu_si128((__m128i*)dst, secondHalf); // store executed (the execution status of this line is deduced): _mm_storeu_si128((__m128i*)dst, secondHalf); | - |
| 4069 | dst += 8; executed (the execution status of this line is deduced): dst += 8; | - |
| 4070 | } executed: }Execution Count:2470441 | 2470441 |
| 4071 | size = size % 16; executed (the execution status of this line is deduced): size = size % 16; | - |
| 4072 | } executed: }Execution Count:835959 | 835959 |
| 4073 | #endif | - |
| 4074 | while (size--) evaluated: size--| yes Evaluation Count:33993822 | yes Evaluation Count:5128269 |
| 5128269-33993822 |
| 4075 | *dst++ = (uchar)*str++; executed: *dst++ = (uchar)*str++;Execution Count:33993824 | 33993824 |
| 4076 | } executed: }Execution Count:5128269 | 5128269 |
| 4077 | return d; executed: return d;Execution Count:5179295 | 5179295 |
| 4078 | } | - |
| 4079 | | - |
| 4080 | QString::Data *QString::fromAscii_helper(const char *str, int size) | - |
| 4081 | { | - |
| 4082 | QString s = fromUtf8(str, size); executed (the execution status of this line is deduced): QString s = fromUtf8(str, size); | - |
| 4083 | s.d->ref.ref(); executed (the execution status of this line is deduced): s.d->ref.ref(); | - |
| 4084 | return s.d; executed: return s.d;Execution Count:4416426 | 4416426 |
| 4085 | } | - |
| 4086 | | - |
| 4087 | /*! \fn QString QString::fromLatin1(const char *str, int size) | - |
| 4088 | Returns a QString initialized with the first \a size characters | - |
| 4089 | of the Latin-1 string \a str. | - |
| 4090 | | - |
| 4091 | If \a size is -1 (default), it is taken to be strlen(\a | - |
| 4092 | str). | - |
| 4093 | | - |
| 4094 | \sa toLatin1(), fromUtf8(), fromLocal8Bit() | - |
| 4095 | */ | - |
| 4096 | | - |
| 4097 | | - |
| 4098 | /*! \fn QString QString::fromLocal8Bit(const char *str, int size) | - |
| 4099 | Returns a QString initialized with the first \a size characters | - |
| 4100 | of the 8-bit string \a str. | - |
| 4101 | | - |
| 4102 | If \a size is -1 (default), it is taken to be strlen(\a | - |
| 4103 | str). | - |
| 4104 | | - |
| 4105 | QTextCodec::codecForLocale() is used to perform the conversion. | - |
| 4106 | | - |
| 4107 | \sa toLocal8Bit(), fromLatin1(), fromUtf8() | - |
| 4108 | */ | - |
| 4109 | QString QString::fromLocal8Bit_helper(const char *str, int size) | - |
| 4110 | { | - |
| 4111 | if (!str) partially evaluated: !str| no Evaluation Count:0 | yes Evaluation Count:187532 |
| 0-187532 |
| 4112 | return QString(); never executed: return QString(); | 0 |
| 4113 | if (size == 0 || (!*str && size < 0)) { evaluated: size == 0| yes Evaluation Count:3088 | yes Evaluation Count:184444 |
evaluated: !*str| yes Evaluation Count:3 | yes Evaluation Count:184440 |
partially evaluated: size < 0| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-184444 |
| 4114 | QStringDataPtr empty = { Data::allocate(0) }; executed (the execution status of this line is deduced): QStringDataPtr empty = { Data::allocate(0) }; | - |
| 4115 | return QString(empty); executed: return QString(empty);Execution Count:3088 | 3088 |
| 4116 | } | - |
| 4117 | #if !defined(QT_NO_TEXTCODEC) | - |
| 4118 | if (size < 0) partially evaluated: size < 0| no Evaluation Count:0 | yes Evaluation Count:184441 |
| 0-184441 |
| 4119 | size = qstrlen(str); never executed: size = qstrlen(str); | 0 |
| 4120 | QTextCodec *codec = QTextCodec::codecForLocale(); executed (the execution status of this line is deduced): QTextCodec *codec = QTextCodec::codecForLocale(); | - |
| 4121 | if (codec) partially evaluated: codec| yes Evaluation Count:184420 | no Evaluation Count:0 |
| 0-184420 |
| 4122 | return codec->toUnicode(str, size); executed: return codec->toUnicode(str, size);Execution Count:184432 | 184432 |
| 4123 | #endif // !QT_NO_TEXTCODEC | - |
| 4124 | return fromLatin1(str, size); never executed: return fromLatin1(str, size); | 0 |
| 4125 | } | - |
| 4126 | | - |
| 4127 | /*! \fn QString QString::fromAscii(const char *, int size); | - |
| 4128 | \deprecated | - |
| 4129 | | - |
| 4130 | Returns a QString initialized with the first \a size characters | - |
| 4131 | from the string \a str. | - |
| 4132 | | - |
| 4133 | If \a size is -1 (default), it is taken to be strlen(\a | - |
| 4134 | str). | - |
| 4135 | | - |
| 4136 | This function does the same as fromLatin1(). | - |
| 4137 | | - |
| 4138 | \sa toAscii(), fromLatin1(), fromUtf8(), fromLocal8Bit() | - |
| 4139 | */ | - |
| 4140 | | - |
| 4141 | /*! \fn QString QString::fromUtf8(const char *str, int size) | - |
| 4142 | Returns a QString initialized with the first \a size bytes | - |
| 4143 | of the UTF-8 string \a str. | - |
| 4144 | | - |
| 4145 | If \a size is -1 (default), it is taken to be strlen(\a | - |
| 4146 | str). | - |
| 4147 | | - |
| 4148 | UTF-8 is a Unicode codec and can represent all characters in a Unicode | - |
| 4149 | string like QString. However, invalid sequences are possible with UTF-8 | - |
| 4150 | and, if any such are found, they will be replaced with one or more | - |
| 4151 | "replacement characters", or suppressed. These include non-Unicode | - |
| 4152 | sequences, non-characters, overlong sequences or surrogate codepoints | - |
| 4153 | encoded into UTF-8. | - |
| 4154 | | - |
| 4155 | Non-characters are codepoints that the Unicode standard reserves and must | - |
| 4156 | not be used in text interchange. They are the last two codepoints in each | - |
| 4157 | Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, etc.), as well | - |
| 4158 | as 32 codepoints in the range U+FDD0..U+FDEF, inclusive. | - |
| 4159 | | - |
| 4160 | \sa toUtf8(), fromLatin1(), fromLocal8Bit() | - |
| 4161 | */ | - |
| 4162 | QString QString::fromUtf8_helper(const char *str, int size) | - |
| 4163 | { | - |
| 4164 | if (!str) evaluated: !str| yes Evaluation Count:5021 | yes Evaluation Count:20545912 |
| 5021-20545912 |
| 4165 | return QString(); executed: return QString();Execution Count:5021 | 5021 |
| 4166 | | - |
| 4167 | Q_ASSERT(size != -1); executed (the execution status of this line is deduced): qt_noop(); | - |
| 4168 | return QUtf8::convertToUnicode(str, size, 0); executed: return QUtf8::convertToUnicode(str, size, 0);Execution Count:20545904 | 20545904 |
| 4169 | } | - |
| 4170 | | - |
| 4171 | /*! | - |
| 4172 | Returns a QString initialized with the first \a size characters | - |
| 4173 | of the Unicode string \a unicode (ISO-10646-UTF-16 encoded). | - |
| 4174 | | - |
| 4175 | If \a size is -1 (default), \a unicode must be terminated | - |
| 4176 | with a 0. | - |
| 4177 | | - |
| 4178 | This function checks for a Byte Order Mark (BOM). If it is missing, | - |
| 4179 | host byte order is assumed. | - |
| 4180 | | - |
| 4181 | This function is slow compared to the other Unicode conversions. | - |
| 4182 | Use QString(const QChar *, int) or QString(const QChar *) if possible. | - |
| 4183 | | - |
| 4184 | QString makes a deep copy of the Unicode data. | - |
| 4185 | | - |
| 4186 | \sa utf16(), setUtf16() | - |
| 4187 | */ | - |
| 4188 | QString QString::fromUtf16(const ushort *unicode, int size) | - |
| 4189 | { | - |
| 4190 | if (!unicode) partially evaluated: !unicode| no Evaluation Count:0 | yes Evaluation Count:106 |
| 0-106 |
| 4191 | return QString(); never executed: return QString(); | 0 |
| 4192 | if (size < 0) { evaluated: size < 0| yes Evaluation Count:69 | yes Evaluation Count:37 |
| 37-69 |
| 4193 | size = 0; executed (the execution status of this line is deduced): size = 0; | - |
| 4194 | while (unicode[size] != 0) evaluated: unicode[size] != 0| yes Evaluation Count:172 | yes Evaluation Count:69 |
| 69-172 |
| 4195 | ++size; executed: ++size;Execution Count:172 | 172 |
| 4196 | } executed: }Execution Count:69 | 69 |
| 4197 | return QUtf16::convertToUnicode((const char *)unicode, size*2, 0); executed: return QUtf16::convertToUnicode((const char *)unicode, size*2, 0);Execution Count:106 | 106 |
| 4198 | } | - |
| 4199 | | - |
| 4200 | | - |
| 4201 | /*! | - |
| 4202 | \since 4.2 | - |
| 4203 | | - |
| 4204 | Returns a QString initialized with the first \a size characters | - |
| 4205 | of the Unicode string \a unicode (ISO-10646-UCS-4 encoded). | - |
| 4206 | | - |
| 4207 | If \a size is -1 (default), \a unicode must be terminated | - |
| 4208 | with a 0. | - |
| 4209 | | - |
| 4210 | \sa toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray() | - |
| 4211 | */ | - |
| 4212 | QString QString::fromUcs4(const uint *unicode, int size) | - |
| 4213 | { | - |
| 4214 | if (!unicode) partially evaluated: !unicode| no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
| 4215 | return QString(); never executed: return QString(); | 0 |
| 4216 | if (size < 0) { evaluated: size < 0| yes Evaluation Count:2 | yes Evaluation Count:18 |
| 2-18 |
| 4217 | size = 0; executed (the execution status of this line is deduced): size = 0; | - |
| 4218 | while (unicode[size] != 0) evaluated: unicode[size] != 0| yes Evaluation Count:28 | yes Evaluation Count:2 |
| 2-28 |
| 4219 | ++size; executed: ++size;Execution Count:28 | 28 |
| 4220 | } executed: }Execution Count:2 | 2 |
| 4221 | return QUtf32::convertToUnicode((const char *)unicode, size*4, 0); executed: return QUtf32::convertToUnicode((const char *)unicode, size*4, 0);Execution Count:20 | 20 |
| 4222 | } | - |
| 4223 | | - |
| 4224 | /*! | - |
| 4225 | Resizes the string to \a size characters and copies \a unicode | - |
| 4226 | into the string. | - |
| 4227 | | - |
| 4228 | If \a unicode is 0, nothing is copied, but the string is still | - |
| 4229 | resized to \a size. | - |
| 4230 | | - |
| 4231 | \sa unicode(), setUtf16() | - |
| 4232 | */ | - |
| 4233 | QString& QString::setUnicode(const QChar *unicode, int size) | - |
| 4234 | { | - |
| 4235 | resize(size); never executed (the execution status of this line is deduced): resize(size); | - |
| 4236 | if (unicode && size) never evaluated: unicode never evaluated: size | 0 |
| 4237 | memcpy(d->data(), unicode, size * sizeof(QChar)); never executed: memcpy(d->data(), unicode, size * sizeof(QChar)); | 0 |
| 4238 | return *this; never executed: return *this; | 0 |
| 4239 | } | - |
| 4240 | | - |
| 4241 | /*! | - |
| 4242 | \fn QString &QString::setUtf16(const ushort *unicode, int size) | - |
| 4243 | | - |
| 4244 | Resizes the string to \a size characters and copies \a unicode | - |
| 4245 | into the string. | - |
| 4246 | | - |
| 4247 | If \a unicode is 0, nothing is copied, but the string is still | - |
| 4248 | resized to \a size. | - |
| 4249 | | - |
| 4250 | Note that unlike fromUtf16(), this function does not consider BOMs and | - |
| 4251 | possibly differing byte ordering. | - |
| 4252 | | - |
| 4253 | \sa utf16(), setUnicode() | - |
| 4254 | */ | - |
| 4255 | | - |
| 4256 | /*! | - |
| 4257 | Returns a string that has whitespace removed from the start | - |
| 4258 | and the end, and that has each sequence of internal whitespace | - |
| 4259 | replaced with a single space. | - |
| 4260 | | - |
| 4261 | Whitespace means any character for which QChar::isSpace() returns | - |
| 4262 | true. This includes the ASCII characters '\\t', '\\n', '\\v', | - |
| 4263 | '\\f', '\\r', and ' '. | - |
| 4264 | | - |
| 4265 | Example: | - |
| 4266 | | - |
| 4267 | \snippet qstring/main.cpp 57 | - |
| 4268 | | - |
| 4269 | \sa trimmed() | - |
| 4270 | */ | - |
| 4271 | QString QString::simplified() const | - |
| 4272 | { | - |
| 4273 | if (d->size == 0) evaluated: d->size == 0| yes Evaluation Count:1680 | yes Evaluation Count:78710 |
| 1680-78710 |
| 4274 | return *this; executed: return *this;Execution Count:1680 | 1680 |
| 4275 | | - |
| 4276 | const QChar * const start = reinterpret_cast<QChar *>(d->data()); executed (the execution status of this line is deduced): const QChar * const start = reinterpret_cast<QChar *>(d->data()); | - |
| 4277 | const QChar *from = start; executed (the execution status of this line is deduced): const QChar *from = start; | - |
| 4278 | const QChar *fromEnd = start + d->size; executed (the execution status of this line is deduced): const QChar *fromEnd = start + d->size; | - |
| 4279 | forever { executed (the execution status of this line is deduced): for(;;) { | - |
| 4280 | QChar ch = *from; executed (the execution status of this line is deduced): QChar ch = *from; | - |
| 4281 | if (!ch.isSpace()) evaluated: !ch.isSpace()| yes Evaluation Count:42188 | yes Evaluation Count:210344 |
| 42188-210344 |
| 4282 | break; executed: break;Execution Count:42188 | 42188 |
| 4283 | if (++from == fromEnd) { evaluated: ++from == fromEnd| yes Evaluation Count:36522 | yes Evaluation Count:173822 |
| 36522-173822 |
| 4284 | // All-whitespace string | - |
| 4285 | QStringDataPtr empty = { Data::allocate(0) }; executed (the execution status of this line is deduced): QStringDataPtr empty = { Data::allocate(0) }; | - |
| 4286 | return QString(empty); executed: return QString(empty);Execution Count:36522 | 36522 |
| 4287 | } | - |
| 4288 | } executed: }Execution Count:173822 | 173822 |
| 4289 | // This loop needs no underflow check, as we already determined that | - |
| 4290 | // the string contains non-whitespace. If the string has exactly one | - |
| 4291 | // non-whitespace, it will be checked twice - we can live with that. | - |
| 4292 | while (fromEnd[-1].isSpace()) evaluated: fromEnd[-1].isSpace()| yes Evaluation Count:12399 | yes Evaluation Count:42188 |
| 12399-42188 |
| 4293 | fromEnd--; executed: fromEnd--;Execution Count:12399 | 12399 |
| 4294 | // The rest of the function depends on the fact that we already know | - |
| 4295 | // that the last character in the source is no whitespace. | - |
| 4296 | const QChar *copyFrom = from; executed (the execution status of this line is deduced): const QChar *copyFrom = from; | - |
| 4297 | int copyCount; executed (the execution status of this line is deduced): int copyCount; | - |
| 4298 | forever { executed (the execution status of this line is deduced): for(;;) { | - |
| 4299 | if (++from == fromEnd) { evaluated: ++from == fromEnd| yes Evaluation Count:39488 | yes Evaluation Count:683988 |
| 39488-683988 |
| 4300 | // Only leading and/or trailing whitespace, if any at all | - |
| 4301 | return mid(copyFrom - start, from - copyFrom); executed: return mid(copyFrom - start, from - copyFrom);Execution Count:39488 | 39488 |
| 4302 | } | - |
| 4303 | QChar ch = *from; executed (the execution status of this line is deduced): QChar ch = *from; | - |
| 4304 | if (!ch.isSpace()) evaluated: !ch.isSpace()| yes Evaluation Count:649853 | yes Evaluation Count:34135 |
| 34135-649853 |
| 4305 | continue; executed: continue;Execution Count:649853 | 649853 |
| 4306 | if (ch != QLatin1Char(' ')) { evaluated: ch != QLatin1Char(' ')| yes Evaluation Count:1658 | yes Evaluation Count:32477 |
| 1658-32477 |
| 4307 | copyCount = from - copyFrom; executed (the execution status of this line is deduced): copyCount = from - copyFrom; | - |
| 4308 | break; executed: break;Execution Count:1658 | 1658 |
| 4309 | } | - |
| 4310 | ch = *++from; executed (the execution status of this line is deduced): ch = *++from; | - |
| 4311 | if (ch.isSpace()) { evaluated: ch.isSpace()| yes Evaluation Count:1042 | yes Evaluation Count:31435 |
| 1042-31435 |
| 4312 | copyCount = from - copyFrom - 1; executed (the execution status of this line is deduced): copyCount = from - copyFrom - 1; | - |
| 4313 | break; executed: break;Execution Count:1042 | 1042 |
| 4314 | } | - |
| 4315 | } executed: }Execution Count:31435 | 31435 |
| 4316 | // 'from' now points at the non-trailing whitespace which made the | - |
| 4317 | // string not simplified in the first place. 'copyCount' is the number | - |
| 4318 | // of already simplified characters - at least one, obviously - | - |
| 4319 | // without a trailing space. | - |
| 4320 | QString result((fromEnd - from) + copyCount, Qt::Uninitialized); executed (the execution status of this line is deduced): QString result((fromEnd - from) + copyCount, Qt::Uninitialized); | - |
| 4321 | QChar *to = reinterpret_cast<QChar *>(result.d->data()); executed (the execution status of this line is deduced): QChar *to = reinterpret_cast<QChar *>(result.d->data()); | - |
| 4322 | ::memcpy(to, copyFrom, copyCount * 2); executed (the execution status of this line is deduced): ::memcpy(to, copyFrom, copyCount * 2); | - |
| 4323 | to += copyCount; executed (the execution status of this line is deduced): to += copyCount; | - |
| 4324 | fromEnd--; executed (the execution status of this line is deduced): fromEnd--; | - |
| 4325 | QChar ch; executed (the execution status of this line is deduced): QChar ch; | - |
| 4326 | forever { executed (the execution status of this line is deduced): for(;;) { | - |
| 4327 | *to++ = QLatin1Char(' '); executed (the execution status of this line is deduced): *to++ = QLatin1Char(' '); | - |
| 4328 | do { | - |
| 4329 | ch = *++from; executed (the execution status of this line is deduced): ch = *++from; | - |
| 4330 | } while (ch.isSpace()); executed: }Execution Count:62937 evaluated: ch.isSpace()| yes Evaluation Count:18816 | yes Evaluation Count:44121 |
| 18816-62937 |
| 4331 | if (from == fromEnd) evaluated: from == fromEnd| yes Evaluation Count:306 | yes Evaluation Count:43815 |
| 306-43815 |
| 4332 | break; executed: break;Execution Count:306 | 306 |
| 4333 | do { | - |
| 4334 | *to++ = ch; executed (the execution status of this line is deduced): *to++ = ch; | - |
| 4335 | ch = *++from; executed (the execution status of this line is deduced): ch = *++from; | - |
| 4336 | if (from == fromEnd) evaluated: from == fromEnd| yes Evaluation Count:2394 | yes Evaluation Count:258519 |
| 2394-258519 |
| 4337 | goto done; executed: goto done;Execution Count:2394 | 2394 |
| 4338 | } while (!ch.isSpace()); executed: }Execution Count:258519 evaluated: !ch.isSpace()| yes Evaluation Count:217098 | yes Evaluation Count:41421 |
| 41421-258519 |
| 4339 | | - |
| 4340 | } executed: }Execution Count:41421 | 41421 |
| 4341 | done: code before this statement executed: done:Execution Count:306 | 306 |
| 4342 | *to++ = ch; executed (the execution status of this line is deduced): *to++ = ch; | - |
| 4343 | result.truncate(to - reinterpret_cast<QChar *>(result.d->data())); executed (the execution status of this line is deduced): result.truncate(to - reinterpret_cast<QChar *>(result.d->data())); | - |
| 4344 | return result; executed: return result;Execution Count:2700 | 2700 |
| 4345 | } | - |
| 4346 | | - |
| 4347 | /*! | - |
| 4348 | Returns a string that has whitespace removed from the start and | - |
| 4349 | the end. | - |
| 4350 | | - |
| 4351 | Whitespace means any character for which QChar::isSpace() returns | - |
| 4352 | true. This includes the ASCII characters '\\t', '\\n', '\\v', | - |
| 4353 | '\\f', '\\r', and ' '. | - |
| 4354 | | - |
| 4355 | Example: | - |
| 4356 | | - |
| 4357 | \snippet qstring/main.cpp 82 | - |
| 4358 | | - |
| 4359 | Unlike simplified(), trimmed() leaves internal whitespace alone. | - |
| 4360 | | - |
| 4361 | \sa simplified() | - |
| 4362 | */ | - |
| 4363 | QString QString::trimmed() const | - |
| 4364 | { | - |
| 4365 | if (d->size == 0) evaluated: d->size == 0| yes Evaluation Count:2810 | yes Evaluation Count:14584 |
| 2810-14584 |
| 4366 | return *this; executed: return *this;Execution Count:2810 | 2810 |
| 4367 | const QChar *s = (const QChar*)d->data(); executed (the execution status of this line is deduced): const QChar *s = (const QChar*)d->data(); | - |
| 4368 | if (!s->isSpace() && !s[d->size-1].isSpace()) evaluated: !s->isSpace()| yes Evaluation Count:13849 | yes Evaluation Count:735 |
evaluated: !s[d->size-1].isSpace()| yes Evaluation Count:12023 | yes Evaluation Count:1826 |
| 735-13849 |
| 4369 | return *this; executed: return *this;Execution Count:12023 | 12023 |
| 4370 | int start = 0; executed (the execution status of this line is deduced): int start = 0; | - |
| 4371 | int end = d->size - 1; executed (the execution status of this line is deduced): int end = d->size - 1; | - |
| 4372 | while (start<=end && s[start].isSpace()) // skip white space from start evaluated: start<=end| yes Evaluation Count:4330 | yes Evaluation Count:11 |
evaluated: s[start].isSpace()| yes Evaluation Count:1780 | yes Evaluation Count:2550 |
| 11-4330 |
| 4373 | start++; executed: start++;Execution Count:1780 | 1780 |
| 4374 | if (start <= end) { // only white space evaluated: start <= end| yes Evaluation Count:2550 | yes Evaluation Count:11 |
| 11-2550 |
| 4375 | while (end && s[end].isSpace()) // skip white space from end evaluated: end| yes Evaluation Count:6600 | yes Evaluation Count:3 |
evaluated: s[end].isSpace()| yes Evaluation Count:4053 | yes Evaluation Count:2547 |
| 3-6600 |
| 4376 | end--; executed: end--;Execution Count:4053 | 4053 |
| 4377 | } executed: }Execution Count:2550 | 2550 |
| 4378 | int l = end - start + 1; executed (the execution status of this line is deduced): int l = end - start + 1; | - |
| 4379 | if (l <= 0) { evaluated: l <= 0| yes Evaluation Count:11 | yes Evaluation Count:2550 |
| 11-2550 |
| 4380 | QStringDataPtr empty = { Data::allocate(0) }; executed (the execution status of this line is deduced): QStringDataPtr empty = { Data::allocate(0) }; | - |
| 4381 | return QString(empty); executed: return QString(empty);Execution Count:11 | 11 |
| 4382 | } | - |
| 4383 | return QString(s + start, l); executed: return QString(s + start, l);Execution Count:2550 | 2550 |
| 4384 | } | - |
| 4385 | | - |
| 4386 | /*! \fn const QChar QString::at(int position) const | - |
| 4387 | | - |
| 4388 | Returns the character at the given index \a position in the | - |
| 4389 | string. | - |
| 4390 | | - |
| 4391 | The \a position must be a valid index position in the string | - |
| 4392 | (i.e., 0 <= \a position < size()). | - |
| 4393 | | - |
| 4394 | \sa operator[]() | - |
| 4395 | */ | - |
| 4396 | | - |
| 4397 | /*! | - |
| 4398 | \fn QCharRef QString::operator[](int position) | - |
| 4399 | | - |
| 4400 | Returns the character at the specified \a position in the string as a | - |
| 4401 | modifiable reference. | - |
| 4402 | | - |
| 4403 | Example: | - |
| 4404 | | - |
| 4405 | \snippet qstring/main.cpp 85 | - |
| 4406 | | - |
| 4407 | The return value is of type QCharRef, a helper class for QString. | - |
| 4408 | When you get an object of type QCharRef, you can use it as if it | - |
| 4409 | were a QChar &. If you assign to it, the assignment will apply to | - |
| 4410 | the character in the QString from which you got the reference. | - |
| 4411 | | - |
| 4412 | \sa at() | - |
| 4413 | */ | - |
| 4414 | | - |
| 4415 | /*! | - |
| 4416 | \fn const QChar QString::operator[](int position) const | - |
| 4417 | | - |
| 4418 | \overload operator[]() | - |
| 4419 | */ | - |
| 4420 | | - |
| 4421 | /*! \fn QCharRef QString::operator[](uint position) | - |
| 4422 | | - |
| 4423 | \overload operator[]() | - |
| 4424 | | - |
| 4425 | Returns the character at the specified \a position in the string as a | - |
| 4426 | modifiable reference. Equivalent to \c at(position). | - |
| 4427 | */ | - |
| 4428 | | - |
| 4429 | /*! \fn const QChar QString::operator[](uint position) const | - |
| 4430 | | - |
| 4431 | \overload operator[]() | - |
| 4432 | */ | - |
| 4433 | | - |
| 4434 | /*! | - |
| 4435 | \fn void QString::truncate(int position) | - |
| 4436 | | - |
| 4437 | Truncates the string at the given \a position index. | - |
| 4438 | | - |
| 4439 | If the specified \a position index is beyond the end of the | - |
| 4440 | string, nothing happens. | - |
| 4441 | | - |
| 4442 | Example: | - |
| 4443 | | - |
| 4444 | \snippet qstring/main.cpp 83 | - |
| 4445 | | - |
| 4446 | If \a position is negative, it is equivalent to passing zero. | - |
| 4447 | | - |
| 4448 | \sa chop(), resize(), left() | - |
| 4449 | */ | - |
| 4450 | | - |
| 4451 | void QString::truncate(int pos) | - |
| 4452 | { | - |
| 4453 | if (pos < d->size) evaluated: pos < d->size| yes Evaluation Count:61892325 | yes Evaluation Count:17997 |
| 17997-61892325 |
| 4454 | resize(pos); executed: resize(pos);Execution Count:61892313 | 61892313 |
| 4455 | } executed: }Execution Count:61910330 | 61910330 |
| 4456 | | - |
| 4457 | | - |
| 4458 | /*! | - |
| 4459 | Removes \a n characters from the end of the string. | - |
| 4460 | | - |
| 4461 | If \a n is greater than size(), the result is an empty string. | - |
| 4462 | | - |
| 4463 | Example: | - |
| 4464 | \snippet qstring/main.cpp 15 | - |
| 4465 | | - |
| 4466 | If you want to remove characters from the \e beginning of the | - |
| 4467 | string, use remove() instead. | - |
| 4468 | | - |
| 4469 | \sa truncate(), resize(), remove() | - |
| 4470 | */ | - |
| 4471 | void QString::chop(int n) | - |
| 4472 | { | - |
| 4473 | if (n > 0) evaluated: n > 0| yes Evaluation Count:21425 | yes Evaluation Count:6 |
| 6-21425 |
| 4474 | resize(d->size - n); executed: resize(d->size - n);Execution Count:21425 | 21425 |
| 4475 | } executed: }Execution Count:21431 | 21431 |
| 4476 | | - |
| 4477 | /*! | - |
| 4478 | Sets every character in the string to character \a ch. If \a size | - |
| 4479 | is different from -1 (default), the string is resized to \a | - |
| 4480 | size beforehand. | - |
| 4481 | | - |
| 4482 | Example: | - |
| 4483 | | - |
| 4484 | \snippet qstring/main.cpp 21 | - |
| 4485 | | - |
| 4486 | \sa resize() | - |
| 4487 | */ | - |
| 4488 | | - |
| 4489 | QString& QString::fill(QChar ch, int size) | - |
| 4490 | { | - |
| 4491 | resize(size < 0 ? d->size : size); executed (the execution status of this line is deduced): resize(size < 0 ? d->size : size); | - |
| 4492 | if (d->size) { evaluated: d->size| yes Evaluation Count:11528 | yes Evaluation Count:5438 |
| 5438-11528 |
| 4493 | QChar *i = (QChar*)d->data() + d->size; executed (the execution status of this line is deduced): QChar *i = (QChar*)d->data() + d->size; | - |
| 4494 | QChar *b = (QChar*)d->data(); executed (the execution status of this line is deduced): QChar *b = (QChar*)d->data(); | - |
| 4495 | while (i != b) evaluated: i != b| yes Evaluation Count:2697342 | yes Evaluation Count:11528 |
| 11528-2697342 |
| 4496 | *--i = ch; executed: *--i = ch;Execution Count:2697342 | 2697342 |
| 4497 | } executed: }Execution Count:11528 | 11528 |
| 4498 | return *this; executed: return *this;Execution Count:16966 | 16966 |
| 4499 | } | - |
| 4500 | | - |
| 4501 | /*! | - |
| 4502 | \fn int QString::length() const | - |
| 4503 | | - |
| 4504 | Returns the number of characters in this string. Equivalent to | - |
| 4505 | size(). | - |
| 4506 | | - |
| 4507 | \sa resize() | - |
| 4508 | */ | - |
| 4509 | | - |
| 4510 | /*! | - |
| 4511 | \fn int QString::size() const | - |
| 4512 | | - |
| 4513 | Returns the number of characters in this string. | - |
| 4514 | | - |
| 4515 | The last character in the string is at position size() - 1. In | - |
| 4516 | addition, QString ensures that the character at position size() | - |
| 4517 | is always '\\0', so that you can use the return value of data() | - |
| 4518 | and constData() as arguments to functions that expect | - |
| 4519 | '\\0'-terminated strings. | - |
| 4520 | | - |
| 4521 | Example: | - |
| 4522 | | - |
| 4523 | \snippet qstring/main.cpp 58 | - |
| 4524 | | - |
| 4525 | \sa isEmpty(), resize() | - |
| 4526 | */ | - |
| 4527 | | - |
| 4528 | /*! \fn bool QString::isNull() const | - |
| 4529 | | - |
| 4530 | Returns true if this string is null; otherwise returns false. | - |
| 4531 | | - |
| 4532 | Example: | - |
| 4533 | | - |
| 4534 | \snippet qstring/main.cpp 28 | - |
| 4535 | | - |
| 4536 | Qt makes a distinction between null strings and empty strings for | - |
| 4537 | historical reasons. For most applications, what matters is | - |
| 4538 | whether or not a string contains any data, and this can be | - |
| 4539 | determined using the isEmpty() function. | - |
| 4540 | | - |
| 4541 | \sa isEmpty() | - |
| 4542 | */ | - |
| 4543 | | - |
| 4544 | /*! \fn bool QString::isEmpty() const | - |
| 4545 | | - |
| 4546 | Returns true if the string has no characters; otherwise returns | - |
| 4547 | false. | - |
| 4548 | | - |
| 4549 | Example: | - |
| 4550 | | - |
| 4551 | \snippet qstring/main.cpp 27 | - |
| 4552 | | - |
| 4553 | \sa size() | - |
| 4554 | */ | - |
| 4555 | | - |
| 4556 | /*! \fn QString &QString::operator+=(const QString &other) | - |
| 4557 | | - |
| 4558 | Appends the string \a other onto the end of this string and | - |
| 4559 | returns a reference to this string. | - |
| 4560 | | - |
| 4561 | Example: | - |
| 4562 | | - |
| 4563 | \snippet qstring/main.cpp 84 | - |
| 4564 | | - |
| 4565 | This operation is typically very fast (\l{constant time}), | - |
| 4566 | because QString preallocates extra space at the end of the string | - |
| 4567 | data so it can grow without reallocating the entire string each | - |
| 4568 | time. | - |
| 4569 | | - |
| 4570 | \sa append(), prepend() | - |
| 4571 | */ | - |
| 4572 | | - |
| 4573 | /*! \fn QString &QString::operator+=(QLatin1String str) | - |
| 4574 | | - |
| 4575 | \overload operator+=() | - |
| 4576 | | - |
| 4577 | Appends the Latin-1 string \a str to this string. | - |
| 4578 | */ | - |
| 4579 | | - |
| 4580 | /*! \fn QString &QString::operator+=(const QByteArray &ba) | - |
| 4581 | | - |
| 4582 | \overload operator+=() | - |
| 4583 | | - |
| 4584 | Appends the byte array \a ba to this string. The byte array is converted | - |
| 4585 | to Unicode using the fromUtf8() function. If any NUL characters ('\\0') | - |
| 4586 | are embedded in the \a ba byte array, they will be included in the | - |
| 4587 | transformation. | - |
| 4588 | | - |
| 4589 | You can disable this function by defining \c | - |
| 4590 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 4591 | can be useful if you want to ensure that all user-visible strings | - |
| 4592 | go through QObject::tr(), for example. | - |
| 4593 | */ | - |
| 4594 | | - |
| 4595 | /*! \fn QString &QString::operator+=(const char *str) | - |
| 4596 | | - |
| 4597 | \overload operator+=() | - |
| 4598 | | - |
| 4599 | Appends the string \a str to this string. The const char pointer | - |
| 4600 | is converted to Unicode using the fromUtf8() function. | - |
| 4601 | | - |
| 4602 | You can disable this function by defining \c QT_NO_CAST_FROM_ASCII | - |
| 4603 | when you compile your applications. This can be useful if you want | - |
| 4604 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 4605 | for example. | - |
| 4606 | */ | - |
| 4607 | | - |
| 4608 | /*! \fn QString &QString::operator+=(const QStringRef &str) | - |
| 4609 | | - |
| 4610 | \overload operator+=() | - |
| 4611 | | - |
| 4612 | Appends the string section referenced by \a str to this string. | - |
| 4613 | */ | - |
| 4614 | | - |
| 4615 | /*! \fn QString &QString::operator+=(char ch) | - |
| 4616 | | - |
| 4617 | \overload operator+=() | - |
| 4618 | | - |
| 4619 | Appends the character \a ch to this string. Note that the character is | - |
| 4620 | converted to Unicode using the fromLatin1() function, unlike other 8-bit | - |
| 4621 | functions that operate on UTF-8 data. | - |
| 4622 | | - |
| 4623 | You can disable this function by defining \c QT_NO_CAST_FROM_ASCII | - |
| 4624 | when you compile your applications. This can be useful if you want | - |
| 4625 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 4626 | for example. | - |
| 4627 | */ | - |
| 4628 | | - |
| 4629 | /*! \fn QString &QString::operator+=(QChar ch) | - |
| 4630 | | - |
| 4631 | \overload operator+=() | - |
| 4632 | | - |
| 4633 | Appends the character \a ch to the string. | - |
| 4634 | */ | - |
| 4635 | | - |
| 4636 | /*! \fn QString &QString::operator+=(QChar::SpecialCharacter c) | - |
| 4637 | | - |
| 4638 | \overload operator+=() | - |
| 4639 | | - |
| 4640 | \internal | - |
| 4641 | */ | - |
| 4642 | | - |
| 4643 | /*! | - |
| 4644 | \fn bool operator==(const char *s1, const QString &s2) | - |
| 4645 | | - |
| 4646 | \overload operator==() | - |
| 4647 | \relates QString | - |
| 4648 | | - |
| 4649 | Returns true if \a s1 is equal to \a s2; otherwise returns false. | - |
| 4650 | Note that no string is equal to \a s1 being 0. | - |
| 4651 | | - |
| 4652 | Equivalent to \c {s1 != 0 && compare(s1, s2) == 0}. | - |
| 4653 | | - |
| 4654 | \sa QString::compare() | - |
| 4655 | */ | - |
| 4656 | | - |
| 4657 | /*! | - |
| 4658 | \fn bool operator!=(const char *s1, const QString &s2) | - |
| 4659 | \relates QString | - |
| 4660 | | - |
| 4661 | Returns true if \a s1 is not equal to \a s2; otherwise returns | - |
| 4662 | false. | - |
| 4663 | | - |
| 4664 | For \a s1 != 0, this is equivalent to \c {compare(} \a s1, \a s2 | - |
| 4665 | \c {) != 0}. Note that no string is equal to \a s1 being 0. | - |
| 4666 | | - |
| 4667 | \sa QString::compare() | - |
| 4668 | */ | - |
| 4669 | | - |
| 4670 | /*! | - |
| 4671 | \fn bool operator<(const char *s1, const QString &s2) | - |
| 4672 | \relates QString | - |
| 4673 | | - |
| 4674 | Returns true if \a s1 is lexically less than \a s2; otherwise | - |
| 4675 | returns false. For \a s1 != 0, this is equivalent to \c | - |
| 4676 | {compare(s1, s2) < 0}. | - |
| 4677 | | - |
| 4678 | The comparison is based exclusively on the numeric Unicode values | - |
| 4679 | of the characters and is very fast, but is not what a human would | - |
| 4680 | expect. Consider sorting user-interface strings using the | - |
| 4681 | QString::localeAwareCompare() function. | - |
| 4682 | | - |
| 4683 | \sa QString::compare() | - |
| 4684 | */ | - |
| 4685 | | - |
| 4686 | /*! | - |
| 4687 | \fn bool operator<=(const char *s1, const QString &s2) | - |
| 4688 | \relates QString | - |
| 4689 | | - |
| 4690 | Returns true if \a s1 is lexically less than or equal to \a s2; | - |
| 4691 | otherwise returns false. For \a s1 != 0, this is equivalent to \c | - |
| 4692 | {compare(s1, s2) <= 0}. | - |
| 4693 | | - |
| 4694 | The comparison is based exclusively on the numeric Unicode values | - |
| 4695 | of the characters and is very fast, but is not what a human would | - |
| 4696 | expect. Consider sorting user-interface strings with | - |
| 4697 | QString::localeAwareCompare(). | - |
| 4698 | | - |
| 4699 | \sa QString::compare() | - |
| 4700 | */ | - |
| 4701 | | - |
| 4702 | /*! | - |
| 4703 | \fn bool operator>(const char *s1, const QString &s2) | - |
| 4704 | \relates QString | - |
| 4705 | | - |
| 4706 | Returns true if \a s1 is lexically greater than \a s2; otherwise | - |
| 4707 | returns false. Equivalent to \c {compare(s1, s2) > 0}. | - |
| 4708 | | - |
| 4709 | The comparison is based exclusively on the numeric Unicode values | - |
| 4710 | of the characters and is very fast, but is not what a human would | - |
| 4711 | expect. Consider sorting user-interface strings using the | - |
| 4712 | QString::localeAwareCompare() function. | - |
| 4713 | | - |
| 4714 | \sa QString::compare() | - |
| 4715 | */ | - |
| 4716 | | - |
| 4717 | /*! | - |
| 4718 | \fn bool operator>=(const char *s1, const QString &s2) | - |
| 4719 | \relates QString | - |
| 4720 | | - |
| 4721 | Returns true if \a s1 is lexically greater than or equal to \a s2; | - |
| 4722 | otherwise returns false. For \a s1 != 0, this is equivalent to \c | - |
| 4723 | {compare(s1, s2) >= 0}. | - |
| 4724 | | - |
| 4725 | The comparison is based exclusively on the numeric Unicode values | - |
| 4726 | of the characters and is very fast, but is not what a human would | - |
| 4727 | expect. Consider sorting user-interface strings using the | - |
| 4728 | QString::localeAwareCompare() function. | - |
| 4729 | */ | - |
| 4730 | | - |
| 4731 | /*! | - |
| 4732 | \fn const QString operator+(const QString &s1, const QString &s2) | - |
| 4733 | \relates QString | - |
| 4734 | | - |
| 4735 | Returns a string which is the result of concatenating \a s1 and \a | - |
| 4736 | s2. | - |
| 4737 | */ | - |
| 4738 | | - |
| 4739 | /*! | - |
| 4740 | \fn const QString operator+(const QString &s1, const char *s2) | - |
| 4741 | \relates QString | - |
| 4742 | | - |
| 4743 | Returns a string which is the result of concatenating \a s1 and \a | - |
| 4744 | s2 (\a s2 is converted to Unicode using the QString::fromUtf8() | - |
| 4745 | function). | - |
| 4746 | | - |
| 4747 | \sa QString::fromUtf8() | - |
| 4748 | */ | - |
| 4749 | | - |
| 4750 | /*! | - |
| 4751 | \fn const QString operator+(const char *s1, const QString &s2) | - |
| 4752 | \relates QString | - |
| 4753 | | - |
| 4754 | Returns a string which is the result of concatenating \a s1 and \a | - |
| 4755 | s2 (\a s1 is converted to Unicode using the QString::fromUtf8() | - |
| 4756 | function). | - |
| 4757 | | - |
| 4758 | \sa QString::fromUtf8() | - |
| 4759 | */ | - |
| 4760 | | - |
| 4761 | /*! | - |
| 4762 | \fn const QString operator+(const QString &s, char ch) | - |
| 4763 | \relates QString | - |
| 4764 | | - |
| 4765 | Returns a string which is the result of concatenating the string | - |
| 4766 | \a s and the character \a ch. | - |
| 4767 | */ | - |
| 4768 | | - |
| 4769 | /*! | - |
| 4770 | \fn const QString operator+(char ch, const QString &s) | - |
| 4771 | \relates QString | - |
| 4772 | | - |
| 4773 | Returns a string which is the result of concatenating the | - |
| 4774 | character \a ch and the string \a s. | - |
| 4775 | */ | - |
| 4776 | | - |
| 4777 | /*! | - |
| 4778 | \fn int QString::compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs) | - |
| 4779 | \since 4.2 | - |
| 4780 | | - |
| 4781 | Compares \a s1 with \a s2 and returns an integer less than, equal | - |
| 4782 | to, or greater than zero if \a s1 is less than, equal to, or | - |
| 4783 | greater than \a s2. | - |
| 4784 | | - |
| 4785 | If \a cs is Qt::CaseSensitive, the comparison is case sensitive; | - |
| 4786 | otherwise the comparison is case insensitive. | - |
| 4787 | | - |
| 4788 | Case sensitive comparison is based exclusively on the numeric | - |
| 4789 | Unicode values of the characters and is very fast, but is not what | - |
| 4790 | a human would expect. Consider sorting user-visible strings with | - |
| 4791 | localeAwareCompare(). | - |
| 4792 | | - |
| 4793 | \snippet qstring/main.cpp 16 | - |
| 4794 | | - |
| 4795 | \sa operator==(), operator<(), operator>() | - |
| 4796 | */ | - |
| 4797 | | - |
| 4798 | /*! | - |
| 4799 | \fn int QString::compare(const QString &s1, QLatin1String s2, Qt::CaseSensitivity cs) | - |
| 4800 | \since 4.2 | - |
| 4801 | \overload compare() | - |
| 4802 | | - |
| 4803 | Performs a comparison of \a s1 and \a s2, using the case | - |
| 4804 | sensitivity setting \a cs. | - |
| 4805 | */ | - |
| 4806 | | - |
| 4807 | /*! | - |
| 4808 | \fn int QString::compare(QLatin1String s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) | - |
| 4809 | | - |
| 4810 | \since 4.2 | - |
| 4811 | \overload compare() | - |
| 4812 | | - |
| 4813 | Performs a comparison of \a s1 and \a s2, using the case | - |
| 4814 | sensitivity setting \a cs. | - |
| 4815 | */ | - |
| 4816 | | - |
| 4817 | | - |
| 4818 | /*! | - |
| 4819 | \overload compare() | - |
| 4820 | \since 4.2 | - |
| 4821 | | - |
| 4822 | Lexically compares this string with the \a other string and | - |
| 4823 | returns an integer less than, equal to, or greater than zero if | - |
| 4824 | this string is less than, equal to, or greater than the other | - |
| 4825 | string. | - |
| 4826 | | - |
| 4827 | Same as compare(*this, \a other, \a cs). | - |
| 4828 | */ | - |
| 4829 | int QString::compare(const QString &other, Qt::CaseSensitivity cs) const | - |
| 4830 | { | - |
| 4831 | if (cs == Qt::CaseSensitive) evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:196883 | yes Evaluation Count:3753201 |
| 196883-3753201 |
| 4832 | return ucstrcmp(constData(), length(), other.constData(), other.length()); executed: return ucstrcmp(constData(), length(), other.constData(), other.length());Execution Count:196883 | 196883 |
| 4833 | return ucstricmp(d->data(), d->data() + d->size, other.d->data(), other.d->data() + other.d->size); executed: return ucstricmp(d->data(), d->data() + d->size, other.d->data(), other.d->data() + other.d->size);Execution Count:3753201 | 3753201 |
| 4834 | } | - |
| 4835 | | - |
| 4836 | /*! | - |
| 4837 | \internal | - |
| 4838 | \since 4.5 | - |
| 4839 | */ | - |
| 4840 | int QString::compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, | - |
| 4841 | Qt::CaseSensitivity cs) | - |
| 4842 | { | - |
| 4843 | if (cs == Qt::CaseSensitive) evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:195129 | yes Evaluation Count:88 |
| 88-195129 |
| 4844 | return ucstrcmp(data1, length1, data2, length2); executed: return ucstrcmp(data1, length1, data2, length2);Execution Count:195129 | 195129 |
| 4845 | register const ushort *s1 = reinterpret_cast<const ushort *>(data1); executed (the execution status of this line is deduced): register const ushort *s1 = reinterpret_cast<const ushort *>(data1); | - |
| 4846 | register const ushort *s2 = reinterpret_cast<const ushort *>(data2); executed (the execution status of this line is deduced): register const ushort *s2 = reinterpret_cast<const ushort *>(data2); | - |
| 4847 | return ucstricmp(s1, s1 + length1, s2, s2 + length2); executed: return ucstricmp(s1, s1 + length1, s2, s2 + length2);Execution Count:88 | 88 |
| 4848 | } | - |
| 4849 | | - |
| 4850 | /*! | - |
| 4851 | \overload compare() | - |
| 4852 | \since 4.2 | - |
| 4853 | | - |
| 4854 | Same as compare(*this, \a other, \a cs). | - |
| 4855 | */ | - |
| 4856 | int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const | - |
| 4857 | { | - |
| 4858 | return compare_helper(unicode(), length(), other, cs); executed: return compare_helper(unicode(), length(), other, cs);Execution Count:6727 | 6727 |
| 4859 | } | - |
| 4860 | | - |
| 4861 | /*! | - |
| 4862 | \fn int QString::compare(const QStringRef &ref, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 4863 | \overload compare() | - |
| 4864 | | - |
| 4865 | Compares the string reference, \a ref, with the string and returns | - |
| 4866 | an integer less than, equal to, or greater than zero if the string | - |
| 4867 | is less than, equal to, or greater than \a ref. | - |
| 4868 | */ | - |
| 4869 | | - |
| 4870 | /*! | - |
| 4871 | \internal | - |
| 4872 | \since 5.0 | - |
| 4873 | */ | - |
| 4874 | int QString::compare_helper(const QChar *data1, int length1, const char *data2, int length2, | - |
| 4875 | Qt::CaseSensitivity cs) | - |
| 4876 | { | - |
| 4877 | // ### optimize me | - |
| 4878 | const QString s2 = QString::fromUtf8(data2, length2 == -1 ? (data2 ? int(strlen(data2)) : -1) : length2); executed (the execution status of this line is deduced): const QString s2 = QString::fromUtf8(data2, length2 == -1 ? (data2 ? int(strlen(data2)) : -1) : length2); | - |
| 4879 | return compare_helper(data1, length1, s2.constData(), s2.size(), cs); executed: return compare_helper(data1, length1, s2.constData(), s2.size(), cs);Execution Count:194981 | 194981 |
| 4880 | } | - |
| 4881 | | - |
| 4882 | /*! | - |
| 4883 | \fn int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) | - |
| 4884 | \overload compare() | - |
| 4885 | */ | - |
| 4886 | | - |
| 4887 | /*! | - |
| 4888 | \internal | - |
| 4889 | \since 4.5 | - |
| 4890 | */ | - |
| 4891 | int QString::compare_helper(const QChar *data1, int length1, QLatin1String s2, | - |
| 4892 | Qt::CaseSensitivity cs) | - |
| 4893 | { | - |
| 4894 | const ushort *uc = reinterpret_cast<const ushort *>(data1); executed (the execution status of this line is deduced): const ushort *uc = reinterpret_cast<const ushort *>(data1); | - |
| 4895 | const ushort *uce = uc + length1; executed (the execution status of this line is deduced): const ushort *uce = uc + length1; | - |
| 4896 | const uchar *c = (uchar *)s2.latin1(); executed (the execution status of this line is deduced): const uchar *c = (uchar *)s2.latin1(); | - |
| 4897 | | - |
| 4898 | if (!c) partially evaluated: !c| no Evaluation Count:0 | yes Evaluation Count:6785 |
| 0-6785 |
| 4899 | return length1; never executed: return length1; | 0 |
| 4900 | | - |
| 4901 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:560 | yes Evaluation Count:6225 |
| 560-6225 |
| 4902 | const ushort *e = uc + length1; executed (the execution status of this line is deduced): const ushort *e = uc + length1; | - |
| 4903 | if (s2.size() < length1) evaluated: s2.size() < length1| yes Evaluation Count:256 | yes Evaluation Count:304 |
| 256-304 |
| 4904 | e = uc + s2.size(); executed: e = uc + s2.size();Execution Count:256 | 256 |
| 4905 | while (uc < e) { evaluated: uc < e| yes Evaluation Count:634 | yes Evaluation Count:536 |
| 536-634 |
| 4906 | int diff = *uc - *c; executed (the execution status of this line is deduced): int diff = *uc - *c; | - |
| 4907 | if (diff) evaluated: diff| yes Evaluation Count:24 | yes Evaluation Count:610 |
| 24-610 |
| 4908 | return diff; executed: return diff;Execution Count:24 | 24 |
| 4909 | uc++, c++; executed (the execution status of this line is deduced): uc++, c++; | - |
| 4910 | } executed: }Execution Count:610 | 610 |
| 4911 | | - |
| 4912 | if (uc == uce) { evaluated: uc == uce| yes Evaluation Count:286 | yes Evaluation Count:250 |
| 250-286 |
| 4913 | if (c == (const uchar *)s2.latin1() + s2.size()) evaluated: c == (const uchar *)s2.latin1() + s2.size()| yes Evaluation Count:269 | yes Evaluation Count:17 |
| 17-269 |
| 4914 | return 0; executed: return 0;Execution Count:269 | 269 |
| 4915 | return -1; executed: return -1;Execution Count:17 | 17 |
| 4916 | } | - |
| 4917 | return 1; executed: return 1;Execution Count:250 | 250 |
| 4918 | } else { | - |
| 4919 | return ucstricmp(uc, uce, c, c + s2.size()); executed: return ucstricmp(uc, uce, c, c + s2.size());Execution Count:6225 | 6225 |
| 4920 | } | - |
| 4921 | } | - |
| 4922 | | - |
| 4923 | /*! | - |
| 4924 | \fn int QString::localeAwareCompare(const QString & s1, const QString & s2) | - |
| 4925 | | - |
| 4926 | Compares \a s1 with \a s2 and returns an integer less than, equal | - |
| 4927 | to, or greater than zero if \a s1 is less than, equal to, or | - |
| 4928 | greater than \a s2. | - |
| 4929 | | - |
| 4930 | The comparison is performed in a locale- and also | - |
| 4931 | platform-dependent manner. Use this function to present sorted | - |
| 4932 | lists of strings to the user. | - |
| 4933 | | - |
| 4934 | On Mac OS X since Qt 4.3, this function compares according the | - |
| 4935 | "Order for sorted lists" setting in the International preferences panel. | - |
| 4936 | | - |
| 4937 | \sa compare(), QTextCodec::locale() | - |
| 4938 | */ | - |
| 4939 | | - |
| 4940 | /*! | - |
| 4941 | \fn int QString::localeAwareCompare(const QStringRef &other) const | - |
| 4942 | \since 4.5 | - |
| 4943 | \overload localeAwareCompare() | - |
| 4944 | | - |
| 4945 | Compares this string with the \a other string and returns an | - |
| 4946 | integer less than, equal to, or greater than zero if this string | - |
| 4947 | is less than, equal to, or greater than the \a other string. | - |
| 4948 | | - |
| 4949 | The comparison is performed in a locale- and also | - |
| 4950 | platform-dependent manner. Use this function to present sorted | - |
| 4951 | lists of strings to the user. | - |
| 4952 | | - |
| 4953 | Same as \c {localeAwareCompare(*this, other)}. | - |
| 4954 | */ | - |
| 4955 | | - |
| 4956 | /*! | - |
| 4957 | \fn int QString::localeAwareCompare(const QString &s1, const QStringRef &s2) | - |
| 4958 | \since 4.5 | - |
| 4959 | \overload localeAwareCompare() | - |
| 4960 | | - |
| 4961 | Compares \a s1 with \a s2 and returns an integer less than, equal | - |
| 4962 | to, or greater than zero if \a s1 is less than, equal to, or | - |
| 4963 | greater than \a s2. | - |
| 4964 | | - |
| 4965 | The comparison is performed in a locale- and also | - |
| 4966 | platform-dependent manner. Use this function to present sorted | - |
| 4967 | lists of strings to the user. | - |
| 4968 | */ | - |
| 4969 | | - |
| 4970 | | - |
| 4971 | #if !defined(CSTR_LESS_THAN) | - |
| 4972 | #define CSTR_LESS_THAN 1 | - |
| 4973 | #define CSTR_EQUAL 2 | - |
| 4974 | #define CSTR_GREATER_THAN 3 | - |
| 4975 | #endif | - |
| 4976 | | - |
| 4977 | /*! | - |
| 4978 | \overload localeAwareCompare() | - |
| 4979 | | - |
| 4980 | Compares this string with the \a other string and returns an | - |
| 4981 | integer less than, equal to, or greater than zero if this string | - |
| 4982 | is less than, equal to, or greater than the \a other string. | - |
| 4983 | | - |
| 4984 | The comparison is performed in a locale- and also | - |
| 4985 | platform-dependent manner. Use this function to present sorted | - |
| 4986 | lists of strings to the user. | - |
| 4987 | | - |
| 4988 | Same as \c {localeAwareCompare(*this, other)}. | - |
| 4989 | */ | - |
| 4990 | int QString::localeAwareCompare(const QString &other) const | - |
| 4991 | { | - |
| 4992 | return localeAwareCompare_helper(constData(), length(), other.constData(), other.length()); executed: return localeAwareCompare_helper(constData(), length(), other.constData(), other.length());Execution Count:922069 | 922069 |
| 4993 | } | - |
| 4994 | | - |
| 4995 | /*! | - |
| 4996 | \internal | - |
| 4997 | \since 4.5 | - |
| 4998 | */ | - |
| 4999 | int QString::localeAwareCompare_helper(const QChar *data1, int length1, | - |
| 5000 | const QChar *data2, int length2) | - |
| 5001 | { | - |
| 5002 | // do the right thing for null and empty | - |
| 5003 | if (length1 == 0 || length2 == 0) evaluated: length1 == 0| yes Evaluation Count:7 | yes Evaluation Count:922098 |
partially evaluated: length2 == 0| no Evaluation Count:0 | yes Evaluation Count:922098 |
| 0-922098 |
| 5004 | return ucstrcmp(data1, length1, data2, length2); executed: return ucstrcmp(data1, length1, data2, length2);Execution Count:7 | 7 |
| 5005 | | - |
| 5006 | #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) | - |
| 5007 | int res = CompareString(GetUserDefaultLCID(), 0, (wchar_t*)data1, length1, (wchar_t*)data2, length2); | - |
| 5008 | | - |
| 5009 | switch (res) { | - |
| 5010 | case CSTR_LESS_THAN: | - |
| 5011 | return -1; | - |
| 5012 | case CSTR_GREATER_THAN: | - |
| 5013 | return 1; | - |
| 5014 | default: | - |
| 5015 | return 0; | - |
| 5016 | } | - |
| 5017 | #elif defined (Q_OS_MAC) | - |
| 5018 | // Use CFStringCompare for comparing strings on Mac. This makes Qt order | - |
| 5019 | // strings the same way as native applications do, and also respects | - |
| 5020 | // the "Order for sorted lists" setting in the International preferences | - |
| 5021 | // panel. | - |
| 5022 | const CFStringRef thisString = | - |
| 5023 | CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, | - |
| 5024 | reinterpret_cast<const UniChar *>(data1), length1, kCFAllocatorNull); | - |
| 5025 | const CFStringRef otherString = | - |
| 5026 | CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, | - |
| 5027 | reinterpret_cast<const UniChar *>(data2), length2, kCFAllocatorNull); | - |
| 5028 | | - |
| 5029 | const int result = CFStringCompare(thisString, otherString, kCFCompareLocalized); | - |
| 5030 | CFRelease(thisString); | - |
| 5031 | CFRelease(otherString); | - |
| 5032 | return result; | - |
| 5033 | #elif defined(QT_USE_ICU) | - |
| 5034 | QCollator collator; executed (the execution status of this line is deduced): QCollator collator; | - |
| 5035 | return collator.compare(data1, length1, data2, length2); executed: return collator.compare(data1, length1, data2, length2);Execution Count:922098 | 922098 |
| 5036 | #elif defined(Q_OS_UNIX) | - |
| 5037 | // declared in <string.h> | - |
| 5038 | int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData()); | - |
| 5039 | if (delta == 0) | - |
| 5040 | delta = ucstrcmp(data1, length1, data2, length2); | - |
| 5041 | return delta; | - |
| 5042 | #else | - |
| 5043 | return ucstrcmp(data1, length1, data2, length2); | - |
| 5044 | #endif | - |
| 5045 | } | - |
| 5046 | | - |
| 5047 | | - |
| 5048 | /*! | - |
| 5049 | \fn const QChar *QString::unicode() const | - |
| 5050 | | - |
| 5051 | Returns a '\\0'-terminated Unicode representation of the string. | - |
| 5052 | The result remains valid until the string is modified. | - |
| 5053 | | - |
| 5054 | \sa utf16() | - |
| 5055 | */ | - |
| 5056 | | - |
| 5057 | /*! | - |
| 5058 | \fn const ushort *QString::utf16() const | - |
| 5059 | | - |
| 5060 | Returns the QString as a '\\0\'-terminated array of unsigned | - |
| 5061 | shorts. The result remains valid until the string is modified. | - |
| 5062 | | - |
| 5063 | The returned string is in host byte order. | - |
| 5064 | | - |
| 5065 | \sa unicode() | - |
| 5066 | */ | - |
| 5067 | | - |
| 5068 | const ushort *QString::utf16() const | - |
| 5069 | { | - |
| 5070 | if (IS_RAW_DATA(d)) { partially evaluated: ((d)->offset != sizeof(QStringData))| no Evaluation Count:0 | yes Evaluation Count:118004 |
| 0-118004 |
| 5071 | // ensure '\0'-termination for ::fromRawData strings | - |
| 5072 | const_cast<QString*>(this)->reallocData(uint(d->size) + 1u); never executed (the execution status of this line is deduced): const_cast<QString*>(this)->reallocData(uint(d->size) + 1u); | - |
| 5073 | } | 0 |
| 5074 | return d->data(); executed: return d->data();Execution Count:118004 | 118004 |
| 5075 | } | - |
| 5076 | | - |
| 5077 | /*! | - |
| 5078 | Returns a string of size \a width that contains this string | - |
| 5079 | padded by the \a fill character. | - |
| 5080 | | - |
| 5081 | If \a truncate is false and the size() of the string is more than | - |
| 5082 | \a width, then the returned string is a copy of the string. | - |
| 5083 | | - |
| 5084 | \snippet qstring/main.cpp 32 | - |
| 5085 | | - |
| 5086 | If \a truncate is true and the size() of the string is more than | - |
| 5087 | \a width, then any characters in a copy of the string after | - |
| 5088 | position \a width are removed, and the copy is returned. | - |
| 5089 | | - |
| 5090 | \snippet qstring/main.cpp 33 | - |
| 5091 | | - |
| 5092 | \sa rightJustified() | - |
| 5093 | */ | - |
| 5094 | | - |
| 5095 | QString QString::leftJustified(int width, QChar fill, bool truncate) const | - |
| 5096 | { | - |
| 5097 | QString result; executed (the execution status of this line is deduced): QString result; | - |
| 5098 | int len = length(); executed (the execution status of this line is deduced): int len = length(); | - |
| 5099 | int padlen = width - len; executed (the execution status of this line is deduced): int padlen = width - len; | - |
| 5100 | if (padlen > 0) { evaluated: padlen > 0| yes Evaluation Count:802 | yes Evaluation Count:4209 |
| 802-4209 |
| 5101 | result.resize(len+padlen); executed (the execution status of this line is deduced): result.resize(len+padlen); | - |
| 5102 | if (len) evaluated: len| yes Evaluation Count:801 | yes Evaluation Count:1 |
| 1-801 |
| 5103 | memcpy(result.d->data(), d->data(), sizeof(QChar)*len); executed: memcpy(result.d->data(), d->data(), sizeof(QChar)*len);Execution Count:801 | 801 |
| 5104 | QChar *uc = (QChar*)result.d->data() + len; executed (the execution status of this line is deduced): QChar *uc = (QChar*)result.d->data() + len; | - |
| 5105 | while (padlen--) evaluated: padlen--| yes Evaluation Count:32178 | yes Evaluation Count:802 |
| 802-32178 |
| 5106 | * uc++ = fill; executed: * uc++ = fill;Execution Count:32178 | 32178 |
| 5107 | } else { executed: }Execution Count:802 | 802 |
| 5108 | if (truncate) evaluated: truncate| yes Evaluation Count:4 | yes Evaluation Count:4205 |
| 4-4205 |
| 5109 | result = left(width); executed: result = left(width);Execution Count:4 | 4 |
| 5110 | else | - |
| 5111 | result = *this; executed: result = *this;Execution Count:4205 | 4205 |
| 5112 | } | - |
| 5113 | return result; executed: return result;Execution Count:5011 | 5011 |
| 5114 | } | - |
| 5115 | | - |
| 5116 | /*! | - |
| 5117 | Returns a string of size() \a width that contains the \a fill | - |
| 5118 | character followed by the string. For example: | - |
| 5119 | | - |
| 5120 | \snippet qstring/main.cpp 49 | - |
| 5121 | | - |
| 5122 | If \a truncate is false and the size() of the string is more than | - |
| 5123 | \a width, then the returned string is a copy of the string. | - |
| 5124 | | - |
| 5125 | If \a truncate is true and the size() of the string is more than | - |
| 5126 | \a width, then the resulting string is truncated at position \a | - |
| 5127 | width. | - |
| 5128 | | - |
| 5129 | \snippet qstring/main.cpp 50 | - |
| 5130 | | - |
| 5131 | \sa leftJustified() | - |
| 5132 | */ | - |
| 5133 | | - |
| 5134 | QString QString::rightJustified(int width, QChar fill, bool truncate) const | - |
| 5135 | { | - |
| 5136 | QString result; executed (the execution status of this line is deduced): QString result; | - |
| 5137 | int len = length(); executed (the execution status of this line is deduced): int len = length(); | - |
| 5138 | int padlen = width - len; executed (the execution status of this line is deduced): int padlen = width - len; | - |
| 5139 | if (padlen > 0) { evaluated: padlen > 0| yes Evaluation Count:34075 | yes Evaluation Count:78554 |
| 34075-78554 |
| 5140 | result.resize(len+padlen); executed (the execution status of this line is deduced): result.resize(len+padlen); | - |
| 5141 | QChar *uc = (QChar*)result.d->data(); executed (the execution status of this line is deduced): QChar *uc = (QChar*)result.d->data(); | - |
| 5142 | while (padlen--) evaluated: padlen--| yes Evaluation Count:78617 | yes Evaluation Count:34075 |
| 34075-78617 |
| 5143 | * uc++ = fill; executed: * uc++ = fill;Execution Count:78617 | 78617 |
| 5144 | if (len) evaluated: len| yes Evaluation Count:34074 | yes Evaluation Count:1 |
| 1-34074 |
| 5145 | memcpy(uc, d->data(), sizeof(QChar)*len); executed: memcpy(uc, d->data(), sizeof(QChar)*len);Execution Count:34074 | 34074 |
| 5146 | } else { executed: }Execution Count:34075 | 34075 |
| 5147 | if (truncate) evaluated: truncate| yes Evaluation Count:54671 | yes Evaluation Count:23883 |
| 23883-54671 |
| 5148 | result = left(width); executed: result = left(width);Execution Count:54671 | 54671 |
| 5149 | else | - |
| 5150 | result = *this; executed: result = *this;Execution Count:23883 | 23883 |
| 5151 | } | - |
| 5152 | return result; executed: return result;Execution Count:112629 | 112629 |
| 5153 | } | - |
| 5154 | | - |
| 5155 | /*! | - |
| 5156 | Returns a lowercase copy of the string. | - |
| 5157 | | - |
| 5158 | \snippet qstring/main.cpp 75 | - |
| 5159 | | - |
| 5160 | The case conversion will always happen in the 'C' locale. For locale dependent | - |
| 5161 | case folding use QLocale::toLower() | - |
| 5162 | | - |
| 5163 | \sa toUpper(), QLocale::toLower() | - |
| 5164 | */ | - |
| 5165 | | - |
| 5166 | QString QString::toLower() const | - |
| 5167 | { | - |
| 5168 | const ushort *p = d->data(); executed (the execution status of this line is deduced): const ushort *p = d->data(); | - |
| 5169 | if (!p) partially evaluated: !p| no Evaluation Count:0 | yes Evaluation Count:119898 |
| 0-119898 |
| 5170 | return *this; never executed: return *this; | 0 |
| 5171 | | - |
| 5172 | const ushort *e = p + d->size; executed (the execution status of this line is deduced): const ushort *e = p + d->size; | - |
| 5173 | // this avoids out of bounds check in the loop | - |
| 5174 | while (e != p && QChar::isHighSurrogate(*(e - 1))) evaluated: e != p| yes Evaluation Count:117838 | yes Evaluation Count:2062 |
evaluated: QChar::isHighSurrogate(*(e - 1))| yes Evaluation Count:2 | yes Evaluation Count:117836 |
| 2-117838 |
| 5175 | --e; executed: --e;Execution Count:2 | 2 |
| 5176 | | - |
| 5177 | const QUnicodeTables::Properties *prop; executed (the execution status of this line is deduced): const QUnicodeTables::Properties *prop; | - |
| 5178 | while (p != e) { evaluated: p != e| yes Evaluation Count:247187 | yes Evaluation Count:31380 |
| 31380-247187 |
| 5179 | if (QChar::isHighSurrogate(*p) && QChar::isLowSurrogate(p[1])) { evaluated: QChar::isHighSurrogate(*p)| yes Evaluation Count:4 | yes Evaluation Count:247183 |
partially evaluated: QChar::isLowSurrogate(p[1])| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-247183 |
| 5180 | ushort high = *p++; executed (the execution status of this line is deduced): ushort high = *p++; | - |
| 5181 | prop = qGetProp(QChar::surrogateToUcs4(high, *p)); executed (the execution status of this line is deduced): prop = qGetProp(QChar::surrogateToUcs4(high, *p)); | - |
| 5182 | } else { executed: }Execution Count:4 | 4 |
| 5183 | prop = qGetProp(*p); executed (the execution status of this line is deduced): prop = qGetProp(*p); | - |
| 5184 | } executed: }Execution Count:247183 | 247183 |
| 5185 | if (prop->lowerCaseDiff) { evaluated: prop->lowerCaseDiff| yes Evaluation Count:88518 | yes Evaluation Count:158669 |
| 88518-158669 |
| 5186 | if (QChar::isLowSurrogate(*p)) evaluated: QChar::isLowSurrogate(*p)| yes Evaluation Count:4 | yes Evaluation Count:88514 |
| 4-88514 |
| 5187 | --p; // safe; diff is 0 for surrogates executed: --p;Execution Count:4 | 4 |
| 5188 | QString s(d->size, Qt::Uninitialized); executed (the execution status of this line is deduced): QString s(d->size, Qt::Uninitialized); | - |
| 5189 | memcpy(s.d->data(), d->data(), (p - d->data())*sizeof(ushort)); executed (the execution status of this line is deduced): memcpy(s.d->data(), d->data(), (p - d->data())*sizeof(ushort)); | - |
| 5190 | ushort *pp = s.d->data() + (p - d->data()); executed (the execution status of this line is deduced): ushort *pp = s.d->data() + (p - d->data()); | - |
| 5191 | while (p != e) { evaluated: p != e| yes Evaluation Count:717537 | yes Evaluation Count:88518 |
| 88518-717537 |
| 5192 | if (QChar::isHighSurrogate(*p) && QChar::isLowSurrogate(p[1])) { evaluated: QChar::isHighSurrogate(*p)| yes Evaluation Count:7 | yes Evaluation Count:717530 |
partially evaluated: QChar::isLowSurrogate(p[1])| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-717530 |
| 5193 | *pp = *p++; executed (the execution status of this line is deduced): *pp = *p++; | - |
| 5194 | prop = qGetProp(QChar::surrogateToUcs4(*pp++, *p)); executed (the execution status of this line is deduced): prop = qGetProp(QChar::surrogateToUcs4(*pp++, *p)); | - |
| 5195 | } else { executed: }Execution Count:7 | 7 |
| 5196 | prop = qGetProp(*p); executed (the execution status of this line is deduced): prop = qGetProp(*p); | - |
| 5197 | } executed: }Execution Count:717530 | 717530 |
| 5198 | if (prop->lowerCaseSpecial) { evaluated: prop->lowerCaseSpecial| yes Evaluation Count:1 | yes Evaluation Count:717536 |
| 1-717536 |
| 5199 | const ushort *specialCase = specialCaseMap + prop->lowerCaseDiff; executed (the execution status of this line is deduced): const ushort *specialCase = specialCaseMap + prop->lowerCaseDiff; | - |
| 5200 | ushort length = *specialCase++; executed (the execution status of this line is deduced): ushort length = *specialCase++; | - |
| 5201 | int pos = pp - s.d->data(); executed (the execution status of this line is deduced): int pos = pp - s.d->data(); | - |
| 5202 | s.resize(s.d->size + length - 1); executed (the execution status of this line is deduced): s.resize(s.d->size + length - 1); | - |
| 5203 | pp = s.d->data() + pos; executed (the execution status of this line is deduced): pp = s.d->data() + pos; | - |
| 5204 | while (length--) evaluated: length--| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 5205 | *pp++ = *specialCase++; executed: *pp++ = *specialCase++;Execution Count:2 | 2 |
| 5206 | } else { executed: }Execution Count:1 | 1 |
| 5207 | *pp++ = *p + prop->lowerCaseDiff; executed (the execution status of this line is deduced): *pp++ = *p + prop->lowerCaseDiff; | - |
| 5208 | } executed: }Execution Count:717536 | 717536 |
| 5209 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 5210 | } executed: }Execution Count:717537 | 717537 |
| 5211 | | - |
| 5212 | // this restores high surrogate parts eaten above, if any | - |
| 5213 | while (e != d->data() + d->size) evaluated: e != d->data() + d->size| yes Evaluation Count:2 | yes Evaluation Count:88518 |
| 2-88518 |
| 5214 | *pp++ = *e++; executed: *pp++ = *e++;Execution Count:2 | 2 |
| 5215 | | - |
| 5216 | return s; executed: return s;Execution Count:88518 | 88518 |
| 5217 | } | - |
| 5218 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 5219 | } executed: }Execution Count:158669 | 158669 |
| 5220 | return *this; executed: return *this;Execution Count:31380 | 31380 |
| 5221 | } | - |
| 5222 | | - |
| 5223 | /*! | - |
| 5224 | Returns the case folded equivalent of the string. For most Unicode | - |
| 5225 | characters this is the same as toLower(). | - |
| 5226 | */ | - |
| 5227 | QString QString::toCaseFolded() const | - |
| 5228 | { | - |
| 5229 | const ushort *p = d->data(); executed (the execution status of this line is deduced): const ushort *p = d->data(); | - |
| 5230 | if (!p) partially evaluated: !p| no Evaluation Count:0 | yes Evaluation Count:131114 |
| 0-131114 |
| 5231 | return *this; never executed: return *this; | 0 |
| 5232 | | - |
| 5233 | const ushort *e = p + d->size; executed (the execution status of this line is deduced): const ushort *e = p + d->size; | - |
| 5234 | // this avoids out of bounds check in the loop | - |
| 5235 | while (e != p && QChar::isHighSurrogate(*(e - 1))) evaluated: e != p| yes Evaluation Count:131110 | yes Evaluation Count:2054 |
evaluated: QChar::isHighSurrogate(*(e - 1))| yes Evaluation Count:2050 | yes Evaluation Count:129060 |
| 2050-131110 |
| 5236 | --e; executed: --e;Execution Count:2050 | 2050 |
| 5237 | | - |
| 5238 | const QUnicodeTables::Properties *prop; executed (the execution status of this line is deduced): const QUnicodeTables::Properties *prop; | - |
| 5239 | while (p != e) { evaluated: p != e| yes Evaluation Count:129113 | yes Evaluation Count:129061 |
| 129061-129113 |
| 5240 | if (QChar::isHighSurrogate(*p) && QChar::isLowSurrogate(p[1])) { evaluated: QChar::isHighSurrogate(*p)| yes Evaluation Count:8 | yes Evaluation Count:129105 |
partially evaluated: QChar::isLowSurrogate(p[1])| yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-129105 |
| 5241 | ushort high = *p++; executed (the execution status of this line is deduced): ushort high = *p++; | - |
| 5242 | prop = qGetProp(QChar::surrogateToUcs4(high, *p)); executed (the execution status of this line is deduced): prop = qGetProp(QChar::surrogateToUcs4(high, *p)); | - |
| 5243 | } else { executed: }Execution Count:8 | 8 |
| 5244 | prop = qGetProp(*p); executed (the execution status of this line is deduced): prop = qGetProp(*p); | - |
| 5245 | } executed: }Execution Count:129105 | 129105 |
| 5246 | if (prop->caseFoldDiff) { evaluated: prop->caseFoldDiff| yes Evaluation Count:2053 | yes Evaluation Count:127060 |
| 2053-127060 |
| 5247 | if (QChar::isLowSurrogate(*p)) evaluated: QChar::isLowSurrogate(*p)| yes Evaluation Count:6 | yes Evaluation Count:2047 |
| 6-2047 |
| 5248 | --p; // safe; diff is 0 for surrogates executed: --p;Execution Count:6 | 6 |
| 5249 | QString s(d->size, Qt::Uninitialized); executed (the execution status of this line is deduced): QString s(d->size, Qt::Uninitialized); | - |
| 5250 | memcpy(s.d->data(), d->data(), (p - d->data())*sizeof(ushort)); executed (the execution status of this line is deduced): memcpy(s.d->data(), d->data(), (p - d->data())*sizeof(ushort)); | - |
| 5251 | ushort *pp = s.d->data() + (p - d->data()); executed (the execution status of this line is deduced): ushort *pp = s.d->data() + (p - d->data()); | - |
| 5252 | while (p != e) { evaluated: p != e| yes Evaluation Count:2081 | yes Evaluation Count:2053 |
| 2053-2081 |
| 5253 | if (QChar::isHighSurrogate(*p) && QChar::isLowSurrogate(p[1])) { evaluated: QChar::isHighSurrogate(*p)| yes Evaluation Count:9 | yes Evaluation Count:2072 |
partially evaluated: QChar::isLowSurrogate(p[1])| yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-2072 |
| 5254 | *pp = *p++; executed (the execution status of this line is deduced): *pp = *p++; | - |
| 5255 | prop = qGetProp(QChar::surrogateToUcs4(*pp++, *p)); executed (the execution status of this line is deduced): prop = qGetProp(QChar::surrogateToUcs4(*pp++, *p)); | - |
| 5256 | } else { executed: }Execution Count:9 | 9 |
| 5257 | prop = qGetProp(*p); executed (the execution status of this line is deduced): prop = qGetProp(*p); | - |
| 5258 | } executed: }Execution Count:2072 | 2072 |
| 5259 | if (prop->caseFoldSpecial) { evaluated: prop->caseFoldSpecial| yes Evaluation Count:8 | yes Evaluation Count:2073 |
| 8-2073 |
| 5260 | const ushort *specialCase = specialCaseMap + prop->caseFoldDiff; executed (the execution status of this line is deduced): const ushort *specialCase = specialCaseMap + prop->caseFoldDiff; | - |
| 5261 | ushort length = *specialCase++; executed (the execution status of this line is deduced): ushort length = *specialCase++; | - |
| 5262 | #if 0 | - |
| 5263 | int pos = pp - s.d->data; | - |
| 5264 | s.resize(s.d->size + length - 1); | - |
| 5265 | pp = s.d->data + pos; | - |
| 5266 | while (length--) | - |
| 5267 | *pp++ = *specialCase++; | - |
| 5268 | #else | - |
| 5269 | //### we currently don't support full case foldings | - |
| 5270 | Q_ASSERT(length == 1); executed (the execution status of this line is deduced): qt_noop(); | - |
| 5271 | Q_UNUSED(length) executed (the execution status of this line is deduced): (void)length; | - |
| 5272 | *pp++ = *specialCase; executed (the execution status of this line is deduced): *pp++ = *specialCase; | - |
| 5273 | #endif | - |
| 5274 | } else { executed: }Execution Count:8 | 8 |
| 5275 | *pp++ = *p + prop->caseFoldDiff; executed (the execution status of this line is deduced): *pp++ = *p + prop->caseFoldDiff; | - |
| 5276 | } executed: }Execution Count:2073 | 2073 |
| 5277 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 5278 | } executed: }Execution Count:2081 | 2081 |
| 5279 | | - |
| 5280 | // this restores high surrogate parts eaten above, if any | - |
| 5281 | while (e != d->data() + d->size) evaluated: e != d->data() + d->size| yes Evaluation Count:2 | yes Evaluation Count:2053 |
| 2-2053 |
| 5282 | *pp++ = *e++; executed: *pp++ = *e++;Execution Count:2 | 2 |
| 5283 | | - |
| 5284 | return s; executed: return s;Execution Count:2053 | 2053 |
| 5285 | } | - |
| 5286 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 5287 | } executed: }Execution Count:127060 | 127060 |
| 5288 | return *this; executed: return *this;Execution Count:129061 | 129061 |
| 5289 | } | - |
| 5290 | | - |
| 5291 | /*! | - |
| 5292 | Returns an uppercase copy of the string. | - |
| 5293 | | - |
| 5294 | \snippet qstring/main.cpp 81 | - |
| 5295 | | - |
| 5296 | The case conversion will always happen in the 'C' locale. For locale dependent | - |
| 5297 | case folding use QLocale::toUpper() | - |
| 5298 | | - |
| 5299 | \sa toLower(), QLocale::toLower() | - |
| 5300 | */ | - |
| 5301 | QString QString::toUpper() const | - |
| 5302 | { | - |
| 5303 | const ushort *p = d->data(); executed (the execution status of this line is deduced): const ushort *p = d->data(); | - |
| 5304 | if (!p) partially evaluated: !p| no Evaluation Count:0 | yes Evaluation Count:9170 |
| 0-9170 |
| 5305 | return *this; never executed: return *this; | 0 |
| 5306 | | - |
| 5307 | const ushort *e = p + d->size; executed (the execution status of this line is deduced): const ushort *e = p + d->size; | - |
| 5308 | // this avoids out of bounds check in the loop | - |
| 5309 | while (e != p && QChar::isHighSurrogate(*(e - 1))) evaluated: e != p| yes Evaluation Count:9153 | yes Evaluation Count:19 |
evaluated: QChar::isHighSurrogate(*(e - 1))| yes Evaluation Count:2 | yes Evaluation Count:9151 |
| 2-9153 |
| 5310 | --e; executed: --e;Execution Count:2 | 2 |
| 5311 | | - |
| 5312 | const QUnicodeTables::Properties *prop; executed (the execution status of this line is deduced): const QUnicodeTables::Properties *prop; | - |
| 5313 | while (p != e) { evaluated: p != e| yes Evaluation Count:91990 | yes Evaluation Count:4133 |
| 4133-91990 |
| 5314 | if (QChar::isHighSurrogate(*p) && QChar::isLowSurrogate(p[1])) { evaluated: QChar::isHighSurrogate(*p)| yes Evaluation Count:4 | yes Evaluation Count:91986 |
partially evaluated: QChar::isLowSurrogate(p[1])| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-91986 |
| 5315 | ushort high = *p++; executed (the execution status of this line is deduced): ushort high = *p++; | - |
| 5316 | prop = qGetProp(QChar::surrogateToUcs4(high, *p)); executed (the execution status of this line is deduced): prop = qGetProp(QChar::surrogateToUcs4(high, *p)); | - |
| 5317 | } else { executed: }Execution Count:4 | 4 |
| 5318 | prop = qGetProp(*p); executed (the execution status of this line is deduced): prop = qGetProp(*p); | - |
| 5319 | } executed: }Execution Count:91986 | 91986 |
| 5320 | if (prop->upperCaseDiff) { evaluated: prop->upperCaseDiff| yes Evaluation Count:5037 | yes Evaluation Count:86953 |
| 5037-86953 |
| 5321 | if (QChar::isLowSurrogate(*p)) evaluated: QChar::isLowSurrogate(*p)| yes Evaluation Count:4 | yes Evaluation Count:5033 |
| 4-5033 |
| 5322 | --p; // safe; diff is 0 for surrogates executed: --p;Execution Count:4 | 4 |
| 5323 | QString s(d->size, Qt::Uninitialized); executed (the execution status of this line is deduced): QString s(d->size, Qt::Uninitialized); | - |
| 5324 | memcpy(s.d->data(), d->data(), (p - d->data())*sizeof(ushort)); executed (the execution status of this line is deduced): memcpy(s.d->data(), d->data(), (p - d->data())*sizeof(ushort)); | - |
| 5325 | ushort *pp = s.d->data() + (p - d->data()); executed (the execution status of this line is deduced): ushort *pp = s.d->data() + (p - d->data()); | - |
| 5326 | while (p != e) { evaluated: p != e| yes Evaluation Count:20692 | yes Evaluation Count:5037 |
| 5037-20692 |
| 5327 | if (QChar::isHighSurrogate(*p) && QChar::isLowSurrogate(p[1])) { evaluated: QChar::isHighSurrogate(*p)| yes Evaluation Count:7 | yes Evaluation Count:20685 |
partially evaluated: QChar::isLowSurrogate(p[1])| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-20685 |
| 5328 | *pp = *p++; executed (the execution status of this line is deduced): *pp = *p++; | - |
| 5329 | prop = qGetProp(QChar::surrogateToUcs4(*pp++, *p)); executed (the execution status of this line is deduced): prop = qGetProp(QChar::surrogateToUcs4(*pp++, *p)); | - |
| 5330 | } else { executed: }Execution Count:7 | 7 |
| 5331 | prop = qGetProp(*p); executed (the execution status of this line is deduced): prop = qGetProp(*p); | - |
| 5332 | } executed: }Execution Count:20685 | 20685 |
| 5333 | if (prop->upperCaseSpecial) { evaluated: prop->upperCaseSpecial| yes Evaluation Count:1 | yes Evaluation Count:20691 |
| 1-20691 |
| 5334 | const ushort *specialCase = specialCaseMap + prop->upperCaseDiff; executed (the execution status of this line is deduced): const ushort *specialCase = specialCaseMap + prop->upperCaseDiff; | - |
| 5335 | ushort length = *specialCase++; executed (the execution status of this line is deduced): ushort length = *specialCase++; | - |
| 5336 | int pos = pp - s.d->data(); executed (the execution status of this line is deduced): int pos = pp - s.d->data(); | - |
| 5337 | s.resize(s.d->size + length - 1); executed (the execution status of this line is deduced): s.resize(s.d->size + length - 1); | - |
| 5338 | pp = s.d->data() + pos; executed (the execution status of this line is deduced): pp = s.d->data() + pos; | - |
| 5339 | while (length--) evaluated: length--| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 5340 | *pp++ = *specialCase++; executed: *pp++ = *specialCase++;Execution Count:2 | 2 |
| 5341 | } else { executed: }Execution Count:1 | 1 |
| 5342 | *pp++ = *p + prop->upperCaseDiff; executed (the execution status of this line is deduced): *pp++ = *p + prop->upperCaseDiff; | - |
| 5343 | } executed: }Execution Count:20691 | 20691 |
| 5344 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 5345 | } executed: }Execution Count:20692 | 20692 |
| 5346 | | - |
| 5347 | // this restores high surrogate parts eaten above, if any | - |
| 5348 | while (e != d->data() + d->size) evaluated: e != d->data() + d->size| yes Evaluation Count:2 | yes Evaluation Count:5037 |
| 2-5037 |
| 5349 | *pp++ = *e++; executed: *pp++ = *e++;Execution Count:2 | 2 |
| 5350 | | - |
| 5351 | return s; executed: return s;Execution Count:5037 | 5037 |
| 5352 | } | - |
| 5353 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 5354 | } executed: }Execution Count:86953 | 86953 |
| 5355 | return *this; executed: return *this;Execution Count:4133 | 4133 |
| 5356 | } | - |
| 5357 | | - |
| 5358 | // ### Qt 6: Consider whether this function shouldn't be removed See task 202871. | - |
| 5359 | /*! | - |
| 5360 | Safely builds a formatted string from the format string \a cformat | - |
| 5361 | and an arbitrary list of arguments. | - |
| 5362 | | - |
| 5363 | The %lc escape sequence expects a unicode character of type ushort | - |
| 5364 | (as returned by QChar::unicode()). The %ls escape sequence expects | - |
| 5365 | a pointer to a zero-terminated array of unicode characters of type | - |
| 5366 | ushort (as returned by QString::utf16()). | - |
| 5367 | | - |
| 5368 | \note This function expects a UTF-8 string for %s and Latin-1 for | - |
| 5369 | the format string. | - |
| 5370 | | - |
| 5371 | The format string supports most of the conversion specifiers | - |
| 5372 | provided by printf() in the standard C++ library. It doesn't | - |
| 5373 | honor the length modifiers (e.g. \c h for \c short, \c ll for | - |
| 5374 | \c{long long}). If you need those, use the standard snprintf() | - |
| 5375 | function instead: | - |
| 5376 | | - |
| 5377 | \snippet qstring/main.cpp 63 | - |
| 5378 | | - |
| 5379 | \warning We do not recommend using QString::sprintf() in new Qt | - |
| 5380 | code. Instead, consider using QTextStream or arg(), both of | - |
| 5381 | which support Unicode strings seamlessly and are type-safe. | - |
| 5382 | Here's an example that uses QTextStream: | - |
| 5383 | | - |
| 5384 | \snippet qstring/main.cpp 64 | - |
| 5385 | | - |
| 5386 | For \l {QObject::tr()}{translations}, especially if the strings | - |
| 5387 | contains more than one escape sequence, you should consider using | - |
| 5388 | the arg() function instead. This allows the order of the | - |
| 5389 | replacements to be controlled by the translator. | - |
| 5390 | | - |
| 5391 | \sa arg() | - |
| 5392 | */ | - |
| 5393 | | - |
| 5394 | QString &QString::sprintf(const char *cformat, ...) | - |
| 5395 | { | - |
| 5396 | va_list ap; executed (the execution status of this line is deduced): va_list ap; | - |
| 5397 | va_start(ap, cformat); executed (the execution status of this line is deduced): __builtin_va_start(ap,cformat); | - |
| 5398 | QString &s = vsprintf(cformat, ap); executed (the execution status of this line is deduced): QString &s = vsprintf(cformat, ap); | - |
| 5399 | va_end(ap); executed (the execution status of this line is deduced): __builtin_va_end(ap); | - |
| 5400 | return s; executed: return s;Execution Count:12040 | 12040 |
| 5401 | } | - |
| 5402 | | - |
| 5403 | /*! | - |
| 5404 | Equivalent method to sprintf(), but takes a va_list \a ap | - |
| 5405 | instead a list of variable arguments. See the sprintf() | - |
| 5406 | documentation for an explanation of \a cformat. | - |
| 5407 | | - |
| 5408 | This method does not call the va_end macro, the caller | - |
| 5409 | is responsible to call va_end on \a ap. | - |
| 5410 | | - |
| 5411 | \sa sprintf() | - |
| 5412 | */ | - |
| 5413 | | - |
| 5414 | QString &QString::vsprintf(const char* cformat, va_list ap) | - |
| 5415 | { | - |
| 5416 | QLocale locale(QLocale::C); executed (the execution status of this line is deduced): QLocale locale(QLocale::C); | - |
| 5417 | | - |
| 5418 | if (!cformat || !*cformat) { evaluated: !cformat| yes Evaluation Count:1 | yes Evaluation Count:12974 |
partially evaluated: !*cformat| no Evaluation Count:0 | yes Evaluation Count:12974 |
| 0-12974 |
| 5419 | // Qt 1.x compat | - |
| 5420 | *this = fromLatin1(""); executed (the execution status of this line is deduced): *this = fromLatin1(""); | - |
| 5421 | return *this; executed: return *this;Execution Count:1 | 1 |
| 5422 | } | - |
| 5423 | | - |
| 5424 | // Parse cformat | - |
| 5425 | | - |
| 5426 | QString result; executed (the execution status of this line is deduced): QString result; | - |
| 5427 | const char *c = cformat; executed (the execution status of this line is deduced): const char *c = cformat; | - |
| 5428 | for (;;) { executed (the execution status of this line is deduced): for (;;) { | - |
| 5429 | // Copy non-escape chars to result | - |
| 5430 | while (*c != '\0' && *c != '%') evaluated: *c != '\0'| yes Evaluation Count:71444 | yes Evaluation Count:12974 |
evaluated: *c != '%'| yes Evaluation Count:56185 | yes Evaluation Count:15259 |
| 12974-71444 |
| 5431 | result.append(QLatin1Char(*c++)); executed: result.append(QLatin1Char(*c++));Execution Count:56185 | 56185 |
| 5432 | | - |
| 5433 | if (*c == '\0') evaluated: *c == '\0'| yes Evaluation Count:12974 | yes Evaluation Count:15259 |
| 12974-15259 |
| 5434 | break; executed: break;Execution Count:12974 | 12974 |
| 5435 | | - |
| 5436 | // Found '%' | - |
| 5437 | const char *escape_start = c; executed (the execution status of this line is deduced): const char *escape_start = c; | - |
| 5438 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5439 | | - |
| 5440 | if (*c == '\0') { partially evaluated: *c == '\0'| no Evaluation Count:0 | yes Evaluation Count:15259 |
| 0-15259 |
| 5441 | result.append(QLatin1Char('%')); // a % at the end of the string - treat as non-escape text never executed (the execution status of this line is deduced): result.append(QLatin1Char('%')); | - |
| 5442 | break; | 0 |
| 5443 | } | - |
| 5444 | if (*c == '%') { evaluated: *c == '%'| yes Evaluation Count:1 | yes Evaluation Count:15258 |
| 1-15258 |
| 5445 | result.append(QLatin1Char('%')); // %% executed (the execution status of this line is deduced): result.append(QLatin1Char('%')); | - |
| 5446 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5447 | continue; executed: continue;Execution Count:1 | 1 |
| 5448 | } | - |
| 5449 | | - |
| 5450 | // Parse flag characters | - |
| 5451 | uint flags = 0; executed (the execution status of this line is deduced): uint flags = 0; | - |
| 5452 | bool no_more_flags = false; executed (the execution status of this line is deduced): bool no_more_flags = false; | - |
| 5453 | do { | - |
| 5454 | switch (*c) { | - |
| 5455 | case '#': flags |= QLocalePrivate::Alternate; break; executed: break;Execution Count:4992 | 4992 |
| 5456 | case '0': flags |= QLocalePrivate::ZeroPadded; break; executed: break;Execution Count:7032 | 7032 |
| 5457 | case '-': flags |= QLocalePrivate::LeftAdjusted; break; executed: break;Execution Count:4997 | 4997 |
| 5458 | case ' ': flags |= QLocalePrivate::BlankBeforePositive; break; executed: break;Execution Count:4992 | 4992 |
| 5459 | case '+': flags |= QLocalePrivate::AlwaysShowSign; break; executed: break;Execution Count:4992 | 4992 |
| 5460 | case '\'': flags |= QLocalePrivate::ThousandsGroup; break; executed: break;Execution Count:9984 | 9984 |
| 5461 | default: no_more_flags = true; break; executed: break;Execution Count:15258 | 15258 |
| 5462 | } | - |
| 5463 | | - |
| 5464 | if (!no_more_flags) evaluated: !no_more_flags| yes Evaluation Count:36989 | yes Evaluation Count:15258 |
| 15258-36989 |
| 5465 | ++c; executed: ++c;Execution Count:36989 | 36989 |
| 5466 | } while (!no_more_flags); executed: }Execution Count:52247 evaluated: !no_more_flags| yes Evaluation Count:36989 | yes Evaluation Count:15258 |
| 15258-52247 |
| 5467 | | - |
| 5468 | if (*c == '\0') { partially evaluated: *c == '\0'| no Evaluation Count:0 | yes Evaluation Count:15258 |
| 0-15258 |
| 5469 | result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text never executed (the execution status of this line is deduced): result.append(QLatin1String(escape_start)); | - |
| 5470 | break; | 0 |
| 5471 | } | - |
| 5472 | | - |
| 5473 | // Parse field width | - |
| 5474 | int width = -1; // -1 means unspecified executed (the execution status of this line is deduced): int width = -1; | - |
| 5475 | if (qIsDigit(*c)) { evaluated: qIsDigit(*c)| yes Evaluation Count:9536 | yes Evaluation Count:5722 |
| 5722-9536 |
| 5476 | QString width_str; executed (the execution status of this line is deduced): QString width_str; | - |
| 5477 | while (*c != '\0' && qIsDigit(*c)) partially evaluated: *c != '\0'| yes Evaluation Count:21572 | no Evaluation Count:0 |
evaluated: qIsDigit(*c)| yes Evaluation Count:12036 | yes Evaluation Count:9536 |
| 0-21572 |
| 5478 | width_str.append(QLatin1Char(*c++)); executed: width_str.append(QLatin1Char(*c++));Execution Count:12036 | 12036 |
| 5479 | | - |
| 5480 | // can't be negative - started with a digit | - |
| 5481 | // contains at least one digit | - |
| 5482 | width = width_str.toInt(); executed (the execution status of this line is deduced): width = width_str.toInt(); | - |
| 5483 | } executed: }Execution Count:9536 | 9536 |
| 5484 | else if (*c == '*') { evaluated: *c == '*'| yes Evaluation Count:1 | yes Evaluation Count:5721 |
| 1-5721 |
| 5485 | width = va_arg(ap, int); executed (the execution status of this line is deduced): width = __builtin_va_arg(ap,int); | - |
| 5486 | if (width < 0) partially evaluated: width < 0| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 5487 | width = -1; // treat all negative numbers as unspecified never executed: width = -1; | 0 |
| 5488 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5489 | } executed: }Execution Count:1 | 1 |
| 5490 | | - |
| 5491 | if (*c == '\0') { partially evaluated: *c == '\0'| no Evaluation Count:0 | yes Evaluation Count:15258 |
| 0-15258 |
| 5492 | result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text never executed (the execution status of this line is deduced): result.append(QLatin1String(escape_start)); | - |
| 5493 | break; | 0 |
| 5494 | } | - |
| 5495 | | - |
| 5496 | // Parse precision | - |
| 5497 | int precision = -1; // -1 means unspecified executed (the execution status of this line is deduced): int precision = -1; | - |
| 5498 | if (*c == '.') { evaluated: *c == '.'| yes Evaluation Count:9329 | yes Evaluation Count:5929 |
| 5929-9329 |
| 5499 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5500 | if (qIsDigit(*c)) { evaluated: qIsDigit(*c)| yes Evaluation Count:9328 | yes Evaluation Count:1 |
| 1-9328 |
| 5501 | QString precision_str; executed (the execution status of this line is deduced): QString precision_str; | - |
| 5502 | while (*c != '\0' && qIsDigit(*c)) partially evaluated: *c != '\0'| yes Evaluation Count:21155 | no Evaluation Count:0 |
evaluated: qIsDigit(*c)| yes Evaluation Count:11827 | yes Evaluation Count:9328 |
| 0-21155 |
| 5503 | precision_str.append(QLatin1Char(*c++)); executed: precision_str.append(QLatin1Char(*c++));Execution Count:11827 | 11827 |
| 5504 | | - |
| 5505 | // can't be negative - started with a digit | - |
| 5506 | // contains at least one digit | - |
| 5507 | precision = precision_str.toInt(); executed (the execution status of this line is deduced): precision = precision_str.toInt(); | - |
| 5508 | } executed: }Execution Count:9328 | 9328 |
| 5509 | else if (*c == '*') { partially evaluated: *c == '*'| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 5510 | precision = va_arg(ap, int); executed (the execution status of this line is deduced): precision = __builtin_va_arg(ap,int); | - |
| 5511 | if (precision < 0) partially evaluated: precision < 0| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 5512 | precision = -1; // treat all negative numbers as unspecified never executed: precision = -1; | 0 |
| 5513 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5514 | } executed: }Execution Count:1 | 1 |
| 5515 | } | - |
| 5516 | | - |
| 5517 | if (*c == '\0') { partially evaluated: *c == '\0'| no Evaluation Count:0 | yes Evaluation Count:15258 |
| 0-15258 |
| 5518 | result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text never executed (the execution status of this line is deduced): result.append(QLatin1String(escape_start)); | - |
| 5519 | break; | 0 |
| 5520 | } | - |
| 5521 | | - |
| 5522 | // Parse the length modifier | - |
| 5523 | enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t }; executed (the execution status of this line is deduced): enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t }; | - |
| 5524 | LengthMod length_mod = lm_none; executed (the execution status of this line is deduced): LengthMod length_mod = lm_none; | - |
| 5525 | switch (*c) { | - |
| 5526 | case 'h': | - |
| 5527 | ++c; never executed (the execution status of this line is deduced): ++c; | - |
| 5528 | if (*c == 'h') { never evaluated: *c == 'h' | 0 |
| 5529 | length_mod = lm_hh; never executed (the execution status of this line is deduced): length_mod = lm_hh; | - |
| 5530 | ++c; never executed (the execution status of this line is deduced): ++c; | - |
| 5531 | } | 0 |
| 5532 | else | - |
| 5533 | length_mod = lm_h; never executed: length_mod = lm_h; | 0 |
| 5534 | break; | 0 |
| 5535 | | - |
| 5536 | case 'l': | - |
| 5537 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5538 | if (*c == 'l') { evaluated: *c == 'l'| yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
| 5539 | length_mod = lm_ll; executed (the execution status of this line is deduced): length_mod = lm_ll; | - |
| 5540 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5541 | } executed: }Execution Count:1 | 1 |
| 5542 | else | - |
| 5543 | length_mod = lm_l; executed: length_mod = lm_l;Execution Count:3 | 3 |
| 5544 | break; executed: break;Execution Count:4 | 4 |
| 5545 | | - |
| 5546 | case 'L': | - |
| 5547 | ++c; never executed (the execution status of this line is deduced): ++c; | - |
| 5548 | length_mod = lm_L; never executed (the execution status of this line is deduced): length_mod = lm_L; | - |
| 5549 | break; | 0 |
| 5550 | | - |
| 5551 | case 'j': | - |
| 5552 | ++c; never executed (the execution status of this line is deduced): ++c; | - |
| 5553 | length_mod = lm_j; never executed (the execution status of this line is deduced): length_mod = lm_j; | - |
| 5554 | break; | 0 |
| 5555 | | - |
| 5556 | case 'z': | - |
| 5557 | case 'Z': | - |
| 5558 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5559 | length_mod = lm_z; executed (the execution status of this line is deduced): length_mod = lm_z; | - |
| 5560 | break; executed: break;Execution Count:3 | 3 |
| 5561 | | - |
| 5562 | case 't': | - |
| 5563 | ++c; never executed (the execution status of this line is deduced): ++c; | - |
| 5564 | length_mod = lm_t; never executed (the execution status of this line is deduced): length_mod = lm_t; | - |
| 5565 | break; | 0 |
| 5566 | | - |
| 5567 | default: break; executed: break;Execution Count:15251 | 15251 |
| 5568 | } | - |
| 5569 | | - |
| 5570 | if (*c == '\0') { partially evaluated: *c == '\0'| no Evaluation Count:0 | yes Evaluation Count:15258 |
| 0-15258 |
| 5571 | result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text never executed (the execution status of this line is deduced): result.append(QLatin1String(escape_start)); | - |
| 5572 | break; | 0 |
| 5573 | } | - |
| 5574 | | - |
| 5575 | // Parse the conversion specifier and do the conversion | - |
| 5576 | QString subst; executed (the execution status of this line is deduced): QString subst; | - |
| 5577 | switch (*c) { | - |
| 5578 | case 'd': | - |
| 5579 | case 'i': { | - |
| 5580 | qint64 i; executed (the execution status of this line is deduced): qint64 i; | - |
| 5581 | switch (length_mod) { | - |
| 5582 | case lm_none: i = va_arg(ap, int); break; executed: break;Execution Count:2198 | 2198 |
| 5583 | case lm_hh: i = va_arg(ap, int); break; | 0 |
| 5584 | case lm_h: i = va_arg(ap, int); break; | 0 |
| 5585 | case lm_l: i = va_arg(ap, long int); break; executed: break;Execution Count:1 | 1 |
| 5586 | case lm_ll: i = va_arg(ap, qint64); break; | 0 |
| 5587 | case lm_j: i = va_arg(ap, long int); break; | 0 |
| 5588 | case lm_z: i = va_arg(ap, size_t); break; | 0 |
| 5589 | case lm_t: i = va_arg(ap, int); break; | 0 |
| 5590 | default: i = 0; break; | 0 |
| 5591 | } | - |
| 5592 | subst = locale.d->longLongToString(i, precision, 10, width, flags); executed (the execution status of this line is deduced): subst = locale.d->longLongToString(i, precision, 10, width, flags); | - |
| 5593 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5594 | break; executed: break;Execution Count:2199 | 2199 |
| 5595 | } | - |
| 5596 | case 'o': | - |
| 5597 | case 'u': | - |
| 5598 | case 'x': | - |
| 5599 | case 'X': { | - |
| 5600 | quint64 u; executed (the execution status of this line is deduced): quint64 u; | - |
| 5601 | switch (length_mod) { | - |
| 5602 | case lm_none: u = va_arg(ap, uint); break; executed: break;Execution Count:2046 | 2046 |
| 5603 | case lm_hh: u = va_arg(ap, uint); break; | 0 |
| 5604 | case lm_h: u = va_arg(ap, uint); break; | 0 |
| 5605 | case lm_l: u = va_arg(ap, ulong); break; | 0 |
| 5606 | case lm_ll: u = va_arg(ap, quint64); break; | 0 |
| 5607 | case lm_z: u = va_arg(ap, size_t); break; executed: break;Execution Count:3 | 3 |
| 5608 | default: u = 0; break; | 0 |
| 5609 | } | - |
| 5610 | | - |
| 5611 | if (qIsUpper(*c)) partially evaluated: qIsUpper(*c)| no Evaluation Count:0 | yes Evaluation Count:2049 |
| 0-2049 |
| 5612 | flags |= QLocalePrivate::CapitalEorX; never executed: flags |= QLocalePrivate::CapitalEorX; | 0 |
| 5613 | | - |
| 5614 | int base = 10; executed (the execution status of this line is deduced): int base = 10; | - |
| 5615 | switch (qToLower(*c)) { | - |
| 5616 | case 'o': | - |
| 5617 | base = 8; break; | 0 |
| 5618 | case 'u': | - |
| 5619 | base = 10; break; executed: break;Execution Count:6 | 6 |
| 5620 | case 'x': | - |
| 5621 | base = 16; break; executed: break;Execution Count:2043 | 2043 |
| 5622 | default: break; | 0 |
| 5623 | } | - |
| 5624 | subst = locale.d->unsLongLongToString(u, precision, base, width, flags); executed (the execution status of this line is deduced): subst = locale.d->unsLongLongToString(u, precision, base, width, flags); | - |
| 5625 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5626 | break; executed: break;Execution Count:2049 | 2049 |
| 5627 | } | - |
| 5628 | case 'E': | - |
| 5629 | case 'e': | - |
| 5630 | case 'F': | - |
| 5631 | case 'f': | - |
| 5632 | case 'G': | - |
| 5633 | case 'g': | - |
| 5634 | case 'A': | - |
| 5635 | case 'a': { | - |
| 5636 | double d; executed (the execution status of this line is deduced): double d; | - |
| 5637 | if (length_mod == lm_L) partially evaluated: length_mod == lm_L| no Evaluation Count:0 | yes Evaluation Count:10009 |
| 0-10009 |
| 5638 | d = va_arg(ap, long double); // not supported - converted to a double never executed: d = __builtin_va_arg(ap,long double); | 0 |
| 5639 | else | - |
| 5640 | d = va_arg(ap, double); executed: d = __builtin_va_arg(ap,double);Execution Count:10009 | 10009 |
| 5641 | | - |
| 5642 | if (qIsUpper(*c)) evaluated: qIsUpper(*c)| yes Evaluation Count:4992 | yes Evaluation Count:5017 |
| 4992-5017 |
| 5643 | flags |= QLocalePrivate::CapitalEorX; executed: flags |= QLocalePrivate::CapitalEorX;Execution Count:4992 | 4992 |
| 5644 | | - |
| 5645 | QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; executed (the execution status of this line is deduced): QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; | - |
| 5646 | switch (qToLower(*c)) { | - |
| 5647 | case 'e': form = QLocalePrivate::DFExponent; break; | 0 |
| 5648 | case 'a': // not supported - decimal form used instead | - |
| 5649 | case 'f': form = QLocalePrivate::DFDecimal; break; executed: break;Execution Count:16 | 16 |
| 5650 | case 'g': form = QLocalePrivate::DFSignificantDigits; break; executed: break;Execution Count:9993 | 9993 |
| 5651 | default: break; | 0 |
| 5652 | } | - |
| 5653 | subst = locale.d->doubleToString(d, precision, form, width, flags); executed (the execution status of this line is deduced): subst = locale.d->doubleToString(d, precision, form, width, flags); | - |
| 5654 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5655 | break; executed: break;Execution Count:10009 | 10009 |
| 5656 | } | - |
| 5657 | case 'c': { | - |
| 5658 | if (length_mod == lm_l) partially evaluated: length_mod == lm_l| no Evaluation Count:0 | yes Evaluation Count:120 |
| 0-120 |
| 5659 | subst = QChar((ushort) va_arg(ap, int)); never executed: subst = QChar((ushort) __builtin_va_arg(ap,int)); | 0 |
| 5660 | else | - |
| 5661 | subst = QLatin1Char((uchar) va_arg(ap, int)); executed: subst = QLatin1Char((uchar) __builtin_va_arg(ap,int));Execution Count:120 | 120 |
| 5662 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5663 | break; executed: break;Execution Count:120 | 120 |
| 5664 | } | - |
| 5665 | case 's': { | - |
| 5666 | if (length_mod == lm_l) { partially evaluated: length_mod == lm_l| no Evaluation Count:0 | yes Evaluation Count:844 |
| 0-844 |
| 5667 | const ushort *buff = va_arg(ap, const ushort*); never executed (the execution status of this line is deduced): const ushort *buff = __builtin_va_arg(ap,const ushort*); | - |
| 5668 | const ushort *ch = buff; never executed (the execution status of this line is deduced): const ushort *ch = buff; | - |
| 5669 | while (*ch != 0) never evaluated: *ch != 0 | 0 |
| 5670 | ++ch; | 0 |
| 5671 | subst.setUtf16(buff, ch - buff); never executed (the execution status of this line is deduced): subst.setUtf16(buff, ch - buff); | - |
| 5672 | } else | 0 |
| 5673 | subst = QString::fromUtf8(va_arg(ap, const char*)); executed: subst = QString::fromUtf8(__builtin_va_arg(ap,const char*));Execution Count:844 | 844 |
| 5674 | if (precision != -1) evaluated: precision != -1| yes Evaluation Count:7 | yes Evaluation Count:837 |
| 7-837 |
| 5675 | subst.truncate(precision); executed: subst.truncate(precision);Execution Count:7 | 7 |
| 5676 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5677 | break; executed: break;Execution Count:844 | 844 |
| 5678 | } | - |
| 5679 | case 'p': { | - |
| 5680 | void *arg = va_arg(ap, void*); executed (the execution status of this line is deduced): void *arg = __builtin_va_arg(ap,void*); | - |
| 5681 | #ifdef Q_OS_WIN64 | - |
| 5682 | quint64 i = reinterpret_cast<quint64>(arg); | - |
| 5683 | #else | - |
| 5684 | quint64 i = reinterpret_cast<unsigned long>(arg); executed (the execution status of this line is deduced): quint64 i = reinterpret_cast<unsigned long>(arg); | - |
| 5685 | #endif | - |
| 5686 | flags |= QLocalePrivate::Alternate; executed (the execution status of this line is deduced): flags |= QLocalePrivate::Alternate; | - |
| 5687 | subst = locale.d->unsLongLongToString(i, precision, 16, width, flags); executed (the execution status of this line is deduced): subst = locale.d->unsLongLongToString(i, precision, 16, width, flags); | - |
| 5688 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5689 | break; executed: break;Execution Count:35 | 35 |
| 5690 | } | - |
| 5691 | case 'n': | - |
| 5692 | switch (length_mod) { | - |
| 5693 | case lm_hh: { | - |
| 5694 | signed char *n = va_arg(ap, signed char*); never executed (the execution status of this line is deduced): signed char *n = __builtin_va_arg(ap,signed char*); | - |
| 5695 | *n = result.length(); never executed (the execution status of this line is deduced): *n = result.length(); | - |
| 5696 | break; | 0 |
| 5697 | } | - |
| 5698 | case lm_h: { | - |
| 5699 | short int *n = va_arg(ap, short int*); never executed (the execution status of this line is deduced): short int *n = __builtin_va_arg(ap,short int*); | - |
| 5700 | *n = result.length(); never executed (the execution status of this line is deduced): *n = result.length(); | - |
| 5701 | break; | 0 |
| 5702 | } | - |
| 5703 | case lm_l: { | - |
| 5704 | long int *n = va_arg(ap, long int*); never executed (the execution status of this line is deduced): long int *n = __builtin_va_arg(ap,long int*); | - |
| 5705 | *n = result.length(); never executed (the execution status of this line is deduced): *n = result.length(); | - |
| 5706 | break; | 0 |
| 5707 | } | - |
| 5708 | case lm_ll: { | - |
| 5709 | qint64 *n = va_arg(ap, qint64*); executed (the execution status of this line is deduced): qint64 *n = __builtin_va_arg(ap,qint64*); | - |
| 5710 | volatile uint tmp = result.length(); // egcs-2.91.66 gets internal executed (the execution status of this line is deduced): volatile uint tmp = result.length(); | - |
| 5711 | *n = tmp; // compiler error without volatile executed (the execution status of this line is deduced): *n = tmp; | - |
| 5712 | break; executed: break;Execution Count:1 | 1 |
| 5713 | } | - |
| 5714 | default: { | - |
| 5715 | int *n = va_arg(ap, int*); executed (the execution status of this line is deduced): int *n = __builtin_va_arg(ap,int*); | - |
| 5716 | *n = result.length(); executed (the execution status of this line is deduced): *n = result.length(); | - |
| 5717 | break; executed: break;Execution Count:1 | 1 |
| 5718 | } | - |
| 5719 | } | - |
| 5720 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 5721 | break; executed: break;Execution Count:2 | 2 |
| 5722 | | - |
| 5723 | default: // bad escape, treat as non-escape text | - |
| 5724 | for (const char *cc = escape_start; cc != c; ++cc) | 0 |
| 5725 | result.append(QLatin1Char(*cc)); never executed: result.append(QLatin1Char(*cc)); | 0 |
| 5726 | continue; never executed: continue; | 0 |
| 5727 | } | - |
| 5728 | | - |
| 5729 | if (flags & QLocalePrivate::LeftAdjusted) evaluated: flags & QLocalePrivate::LeftAdjusted| yes Evaluation Count:4997 | yes Evaluation Count:10261 |
| 4997-10261 |
| 5730 | result.append(subst.leftJustified(width)); executed: result.append(subst.leftJustified(width));Execution Count:4997 | 4997 |
| 5731 | else | - |
| 5732 | result.append(subst.rightJustified(width)); executed: result.append(subst.rightJustified(width));Execution Count:10261 | 10261 |
| 5733 | } | - |
| 5734 | | - |
| 5735 | *this = result; executed (the execution status of this line is deduced): *this = result; | - |
| 5736 | | - |
| 5737 | return *this; executed: return *this;Execution Count:12974 | 12974 |
| 5738 | } | - |
| 5739 | | - |
| 5740 | /*! | - |
| 5741 | Returns the string converted to a \c{long long} using base \a | - |
| 5742 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5743 | Returns 0 if the conversion fails. | - |
| 5744 | | - |
| 5745 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5746 | *\a{ok} is set to true. | - |
| 5747 | | - |
| 5748 | If \a base is 0, the C language convention is used: If the string | - |
| 5749 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5750 | base 8 is used; otherwise, base 10 is used. | - |
| 5751 | | - |
| 5752 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5753 | dependent conversion use QLocale::toLongLong() | - |
| 5754 | | - |
| 5755 | Example: | - |
| 5756 | | - |
| 5757 | \snippet qstring/main.cpp 74 | - |
| 5758 | | - |
| 5759 | \sa number(), toULongLong(), toInt(), QLocale::toLongLong() | - |
| 5760 | */ | - |
| 5761 | | - |
| 5762 | qint64 QString::toLongLong(bool *ok, int base) const | - |
| 5763 | { | - |
| 5764 | #if defined(QT_CHECK_RANGE) | - |
| 5765 | if (base != 0 && (base < 2 || base > 36)) { | - |
| 5766 | qWarning("QString::toLongLong: Invalid base (%d)", base); | - |
| 5767 | base = 10; | - |
| 5768 | } | - |
| 5769 | #endif | - |
| 5770 | | - |
| 5771 | QLocale c_locale(QLocale::C); executed (the execution status of this line is deduced): QLocale c_locale(QLocale::C); | - |
| 5772 | return c_locale.d->stringToLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators); executed: return c_locale.d->stringToLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);Execution Count:84814 | 84814 |
| 5773 | } | - |
| 5774 | | - |
| 5775 | /*! | - |
| 5776 | Returns the string converted to an \c{unsigned long long} using base \a | - |
| 5777 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5778 | Returns 0 if the conversion fails. | - |
| 5779 | | - |
| 5780 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5781 | *\a{ok} is set to true. | - |
| 5782 | | - |
| 5783 | If \a base is 0, the C language convention is used: If the string | - |
| 5784 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5785 | base 8 is used; otherwise, base 10 is used. | - |
| 5786 | | - |
| 5787 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5788 | dependent conversion use QLocale::toULongLong() | - |
| 5789 | | - |
| 5790 | Example: | - |
| 5791 | | - |
| 5792 | \snippet qstring/main.cpp 79 | - |
| 5793 | | - |
| 5794 | \sa number(), toLongLong(), QLocale::toULongLong() | - |
| 5795 | */ | - |
| 5796 | | - |
| 5797 | quint64 QString::toULongLong(bool *ok, int base) const | - |
| 5798 | { | - |
| 5799 | #if defined(QT_CHECK_RANGE) | - |
| 5800 | if (base != 0 && (base < 2 || base > 36)) { | - |
| 5801 | qWarning("QString::toULongLong: Invalid base (%d)", base); | - |
| 5802 | base = 10; | - |
| 5803 | } | - |
| 5804 | #endif | - |
| 5805 | | - |
| 5806 | QLocale c_locale(QLocale::C); executed (the execution status of this line is deduced): QLocale c_locale(QLocale::C); | - |
| 5807 | return c_locale.d->stringToUnsLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators); executed: return c_locale.d->stringToUnsLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);Execution Count:13022 | 13022 |
| 5808 | } | - |
| 5809 | | - |
| 5810 | /*! | - |
| 5811 | \fn long QString::toLong(bool *ok, int base) const | - |
| 5812 | | - |
| 5813 | Returns the string converted to a \c long using base \a | - |
| 5814 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5815 | Returns 0 if the conversion fails. | - |
| 5816 | | - |
| 5817 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5818 | *\a{ok} is set to true. | - |
| 5819 | | - |
| 5820 | If \a base is 0, the C language convention is used: If the string | - |
| 5821 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5822 | base 8 is used; otherwise, base 10 is used. | - |
| 5823 | | - |
| 5824 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5825 | dependent conversion use QLocale::toLong() | - |
| 5826 | | - |
| 5827 | Example: | - |
| 5828 | | - |
| 5829 | \snippet qstring/main.cpp 73 | - |
| 5830 | | - |
| 5831 | \sa number(), toULong(), toInt(), QLocale::toLong() | - |
| 5832 | */ | - |
| 5833 | | - |
| 5834 | long QString::toLong(bool *ok, int base) const | - |
| 5835 | { | - |
| 5836 | qint64 v = toLongLong(ok, base); executed (the execution status of this line is deduced): qint64 v = toLongLong(ok, base); | - |
| 5837 | if (v < LONG_MIN || v > LONG_MAX) { partially evaluated: v < (-9223372036854775807L - 1L)| no Evaluation Count:0 | yes Evaluation Count:54 |
partially evaluated: v > 9223372036854775807L| no Evaluation Count:0 | yes Evaluation Count:54 |
| 0-54 |
| 5838 | if (ok) | 0 |
| 5839 | *ok = false; never executed: *ok = false; | 0 |
| 5840 | v = 0; never executed (the execution status of this line is deduced): v = 0; | - |
| 5841 | } | 0 |
| 5842 | return (long)v; executed: return (long)v;Execution Count:54 | 54 |
| 5843 | } | - |
| 5844 | | - |
| 5845 | /*! | - |
| 5846 | \fn ulong QString::toULong(bool *ok, int base) const | - |
| 5847 | | - |
| 5848 | Returns the string converted to an \c{unsigned long} using base \a | - |
| 5849 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5850 | Returns 0 if the conversion fails. | - |
| 5851 | | - |
| 5852 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5853 | *\a{ok} is set to true. | - |
| 5854 | | - |
| 5855 | If \a base is 0, the C language convention is used: If the string | - |
| 5856 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5857 | base 8 is used; otherwise, base 10 is used. | - |
| 5858 | | - |
| 5859 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5860 | dependent conversion use QLocale::toULong() | - |
| 5861 | | - |
| 5862 | Example: | - |
| 5863 | | - |
| 5864 | \snippet qstring/main.cpp 78 | - |
| 5865 | | - |
| 5866 | \sa number(), QLocale::toULong() | - |
| 5867 | */ | - |
| 5868 | | - |
| 5869 | ulong QString::toULong(bool *ok, int base) const | - |
| 5870 | { | - |
| 5871 | quint64 v = toULongLong(ok, base); executed (the execution status of this line is deduced): quint64 v = toULongLong(ok, base); | - |
| 5872 | if (v > ULONG_MAX) { partially evaluated: v > (9223372036854775807L * 2UL + 1UL)| no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
| 5873 | if (ok) | 0 |
| 5874 | *ok = false; never executed: *ok = false; | 0 |
| 5875 | v = 0; never executed (the execution status of this line is deduced): v = 0; | - |
| 5876 | } | 0 |
| 5877 | return (ulong)v; executed: return (ulong)v;Execution Count:40 | 40 |
| 5878 | } | - |
| 5879 | | - |
| 5880 | | - |
| 5881 | /*! | - |
| 5882 | Returns the string converted to an \c int using base \a | - |
| 5883 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5884 | Returns 0 if the conversion fails. | - |
| 5885 | | - |
| 5886 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5887 | *\a{ok} is set to true. | - |
| 5888 | | - |
| 5889 | If \a base is 0, the C language convention is used: If the string | - |
| 5890 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5891 | base 8 is used; otherwise, base 10 is used. | - |
| 5892 | | - |
| 5893 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5894 | dependent conversion use QLocale::toInt() | - |
| 5895 | | - |
| 5896 | Example: | - |
| 5897 | | - |
| 5898 | \snippet qstring/main.cpp 72 | - |
| 5899 | | - |
| 5900 | \sa number(), toUInt(), toDouble(), QLocale::toInt() | - |
| 5901 | */ | - |
| 5902 | | - |
| 5903 | int QString::toInt(bool *ok, int base) const | - |
| 5904 | { | - |
| 5905 | qint64 v = toLongLong(ok, base); executed (the execution status of this line is deduced): qint64 v = toLongLong(ok, base); | - |
| 5906 | if (v < INT_MIN || v > INT_MAX) { evaluated: v < (-2147483647 - 1)| yes Evaluation Count:1 | yes Evaluation Count:37015 |
evaluated: v > 2147483647| yes Evaluation Count:9 | yes Evaluation Count:37007 |
| 1-37015 |
| 5907 | if (ok) evaluated: ok| yes Evaluation Count:6 | yes Evaluation Count:4 |
| 4-6 |
| 5908 | *ok = false; executed: *ok = false;Execution Count:6 | 6 |
| 5909 | v = 0; executed (the execution status of this line is deduced): v = 0; | - |
| 5910 | } executed: }Execution Count:10 | 10 |
| 5911 | return v; executed: return v;Execution Count:37016 | 37016 |
| 5912 | } | - |
| 5913 | | - |
| 5914 | /*! | - |
| 5915 | Returns the string converted to an \c{unsigned int} using base \a | - |
| 5916 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5917 | Returns 0 if the conversion fails. | - |
| 5918 | | - |
| 5919 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5920 | *\a{ok} is set to true. | - |
| 5921 | | - |
| 5922 | If \a base is 0, the C language convention is used: If the string | - |
| 5923 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5924 | base 8 is used; otherwise, base 10 is used. | - |
| 5925 | | - |
| 5926 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5927 | dependent conversion use QLocale::toUInt() | - |
| 5928 | | - |
| 5929 | Example: | - |
| 5930 | | - |
| 5931 | \snippet qstring/main.cpp 77 | - |
| 5932 | | - |
| 5933 | \sa number(), toInt(), QLocale::toUInt() | - |
| 5934 | */ | - |
| 5935 | | - |
| 5936 | uint QString::toUInt(bool *ok, int base) const | - |
| 5937 | { | - |
| 5938 | quint64 v = toULongLong(ok, base); executed (the execution status of this line is deduced): quint64 v = toULongLong(ok, base); | - |
| 5939 | if (v > UINT_MAX) { evaluated: v > (2147483647 * 2U + 1U)| yes Evaluation Count:3 | yes Evaluation Count:12847 |
| 3-12847 |
| 5940 | if (ok) evaluated: ok| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 5941 | *ok = false; executed: *ok = false;Execution Count:2 | 2 |
| 5942 | v = 0; executed (the execution status of this line is deduced): v = 0; | - |
| 5943 | } executed: }Execution Count:3 | 3 |
| 5944 | return (uint)v; executed: return (uint)v;Execution Count:12850 | 12850 |
| 5945 | } | - |
| 5946 | | - |
| 5947 | /*! | - |
| 5948 | Returns the string converted to a \c short using base \a | - |
| 5949 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5950 | Returns 0 if the conversion fails. | - |
| 5951 | | - |
| 5952 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5953 | *\a{ok} is set to true. | - |
| 5954 | | - |
| 5955 | If \a base is 0, the C language convention is used: If the string | - |
| 5956 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5957 | base 8 is used; otherwise, base 10 is used. | - |
| 5958 | | - |
| 5959 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5960 | dependent conversion use QLocale::toShort() | - |
| 5961 | | - |
| 5962 | Example: | - |
| 5963 | | - |
| 5964 | \snippet qstring/main.cpp 76 | - |
| 5965 | | - |
| 5966 | \sa number(), toUShort(), toInt(), QLocale::toShort() | - |
| 5967 | */ | - |
| 5968 | | - |
| 5969 | short QString::toShort(bool *ok, int base) const | - |
| 5970 | { | - |
| 5971 | long v = toLongLong(ok, base); executed (the execution status of this line is deduced): long v = toLongLong(ok, base); | - |
| 5972 | if (v < SHRT_MIN || v > SHRT_MAX) { evaluated: v < (-32767 - 1)| yes Evaluation Count:3 | yes Evaluation Count:67 |
evaluated: v > 32767| yes Evaluation Count:5 | yes Evaluation Count:62 |
| 3-67 |
| 5973 | if (ok) evaluated: ok| yes Evaluation Count:5 | yes Evaluation Count:3 |
| 3-5 |
| 5974 | *ok = false; executed: *ok = false;Execution Count:5 | 5 |
| 5975 | v = 0; executed (the execution status of this line is deduced): v = 0; | - |
| 5976 | } executed: }Execution Count:8 | 8 |
| 5977 | return (short)v; executed: return (short)v;Execution Count:70 | 70 |
| 5978 | } | - |
| 5979 | | - |
| 5980 | /*! | - |
| 5981 | Returns the string converted to an \c{unsigned short} using base \a | - |
| 5982 | base, which is 10 by default and must be between 2 and 36, or 0. | - |
| 5983 | Returns 0 if the conversion fails. | - |
| 5984 | | - |
| 5985 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 5986 | *\a{ok} is set to true. | - |
| 5987 | | - |
| 5988 | If \a base is 0, the C language convention is used: If the string | - |
| 5989 | begins with "0x", base 16 is used; if the string begins with "0", | - |
| 5990 | base 8 is used; otherwise, base 10 is used. | - |
| 5991 | | - |
| 5992 | The string conversion will always happen in the 'C' locale. For locale | - |
| 5993 | dependent conversion use QLocale::toUShort() | - |
| 5994 | | - |
| 5995 | Example: | - |
| 5996 | | - |
| 5997 | \snippet qstring/main.cpp 80 | - |
| 5998 | | - |
| 5999 | \sa number(), toShort(), QLocale::toUShort() | - |
| 6000 | */ | - |
| 6001 | | - |
| 6002 | ushort QString::toUShort(bool *ok, int base) const | - |
| 6003 | { | - |
| 6004 | ulong v = toULongLong(ok, base); executed (the execution status of this line is deduced): ulong v = toULongLong(ok, base); | - |
| 6005 | if (v > USHRT_MAX) { evaluated: v > (32767 * 2 + 1)| yes Evaluation Count:7 | yes Evaluation Count:55 |
| 7-55 |
| 6006 | if (ok) evaluated: ok| yes Evaluation Count:4 | yes Evaluation Count:3 |
| 3-4 |
| 6007 | *ok = false; executed: *ok = false;Execution Count:4 | 4 |
| 6008 | v = 0; executed (the execution status of this line is deduced): v = 0; | - |
| 6009 | } executed: }Execution Count:7 | 7 |
| 6010 | return (ushort)v; executed: return (ushort)v;Execution Count:62 | 62 |
| 6011 | } | - |
| 6012 | | - |
| 6013 | | - |
| 6014 | /*! | - |
| 6015 | Returns the string converted to a \c double value. | - |
| 6016 | | - |
| 6017 | Returns 0.0 if the conversion fails. | - |
| 6018 | | - |
| 6019 | If a conversion error occurs, \c{*}\a{ok} is set to false; | - |
| 6020 | otherwise \c{*}\a{ok} is set to true. | - |
| 6021 | | - |
| 6022 | \snippet qstring/main.cpp 66 | - |
| 6023 | | - |
| 6024 | Various string formats for floating point numbers can be converted | - |
| 6025 | to double values: | - |
| 6026 | | - |
| 6027 | \snippet qstring/main.cpp 67 | - |
| 6028 | | - |
| 6029 | The string conversion will always happen in the 'C' locale. For locale | - |
| 6030 | dependent conversion use QLocale::toDouble() | - |
| 6031 | | - |
| 6032 | \snippet qstring/main.cpp 68 | - |
| 6033 | | - |
| 6034 | For historic reasons, this function does not handle | - |
| 6035 | thousands group separators. If you need to convert such numbers, | - |
| 6036 | use QLocale::toDouble(). | - |
| 6037 | | - |
| 6038 | \snippet qstring/main.cpp 69 | - |
| 6039 | | - |
| 6040 | \sa number(), QLocale::setDefault(), QLocale::toDouble(), trimmed() | - |
| 6041 | */ | - |
| 6042 | | - |
| 6043 | double QString::toDouble(bool *ok) const | - |
| 6044 | { | - |
| 6045 | QLocale c_locale(QLocale::C); executed (the execution status of this line is deduced): QLocale c_locale(QLocale::C); | - |
| 6046 | return c_locale.d->stringToDouble(*this, ok, QLocalePrivate::FailOnGroupSeparators); executed: return c_locale.d->stringToDouble(*this, ok, QLocalePrivate::FailOnGroupSeparators);Execution Count:2434 | 2434 |
| 6047 | } | - |
| 6048 | | - |
| 6049 | /*! | - |
| 6050 | Returns the string converted to a \c float value. | - |
| 6051 | | - |
| 6052 | If a conversion error occurs, *\a{ok} is set to false; otherwise | - |
| 6053 | *\a{ok} is set to true. Returns 0.0 if the conversion fails. | - |
| 6054 | | - |
| 6055 | The string conversion will always happen in the 'C' locale. For locale | - |
| 6056 | dependent conversion use QLocale::toFloat() | - |
| 6057 | | - |
| 6058 | Example: | - |
| 6059 | | - |
| 6060 | \snippet qstring/main.cpp 71 | - |
| 6061 | | - |
| 6062 | \sa number(), toDouble(), toInt(), QLocale::toFloat() | - |
| 6063 | */ | - |
| 6064 | | - |
| 6065 | #define QT_MAX_FLOAT 3.4028234663852886e+38 | - |
| 6066 | | - |
| 6067 | float QString::toFloat(bool *ok) const | - |
| 6068 | { | - |
| 6069 | bool myOk; executed (the execution status of this line is deduced): bool myOk; | - |
| 6070 | double d = toDouble(&myOk); executed (the execution status of this line is deduced): double d = toDouble(&myOk); | - |
| 6071 | if (!myOk) { evaluated: !myOk| yes Evaluation Count:13 | yes Evaluation Count:18 |
| 13-18 |
| 6072 | if (ok != 0) partially evaluated: ok != 0| yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
| 6073 | *ok = false; executed: *ok = false;Execution Count:13 | 13 |
| 6074 | return 0.0; executed: return 0.0;Execution Count:13 | 13 |
| 6075 | } | - |
| 6076 | if (qIsInf(d)) evaluated: qIsInf(d)| yes Evaluation Count:2 | yes Evaluation Count:16 |
| 2-16 |
| 6077 | return float(d); executed: return float(d);Execution Count:2 | 2 |
| 6078 | if (d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) { evaluated: d > 3.4028234663852886e+38| yes Evaluation Count:1 | yes Evaluation Count:15 |
evaluated: d < -3.4028234663852886e+38| yes Evaluation Count:1 | yes Evaluation Count:14 |
| 1-15 |
| 6079 | if (ok != 0) partially evaluated: ok != 0| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 6080 | *ok = false; executed: *ok = false;Execution Count:2 | 2 |
| 6081 | return 0.0; executed: return 0.0;Execution Count:2 | 2 |
| 6082 | } | - |
| 6083 | if (ok != 0) partially evaluated: ok != 0| yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
| 6084 | *ok = true; executed: *ok = true;Execution Count:14 | 14 |
| 6085 | return float(d); executed: return float(d);Execution Count:14 | 14 |
| 6086 | } | - |
| 6087 | | - |
| 6088 | /*! \fn QString &QString::setNum(int n, int base) | - |
| 6089 | | - |
| 6090 | Sets the string to the printed value of \a n in the specified \a | - |
| 6091 | base, and returns a reference to the string. | - |
| 6092 | | - |
| 6093 | The base is 10 by default and must be between 2 and 36. For bases | - |
| 6094 | other than 10, \a n is treated as an unsigned integer. | - |
| 6095 | | - |
| 6096 | \snippet qstring/main.cpp 56 | - |
| 6097 | | - |
| 6098 | The formatting always uses QLocale::C, i.e., English/UnitedStates. | - |
| 6099 | To get a localized string representation of a number, use | - |
| 6100 | QLocale::toString() with the appropriate locale. | - |
| 6101 | */ | - |
| 6102 | | - |
| 6103 | /*! \fn QString &QString::setNum(uint n, int base) | - |
| 6104 | | - |
| 6105 | \overload | - |
| 6106 | */ | - |
| 6107 | | - |
| 6108 | /*! \fn QString &QString::setNum(long n, int base) | - |
| 6109 | | - |
| 6110 | \overload | - |
| 6111 | */ | - |
| 6112 | | - |
| 6113 | /*! \fn QString &QString::setNum(ulong n, int base) | - |
| 6114 | | - |
| 6115 | \overload | - |
| 6116 | */ | - |
| 6117 | | - |
| 6118 | /*! | - |
| 6119 | \overload | - |
| 6120 | */ | - |
| 6121 | QString &QString::setNum(qlonglong n, int base) | - |
| 6122 | { | - |
| 6123 | #if defined(QT_CHECK_RANGE) | - |
| 6124 | if (base < 2 || base > 36) { | - |
| 6125 | qWarning("QString::setNum: Invalid base (%d)", base); | - |
| 6126 | base = 10; | - |
| 6127 | } | - |
| 6128 | #endif | - |
| 6129 | QLocale locale(QLocale::C); executed (the execution status of this line is deduced): QLocale locale(QLocale::C); | - |
| 6130 | *this = locale.d->longLongToString(n, -1, base); executed (the execution status of this line is deduced): *this = locale.d->longLongToString(n, -1, base); | - |
| 6131 | return *this; executed: return *this;Execution Count:441178 | 441178 |
| 6132 | } | - |
| 6133 | | - |
| 6134 | /*! | - |
| 6135 | \overload | - |
| 6136 | */ | - |
| 6137 | QString &QString::setNum(qulonglong n, int base) | - |
| 6138 | { | - |
| 6139 | #if defined(QT_CHECK_RANGE) | - |
| 6140 | if (base < 2 || base > 36) { | - |
| 6141 | qWarning("QString::setNum: Invalid base (%d)", base); | - |
| 6142 | base = 10; | - |
| 6143 | } | - |
| 6144 | #endif | - |
| 6145 | QLocale locale(QLocale::C); executed (the execution status of this line is deduced): QLocale locale(QLocale::C); | - |
| 6146 | *this = locale.d->unsLongLongToString(n, -1, base); executed (the execution status of this line is deduced): *this = locale.d->unsLongLongToString(n, -1, base); | - |
| 6147 | return *this; executed: return *this;Execution Count:25880 | 25880 |
| 6148 | } | - |
| 6149 | | - |
| 6150 | /*! \fn QString &QString::setNum(short n, int base) | - |
| 6151 | | - |
| 6152 | \overload | - |
| 6153 | */ | - |
| 6154 | | - |
| 6155 | /*! \fn QString &QString::setNum(ushort n, int base) | - |
| 6156 | | - |
| 6157 | \overload | - |
| 6158 | */ | - |
| 6159 | | - |
| 6160 | /*! | - |
| 6161 | \fn QString &QString::setNum(double n, char format, int precision) | - |
| 6162 | \overload | - |
| 6163 | | - |
| 6164 | Sets the string to the printed value of \a n, formatted according | - |
| 6165 | to the given \a format and \a precision, and returns a reference | - |
| 6166 | to the string. | - |
| 6167 | | - |
| 6168 | The \a format can be 'f', 'F', 'e', 'E', 'g' or 'G' (see the | - |
| 6169 | arg() function documentation for an explanation of the formats). | - |
| 6170 | | - |
| 6171 | The formatting always uses QLocale::C, i.e., English/UnitedStates. | - |
| 6172 | To get a localized string representation of a number, use | - |
| 6173 | QLocale::toString() with the appropriate locale. | - |
| 6174 | */ | - |
| 6175 | | - |
| 6176 | QString &QString::setNum(double n, char f, int prec) | - |
| 6177 | { | - |
| 6178 | QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; executed (the execution status of this line is deduced): QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; | - |
| 6179 | uint flags = 0; executed (the execution status of this line is deduced): uint flags = 0; | - |
| 6180 | | - |
| 6181 | if (qIsUpper(f)) partially evaluated: qIsUpper(f)| no Evaluation Count:0 | yes Evaluation Count:1862 |
| 0-1862 |
| 6182 | flags = QLocalePrivate::CapitalEorX; never executed: flags = QLocalePrivate::CapitalEorX; | 0 |
| 6183 | f = qToLower(f); executed (the execution status of this line is deduced): f = qToLower(f); | - |
| 6184 | | - |
| 6185 | switch (f) { | - |
| 6186 | case 'f': | - |
| 6187 | form = QLocalePrivate::DFDecimal; executed (the execution status of this line is deduced): form = QLocalePrivate::DFDecimal; | - |
| 6188 | break; executed: break;Execution Count:682 | 682 |
| 6189 | case 'e': | - |
| 6190 | form = QLocalePrivate::DFExponent; executed (the execution status of this line is deduced): form = QLocalePrivate::DFExponent; | - |
| 6191 | break; executed: break;Execution Count:6 | 6 |
| 6192 | case 'g': | - |
| 6193 | form = QLocalePrivate::DFSignificantDigits; executed (the execution status of this line is deduced): form = QLocalePrivate::DFSignificantDigits; | - |
| 6194 | break; executed: break;Execution Count:1174 | 1174 |
| 6195 | default: | - |
| 6196 | #if defined(QT_CHECK_RANGE) | - |
| 6197 | qWarning("QString::setNum: Invalid format char '%c'", f); | - |
| 6198 | #endif | - |
| 6199 | break; | 0 |
| 6200 | } | - |
| 6201 | | - |
| 6202 | QLocale locale(QLocale::C); executed (the execution status of this line is deduced): QLocale locale(QLocale::C); | - |
| 6203 | *this = locale.d->doubleToString(n, prec, form, -1, flags); executed (the execution status of this line is deduced): *this = locale.d->doubleToString(n, prec, form, -1, flags); | - |
| 6204 | return *this; executed: return *this;Execution Count:1862 | 1862 |
| 6205 | } | - |
| 6206 | | - |
| 6207 | /*! | - |
| 6208 | \fn QString &QString::setNum(float n, char format, int precision) | - |
| 6209 | \overload | - |
| 6210 | | - |
| 6211 | Sets the string to the printed value of \a n, formatted according | - |
| 6212 | to the given \a format and \a precision, and returns a reference | - |
| 6213 | to the string. | - |
| 6214 | | - |
| 6215 | The formatting always uses QLocale::C, i.e., English/UnitedStates. | - |
| 6216 | To get a localized string representation of a number, use | - |
| 6217 | QLocale::toString() with the appropriate locale. | - |
| 6218 | */ | - |
| 6219 | | - |
| 6220 | | - |
| 6221 | /*! | - |
| 6222 | \fn QString QString::number(long n, int base) | - |
| 6223 | | - |
| 6224 | Returns a string equivalent of the number \a n according to the | - |
| 6225 | specified \a base. | - |
| 6226 | | - |
| 6227 | The base is 10 by default and must be between 2 | - |
| 6228 | and 36. For bases other than 10, \a n is treated as an | - |
| 6229 | unsigned integer. | - |
| 6230 | | - |
| 6231 | The formatting always uses QLocale::C, i.e., English/UnitedStates. | - |
| 6232 | To get a localized string representation of a number, use | - |
| 6233 | QLocale::toString() with the appropriate locale. | - |
| 6234 | | - |
| 6235 | \snippet qstring/main.cpp 35 | - |
| 6236 | | - |
| 6237 | \sa setNum() | - |
| 6238 | */ | - |
| 6239 | | - |
| 6240 | QString QString::number(long n, int base) | - |
| 6241 | { | - |
| 6242 | QString s; executed (the execution status of this line is deduced): QString s; | - |
| 6243 | s.setNum(n, base); executed (the execution status of this line is deduced): s.setNum(n, base); | - |
| 6244 | return s; executed: return s;Execution Count:1 | 1 |
| 6245 | } | - |
| 6246 | | - |
| 6247 | /*! | - |
| 6248 | \fn QString QString::number(ulong n, int base) | - |
| 6249 | | - |
| 6250 | \overload | - |
| 6251 | */ | - |
| 6252 | QString QString::number(ulong n, int base) | - |
| 6253 | { | - |
| 6254 | QString s; executed (the execution status of this line is deduced): QString s; | - |
| 6255 | s.setNum(n, base); executed (the execution status of this line is deduced): s.setNum(n, base); | - |
| 6256 | return s; executed: return s;Execution Count:17 | 17 |
| 6257 | } | - |
| 6258 | | - |
| 6259 | /*! | - |
| 6260 | \overload | - |
| 6261 | */ | - |
| 6262 | QString QString::number(int n, int base) | - |
| 6263 | { | - |
| 6264 | QString s; executed (the execution status of this line is deduced): QString s; | - |
| 6265 | s.setNum(n, base); executed (the execution status of this line is deduced): s.setNum(n, base); | - |
| 6266 | return s; executed: return s;Execution Count:377260 | 377260 |
| 6267 | } | - |
| 6268 | | - |
| 6269 | /*! | - |
| 6270 | \overload | - |
| 6271 | */ | - |
| 6272 | QString QString::number(uint n, int base) | - |
| 6273 | { | - |
| 6274 | QString s; executed (the execution status of this line is deduced): QString s; | - |
| 6275 | s.setNum(n, base); executed (the execution status of this line is deduced): s.setNum(n, base); | - |
| 6276 | return s; executed: return s;Execution Count:25737 | 25737 |
| 6277 | } | - |
| 6278 | | - |
| 6279 | /*! | - |
| 6280 | \overload | - |
| 6281 | */ | - |
| 6282 | QString QString::number(qlonglong n, int base) | - |
| 6283 | { | - |
| 6284 | QString s; executed (the execution status of this line is deduced): QString s; | - |
| 6285 | s.setNum(n, base); executed (the execution status of this line is deduced): s.setNum(n, base); | - |
| 6286 | return s; executed: return s;Execution Count:37082 | 37082 |
| 6287 | } | - |
| 6288 | | - |
| 6289 | /*! | - |
| 6290 | \overload | - |
| 6291 | */ | - |
| 6292 | QString QString::number(qulonglong n, int base) | - |
| 6293 | { | - |
| 6294 | QString s; executed (the execution status of this line is deduced): QString s; | - |
| 6295 | s.setNum(n, base); executed (the execution status of this line is deduced): s.setNum(n, base); | - |
| 6296 | return s; executed: return s;Execution Count:122 | 122 |
| 6297 | } | - |
| 6298 | | - |
| 6299 | | - |
| 6300 | /*! | - |
| 6301 | \fn QString QString::number(double n, char format, int precision) | - |
| 6302 | | - |
| 6303 | Returns a string equivalent of the number \a n, formatted | - |
| 6304 | according to the specified \a format and \a precision. See | - |
| 6305 | \l{Argument Formats} for details. | - |
| 6306 | | - |
| 6307 | Unlike QLocale::toString(), this function does not honor the | - |
| 6308 | user's locale settings. | - |
| 6309 | | - |
| 6310 | \sa setNum(), QLocale::toString() | - |
| 6311 | */ | - |
| 6312 | QString QString::number(double n, char f, int prec) | - |
| 6313 | { | - |
| 6314 | QString s; executed (the execution status of this line is deduced): QString s; | - |
| 6315 | s.setNum(n, f, prec); executed (the execution status of this line is deduced): s.setNum(n, f, prec); | - |
| 6316 | return s; executed: return s;Execution Count:1858 | 1858 |
| 6317 | } | - |
| 6318 | | - |
| 6319 | /*! | - |
| 6320 | Splits the string into substrings wherever \a sep occurs, and | - |
| 6321 | returns the list of those strings. If \a sep does not match | - |
| 6322 | anywhere in the string, split() returns a single-element list | - |
| 6323 | containing this string. | - |
| 6324 | | - |
| 6325 | \a cs specifies whether \a sep should be matched case | - |
| 6326 | sensitively or case insensitively. | - |
| 6327 | | - |
| 6328 | If \a behavior is QString::SkipEmptyParts, empty entries don't | - |
| 6329 | appear in the result. By default, empty entries are kept. | - |
| 6330 | | - |
| 6331 | Example: | - |
| 6332 | | - |
| 6333 | \snippet qstring/main.cpp 62 | - |
| 6334 | | - |
| 6335 | \sa QStringList::join(), section() | - |
| 6336 | */ | - |
| 6337 | QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const | - |
| 6338 | { | - |
| 6339 | QStringList list; executed (the execution status of this line is deduced): QStringList list; | - |
| 6340 | int start = 0; executed (the execution status of this line is deduced): int start = 0; | - |
| 6341 | int extra = 0; executed (the execution status of this line is deduced): int extra = 0; | - |
| 6342 | int end; executed (the execution status of this line is deduced): int end; | - |
| 6343 | while ((end = indexOf(sep, start + extra, cs)) != -1) { evaluated: (end = indexOf(sep, start + extra, cs)) != -1| yes Evaluation Count:23514 | yes Evaluation Count:3262 |
| 3262-23514 |
| 6344 | if (start != end || behavior == KeepEmptyParts) evaluated: start != end| yes Evaluation Count:18459 | yes Evaluation Count:5055 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:157 | yes Evaluation Count:4898 |
| 157-18459 |
| 6345 | list.append(mid(start, end - start)); executed: list.append(mid(start, end - start));Execution Count:18616 | 18616 |
| 6346 | start = end + sep.size(); executed (the execution status of this line is deduced): start = end + sep.size(); | - |
| 6347 | extra = (sep.size() == 0 ? 1 : 0); evaluated: sep.size() == 0| yes Evaluation Count:15 | yes Evaluation Count:23499 |
| 15-23499 |
| 6348 | } executed: }Execution Count:23514 | 23514 |
| 6349 | if (start != size() || behavior == KeepEmptyParts) evaluated: start != size()| yes Evaluation Count:1232 | yes Evaluation Count:2030 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:2019 | yes Evaluation Count:11 |
| 11-2030 |
| 6350 | list.append(mid(start)); executed: list.append(mid(start));Execution Count:3251 | 3251 |
| 6351 | return list; executed: return list;Execution Count:3262 | 3262 |
| 6352 | } | - |
| 6353 | | - |
| 6354 | /*! | - |
| 6355 | \overload | - |
| 6356 | */ | - |
| 6357 | QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const | - |
| 6358 | { | - |
| 6359 | QStringList list; executed (the execution status of this line is deduced): QStringList list; | - |
| 6360 | int start = 0; executed (the execution status of this line is deduced): int start = 0; | - |
| 6361 | int end; executed (the execution status of this line is deduced): int end; | - |
| 6362 | while ((end = indexOf(sep, start, cs)) != -1) { evaluated: (end = indexOf(sep, start, cs)) != -1| yes Evaluation Count:41625 | yes Evaluation Count:11891 |
| 11891-41625 |
| 6363 | if (start != end || behavior == KeepEmptyParts) evaluated: start != end| yes Evaluation Count:35325 | yes Evaluation Count:6300 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:1160 | yes Evaluation Count:5140 |
| 1160-35325 |
| 6364 | list.append(mid(start, end - start)); executed: list.append(mid(start, end - start));Execution Count:36485 | 36485 |
| 6365 | start = end + 1; executed (the execution status of this line is deduced): start = end + 1; | - |
| 6366 | } executed: }Execution Count:41625 | 41625 |
| 6367 | if (start != size() || behavior == KeepEmptyParts) evaluated: start != size()| yes Evaluation Count:11539 | yes Evaluation Count:352 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:218 | yes Evaluation Count:134 |
| 134-11539 |
| 6368 | list.append(mid(start)); executed: list.append(mid(start));Execution Count:11757 | 11757 |
| 6369 | return list; executed: return list;Execution Count:11891 | 11891 |
| 6370 | } | - |
| 6371 | | - |
| 6372 | #ifndef QT_NO_REGEXP | - |
| 6373 | /*! | - |
| 6374 | \overload | - |
| 6375 | | - |
| 6376 | Splits the string into substrings wherever the regular expression | - |
| 6377 | \a rx matches, and returns the list of those strings. If \a rx | - |
| 6378 | does not match anywhere in the string, split() returns a | - |
| 6379 | single-element list containing this string. | - |
| 6380 | | - |
| 6381 | Here's an example where we extract the words in a sentence | - |
| 6382 | using one or more whitespace characters as the separator: | - |
| 6383 | | - |
| 6384 | \snippet qstring/main.cpp 59 | - |
| 6385 | | - |
| 6386 | Here's a similar example, but this time we use any sequence of | - |
| 6387 | non-word characters as the separator: | - |
| 6388 | | - |
| 6389 | \snippet qstring/main.cpp 60 | - |
| 6390 | | - |
| 6391 | Here's a third example where we use a zero-length assertion, | - |
| 6392 | \b{\\b} (word boundary), to split the string into an | - |
| 6393 | alternating sequence of non-word and word tokens: | - |
| 6394 | | - |
| 6395 | \snippet qstring/main.cpp 61 | - |
| 6396 | | - |
| 6397 | \sa QStringList::join(), section() | - |
| 6398 | */ | - |
| 6399 | QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const | - |
| 6400 | { | - |
| 6401 | QRegExp rx2(rx); executed (the execution status of this line is deduced): QRegExp rx2(rx); | - |
| 6402 | QStringList list; executed (the execution status of this line is deduced): QStringList list; | - |
| 6403 | int start = 0; executed (the execution status of this line is deduced): int start = 0; | - |
| 6404 | int extra = 0; executed (the execution status of this line is deduced): int extra = 0; | - |
| 6405 | int end; executed (the execution status of this line is deduced): int end; | - |
| 6406 | while ((end = rx2.indexIn(*this, start + extra)) != -1) { evaluated: (end = rx2.indexIn(*this, start + extra)) != -1| yes Evaluation Count:2342 | yes Evaluation Count:513 |
| 513-2342 |
| 6407 | int matchedLen = rx2.matchedLength(); executed (the execution status of this line is deduced): int matchedLen = rx2.matchedLength(); | - |
| 6408 | if (start != end || behavior == KeepEmptyParts) evaluated: start != end| yes Evaluation Count:1980 | yes Evaluation Count:362 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:351 | yes Evaluation Count:11 |
| 11-1980 |
| 6409 | list.append(mid(start, end - start)); executed: list.append(mid(start, end - start));Execution Count:2331 | 2331 |
| 6410 | start = end + matchedLen; executed (the execution status of this line is deduced): start = end + matchedLen; | - |
| 6411 | extra = (matchedLen == 0) ? 1 : 0; evaluated: (matchedLen == 0)| yes Evaluation Count:31 | yes Evaluation Count:2311 |
| 31-2311 |
| 6412 | } executed: }Execution Count:2342 | 2342 |
| 6413 | if (start != size() || behavior == KeepEmptyParts) evaluated: start != size()| yes Evaluation Count:212 | yes Evaluation Count:301 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:295 | yes Evaluation Count:6 |
| 6-301 |
| 6414 | list.append(mid(start)); executed: list.append(mid(start));Execution Count:507 | 507 |
| 6415 | return list; executed: return list;Execution Count:513 | 513 |
| 6416 | } | - |
| 6417 | #endif | - |
| 6418 | | - |
| 6419 | #ifndef QT_NO_REGEXP | - |
| 6420 | #ifndef QT_BOOTSTRAPPED | - |
| 6421 | /*! | - |
| 6422 | \overload | - |
| 6423 | \since 5.0 | - |
| 6424 | | - |
| 6425 | Splits the string into substrings wherever the regular expression | - |
| 6426 | \a re matches, and returns the list of those strings. If \a re | - |
| 6427 | does not match anywhere in the string, split() returns a | - |
| 6428 | single-element list containing this string. | - |
| 6429 | | - |
| 6430 | Here's an example where we extract the words in a sentence | - |
| 6431 | using one or more whitespace characters as the separator: | - |
| 6432 | | - |
| 6433 | \snippet qstring/main.cpp 90 | - |
| 6434 | | - |
| 6435 | Here's a similar example, but this time we use any sequence of | - |
| 6436 | non-word characters as the separator: | - |
| 6437 | | - |
| 6438 | \snippet qstring/main.cpp 91 | - |
| 6439 | | - |
| 6440 | Here's a third example where we use a zero-length assertion, | - |
| 6441 | \b{\\b} (word boundary), to split the string into an | - |
| 6442 | alternating sequence of non-word and word tokens: | - |
| 6443 | | - |
| 6444 | \snippet qstring/main.cpp 92 | - |
| 6445 | | - |
| 6446 | \sa QStringList::join(), section() | - |
| 6447 | */ | - |
| 6448 | QStringList QString::split(const QRegularExpression &re, SplitBehavior behavior) const | - |
| 6449 | { | - |
| 6450 | QStringList list; executed (the execution status of this line is deduced): QStringList list; | - |
| 6451 | if (!re.isValid()) { partially evaluated: !re.isValid()| no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
| 6452 | qWarning("QString::split: invalid QRegularExpression object"); never executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 6452, __PRETTY_FUNCTION__).warning("QString::split: invalid QRegularExpression object"); | - |
| 6453 | return list; never executed: return list; | 0 |
| 6454 | } | - |
| 6455 | | - |
| 6456 | int start = 0; executed (the execution status of this line is deduced): int start = 0; | - |
| 6457 | int end = 0; executed (the execution status of this line is deduced): int end = 0; | - |
| 6458 | QRegularExpressionMatchIterator iterator = re.globalMatch(*this); executed (the execution status of this line is deduced): QRegularExpressionMatchIterator iterator = re.globalMatch(*this); | - |
| 6459 | while (iterator.hasNext()) { evaluated: iterator.hasNext()| yes Evaluation Count:105 | yes Evaluation Count:27 |
| 27-105 |
| 6460 | QRegularExpressionMatch match = iterator.next(); executed (the execution status of this line is deduced): QRegularExpressionMatch match = iterator.next(); | - |
| 6461 | end = match.capturedStart(); executed (the execution status of this line is deduced): end = match.capturedStart(); | - |
| 6462 | if (start != end || behavior == KeepEmptyParts) evaluated: start != end| yes Evaluation Count:73 | yes Evaluation Count:32 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:21 | yes Evaluation Count:11 |
| 11-73 |
| 6463 | list.append(mid(start, end - start)); executed: list.append(mid(start, end - start));Execution Count:94 | 94 |
| 6464 | start = match.capturedEnd(); executed (the execution status of this line is deduced): start = match.capturedEnd(); | - |
| 6465 | } executed: }Execution Count:105 | 105 |
| 6466 | | - |
| 6467 | if (start != size() || behavior == KeepEmptyParts) evaluated: start != size()| yes Evaluation Count:10 | yes Evaluation Count:17 |
evaluated: behavior == KeepEmptyParts| yes Evaluation Count:11 | yes Evaluation Count:6 |
| 6-17 |
| 6468 | list.append(mid(start)); executed: list.append(mid(start));Execution Count:21 | 21 |
| 6469 | | - |
| 6470 | return list; executed: return list;Execution Count:27 | 27 |
| 6471 | } | - |
| 6472 | #endif // QT_BOOTSTRAPPED | - |
| 6473 | #endif // QT_NO_REGEXP | - |
| 6474 | | - |
| 6475 | /*! | - |
| 6476 | \enum QString::NormalizationForm | - |
| 6477 | | - |
| 6478 | This enum describes the various normalized forms of Unicode text. | - |
| 6479 | | - |
| 6480 | \value NormalizationForm_D Canonical Decomposition | - |
| 6481 | \value NormalizationForm_C Canonical Decomposition followed by Canonical Composition | - |
| 6482 | \value NormalizationForm_KD Compatibility Decomposition | - |
| 6483 | \value NormalizationForm_KC Compatibility Decomposition followed by Canonical Composition | - |
| 6484 | | - |
| 6485 | \sa normalized(), | - |
| 6486 | {http://www.unicode.org/reports/tr15/}{Unicode Standard Annex #15} | - |
| 6487 | */ | - |
| 6488 | | - |
| 6489 | /*! | - |
| 6490 | \since 4.5 | - |
| 6491 | | - |
| 6492 | Returns a copy of this string repeated the specified number of \a times. | - |
| 6493 | | - |
| 6494 | If \a times is less than 1, an empty string is returned. | - |
| 6495 | | - |
| 6496 | Example: | - |
| 6497 | | - |
| 6498 | \code | - |
| 6499 | QString str("ab"); | - |
| 6500 | str.repeated(4); // returns "abababab" | - |
| 6501 | \endcode | - |
| 6502 | */ | - |
| 6503 | QString QString::repeated(int times) const | - |
| 6504 | { | - |
| 6505 | if (d->size == 0) evaluated: d->size == 0| yes Evaluation Count:5 | yes Evaluation Count:9 |
| 5-9 |
| 6506 | return *this; executed: return *this;Execution Count:5 | 5 |
| 6507 | | - |
| 6508 | if (times <= 1) { evaluated: times <= 1| yes Evaluation Count:4 | yes Evaluation Count:5 |
| 4-5 |
| 6509 | if (times == 1) evaluated: times == 1| yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
| 6510 | return *this; executed: return *this;Execution Count:1 | 1 |
| 6511 | return QString(); executed: return QString();Execution Count:3 | 3 |
| 6512 | } | - |
| 6513 | | - |
| 6514 | const int resultSize = times * d->size; executed (the execution status of this line is deduced): const int resultSize = times * d->size; | - |
| 6515 | | - |
| 6516 | QString result; executed (the execution status of this line is deduced): QString result; | - |
| 6517 | result.reserve(resultSize); executed (the execution status of this line is deduced): result.reserve(resultSize); | - |
| 6518 | if (result.d->alloc != uint(resultSize) + 1u) partially evaluated: result.d->alloc != uint(resultSize) + 1u| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 6519 | return QString(); // not enough memory never executed: return QString(); | 0 |
| 6520 | | - |
| 6521 | memcpy(result.d->data(), d->data(), d->size * sizeof(ushort)); executed (the execution status of this line is deduced): memcpy(result.d->data(), d->data(), d->size * sizeof(ushort)); | - |
| 6522 | | - |
| 6523 | int sizeSoFar = d->size; executed (the execution status of this line is deduced): int sizeSoFar = d->size; | - |
| 6524 | ushort *end = result.d->data() + sizeSoFar; executed (the execution status of this line is deduced): ushort *end = result.d->data() + sizeSoFar; | - |
| 6525 | | - |
| 6526 | const int halfResultSize = resultSize >> 1; executed (the execution status of this line is deduced): const int halfResultSize = resultSize >> 1; | - |
| 6527 | while (sizeSoFar <= halfResultSize) { evaluated: sizeSoFar <= halfResultSize| yes Evaluation Count:16 | yes Evaluation Count:5 |
| 5-16 |
| 6528 | memcpy(end, result.d->data(), sizeSoFar * sizeof(ushort)); executed (the execution status of this line is deduced): memcpy(end, result.d->data(), sizeSoFar * sizeof(ushort)); | - |
| 6529 | end += sizeSoFar; executed (the execution status of this line is deduced): end += sizeSoFar; | - |
| 6530 | sizeSoFar <<= 1; executed (the execution status of this line is deduced): sizeSoFar <<= 1; | - |
| 6531 | } executed: }Execution Count:16 | 16 |
| 6532 | memcpy(end, result.d->data(), (resultSize - sizeSoFar) * sizeof(ushort)); executed (the execution status of this line is deduced): memcpy(end, result.d->data(), (resultSize - sizeSoFar) * sizeof(ushort)); | - |
| 6533 | result.d->data()[resultSize] = '\0'; executed (the execution status of this line is deduced): result.d->data()[resultSize] = '\0'; | - |
| 6534 | result.d->size = resultSize; executed (the execution status of this line is deduced): result.d->size = resultSize; | - |
| 6535 | return result; executed: return result;Execution Count:5 | 5 |
| 6536 | } | - |
| 6537 | | - |
| 6538 | void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, int from) | - |
| 6539 | { | - |
| 6540 | bool simple = true; executed (the execution status of this line is deduced): bool simple = true; | - |
| 6541 | const QChar *p = data->constData(); executed (the execution status of this line is deduced): const QChar *p = data->constData(); | - |
| 6542 | int len = data->length(); executed (the execution status of this line is deduced): int len = data->length(); | - |
| 6543 | for (int i = from; i < len; ++i) { evaluated: i < len| yes Evaluation Count:400788 | yes Evaluation Count:11129 |
| 11129-400788 |
| 6544 | if (p[i].unicode() >= 0x80) { evaluated: p[i].unicode() >= 0x80| yes Evaluation Count:356558 | yes Evaluation Count:44230 |
| 44230-356558 |
| 6545 | simple = false; executed (the execution status of this line is deduced): simple = false; | - |
| 6546 | break; executed: break;Execution Count:356558 | 356558 |
| 6547 | } | - |
| 6548 | } executed: }Execution Count:44230 | 44230 |
| 6549 | if (simple) evaluated: simple| yes Evaluation Count:11129 | yes Evaluation Count:356558 |
| 11129-356558 |
| 6550 | return; executed: return;Execution Count:11129 | 11129 |
| 6551 | | - |
| 6552 | if (version == QChar::Unicode_Unassigned) { evaluated: version == QChar::Unicode_Unassigned| yes Evaluation Count:356431 | yes Evaluation Count:127 |
| 127-356431 |
| 6553 | version = QChar::currentUnicodeVersion(); executed (the execution status of this line is deduced): version = QChar::currentUnicodeVersion(); | - |
| 6554 | } else if (int(version) <= NormalizationCorrectionsVersionMax) { executed: }Execution Count:356431 partially evaluated: int(version) <= NormalizationCorrectionsVersionMax| yes Evaluation Count:127 | no Evaluation Count:0 |
| 0-356431 |
| 6555 | const QString &s = *data; executed (the execution status of this line is deduced): const QString &s = *data; | - |
| 6556 | QChar *d = 0; executed (the execution status of this line is deduced): QChar *d = 0; | - |
| 6557 | for (int i = 0; i < NumNormalizationCorrections; ++i) { evaluated: i < NumNormalizationCorrections| yes Evaluation Count:762 | yes Evaluation Count:127 |
| 127-762 |
| 6558 | const NormalizationCorrection &n = uc_normalization_corrections[i]; executed (the execution status of this line is deduced): const NormalizationCorrection &n = uc_normalization_corrections[i]; | - |
| 6559 | if (n.version > version) { evaluated: n.version > version| yes Evaluation Count:637 | yes Evaluation Count:125 |
| 125-637 |
| 6560 | int pos = from; executed (the execution status of this line is deduced): int pos = from; | - |
| 6561 | if (QChar::requiresSurrogates(n.ucs4)) { evaluated: QChar::requiresSurrogates(n.ucs4)| yes Evaluation Count:635 | yes Evaluation Count:2 |
| 2-635 |
| 6562 | ushort ucs4High = QChar::highSurrogate(n.ucs4); executed (the execution status of this line is deduced): ushort ucs4High = QChar::highSurrogate(n.ucs4); | - |
| 6563 | ushort ucs4Low = QChar::lowSurrogate(n.ucs4); executed (the execution status of this line is deduced): ushort ucs4Low = QChar::lowSurrogate(n.ucs4); | - |
| 6564 | ushort oldHigh = QChar::highSurrogate(n.old_mapping); executed (the execution status of this line is deduced): ushort oldHigh = QChar::highSurrogate(n.old_mapping); | - |
| 6565 | ushort oldLow = QChar::lowSurrogate(n.old_mapping); executed (the execution status of this line is deduced): ushort oldLow = QChar::lowSurrogate(n.old_mapping); | - |
| 6566 | while (pos < s.length() - 1) { evaluated: pos < s.length() - 1| yes Evaluation Count:2325 | yes Evaluation Count:635 |
| 635-2325 |
| 6567 | if (s.at(pos).unicode() == ucs4High && s.at(pos + 1).unicode() == ucs4Low) { evaluated: s.at(pos).unicode() == ucs4High| yes Evaluation Count:2 | yes Evaluation Count:2323 |
partially evaluated: s.at(pos + 1).unicode() == ucs4Low| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2323 |
| 6568 | if (!d) partially evaluated: !d| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 6569 | d = data->data(); executed: d = data->data();Execution Count:2 | 2 |
| 6570 | d[pos] = QChar(oldHigh); executed (the execution status of this line is deduced): d[pos] = QChar(oldHigh); | - |
| 6571 | d[++pos] = QChar(oldLow); executed (the execution status of this line is deduced): d[++pos] = QChar(oldLow); | - |
| 6572 | } executed: }Execution Count:2 | 2 |
| 6573 | ++pos; executed (the execution status of this line is deduced): ++pos; | - |
| 6574 | } executed: }Execution Count:2325 | 2325 |
| 6575 | } else { executed: }Execution Count:635 | 635 |
| 6576 | while (pos < s.length()) { evaluated: pos < s.length()| yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
| 6577 | if (s.at(pos).unicode() == n.ucs4) { evaluated: s.at(pos).unicode() == n.ucs4| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
| 6578 | if (!d) partially evaluated: !d| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 6579 | d = data->data(); executed: d = data->data();Execution Count:1 | 1 |
| 6580 | d[pos] = QChar(n.old_mapping); executed (the execution status of this line is deduced): d[pos] = QChar(n.old_mapping); | - |
| 6581 | } executed: }Execution Count:1 | 1 |
| 6582 | ++pos; executed (the execution status of this line is deduced): ++pos; | - |
| 6583 | } executed: }Execution Count:3 | 3 |
| 6584 | } executed: }Execution Count:2 | 2 |
| 6585 | } | - |
| 6586 | } executed: }Execution Count:762 | 762 |
| 6587 | } executed: }Execution Count:127 | 127 |
| 6588 | decomposeHelper(data, mode < QString::NormalizationForm_KD, version, from); executed (the execution status of this line is deduced): decomposeHelper(data, mode < QString::NormalizationForm_KD, version, from); | - |
| 6589 | | - |
| 6590 | canonicalOrderHelper(data, version, from); executed (the execution status of this line is deduced): canonicalOrderHelper(data, version, from); | - |
| 6591 | | - |
| 6592 | if (mode == QString::NormalizationForm_D || mode == QString::NormalizationForm_KD) evaluated: mode == QString::NormalizationForm_D| yes Evaluation Count:89109 | yes Evaluation Count:267449 |
evaluated: mode == QString::NormalizationForm_KD| yes Evaluation Count:89107 | yes Evaluation Count:178342 |
| 89107-267449 |
| 6593 | return; executed: return;Execution Count:178216 | 178216 |
| 6594 | | - |
| 6595 | composeHelper(data, version, from); executed (the execution status of this line is deduced): composeHelper(data, version, from); | - |
| 6596 | } executed: }Execution Count:178342 | 178342 |
| 6597 | | - |
| 6598 | /*! | - |
| 6599 | Returns the string in the given Unicode normalization \a mode, | - |
| 6600 | according to the given \a version of the Unicode standard. | - |
| 6601 | */ | - |
| 6602 | QString QString::normalized(QString::NormalizationForm mode, QChar::UnicodeVersion version) const | - |
| 6603 | { | - |
| 6604 | QString copy = *this; executed (the execution status of this line is deduced): QString copy = *this; | - |
| 6605 | qt_string_normalize(©, mode, version, 0); executed (the execution status of this line is deduced): qt_string_normalize(©, mode, version, 0); | - |
| 6606 | return copy; executed: return copy;Execution Count:367563 | 367563 |
| 6607 | } | - |
| 6608 | | - |
| 6609 | | - |
| 6610 | struct ArgEscapeData | - |
| 6611 | { | - |
| 6612 | int min_escape; // lowest escape sequence number | - |
| 6613 | int occurrences; // number of occurrences of the lowest escape sequence number | - |
| 6614 | int locale_occurrences; // number of occurrences of the lowest escape sequence number that | - |
| 6615 | // contain 'L' | - |
| 6616 | int escape_len; // total length of escape sequences which will be replaced | - |
| 6617 | }; | - |
| 6618 | | - |
| 6619 | static ArgEscapeData findArgEscapes(const QString &s) | - |
| 6620 | { | - |
| 6621 | const QChar *uc_begin = s.unicode(); executed (the execution status of this line is deduced): const QChar *uc_begin = s.unicode(); | - |
| 6622 | const QChar *uc_end = uc_begin + s.length(); executed (the execution status of this line is deduced): const QChar *uc_end = uc_begin + s.length(); | - |
| 6623 | | - |
| 6624 | ArgEscapeData d; executed (the execution status of this line is deduced): ArgEscapeData d; | - |
| 6625 | | - |
| 6626 | d.min_escape = INT_MAX; executed (the execution status of this line is deduced): d.min_escape = 2147483647; | - |
| 6627 | d.occurrences = 0; executed (the execution status of this line is deduced): d.occurrences = 0; | - |
| 6628 | d.escape_len = 0; executed (the execution status of this line is deduced): d.escape_len = 0; | - |
| 6629 | d.locale_occurrences = 0; executed (the execution status of this line is deduced): d.locale_occurrences = 0; | - |
| 6630 | | - |
| 6631 | const QChar *c = uc_begin; executed (the execution status of this line is deduced): const QChar *c = uc_begin; | - |
| 6632 | while (c != uc_end) { evaluated: c != uc_end| yes Evaluation Count:27431553 | yes Evaluation Count:10513349 |
| 10513349-27431553 |
| 6633 | while (c != uc_end && c->unicode() != '%') evaluated: c != uc_end| yes Evaluation Count:100687666 | yes Evaluation Count:2288166 |
evaluated: c->unicode() != '%'| yes Evaluation Count:75544290 | yes Evaluation Count:25143384 |
| 2288166-100687666 |
| 6634 | ++c; executed: ++c;Execution Count:75544290 | 75544290 |
| 6635 | | - |
| 6636 | if (c == uc_end) evaluated: c == uc_end| yes Evaluation Count:2288166 | yes Evaluation Count:25143384 |
| 2288166-25143384 |
| 6637 | break; executed: break;Execution Count:2288166 | 2288166 |
| 6638 | const QChar *escape_start = c; executed (the execution status of this line is deduced): const QChar *escape_start = c; | - |
| 6639 | if (++c == uc_end) evaluated: ++c == uc_end| yes Evaluation Count:5 | yes Evaluation Count:25143379 |
| 5-25143379 |
| 6640 | break; executed: break;Execution Count:5 | 5 |
| 6641 | | - |
| 6642 | bool locale_arg = false; executed (the execution status of this line is deduced): bool locale_arg = false; | - |
| 6643 | if (c->unicode() == 'L') { evaluated: c->unicode() == 'L'| yes Evaluation Count:265 | yes Evaluation Count:25143114 |
| 265-25143114 |
| 6644 | locale_arg = true; executed (the execution status of this line is deduced): locale_arg = true; | - |
| 6645 | if (++c == uc_end) evaluated: ++c == uc_end| yes Evaluation Count:16 | yes Evaluation Count:249 |
| 16-249 |
| 6646 | break; executed: break;Execution Count:16 | 16 |
| 6647 | } executed: }Execution Count:249 | 249 |
| 6648 | | - |
| 6649 | if (c->digitValue() == -1) evaluated: c->digitValue() == -1| yes Evaluation Count:195 | yes Evaluation Count:25143161 |
| 195-25143161 |
| 6650 | continue; executed: continue;Execution Count:195 | 195 |
| 6651 | | - |
| 6652 | int escape = c->digitValue(); executed (the execution status of this line is deduced): int escape = c->digitValue(); | - |
| 6653 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 6654 | | - |
| 6655 | if (c != uc_end && c->digitValue() != -1) { evaluated: c != uc_end| yes Evaluation Count:14629818 | yes Evaluation Count:10513349 |
evaluated: c->digitValue() != -1| yes Evaluation Count:94 | yes Evaluation Count:14629724 |
| 94-14629818 |
| 6656 | escape = (10 * escape) + c->digitValue(); executed (the execution status of this line is deduced): escape = (10 * escape) + c->digitValue(); | - |
| 6657 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 6658 | } executed: }Execution Count:94 | 94 |
| 6659 | | - |
| 6660 | if (escape > d.min_escape) evaluated: escape > d.min_escape| yes Evaluation Count:12285169 | yes Evaluation Count:12857992 |
| 12285169-12857992 |
| 6661 | continue; executed: continue;Execution Count:12285169 | 12285169 |
| 6662 | | - |
| 6663 | if (escape < d.min_escape) { evaluated: escape < d.min_escape| yes Evaluation Count:12857887 | yes Evaluation Count:106 |
| 106-12857887 |
| 6664 | d.min_escape = escape; executed (the execution status of this line is deduced): d.min_escape = escape; | - |
| 6665 | d.occurrences = 0; executed (the execution status of this line is deduced): d.occurrences = 0; | - |
| 6666 | d.escape_len = 0; executed (the execution status of this line is deduced): d.escape_len = 0; | - |
| 6667 | d.locale_occurrences = 0; executed (the execution status of this line is deduced): d.locale_occurrences = 0; | - |
| 6668 | } executed: }Execution Count:12857887 | 12857887 |
| 6669 | | - |
| 6670 | ++d.occurrences; executed (the execution status of this line is deduced): ++d.occurrences; | - |
| 6671 | if (locale_arg) evaluated: locale_arg| yes Evaluation Count:215 | yes Evaluation Count:12857779 |
| 215-12857779 |
| 6672 | ++d.locale_occurrences; executed: ++d.locale_occurrences;Execution Count:215 | 215 |
| 6673 | d.escape_len += c - escape_start; executed (the execution status of this line is deduced): d.escape_len += c - escape_start; | - |
| 6674 | } executed: }Execution Count:12857993 | 12857993 |
| 6675 | return d; executed: return d;Execution Count:12801536 | 12801536 |
| 6676 | } | - |
| 6677 | | - |
| 6678 | static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int field_width, | - |
| 6679 | const QString &arg, const QString &larg, QChar fillChar = QLatin1Char(' ')) | - |
| 6680 | { | - |
| 6681 | const QChar *uc_begin = s.unicode(); executed (the execution status of this line is deduced): const QChar *uc_begin = s.unicode(); | - |
| 6682 | const QChar *uc_end = uc_begin + s.length(); executed (the execution status of this line is deduced): const QChar *uc_end = uc_begin + s.length(); | - |
| 6683 | | - |
| 6684 | int abs_field_width = qAbs(field_width); executed (the execution status of this line is deduced): int abs_field_width = qAbs(field_width); | - |
| 6685 | int result_len = s.length() executed (the execution status of this line is deduced): int result_len = s.length() | - |
| 6686 | - d.escape_len executed (the execution status of this line is deduced): - d.escape_len | - |
| 6687 | + (d.occurrences - d.locale_occurrences) executed (the execution status of this line is deduced): + (d.occurrences - d.locale_occurrences) | - |
| 6688 | *qMax(abs_field_width, arg.length()) executed (the execution status of this line is deduced): *qMax(abs_field_width, arg.length()) | - |
| 6689 | + d.locale_occurrences executed (the execution status of this line is deduced): + d.locale_occurrences | - |
| 6690 | *qMax(abs_field_width, larg.length()); executed (the execution status of this line is deduced): *qMax(abs_field_width, larg.length()); | - |
| 6691 | | - |
| 6692 | QString result(result_len, Qt::Uninitialized); executed (the execution status of this line is deduced): QString result(result_len, Qt::Uninitialized); | - |
| 6693 | QChar *result_buff = (QChar*) result.unicode(); executed (the execution status of this line is deduced): QChar *result_buff = (QChar*) result.unicode(); | - |
| 6694 | | - |
| 6695 | QChar *rc = result_buff; executed (the execution status of this line is deduced): QChar *rc = result_buff; | - |
| 6696 | const QChar *c = uc_begin; executed (the execution status of this line is deduced): const QChar *c = uc_begin; | - |
| 6697 | int repl_cnt = 0; executed (the execution status of this line is deduced): int repl_cnt = 0; | - |
| 6698 | while (c != uc_end) { evaluated: c != uc_end| yes Evaluation Count:12914385 | yes Evaluation Count:12801513 |
| 12801513-12914385 |
| 6699 | /* We don't have to check if we run off the end of the string with c, | - |
| 6700 | because as long as d.occurrences > 0 we KNOW there are valid escape | - |
| 6701 | sequences. */ | - |
| 6702 | | - |
| 6703 | const QChar *text_start = c; executed (the execution status of this line is deduced): const QChar *text_start = c; | - |
| 6704 | | - |
| 6705 | while (c->unicode() != '%') evaluated: c->unicode() != '%'| yes Evaluation Count:55835202 | yes Evaluation Count:12914380 |
| 12914380-55835202 |
| 6706 | ++c; executed: ++c;Execution Count:55835204 | 55835204 |
| 6707 | | - |
| 6708 | const QChar *escape_start = c++; executed (the execution status of this line is deduced): const QChar *escape_start = c++; | - |
| 6709 | | - |
| 6710 | bool locale_arg = false; executed (the execution status of this line is deduced): bool locale_arg = false; | - |
| 6711 | if (c->unicode() == 'L') { evaluated: c->unicode() == 'L'| yes Evaluation Count:215 | yes Evaluation Count:12914164 |
| 215-12914164 |
| 6712 | locale_arg = true; executed (the execution status of this line is deduced): locale_arg = true; | - |
| 6713 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 6714 | } executed: }Execution Count:215 | 215 |
| 6715 | | - |
| 6716 | int escape = c->digitValue(); executed (the execution status of this line is deduced): int escape = c->digitValue(); | - |
| 6717 | if (escape != -1) { evaluated: escape != -1| yes Evaluation Count:12914316 | yes Evaluation Count:63 |
| 63-12914316 |
| 6718 | if (c + 1 != uc_end && (c + 1)->digitValue() != -1) { evaluated: c + 1 != uc_end| yes Evaluation Count:9320364 | yes Evaluation Count:3593962 |
evaluated: (c + 1)->digitValue() != -1| yes Evaluation Count:8 | yes Evaluation Count:9320355 |
| 8-9320364 |
| 6719 | escape = (10 * escape) + (c + 1)->digitValue(); executed (the execution status of this line is deduced): escape = (10 * escape) + (c + 1)->digitValue(); | - |
| 6720 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 6721 | } executed: }Execution Count:8 | 8 |
| 6722 | } executed: }Execution Count:12914313 | 12914313 |
| 6723 | | - |
| 6724 | if (escape != d.min_escape) { evaluated: escape != d.min_escape| yes Evaluation Count:112760 | yes Evaluation Count:12801613 |
| 112760-12801613 |
| 6725 | memcpy(rc, text_start, (c - text_start)*sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(rc, text_start, (c - text_start)*sizeof(QChar)); | - |
| 6726 | rc += c - text_start; executed (the execution status of this line is deduced): rc += c - text_start; | - |
| 6727 | } executed: }Execution Count:112760 | 112760 |
| 6728 | else { | - |
| 6729 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 6730 | | - |
| 6731 | memcpy(rc, text_start, (escape_start - text_start)*sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(rc, text_start, (escape_start - text_start)*sizeof(QChar)); | - |
| 6732 | rc += escape_start - text_start; executed (the execution status of this line is deduced): rc += escape_start - text_start; | - |
| 6733 | | - |
| 6734 | uint pad_chars; executed (the execution status of this line is deduced): uint pad_chars; | - |
| 6735 | if (locale_arg) evaluated: locale_arg| yes Evaluation Count:214 | yes Evaluation Count:12801400 |
| 214-12801400 |
| 6736 | pad_chars = qMax(abs_field_width, larg.length()) - larg.length(); executed: pad_chars = qMax(abs_field_width, larg.length()) - larg.length();Execution Count:214 | 214 |
| 6737 | else | - |
| 6738 | pad_chars = qMax(abs_field_width, arg.length()) - arg.length(); executed: pad_chars = qMax(abs_field_width, arg.length()) - arg.length();Execution Count:12801398 | 12801398 |
| 6739 | | - |
| 6740 | if (field_width > 0) { // left padded evaluated: field_width > 0| yes Evaluation Count:912 | yes Evaluation Count:12800700 |
| 912-12800700 |
| 6741 | for (uint i = 0; i < pad_chars; ++i) evaluated: i < pad_chars| yes Evaluation Count:4895 | yes Evaluation Count:912 |
| 912-4895 |
| 6742 | (rc++)->unicode() = fillChar.unicode(); executed: (rc++)->unicode() = fillChar.unicode();Execution Count:4895 | 4895 |
| 6743 | } executed: }Execution Count:912 | 912 |
| 6744 | | - |
| 6745 | if (locale_arg) { evaluated: locale_arg| yes Evaluation Count:214 | yes Evaluation Count:12801398 |
| 214-12801398 |
| 6746 | memcpy(rc, larg.unicode(), larg.length()*sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(rc, larg.unicode(), larg.length()*sizeof(QChar)); | - |
| 6747 | rc += larg.length(); executed (the execution status of this line is deduced): rc += larg.length(); | - |
| 6748 | } executed: }Execution Count:214 | 214 |
| 6749 | else { | - |
| 6750 | memcpy(rc, arg.unicode(), arg.length()*sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(rc, arg.unicode(), arg.length()*sizeof(QChar)); | - |
| 6751 | rc += arg.length(); executed (the execution status of this line is deduced): rc += arg.length(); | - |
| 6752 | } executed: }Execution Count:12801398 | 12801398 |
| 6753 | | - |
| 6754 | if (field_width < 0) { // right padded evaluated: field_width < 0| yes Evaluation Count:5 | yes Evaluation Count:12801607 |
| 5-12801607 |
| 6755 | for (uint i = 0; i < pad_chars; ++i) evaluated: i < pad_chars| yes Evaluation Count:12 | yes Evaluation Count:5 |
| 5-12 |
| 6756 | (rc++)->unicode() = fillChar.unicode(); executed: (rc++)->unicode() = fillChar.unicode();Execution Count:12 | 12 |
| 6757 | } executed: }Execution Count:5 | 5 |
| 6758 | | - |
| 6759 | if (++repl_cnt == d.occurrences) { evaluated: ++repl_cnt == d.occurrences| yes Evaluation Count:12801508 | yes Evaluation Count:104 |
| 104-12801508 |
| 6760 | memcpy(rc, c, (uc_end - c)*sizeof(QChar)); executed (the execution status of this line is deduced): memcpy(rc, c, (uc_end - c)*sizeof(QChar)); | - |
| 6761 | rc += uc_end - c; executed (the execution status of this line is deduced): rc += uc_end - c; | - |
| 6762 | Q_ASSERT(rc - result_buff == result_len); executed (the execution status of this line is deduced): qt_noop(); | - |
| 6763 | c = uc_end; executed (the execution status of this line is deduced): c = uc_end; | - |
| 6764 | } executed: }Execution Count:12801511 | 12801511 |
| 6765 | } executed: }Execution Count:12801615 | 12801615 |
| 6766 | } | - |
| 6767 | Q_ASSERT(rc == result_buff + result_len); executed (the execution status of this line is deduced): qt_noop(); | - |
| 6768 | | - |
| 6769 | return result; executed: return result;Execution Count:12801513 | 12801513 |
| 6770 | } | - |
| 6771 | | - |
| 6772 | /*! | - |
| 6773 | Returns a copy of this string with the lowest numbered place marker | - |
| 6774 | replaced by string \a a, i.e., \c %1, \c %2, ..., \c %99. | - |
| 6775 | | - |
| 6776 | \a fieldWidth specifies the minimum amount of space that argument \a | - |
| 6777 | a shall occupy. If \a a requires less space than \a fieldWidth, it | - |
| 6778 | is padded to \a fieldWidth with character \a fillChar. A positive | - |
| 6779 | \a fieldWidth produces right-aligned text. A negative \a fieldWidth | - |
| 6780 | produces left-aligned text. | - |
| 6781 | | - |
| 6782 | This example shows how we might create a \c status string for | - |
| 6783 | reporting progress while processing a list of files: | - |
| 6784 | | - |
| 6785 | \snippet qstring/main.cpp 11 | - |
| 6786 | | - |
| 6787 | First, \c arg(i) replaces \c %1. Then \c arg(total) replaces \c | - |
| 6788 | %2. Finally, \c arg(fileName) replaces \c %3. | - |
| 6789 | | - |
| 6790 | One advantage of using arg() over sprintf() is that the order of the | - |
| 6791 | numbered place markers can change, if the application's strings are | - |
| 6792 | translated into other languages, but each arg() will still replace | - |
| 6793 | the lowest numbered unreplaced place marker, no matter where it | - |
| 6794 | appears. Also, if place marker \c %i appears more than once in the | - |
| 6795 | string, the arg() replaces all of them. | - |
| 6796 | | - |
| 6797 | If there is no unreplaced place marker remaining, a warning message | - |
| 6798 | is output and the result is undefined. Place marker numbers must be | - |
| 6799 | in the range 1 to 99. | - |
| 6800 | */ | - |
| 6801 | QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const | - |
| 6802 | { | - |
| 6803 | ArgEscapeData d = findArgEscapes(*this); executed (the execution status of this line is deduced): ArgEscapeData d = findArgEscapes(*this); | - |
| 6804 | | - |
| 6805 | if (d.occurrences == 0) { partially evaluated: d.occurrences == 0| no Evaluation Count:0 | yes Evaluation Count:44309 |
| 0-44309 |
| 6806 | qWarning("QString::arg: Argument missing: %s, %s", toLocal8Bit().data(), never executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 6806, __PRETTY_FUNCTION__).warning("QString::arg: Argument missing: %s, %s", toLocal8Bit().data(), | - |
| 6807 | a.toLocal8Bit().data()); never executed (the execution status of this line is deduced): a.toLocal8Bit().data()); | - |
| 6808 | return *this; never executed: return *this; | 0 |
| 6809 | } | - |
| 6810 | return replaceArgEscapes(*this, d, fieldWidth, a, a, fillChar); executed: return replaceArgEscapes(*this, d, fieldWidth, a, a, fillChar);Execution Count:44309 | 44309 |
| 6811 | } | - |
| 6812 | | - |
| 6813 | /*! | - |
| 6814 | \fn QString QString::arg(const QString& a1, const QString& a2) const | - |
| 6815 | \overload arg() | - |
| 6816 | | - |
| 6817 | This is the same as \c {str.arg(a1).arg(a2)}, except that the | - |
| 6818 | strings \a a1 and \a a2 are replaced in one pass. This can make a | - |
| 6819 | difference if \a a1 contains e.g. \c{%1}: | - |
| 6820 | | - |
| 6821 | \snippet qstring/main.cpp 13 | - |
| 6822 | */ | - |
| 6823 | | - |
| 6824 | /*! | - |
| 6825 | \fn QString QString::arg(const QString& a1, const QString& a2, const QString& a3) const | - |
| 6826 | \overload arg() | - |
| 6827 | | - |
| 6828 | This is the same as calling \c str.arg(a1).arg(a2).arg(a3), except | - |
| 6829 | that the strings \a a1, \a a2 and \a a3 are replaced in one pass. | - |
| 6830 | */ | - |
| 6831 | | - |
| 6832 | /*! | - |
| 6833 | \fn QString QString::arg(const QString& a1, const QString& a2, const QString& a3, const QString& a4) const | - |
| 6834 | \overload arg() | - |
| 6835 | | - |
| 6836 | This is the same as calling \c | - |
| 6837 | {str.arg(a1).arg(a2).arg(a3).arg(a4)}, except that the strings \a | - |
| 6838 | a1, \a a2, \a a3 and \a a4 are replaced in one pass. | - |
| 6839 | */ | - |
| 6840 | | - |
| 6841 | /*! | - |
| 6842 | \fn QString QString::arg(const QString& a1, const QString& a2, const QString& a3, const QString& a4, const QString& a5) const | - |
| 6843 | \overload arg() | - |
| 6844 | | - |
| 6845 | This is the same as calling \c | - |
| 6846 | {str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5)}, except that the strings | - |
| 6847 | \a a1, \a a2, \a a3, \a a4, and \a a5 are replaced in one pass. | - |
| 6848 | */ | - |
| 6849 | | - |
| 6850 | /*! | - |
| 6851 | \fn QString QString::arg(const QString& a1, const QString& a2, const QString& a3, const QString& a4, const QString& a5, const QString& a6) const | - |
| 6852 | \overload arg() | - |
| 6853 | | - |
| 6854 | This is the same as calling \c | - |
| 6855 | {str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6))}, except that | - |
| 6856 | the strings \a a1, \a a2, \a a3, \a a4, \a a5, and \a a6 are | - |
| 6857 | replaced in one pass. | - |
| 6858 | */ | - |
| 6859 | | - |
| 6860 | /*! | - |
| 6861 | \fn QString QString::arg(const QString& a1, const QString& a2, const QString& a3, const QString& a4, const QString& a5, const QString& a6, const QString& a7) const | - |
| 6862 | \overload arg() | - |
| 6863 | | - |
| 6864 | This is the same as calling \c | - |
| 6865 | {str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6).arg(a7)}, | - |
| 6866 | except that the strings \a a1, \a a2, \a a3, \a a4, \a a5, \a a6, | - |
| 6867 | and \a a7 are replaced in one pass. | - |
| 6868 | */ | - |
| 6869 | | - |
| 6870 | /*! | - |
| 6871 | \fn QString QString::arg(const QString& a1, const QString& a2, const QString& a3, const QString& a4, const QString& a5, const QString& a6, const QString& a7, const QString& a8) const | - |
| 6872 | \overload arg() | - |
| 6873 | | - |
| 6874 | This is the same as calling \c | - |
| 6875 | {str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6).arg(a7).arg(a8)}, | - |
| 6876 | except that the strings \a a1, \a a2, \a a3, \a a4, \a a5, \a a6, \a | - |
| 6877 | a7, and \a a8 are replaced in one pass. | - |
| 6878 | */ | - |
| 6879 | | - |
| 6880 | /*! | - |
| 6881 | \fn QString QString::arg(const QString& a1, const QString& a2, const QString& a3, const QString& a4, const QString& a5, const QString& a6, const QString& a7, const QString& a8, const QString& a9) const | - |
| 6882 | \overload arg() | - |
| 6883 | | - |
| 6884 | This is the same as calling \c | - |
| 6885 | {str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6).arg(a7).arg(a8).arg(a9)}, | - |
| 6886 | except that the strings \a a1, \a a2, \a a3, \a a4, \a a5, \a a6, \a | - |
| 6887 | a7, \a a8, and \a a9 are replaced in one pass. | - |
| 6888 | */ | - |
| 6889 | | - |
| 6890 | /*! \fn QString QString::arg(int a, int fieldWidth, int base, QChar fillChar) const | - |
| 6891 | \overload arg() | - |
| 6892 | | - |
| 6893 | The \a a argument is expressed in base \a base, which is 10 by | - |
| 6894 | default and must be between 2 and 36. For bases other than 10, \a a | - |
| 6895 | is treated as an unsigned integer. | - |
| 6896 | | - |
| 6897 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 6898 | padded to and filled with the character \a fillChar. A positive | - |
| 6899 | value produces right-aligned text; a negative value produces | - |
| 6900 | left-aligned text. | - |
| 6901 | | - |
| 6902 | The '%' can be followed by an 'L', in which case the sequence is | - |
| 6903 | replaced with a localized representation of \a a. The conversion | - |
| 6904 | uses the default locale, set by QLocale::setDefault(). If no default | - |
| 6905 | locale was specified, the "C" locale is used. The 'L' flag is | - |
| 6906 | ignored if \a base is not 10. | - |
| 6907 | | - |
| 6908 | \snippet qstring/main.cpp 12 | - |
| 6909 | \snippet qstring/main.cpp 14 | - |
| 6910 | | - |
| 6911 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 6912 | used. For negative numbers, zero padding might appear before the | - |
| 6913 | minus sign. | - |
| 6914 | */ | - |
| 6915 | | - |
| 6916 | /*! \fn QString QString::arg(uint a, int fieldWidth, int base, QChar fillChar) const | - |
| 6917 | \overload arg() | - |
| 6918 | | - |
| 6919 | The \a base argument specifies the base to use when converting the | - |
| 6920 | integer \a a into a string. The base must be between 2 and 36. | - |
| 6921 | | - |
| 6922 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 6923 | used. For negative numbers, zero padding might appear before the | - |
| 6924 | minus sign. | - |
| 6925 | */ | - |
| 6926 | | - |
| 6927 | /*! \fn QString QString::arg(long a, int fieldWidth, int base, QChar fillChar) const | - |
| 6928 | \overload arg() | - |
| 6929 | | - |
| 6930 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 6931 | padded to and filled with the character \a fillChar. A positive | - |
| 6932 | value produces right-aligned text; a negative value produces | - |
| 6933 | left-aligned text. | - |
| 6934 | | - |
| 6935 | The \a a argument is expressed in the given \a base, which is 10 by | - |
| 6936 | default and must be between 2 and 36. | - |
| 6937 | | - |
| 6938 | The '%' can be followed by an 'L', in which case the sequence is | - |
| 6939 | replaced with a localized representation of \a a. The conversion | - |
| 6940 | uses the default locale. The default locale is determined from the | - |
| 6941 | system's locale settings at application startup. It can be changed | - |
| 6942 | using QLocale::setDefault(). The 'L' flag is ignored if \a base is | - |
| 6943 | not 10. | - |
| 6944 | | - |
| 6945 | \snippet qstring/main.cpp 12 | - |
| 6946 | \snippet qstring/main.cpp 14 | - |
| 6947 | | - |
| 6948 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 6949 | used. For negative numbers, zero padding might appear before the | - |
| 6950 | minus sign. | - |
| 6951 | */ | - |
| 6952 | | - |
| 6953 | /*! \fn QString QString::arg(ulong a, int fieldWidth, int base, QChar fillChar) const | - |
| 6954 | \overload arg() | - |
| 6955 | | - |
| 6956 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 6957 | padded to and filled with the character \a fillChar. A positive | - |
| 6958 | value produces right-aligned text; a negative value produces | - |
| 6959 | left-aligned text. | - |
| 6960 | | - |
| 6961 | The \a base argument specifies the base to use when converting the | - |
| 6962 | integer \a a to a string. The base must be between 2 and 36, with 8 | - |
| 6963 | giving octal, 10 decimal, and 16 hexadecimal numbers. | - |
| 6964 | | - |
| 6965 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 6966 | used. For negative numbers, zero padding might appear before the | - |
| 6967 | minus sign. | - |
| 6968 | */ | - |
| 6969 | | - |
| 6970 | /*! | - |
| 6971 | \overload arg() | - |
| 6972 | | - |
| 6973 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 6974 | padded to and filled with the character \a fillChar. A positive | - |
| 6975 | value produces right-aligned text; a negative value produces | - |
| 6976 | left-aligned text. | - |
| 6977 | | - |
| 6978 | The \a base argument specifies the base to use when converting the | - |
| 6979 | integer \a a into a string. The base must be between 2 and 36, with | - |
| 6980 | 8 giving octal, 10 decimal, and 16 hexadecimal numbers. | - |
| 6981 | | - |
| 6982 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 6983 | used. For negative numbers, zero padding might appear before the | - |
| 6984 | minus sign. | - |
| 6985 | */ | - |
| 6986 | QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const | - |
| 6987 | { | - |
| 6988 | ArgEscapeData d = findArgEscapes(*this); executed (the execution status of this line is deduced): ArgEscapeData d = findArgEscapes(*this); | - |
| 6989 | | - |
| 6990 | if (d.occurrences == 0) { evaluated: d.occurrences == 0| yes Evaluation Count:6 | yes Evaluation Count:11709840 |
| 6-11709840 |
| 6991 | qWarning() << "QString::arg: Argument missing:" << *this << ',' << a; executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 6991, __PRETTY_FUNCTION__).warning() << "QString::arg: Argument missing:" << *this << ',' << a; | - |
| 6992 | return *this; executed: return *this;Execution Count:6 | 6 |
| 6993 | } | - |
| 6994 | | - |
| 6995 | unsigned flags = QLocalePrivate::NoFlags; executed (the execution status of this line is deduced): unsigned flags = QLocalePrivate::NoFlags; | - |
| 6996 | if (fillChar == QLatin1Char('0')) evaluated: fillChar == QLatin1Char('0')| yes Evaluation Count:314 | yes Evaluation Count:11709525 |
| 314-11709525 |
| 6997 | flags = QLocalePrivate::ZeroPadded; executed: flags = QLocalePrivate::ZeroPadded;Execution Count:314 | 314 |
| 6998 | | - |
| 6999 | QString arg; executed (the execution status of this line is deduced): QString arg; | - |
| 7000 | if (d.occurrences > d.locale_occurrences) evaluated: d.occurrences > d.locale_occurrences| yes Evaluation Count:11709633 | yes Evaluation Count:206 |
| 206-11709633 |
| 7001 | arg = QLocale::c().d->longLongToString(a, -1, base, fieldWidth, flags); executed: arg = QLocale::c().d->longLongToString(a, -1, base, fieldWidth, flags);Execution Count:11709633 | 11709633 |
| 7002 | | - |
| 7003 | QString locale_arg; executed (the execution status of this line is deduced): QString locale_arg; | - |
| 7004 | if (d.locale_occurrences > 0) { evaluated: d.locale_occurrences > 0| yes Evaluation Count:206 | yes Evaluation Count:11709631 |
| 206-11709631 |
| 7005 | QLocale locale; executed (the execution status of this line is deduced): QLocale locale; | - |
| 7006 | if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) evaluated: !(locale.numberOptions() & QLocale::OmitGroupSeparator)| yes Evaluation Count:205 | yes Evaluation Count:1 |
| 1-205 |
| 7007 | flags |= QLocalePrivate::ThousandsGroup; executed: flags |= QLocalePrivate::ThousandsGroup;Execution Count:205 | 205 |
| 7008 | locale_arg = locale.d->longLongToString(a, -1, base, fieldWidth, flags); executed (the execution status of this line is deduced): locale_arg = locale.d->longLongToString(a, -1, base, fieldWidth, flags); | - |
| 7009 | } executed: }Execution Count:206 | 206 |
| 7010 | | - |
| 7011 | return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar); executed: return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);Execution Count:11709837 | 11709837 |
| 7012 | } | - |
| 7013 | | - |
| 7014 | /*! | - |
| 7015 | \overload arg() | - |
| 7016 | | - |
| 7017 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 7018 | padded to and filled with the character \a fillChar. A positive | - |
| 7019 | value produces right-aligned text; a negative value produces | - |
| 7020 | left-aligned text. | - |
| 7021 | | - |
| 7022 | The \a base argument specifies the base to use when converting the | - |
| 7023 | integer \a a into a string. \a base must be between 2 and 36, with 8 | - |
| 7024 | giving octal, 10 decimal, and 16 hexadecimal numbers. | - |
| 7025 | | - |
| 7026 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 7027 | used. For negative numbers, zero padding might appear before the | - |
| 7028 | minus sign. | - |
| 7029 | */ | - |
| 7030 | QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) const | - |
| 7031 | { | - |
| 7032 | ArgEscapeData d = findArgEscapes(*this); executed (the execution status of this line is deduced): ArgEscapeData d = findArgEscapes(*this); | - |
| 7033 | | - |
| 7034 | if (d.occurrences == 0) { partially evaluated: d.occurrences == 0| no Evaluation Count:0 | yes Evaluation Count:4543 |
| 0-4543 |
| 7035 | qWarning() << "QString::arg: Argument missing:" << *this << ',' << a; never executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 7035, __PRETTY_FUNCTION__).warning() << "QString::arg: Argument missing:" << *this << ',' << a; | - |
| 7036 | return *this; never executed: return *this; | 0 |
| 7037 | } | - |
| 7038 | | - |
| 7039 | unsigned flags = QLocalePrivate::NoFlags; executed (the execution status of this line is deduced): unsigned flags = QLocalePrivate::NoFlags; | - |
| 7040 | if (fillChar == QLatin1Char('0')) partially evaluated: fillChar == QLatin1Char('0')| no Evaluation Count:0 | yes Evaluation Count:4543 |
| 0-4543 |
| 7041 | flags = QLocalePrivate::ZeroPadded; never executed: flags = QLocalePrivate::ZeroPadded; | 0 |
| 7042 | | - |
| 7043 | QString arg; executed (the execution status of this line is deduced): QString arg; | - |
| 7044 | if (d.occurrences > d.locale_occurrences) partially evaluated: d.occurrences > d.locale_occurrences| yes Evaluation Count:4541 | no Evaluation Count:0 |
| 0-4541 |
| 7045 | arg = QLocale::c().d->unsLongLongToString(a, -1, base, fieldWidth, flags); executed: arg = QLocale::c().d->unsLongLongToString(a, -1, base, fieldWidth, flags);Execution Count:4543 | 4543 |
| 7046 | | - |
| 7047 | QString locale_arg; executed (the execution status of this line is deduced): QString locale_arg; | - |
| 7048 | if (d.locale_occurrences > 0) { partially evaluated: d.locale_occurrences > 0| no Evaluation Count:0 | yes Evaluation Count:4544 |
| 0-4544 |
| 7049 | QLocale locale; never executed (the execution status of this line is deduced): QLocale locale; | - |
| 7050 | if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) never evaluated: !(locale.numberOptions() & QLocale::OmitGroupSeparator) | 0 |
| 7051 | flags |= QLocalePrivate::ThousandsGroup; never executed: flags |= QLocalePrivate::ThousandsGroup; | 0 |
| 7052 | locale_arg = locale.d->unsLongLongToString(a, -1, base, fieldWidth, flags); never executed (the execution status of this line is deduced): locale_arg = locale.d->unsLongLongToString(a, -1, base, fieldWidth, flags); | - |
| 7053 | } | 0 |
| 7054 | | - |
| 7055 | return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar); executed: return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);Execution Count:4544 | 4544 |
| 7056 | } | - |
| 7057 | | - |
| 7058 | /*! | - |
| 7059 | \overload arg() | - |
| 7060 | | - |
| 7061 | \fn QString QString::arg(short a, int fieldWidth, int base, QChar fillChar) const | - |
| 7062 | | - |
| 7063 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 7064 | padded to and filled with the character \a fillChar. A positive | - |
| 7065 | value produces right-aligned text; a negative value produces | - |
| 7066 | left-aligned text. | - |
| 7067 | | - |
| 7068 | The \a base argument specifies the base to use when converting the | - |
| 7069 | integer \a a into a string. The base must be between 2 and 36, with | - |
| 7070 | 8 giving octal, 10 decimal, and 16 hexadecimal numbers. | - |
| 7071 | | - |
| 7072 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 7073 | used. For negative numbers, zero padding might appear before the | - |
| 7074 | minus sign. | - |
| 7075 | */ | - |
| 7076 | | - |
| 7077 | /*! | - |
| 7078 | \fn QString QString::arg(ushort a, int fieldWidth, int base, QChar fillChar) const | - |
| 7079 | \overload arg() | - |
| 7080 | | - |
| 7081 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 7082 | padded to and filled with the character \a fillChar. A positive | - |
| 7083 | value produces right-aligned text; a negative value produces | - |
| 7084 | left-aligned text. | - |
| 7085 | | - |
| 7086 | The \a base argument specifies the base to use when converting the | - |
| 7087 | integer \a a into a string. The base must be between 2 and 36, with | - |
| 7088 | 8 giving octal, 10 decimal, and 16 hexadecimal numbers. | - |
| 7089 | | - |
| 7090 | If \a fillChar is '0' (the number 0, ASCII 48), the locale's zero is | - |
| 7091 | used. For negative numbers, zero padding might appear before the | - |
| 7092 | minus sign. | - |
| 7093 | */ | - |
| 7094 | | - |
| 7095 | /*! | - |
| 7096 | \overload arg() | - |
| 7097 | */ | - |
| 7098 | QString QString::arg(QChar a, int fieldWidth, QChar fillChar) const | - |
| 7099 | { | - |
| 7100 | QString c; executed (the execution status of this line is deduced): QString c; | - |
| 7101 | c += a; executed (the execution status of this line is deduced): c += a; | - |
| 7102 | return arg(c, fieldWidth, fillChar); executed: return arg(c, fieldWidth, fillChar);Execution Count:470 | 470 |
| 7103 | } | - |
| 7104 | | - |
| 7105 | /*! | - |
| 7106 | \overload arg() | - |
| 7107 | | - |
| 7108 | The \a a argument is interpreted as a Latin-1 character. | - |
| 7109 | */ | - |
| 7110 | QString QString::arg(char a, int fieldWidth, QChar fillChar) const | - |
| 7111 | { | - |
| 7112 | QString c; executed (the execution status of this line is deduced): QString c; | - |
| 7113 | c += QLatin1Char(a); executed (the execution status of this line is deduced): c += QLatin1Char(a); | - |
| 7114 | return arg(c, fieldWidth, fillChar); executed: return arg(c, fieldWidth, fillChar);Execution Count:3 | 3 |
| 7115 | } | - |
| 7116 | | - |
| 7117 | /*! | - |
| 7118 | \fn QString QString::arg(double a, int fieldWidth, char format, int precision, QChar fillChar) const | - |
| 7119 | \overload arg() | - |
| 7120 | | - |
| 7121 | Argument \a a is formatted according to the specified \a format and | - |
| 7122 | \a precision. See \l{Argument Formats} for details. | - |
| 7123 | | - |
| 7124 | \a fieldWidth specifies the minimum amount of space that \a a is | - |
| 7125 | padded to and filled with the character \a fillChar. A positive | - |
| 7126 | value produces right-aligned text; a negative value produces | - |
| 7127 | left-aligned text. | - |
| 7128 | | - |
| 7129 | \snippet code/src_corelib_tools_qstring.cpp 2 | - |
| 7130 | | - |
| 7131 | The '%' can be followed by an 'L', in which case the sequence is | - |
| 7132 | replaced with a localized representation of \a a. The conversion | - |
| 7133 | uses the default locale, set by QLocale::setDefault(). If no | - |
| 7134 | default locale was specified, the "C" locale is used. | - |
| 7135 | | - |
| 7136 | If \a fillChar is '0' (the number 0, ASCII 48), this function will | - |
| 7137 | use the locale's zero to pad. For negative numbers, the zero padding | - |
| 7138 | will probably appear before the minus sign. | - |
| 7139 | | - |
| 7140 | \sa QLocale::toString() | - |
| 7141 | */ | - |
| 7142 | QString QString::arg(double a, int fieldWidth, char fmt, int prec, QChar fillChar) const | - |
| 7143 | { | - |
| 7144 | ArgEscapeData d = findArgEscapes(*this); executed (the execution status of this line is deduced): ArgEscapeData d = findArgEscapes(*this); | - |
| 7145 | | - |
| 7146 | if (d.occurrences == 0) { partially evaluated: d.occurrences == 0| no Evaluation Count:0 | yes Evaluation Count:1042846 |
| 0-1042846 |
| 7147 | qWarning("QString::arg: Argument missing: %s, %g", toLocal8Bit().data(), a); never executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 7147, __PRETTY_FUNCTION__).warning("QString::arg: Argument missing: %s, %g", toLocal8Bit().data(), a); | - |
| 7148 | return *this; never executed: return *this; | 0 |
| 7149 | } | - |
| 7150 | | - |
| 7151 | unsigned flags = QLocalePrivate::NoFlags; executed (the execution status of this line is deduced): unsigned flags = QLocalePrivate::NoFlags; | - |
| 7152 | if (fillChar == QLatin1Char('0')) evaluated: fillChar == QLatin1Char('0')| yes Evaluation Count:2 | yes Evaluation Count:1042844 |
| 2-1042844 |
| 7153 | flags = QLocalePrivate::ZeroPadded; executed: flags = QLocalePrivate::ZeroPadded;Execution Count:2 | 2 |
| 7154 | | - |
| 7155 | if (qIsUpper(fmt)) partially evaluated: qIsUpper(fmt)| no Evaluation Count:0 | yes Evaluation Count:1042846 |
| 0-1042846 |
| 7156 | flags |= QLocalePrivate::CapitalEorX; never executed: flags |= QLocalePrivate::CapitalEorX; | 0 |
| 7157 | fmt = qToLower(fmt); executed (the execution status of this line is deduced): fmt = qToLower(fmt); | - |
| 7158 | | - |
| 7159 | QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; executed (the execution status of this line is deduced): QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal; | - |
| 7160 | switch (fmt) { | - |
| 7161 | case 'f': | - |
| 7162 | form = QLocalePrivate::DFDecimal; never executed (the execution status of this line is deduced): form = QLocalePrivate::DFDecimal; | - |
| 7163 | break; | 0 |
| 7164 | case 'e': | - |
| 7165 | form = QLocalePrivate::DFExponent; never executed (the execution status of this line is deduced): form = QLocalePrivate::DFExponent; | - |
| 7166 | break; | 0 |
| 7167 | case 'g': | - |
| 7168 | form = QLocalePrivate::DFSignificantDigits; executed (the execution status of this line is deduced): form = QLocalePrivate::DFSignificantDigits; | - |
| 7169 | break; executed: break;Execution Count:1042846 | 1042846 |
| 7170 | default: | - |
| 7171 | #if defined(QT_CHECK_RANGE) | - |
| 7172 | qWarning("QString::arg: Invalid format char '%c'", fmt); | - |
| 7173 | #endif | - |
| 7174 | break; | 0 |
| 7175 | } | - |
| 7176 | | - |
| 7177 | QString arg; executed (the execution status of this line is deduced): QString arg; | - |
| 7178 | if (d.occurrences > d.locale_occurrences) evaluated: d.occurrences > d.locale_occurrences| yes Evaluation Count:1042842 | yes Evaluation Count:4 |
| 4-1042842 |
| 7179 | arg = QLocale::c().d->doubleToString(a, prec, form, fieldWidth, flags); executed: arg = QLocale::c().d->doubleToString(a, prec, form, fieldWidth, flags);Execution Count:1042842 | 1042842 |
| 7180 | | - |
| 7181 | QString locale_arg; executed (the execution status of this line is deduced): QString locale_arg; | - |
| 7182 | if (d.locale_occurrences > 0) { evaluated: d.locale_occurrences > 0| yes Evaluation Count:4 | yes Evaluation Count:1042842 |
| 4-1042842 |
| 7183 | QLocale locale; executed (the execution status of this line is deduced): QLocale locale; | - |
| 7184 | | - |
| 7185 | if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) evaluated: !(locale.numberOptions() & QLocale::OmitGroupSeparator)| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
| 7186 | flags |= QLocalePrivate::ThousandsGroup; executed: flags |= QLocalePrivate::ThousandsGroup;Execution Count:3 | 3 |
| 7187 | locale_arg = locale.d->doubleToString(a, prec, form, fieldWidth, flags); executed (the execution status of this line is deduced): locale_arg = locale.d->doubleToString(a, prec, form, fieldWidth, flags); | - |
| 7188 | } executed: }Execution Count:4 | 4 |
| 7189 | | - |
| 7190 | return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar); executed: return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);Execution Count:1042846 | 1042846 |
| 7191 | } | - |
| 7192 | | - |
| 7193 | static int getEscape(const QChar *uc, int *pos, int len, int maxNumber = 999) | - |
| 7194 | { | - |
| 7195 | int i = *pos; executed (the execution status of this line is deduced): int i = *pos; | - |
| 7196 | ++i; executed (the execution status of this line is deduced): ++i; | - |
| 7197 | if (i < len && uc[i] == QLatin1Char('L')) partially evaluated: i < len| yes Evaluation Count:959754 | no Evaluation Count:0 |
partially evaluated: uc[i] == QLatin1Char('L')| no Evaluation Count:0 | yes Evaluation Count:959754 |
| 0-959754 |
| 7198 | ++i; | 0 |
| 7199 | if (i < len) { partially evaluated: i < len| yes Evaluation Count:959754 | no Evaluation Count:0 |
| 0-959754 |
| 7200 | int escape = uc[i].unicode() - '0'; executed (the execution status of this line is deduced): int escape = uc[i].unicode() - '0'; | - |
| 7201 | if (uint(escape) >= 10U) evaluated: uint(escape) >= 10U| yes Evaluation Count:8 | yes Evaluation Count:959746 |
| 8-959746 |
| 7202 | return -1; executed: return -1;Execution Count:8 | 8 |
| 7203 | ++i; executed (the execution status of this line is deduced): ++i; | - |
| 7204 | while (i < len) { evaluated: i < len| yes Evaluation Count:954760 | yes Evaluation Count:5030 |
| 5030-954760 |
| 7205 | int digit = uc[i].unicode() - '0'; executed (the execution status of this line is deduced): int digit = uc[i].unicode() - '0'; | - |
| 7206 | if (uint(digit) >= 10U) evaluated: uint(digit) >= 10U| yes Evaluation Count:954716 | yes Evaluation Count:44 |
| 44-954716 |
| 7207 | break; executed: break;Execution Count:954716 | 954716 |
| 7208 | escape = (escape * 10) + digit; executed (the execution status of this line is deduced): escape = (escape * 10) + digit; | - |
| 7209 | ++i; executed (the execution status of this line is deduced): ++i; | - |
| 7210 | } executed: }Execution Count:44 | 44 |
| 7211 | if (escape <= maxNumber) { evaluated: escape <= maxNumber| yes Evaluation Count:959713 | yes Evaluation Count:33 |
| 33-959713 |
| 7212 | *pos = i; executed (the execution status of this line is deduced): *pos = i; | - |
| 7213 | return escape; executed: return escape;Execution Count:959713 | 959713 |
| 7214 | } | - |
| 7215 | } executed: }Execution Count:33 | 33 |
| 7216 | return -1; executed: return -1;Execution Count:33 | 33 |
| 7217 | } | - |
| 7218 | | - |
| 7219 | QString QString::multiArg(int numArgs, const QString **args) const | - |
| 7220 | { | - |
| 7221 | QString result; executed (the execution status of this line is deduced): QString result; | - |
| 7222 | QMap<int, int> numbersUsed; executed (the execution status of this line is deduced): QMap<int, int> numbersUsed; | - |
| 7223 | const QChar *uc = (const QChar *) d->data(); executed (the execution status of this line is deduced): const QChar *uc = (const QChar *) d->data(); | - |
| 7224 | const int len = d->size; executed (the execution status of this line is deduced): const int len = d->size; | - |
| 7225 | const int end = len - 1; executed (the execution status of this line is deduced): const int end = len - 1; | - |
| 7226 | int lastNumber = -1; executed (the execution status of this line is deduced): int lastNumber = -1; | - |
| 7227 | int i = 0; executed (the execution status of this line is deduced): int i = 0; | - |
| 7228 | | - |
| 7229 | // populate the numbersUsed map with the %n's that actually occur in the string | - |
| 7230 | while (i < end) { evaluated: i < end| yes Evaluation Count:5624272 | yes Evaluation Count:161516 |
| 161516-5624272 |
| 7231 | if (uc[i] == QLatin1Char('%')) { evaluated: uc[i] == QLatin1Char('%')| yes Evaluation Count:479877 | yes Evaluation Count:5144395 |
| 479877-5144395 |
| 7232 | int number = getEscape(uc, &i, len); executed (the execution status of this line is deduced): int number = getEscape(uc, &i, len); | - |
| 7233 | if (number != -1) { evaluated: number != -1| yes Evaluation Count:479871 | yes Evaluation Count:6 |
| 6-479871 |
| 7234 | numbersUsed.insert(number, -1); executed (the execution status of this line is deduced): numbersUsed.insert(number, -1); | - |
| 7235 | continue; executed: continue;Execution Count:479871 | 479871 |
| 7236 | } | - |
| 7237 | } executed: }Execution Count:6 | 6 |
| 7238 | ++i; executed (the execution status of this line is deduced): ++i; | - |
| 7239 | } executed: }Execution Count:5144401 | 5144401 |
| 7240 | | - |
| 7241 | // assign an argument number to each of the %n's | - |
| 7242 | QMap<int, int>::iterator j = numbersUsed.begin(); executed (the execution status of this line is deduced): QMap<int, int>::iterator j = numbersUsed.begin(); | - |
| 7243 | QMap<int, int>::iterator jend = numbersUsed.end(); executed (the execution status of this line is deduced): QMap<int, int>::iterator jend = numbersUsed.end(); | - |
| 7244 | int arg = 0; executed (the execution status of this line is deduced): int arg = 0; | - |
| 7245 | while (j != jend && arg < numArgs) { evaluated: j != jend| yes Evaluation Count:479867 | yes Evaluation Count:161489 |
evaluated: arg < numArgs| yes Evaluation Count:479840 | yes Evaluation Count:27 |
| 27-479867 |
| 7246 | *j = arg++; executed (the execution status of this line is deduced): *j = arg++; | - |
| 7247 | lastNumber = j.key(); executed (the execution status of this line is deduced): lastNumber = j.key(); | - |
| 7248 | ++j; executed (the execution status of this line is deduced): ++j; | - |
| 7249 | } executed: }Execution Count:479840 | 479840 |
| 7250 | | - |
| 7251 | // sanity | - |
| 7252 | if (numArgs > arg) { partially evaluated: numArgs > arg| no Evaluation Count:0 | yes Evaluation Count:161516 |
| 0-161516 |
| 7253 | qWarning("QString::arg: %d argument(s) missing in %s", numArgs - arg, toLocal8Bit().data()); never executed (the execution status of this line is deduced): QMessageLogger("tools/qstring.cpp", 7253, __PRETTY_FUNCTION__).warning("QString::arg: %d argument(s) missing in %s", numArgs - arg, toLocal8Bit().data()); | - |
| 7254 | numArgs = arg; never executed (the execution status of this line is deduced): numArgs = arg; | - |
| 7255 | } | 0 |
| 7256 | | - |
| 7257 | i = 0; executed (the execution status of this line is deduced): i = 0; | - |
| 7258 | while (i < len) { evaluated: i < len| yes Evaluation Count:5783305 | yes Evaluation Count:161516 |
| 161516-5783305 |
| 7259 | if (uc[i] == QLatin1Char('%') && i != end) { evaluated: uc[i] == QLatin1Char('%')| yes Evaluation Count:479878 | yes Evaluation Count:5303427 |
evaluated: i != end| yes Evaluation Count:479877 | yes Evaluation Count:1 |
| 1-5303427 |
| 7260 | int number = getEscape(uc, &i, len, lastNumber); executed (the execution status of this line is deduced): int number = getEscape(uc, &i, len, lastNumber); | - |
| 7261 | int arg = numbersUsed[number]; executed (the execution status of this line is deduced): int arg = numbersUsed[number]; | - |
| 7262 | if (number != -1 && arg != -1) { evaluated: number != -1| yes Evaluation Count:479842 | yes Evaluation Count:35 |
partially evaluated: arg != -1| yes Evaluation Count:479842 | no Evaluation Count:0 |
| 0-479842 |
| 7263 | result += *args[arg]; executed (the execution status of this line is deduced): result += *args[arg]; | - |
| 7264 | continue; executed: continue;Execution Count:479842 | 479842 |
| 7265 | } | - |
| 7266 | } executed: }Execution Count:35 | 35 |
| 7267 | result += uc[i++]; executed (the execution status of this line is deduced): result += uc[i++]; | - |
| 7268 | } executed: }Execution Count:5303463 | 5303463 |
| 7269 | return result; executed: return result;Execution Count:161516 | 161516 |
| 7270 | } | - |
| 7271 | | - |
| 7272 | | - |
| 7273 | /*! \fn bool QString::isSimpleText() const | - |
| 7274 | | - |
| 7275 | \internal | - |
| 7276 | */ | - |
| 7277 | bool QString::isSimpleText() const | - |
| 7278 | { | - |
| 7279 | const ushort *p = d->data(); never executed (the execution status of this line is deduced): const ushort *p = d->data(); | - |
| 7280 | const ushort * const end = p + d->size; never executed (the execution status of this line is deduced): const ushort * const end = p + d->size; | - |
| 7281 | while (p < end) { | 0 |
| 7282 | ushort uc = *p; never executed (the execution status of this line is deduced): ushort uc = *p; | - |
| 7283 | // sort out regions of complex text formatting | - |
| 7284 | if (uc > 0x058f && (uc < 0x1100 || uc > 0xfb0f)) { never evaluated: uc > 0x058f never evaluated: uc < 0x1100 never evaluated: uc > 0xfb0f | 0 |
| 7285 | return false; never executed: return false; | 0 |
| 7286 | } | - |
| 7287 | p++; never executed (the execution status of this line is deduced): p++; | - |
| 7288 | } | 0 |
| 7289 | | - |
| 7290 | return true; never executed: return true; | 0 |
| 7291 | } | - |
| 7292 | | - |
| 7293 | /*! \fn bool QString::isRightToLeft() const | - |
| 7294 | | - |
| 7295 | Returns true if the string is read right to left. | - |
| 7296 | */ | - |
| 7297 | bool QString::isRightToLeft() const | - |
| 7298 | { | - |
| 7299 | const ushort *p = d->data(); executed (the execution status of this line is deduced): const ushort *p = d->data(); | - |
| 7300 | const ushort * const end = p + d->size; executed (the execution status of this line is deduced): const ushort * const end = p + d->size; | - |
| 7301 | while (p < end) { evaluated: p < end| yes Evaluation Count:626149 | yes Evaluation Count:98839 |
| 98839-626149 |
| 7302 | uint ucs4 = *p; executed (the execution status of this line is deduced): uint ucs4 = *p; | - |
| 7303 | if (QChar::isHighSurrogate(ucs4) && p < end - 1) { evaluated: QChar::isHighSurrogate(ucs4)| yes Evaluation Count:3 | yes Evaluation Count:626146 |
partially evaluated: p < end - 1| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-626146 |
| 7304 | ushort low = p[1]; executed (the execution status of this line is deduced): ushort low = p[1]; | - |
| 7305 | if (QChar::isLowSurrogate(low)) { partially evaluated: QChar::isLowSurrogate(low)| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 7306 | ucs4 = QChar::surrogateToUcs4(ucs4, low); executed (the execution status of this line is deduced): ucs4 = QChar::surrogateToUcs4(ucs4, low); | - |
| 7307 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 7308 | } executed: }Execution Count:3 | 3 |
| 7309 | } executed: }Execution Count:3 | 3 |
| 7310 | switch (QChar::direction(ucs4)) | - |
| 7311 | { | - |
| 7312 | case QChar::DirL: | - |
| 7313 | return false; executed: return false;Execution Count:67710 | 67710 |
| 7314 | case QChar::DirR: | - |
| 7315 | case QChar::DirAL: | - |
| 7316 | return true; executed: return true;Execution Count:507 | 507 |
| 7317 | default: | - |
| 7318 | break; executed: break;Execution Count:557932 | 557932 |
| 7319 | } | - |
| 7320 | ++p; executed (the execution status of this line is deduced): ++p; | - |
| 7321 | } executed: }Execution Count:557932 | 557932 |
| 7322 | return false; executed: return false;Execution Count:98839 | 98839 |
| 7323 | } | - |
| 7324 | | - |
| 7325 | /*! \fn QChar *QString::data() | - |
| 7326 | | - |
| 7327 | Returns a pointer to the data stored in the QString. The pointer | - |
| 7328 | can be used to access and modify the characters that compose the | - |
| 7329 | string. For convenience, the data is '\\0'-terminated. | - |
| 7330 | | - |
| 7331 | Example: | - |
| 7332 | | - |
| 7333 | \snippet qstring/main.cpp 19 | - |
| 7334 | | - |
| 7335 | Note that the pointer remains valid only as long as the string is | - |
| 7336 | not modified by other means. For read-only access, constData() is | - |
| 7337 | faster because it never causes a \l{deep copy} to occur. | - |
| 7338 | | - |
| 7339 | \sa constData(), operator[]() | - |
| 7340 | */ | - |
| 7341 | | - |
| 7342 | /*! \fn const QChar *QString::data() const | - |
| 7343 | | - |
| 7344 | \overload | - |
| 7345 | */ | - |
| 7346 | | - |
| 7347 | /*! \fn const QChar *QString::constData() const | - |
| 7348 | | - |
| 7349 | Returns a pointer to the data stored in the QString. The pointer | - |
| 7350 | can be used to access the characters that compose the string. For | - |
| 7351 | convenience, the data is '\\0'-terminated. | - |
| 7352 | | - |
| 7353 | Note that the pointer remains valid only as long as the string is | - |
| 7354 | not modified. | - |
| 7355 | | - |
| 7356 | \sa data(), operator[]() | - |
| 7357 | */ | - |
| 7358 | | - |
| 7359 | /*! \fn void QString::push_front(const QString &other) | - |
| 7360 | | - |
| 7361 | This function is provided for STL compatibility, prepending the | - |
| 7362 | given \a other string to the beginning of this string. It is | - |
| 7363 | equivalent to \c prepend(other). | - |
| 7364 | | - |
| 7365 | \sa prepend() | - |
| 7366 | */ | - |
| 7367 | | - |
| 7368 | /*! \fn void QString::push_front(QChar ch) | - |
| 7369 | | - |
| 7370 | \overload | - |
| 7371 | | - |
| 7372 | Prepends the given \a ch character to the beginning of this string. | - |
| 7373 | */ | - |
| 7374 | | - |
| 7375 | /*! \fn void QString::push_back(const QString &other) | - |
| 7376 | | - |
| 7377 | This function is provided for STL compatibility, appending the | - |
| 7378 | given \a other string onto the end of this string. It is | - |
| 7379 | equivalent to \c append(other). | - |
| 7380 | | - |
| 7381 | \sa append() | - |
| 7382 | */ | - |
| 7383 | | - |
| 7384 | /*! \fn void QString::push_back(QChar ch) | - |
| 7385 | | - |
| 7386 | \overload | - |
| 7387 | | - |
| 7388 | Appends the given \a ch character onto the end of this string. | - |
| 7389 | */ | - |
| 7390 | | - |
| 7391 | /*! | - |
| 7392 | \fn std::string QString::toStdString() const | - |
| 7393 | | - |
| 7394 | Returns a std::string object with the data contained in this | - |
| 7395 | QString. The Unicode data is converted into 8-bit characters using | - |
| 7396 | the toUtf8() function. | - |
| 7397 | | - |
| 7398 | This operator is mostly useful to pass a QString to a function | - |
| 7399 | that accepts a std::string object. | - |
| 7400 | | - |
| 7401 | If the QString contains non-Latin1 Unicode characters, using this | - |
| 7402 | can lead to loss of information. | - |
| 7403 | | - |
| 7404 | \sa toLatin1(), toUtf8(), toLocal8Bit() | - |
| 7405 | */ | - |
| 7406 | | - |
| 7407 | /*! | - |
| 7408 | Constructs a QString that uses the first \a size Unicode characters | - |
| 7409 | in the array \a unicode. The data in \a unicode is \e not | - |
| 7410 | copied. The caller must be able to guarantee that \a unicode will | - |
| 7411 | not be deleted or modified as long as the QString (or an | - |
| 7412 | unmodified copy of it) exists. | - |
| 7413 | | - |
| 7414 | Any attempts to modify the QString or copies of it will cause it | - |
| 7415 | to create a deep copy of the data, ensuring that the raw data | - |
| 7416 | isn't modified. | - |
| 7417 | | - |
| 7418 | Here's an example of how we can use a QRegExp on raw data in | - |
| 7419 | memory without requiring to copy the data into a QString: | - |
| 7420 | | - |
| 7421 | \snippet qstring/main.cpp 22 | - |
| 7422 | \snippet qstring/main.cpp 23 | - |
| 7423 | | - |
| 7424 | \warning A string created with fromRawData() is \e not | - |
| 7425 | '\\0'-terminated, unless the raw data contains a '\\0' character | - |
| 7426 | at position \a size. This means unicode() will \e not return a | - |
| 7427 | '\\0'-terminated string (although utf16() does, at the cost of | - |
| 7428 | copying the raw data). | - |
| 7429 | | - |
| 7430 | \sa fromUtf16(), setRawData() | - |
| 7431 | */ | - |
| 7432 | QString QString::fromRawData(const QChar *unicode, int size) | - |
| 7433 | { | - |
| 7434 | Data *x; executed (the execution status of this line is deduced): Data *x; | - |
| 7435 | if (!unicode) { evaluated: !unicode| yes Evaluation Count:2 | yes Evaluation Count:35702 |
| 2-35702 |
| 7436 | x = Data::sharedNull(); executed (the execution status of this line is deduced): x = Data::sharedNull(); | - |
| 7437 | } else if (!size) { executed: }Execution Count:2 partially evaluated: !size| no Evaluation Count:0 | yes Evaluation Count:35714 |
| 0-35714 |
| 7438 | x = Data::allocate(0); never executed (the execution status of this line is deduced): x = Data::allocate(0); | - |
| 7439 | } else { | 0 |
| 7440 | x = Data::fromRawData(reinterpret_cast<const ushort *>(unicode), size); executed (the execution status of this line is deduced): x = Data::fromRawData(reinterpret_cast<const ushort *>(unicode), size); | - |
| 7441 | Q_CHECK_PTR(x); never executed: qBadAlloc(); executed: }Execution Count:35717 partially evaluated: !(x)| no Evaluation Count:0 | yes Evaluation Count:35724 |
partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:35717 |
| 0-35724 |
| 7442 | } executed: }Execution Count:35720 | 35720 |
| 7443 | QStringDataPtr dataPtr = { x }; executed (the execution status of this line is deduced): QStringDataPtr dataPtr = { x }; | - |
| 7444 | return QString(dataPtr); executed: return QString(dataPtr);Execution Count:35727 | 35727 |
| 7445 | } | - |
| 7446 | | - |
| 7447 | /*! | - |
| 7448 | \since 4.7 | - |
| 7449 | | - |
| 7450 | Resets the QString to use the first \a size Unicode characters | - |
| 7451 | in the array \a unicode. The data in \a unicode is \e not | - |
| 7452 | copied. The caller must be able to guarantee that \a unicode will | - |
| 7453 | not be deleted or modified as long as the QString (or an | - |
| 7454 | unmodified copy of it) exists. | - |
| 7455 | | - |
| 7456 | This function can be used instead of fromRawData() to re-use | - |
| 7457 | existings QString objects to save memory re-allocations. | - |
| 7458 | | - |
| 7459 | \sa fromRawData() | - |
| 7460 | */ | - |
| 7461 | QString &QString::setRawData(const QChar *unicode, int size) | - |
| 7462 | { | - |
| 7463 | if (d->ref.isShared() || d->alloc) { evaluated: d->ref.isShared()| yes Evaluation Count:1 | yes Evaluation Count:2 |
evaluated: d->alloc| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-2 |
| 7464 | *this = fromRawData(unicode, size); executed (the execution status of this line is deduced): *this = fromRawData(unicode, size); | - |
| 7465 | } else { executed: }Execution Count:2 | 2 |
| 7466 | if (unicode) { partially evaluated: unicode| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 7467 | d->size = size; executed (the execution status of this line is deduced): d->size = size; | - |
| 7468 | d->offset = reinterpret_cast<const char *>(unicode) - reinterpret_cast<char *>(d); executed (the execution status of this line is deduced): d->offset = reinterpret_cast<const char *>(unicode) - reinterpret_cast<char *>(d); | - |
| 7469 | } else { executed: }Execution Count:1 | 1 |
| 7470 | d->offset = sizeof(QStringData); never executed (the execution status of this line is deduced): d->offset = sizeof(QStringData); | - |
| 7471 | d->size = 0; never executed (the execution status of this line is deduced): d->size = 0; | - |
| 7472 | } | 0 |
| 7473 | } | - |
| 7474 | return *this; executed: return *this;Execution Count:3 | 3 |
| 7475 | } | - |
| 7476 | | - |
| 7477 | /*! \class QLatin1String | - |
| 7478 | \inmodule QtCore | - |
| 7479 | \brief The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal. | - |
| 7480 | | - |
| 7481 | \ingroup string-processing | - |
| 7482 | \reentrant | - |
| 7483 | | - |
| 7484 | Many of QString's member functions are overloaded to accept | - |
| 7485 | \c{const char *} instead of QString. This includes the copy | - |
| 7486 | constructor, the assignment operator, the comparison operators, | - |
| 7487 | and various other functions such as \l{QString::insert()}{insert()}, \l{QString::replace()}{replace()}, | - |
| 7488 | and \l{QString::indexOf()}{indexOf()}. These functions | - |
| 7489 | are usually optimized to avoid constructing a QString object for | - |
| 7490 | the \c{const char *} data. For example, assuming \c str is a | - |
| 7491 | QString, | - |
| 7492 | | - |
| 7493 | \snippet code/src_corelib_tools_qstring.cpp 3 | - |
| 7494 | | - |
| 7495 | is much faster than | - |
| 7496 | | - |
| 7497 | \snippet code/src_corelib_tools_qstring.cpp 4 | - |
| 7498 | | - |
| 7499 | because it doesn't construct four temporary QString objects and | - |
| 7500 | make a deep copy of the character data. | - |
| 7501 | | - |
| 7502 | Applications that define \c QT_NO_CAST_FROM_ASCII (as explained | - |
| 7503 | in the QString documentation) don't have access to QString's | - |
| 7504 | \c{const char *} API. To provide an efficient way of specifying | - |
| 7505 | constant Latin-1 strings, Qt provides the QLatin1String, which is | - |
| 7506 | just a very thin wrapper around a \c{const char *}. Using | - |
| 7507 | QLatin1String, the example code above becomes | - |
| 7508 | | - |
| 7509 | \snippet code/src_corelib_tools_qstring.cpp 5 | - |
| 7510 | | - |
| 7511 | This is a bit longer to type, but it provides exactly the same | - |
| 7512 | benefits as the first version of the code, and is faster than | - |
| 7513 | converting the Latin-1 strings using QString::fromLatin1(). | - |
| 7514 | | - |
| 7515 | Thanks to the QString(QLatin1String) constructor, | - |
| 7516 | QLatin1String can be used everywhere a QString is expected. For | - |
| 7517 | example: | - |
| 7518 | | - |
| 7519 | \snippet code/src_corelib_tools_qstring.cpp 6 | - |
| 7520 | | - |
| 7521 | \sa QString, QLatin1Char, QStringLiteral | - |
| 7522 | */ | - |
| 7523 | | - |
| 7524 | /*! \fn QLatin1String::QLatin1String(const char *str) | - |
| 7525 | | - |
| 7526 | Constructs a QLatin1String object that stores \a str. Note that if | - |
| 7527 | \a str is 0, an empty string is created; this case is handled by | - |
| 7528 | QString. | - |
| 7529 | | - |
| 7530 | The string data is \e not copied. The caller must be able to | - |
| 7531 | guarantee that \a str will not be deleted or modified as long as | - |
| 7532 | the QLatin1String object exists. | - |
| 7533 | | - |
| 7534 | \sa latin1() | - |
| 7535 | */ | - |
| 7536 | | - |
| 7537 | /*! \fn QLatin1String::QLatin1String(const char *str, int size) | - |
| 7538 | | - |
| 7539 | Constructs a QLatin1String object that stores \a str with \a size. | - |
| 7540 | Note that if \a str is 0, an empty string is created; this case | - |
| 7541 | is handled by QString. | - |
| 7542 | | - |
| 7543 | The string data is \e not copied. The caller must be able to | - |
| 7544 | guarantee that \a str will not be deleted or modified as long as | - |
| 7545 | the QLatin1String object exists. | - |
| 7546 | | - |
| 7547 | \sa latin1() | - |
| 7548 | */ | - |
| 7549 | | - |
| 7550 | /*! \fn QLatin1String::QLatin1String(const QByteArray &str) | - |
| 7551 | | - |
| 7552 | Constructs a QLatin1String object that stores \a str. | - |
| 7553 | | - |
| 7554 | The string data is \e not copied. The caller must be able to | - |
| 7555 | guarantee that \a str will not be deleted or modified as long as | - |
| 7556 | the QLatin1String object exists. | - |
| 7557 | | - |
| 7558 | \sa latin1() | - |
| 7559 | */ | - |
| 7560 | | - |
| 7561 | /*! \fn const char *QLatin1String::latin1() const | - |
| 7562 | | - |
| 7563 | Returns the Latin-1 string stored in this object. | - |
| 7564 | */ | - |
| 7565 | | - |
| 7566 | /*! \fn int QLatin1String::size() const | - |
| 7567 | | - |
| 7568 | Returns the size of the Latin-1 string stored in this object. | - |
| 7569 | */ | - |
| 7570 | | - |
| 7571 | /*! \fn bool QLatin1String::operator==(const QString &other) const | - |
| 7572 | | - |
| 7573 | Returns true if this string is equal to string \a other; | - |
| 7574 | otherwise returns false. | - |
| 7575 | | - |
| 7576 | The comparison is based exclusively on the numeric Unicode values | - |
| 7577 | of the characters and is very fast, but is not what a human would | - |
| 7578 | expect. Consider sorting user-interface strings with | - |
| 7579 | QString::localeAwareCompare(). | - |
| 7580 | */ | - |
| 7581 | | - |
| 7582 | /*! | - |
| 7583 | \fn bool QLatin1String::operator==(const char *other) const | - |
| 7584 | \since 4.3 | - |
| 7585 | \overload | - |
| 7586 | | - |
| 7587 | The \a other const char pointer is converted to a QString using | - |
| 7588 | the QString::fromUtf8() function. | - |
| 7589 | | - |
| 7590 | You can disable this operator by defining \c | - |
| 7591 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 7592 | can be useful if you want to ensure that all user-visible strings | - |
| 7593 | go through QObject::tr(), for example. | - |
| 7594 | */ | - |
| 7595 | | - |
| 7596 | /*! \fn bool QLatin1String::operator!=(const QString &other) const | - |
| 7597 | | - |
| 7598 | Returns true if this string is not equal to string \a other; | - |
| 7599 | otherwise returns false. | - |
| 7600 | | - |
| 7601 | The comparison is based exclusively on the numeric Unicode values | - |
| 7602 | of the characters and is very fast, but is not what a human would | - |
| 7603 | expect. Consider sorting user-interface strings with | - |
| 7604 | QString::localeAwareCompare(). | - |
| 7605 | */ | - |
| 7606 | | - |
| 7607 | /*! | - |
| 7608 | \fn bool QLatin1String::operator!=(const char *other) const | - |
| 7609 | \since 4.3 | - |
| 7610 | \overload operator!=() | - |
| 7611 | | - |
| 7612 | The \a other const char pointer is converted to a QString using | - |
| 7613 | the QString::fromUtf8() function. | - |
| 7614 | | - |
| 7615 | You can disable this operator by defining \c | - |
| 7616 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 7617 | can be useful if you want to ensure that all user-visible strings | - |
| 7618 | go through QObject::tr(), for example. | - |
| 7619 | */ | - |
| 7620 | | - |
| 7621 | /*! | - |
| 7622 | \fn bool QLatin1String::operator>(const QString &other) const | - |
| 7623 | | - |
| 7624 | Returns true if this string is lexically greater than string \a | - |
| 7625 | other; otherwise returns false. | - |
| 7626 | | - |
| 7627 | The comparison is based exclusively on the numeric Unicode values | - |
| 7628 | of the characters and is very fast, but is not what a human would | - |
| 7629 | expect. Consider sorting user-interface strings with | - |
| 7630 | QString::localeAwareCompare(). | - |
| 7631 | */ | - |
| 7632 | | - |
| 7633 | /*! | - |
| 7634 | \fn bool QLatin1String::operator>(const char *other) const | - |
| 7635 | \since 4.3 | - |
| 7636 | \overload | - |
| 7637 | | - |
| 7638 | The \a other const char pointer is converted to a QString using | - |
| 7639 | the QString::fromUtf8() function. | - |
| 7640 | | - |
| 7641 | You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII | - |
| 7642 | when you compile your applications. This can be useful if you want | - |
| 7643 | to ensure that all user-visible strings go through QObject::tr(), | - |
| 7644 | for example. | - |
| 7645 | */ | - |
| 7646 | | - |
| 7647 | /*! | - |
| 7648 | \fn bool QLatin1String::operator<(const QString &other) const | - |
| 7649 | | - |
| 7650 | Returns true if this string is lexically less than the \a other | - |
| 7651 | string; otherwise returns false. | - |
| 7652 | | - |
| 7653 | The comparison is based exclusively on the numeric Unicode values | - |
| 7654 | of the characters and is very fast, but is not what a human would | - |
| 7655 | expect. Consider sorting user-interface strings using the | - |
| 7656 | QString::localeAwareCompare() function. | - |
| 7657 | */ | - |
| 7658 | | - |
| 7659 | /*! | - |
| 7660 | \fn bool QLatin1String::operator<(const char *other) const | - |
| 7661 | \since 4.3 | - |
| 7662 | \overload | - |
| 7663 | | - |
| 7664 | The \a other const char pointer is converted to a QString using | - |
| 7665 | the QString::fromUtf8() function. | - |
| 7666 | | - |
| 7667 | You can disable this operator by defining \c | - |
| 7668 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 7669 | can be useful if you want to ensure that all user-visible strings | - |
| 7670 | go through QObject::tr(), for example. | - |
| 7671 | */ | - |
| 7672 | | - |
| 7673 | /*! | - |
| 7674 | \fn bool QLatin1String::operator>=(const QString &other) const | - |
| 7675 | | - |
| 7676 | Returns true if this string is lexically greater than or equal | - |
| 7677 | to string \a other; otherwise returns false. | - |
| 7678 | | - |
| 7679 | The comparison is based exclusively on the numeric Unicode values | - |
| 7680 | of the characters and is very fast, but is not what a human would | - |
| 7681 | expect. Consider sorting user-interface strings with | - |
| 7682 | QString::localeAwareCompare(). | - |
| 7683 | */ | - |
| 7684 | | - |
| 7685 | /*! | - |
| 7686 | \fn bool QLatin1String::operator>=(const char *other) const | - |
| 7687 | \since 4.3 | - |
| 7688 | \overload | - |
| 7689 | | - |
| 7690 | The \a other const char pointer is converted to a QString using | - |
| 7691 | the QString::fromUtf8() function. | - |
| 7692 | | - |
| 7693 | You can disable this operator by defining \c | - |
| 7694 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 7695 | can be useful if you want to ensure that all user-visible strings | - |
| 7696 | go through QObject::tr(), for example. | - |
| 7697 | */ | - |
| 7698 | | - |
| 7699 | /*! \fn bool QLatin1String::operator<=(const QString &other) const | - |
| 7700 | | - |
| 7701 | Returns true if this string is lexically less than or equal | - |
| 7702 | to string \a other; otherwise returns false. | - |
| 7703 | | - |
| 7704 | The comparison is based exclusively on the numeric Unicode values | - |
| 7705 | of the characters and is very fast, but is not what a human would | - |
| 7706 | expect. Consider sorting user-interface strings with | - |
| 7707 | QString::localeAwareCompare(). | - |
| 7708 | */ | - |
| 7709 | | - |
| 7710 | /*! | - |
| 7711 | \fn bool QLatin1String::operator<=(const char *other) const | - |
| 7712 | \since 4.3 | - |
| 7713 | \overload | - |
| 7714 | | - |
| 7715 | The \a other const char pointer is converted to a QString using | - |
| 7716 | the QString::fromUtf8() function. | - |
| 7717 | | - |
| 7718 | You can disable this operator by defining \c | - |
| 7719 | QT_NO_CAST_FROM_ASCII when you compile your applications. This | - |
| 7720 | can be useful if you want to ensure that all user-visible strings | - |
| 7721 | go through QObject::tr(), for example. | - |
| 7722 | */ | - |
| 7723 | | - |
| 7724 | | - |
| 7725 | | - |
| 7726 | /*! \fn bool operator==(QLatin1String s1, QLatin1String s2) | - |
| 7727 | \relates QLatin1String | - |
| 7728 | | - |
| 7729 | Returns true if string \a s1 is lexically equal to string \a s2; otherwise | - |
| 7730 | returns false. | - |
| 7731 | */ | - |
| 7732 | /*! \fn bool operator!=(QLatin1String s1, QLatin1String s2) | - |
| 7733 | \relates QLatin1String | - |
| 7734 | | - |
| 7735 | Returns true if string \a s1 is lexically unequal to string \a s2; otherwise | - |
| 7736 | returns false. | - |
| 7737 | */ | - |
| 7738 | /*! \fn bool operator<(QLatin1String s1, QLatin1String s2) | - |
| 7739 | \relates QLatin1String | - |
| 7740 | | - |
| 7741 | Returns true if string \a s1 is lexically smaller than string \a s2; otherwise | - |
| 7742 | returns false. | - |
| 7743 | */ | - |
| 7744 | /*! \fn bool operator<=(QLatin1String s1, QLatin1String s2) | - |
| 7745 | \relates QLatin1String | - |
| 7746 | | - |
| 7747 | Returns true if string \a s1 is lexically smaller than or equal to string \a s2; otherwise | - |
| 7748 | returns false. | - |
| 7749 | */ | - |
| 7750 | /*! \fn bool operator>(QLatin1String s1, QLatin1String s2) | - |
| 7751 | \relates QLatin1String | - |
| 7752 | | - |
| 7753 | Returns true if string \a s1 is lexically greater than string \a s2; otherwise | - |
| 7754 | returns false. | - |
| 7755 | */ | - |
| 7756 | /*! \fn bool operator>=(QLatin1String s1, QLatin1String s2) | - |
| 7757 | \relates QLatin1String | - |
| 7758 | | - |
| 7759 | Returns true if string \a s1 is lexically greater than or equal to | - |
| 7760 | string \a s2; otherwise returns false. | - |
| 7761 | */ | - |
| 7762 | | - |
| 7763 | | - |
| 7764 | #if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)) | - |
| 7765 | /*! | - |
| 7766 | \fn QDataStream &operator<<(QDataStream &stream, const QString &string) | - |
| 7767 | \relates QString | - |
| 7768 | | - |
| 7769 | Writes the given \a string to the specified \a stream. | - |
| 7770 | | - |
| 7771 | \sa {Serializing Qt Data Types} | - |
| 7772 | */ | - |
| 7773 | | - |
| 7774 | QDataStream &operator<<(QDataStream &out, const QString &str) | - |
| 7775 | { | - |
| 7776 | if (out.version() == 1) { partially evaluated: out.version() == 1| no Evaluation Count:0 | yes Evaluation Count:14021 |
| 0-14021 |
| 7777 | out << str.toLatin1(); never executed (the execution status of this line is deduced): out << str.toLatin1(); | - |
| 7778 | } else { | 0 |
| 7779 | if (!str.isNull() || out.version() < 3) { evaluated: !str.isNull()| yes Evaluation Count:13793 | yes Evaluation Count:228 |
evaluated: out.version() < 3| yes Evaluation Count:1 | yes Evaluation Count:227 |
| 1-13793 |
| 7780 | if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { partially evaluated: (out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)| no Evaluation Count:0 | yes Evaluation Count:13794 |
| 0-13794 |
| 7781 | out.writeBytes(reinterpret_cast<const char *>(str.unicode()), sizeof(QChar) * str.length()); never executed (the execution status of this line is deduced): out.writeBytes(reinterpret_cast<const char *>(str.unicode()), sizeof(QChar) * str.length()); | - |
| 7782 | } else { | 0 |
| 7783 | QVarLengthArray<ushort> buffer(str.length()); executed (the execution status of this line is deduced): QVarLengthArray<ushort> buffer(str.length()); | - |
| 7784 | const ushort *data = reinterpret_cast<const ushort *>(str.constData()); executed (the execution status of this line is deduced): const ushort *data = reinterpret_cast<const ushort *>(str.constData()); | - |
| 7785 | for (int i = 0; i < str.length(); i++) { evaluated: i < str.length()| yes Evaluation Count:51612 | yes Evaluation Count:13794 |
| 13794-51612 |
| 7786 | buffer[i] = qbswap(*data); executed (the execution status of this line is deduced): buffer[i] = qbswap(*data); | - |
| 7787 | ++data; executed (the execution status of this line is deduced): ++data; | - |
| 7788 | } executed: }Execution Count:51612 | 51612 |
| 7789 | out.writeBytes(reinterpret_cast<const char *>(buffer.data()), sizeof(ushort) * buffer.size()); executed (the execution status of this line is deduced): out.writeBytes(reinterpret_cast<const char *>(buffer.data()), sizeof(ushort) * buffer.size()); | - |
| 7790 | } executed: }Execution Count:13794 | 13794 |
| 7791 | } else { | - |
| 7792 | // write null marker | - |
| 7793 | out << (quint32)0xffffffff; executed (the execution status of this line is deduced): out << (quint32)0xffffffff; | - |
| 7794 | } executed: }Execution Count:227 | 227 |
| 7795 | } | - |
| 7796 | return out; executed: return out;Execution Count:14021 | 14021 |
| 7797 | } | - |
| 7798 | | - |
| 7799 | /*! | - |
| 7800 | \fn QDataStream &operator>>(QDataStream &stream, QString &string) | - |
| 7801 | \relates QString | - |
| 7802 | | - |
| 7803 | Reads a string from the specified \a stream into the given \a string. | - |
| 7804 | | - |
| 7805 | \sa {Serializing Qt Data Types} | - |
| 7806 | */ | - |
| 7807 | | - |
| 7808 | QDataStream &operator>>(QDataStream &in, QString &str) | - |
| 7809 | { | - |
| 7810 | #ifdef QT_QSTRING_UCS_4 | - |
| 7811 | #if defined(Q_CC_GNU) | - |
| 7812 | #warning "operator>> not working properly" | - |
| 7813 | #endif | - |
| 7814 | #endif | - |
| 7815 | | - |
| 7816 | if (in.version() == 1) { partially evaluated: in.version() == 1| no Evaluation Count:0 | yes Evaluation Count:13994 |
| 0-13994 |
| 7817 | QByteArray l; never executed (the execution status of this line is deduced): QByteArray l; | - |
| 7818 | in >> l; never executed (the execution status of this line is deduced): in >> l; | - |
| 7819 | str = QString::fromLatin1(l); never executed (the execution status of this line is deduced): str = QString::fromLatin1(l); | - |
| 7820 | } else { | 0 |
| 7821 | quint32 bytes = 0; executed (the execution status of this line is deduced): quint32 bytes = 0; | - |
| 7822 | in >> bytes; // read size of string executed (the execution status of this line is deduced): in >> bytes; | - |
| 7823 | if (bytes == 0xffffffff) { // null string evaluated: bytes == 0xffffffff| yes Evaluation Count:222 | yes Evaluation Count:13772 |
| 222-13772 |
| 7824 | str.clear(); executed (the execution status of this line is deduced): str.clear(); | - |
| 7825 | } else if (bytes > 0) { // not empty executed: }Execution Count:222 evaluated: bytes > 0| yes Evaluation Count:13521 | yes Evaluation Count:251 |
| 222-13521 |
| 7826 | if (bytes & 0x1) { evaluated: bytes & 0x1| yes Evaluation Count:6 | yes Evaluation Count:13515 |
| 6-13515 |
| 7827 | str.clear(); executed (the execution status of this line is deduced): str.clear(); | - |
| 7828 | in.setStatus(QDataStream::ReadCorruptData); executed (the execution status of this line is deduced): in.setStatus(QDataStream::ReadCorruptData); | - |
| 7829 | return in; executed: return in;Execution Count:6 | 6 |
| 7830 | } | - |
| 7831 | | - |
| 7832 | const quint32 Step = 1024 * 1024; executed (the execution status of this line is deduced): const quint32 Step = 1024 * 1024; | - |
| 7833 | quint32 len = bytes / 2; executed (the execution status of this line is deduced): quint32 len = bytes / 2; | - |
| 7834 | quint32 allocated = 0; executed (the execution status of this line is deduced): quint32 allocated = 0; | - |
| 7835 | | - |
| 7836 | while (allocated < len) { evaluated: allocated < len| yes Evaluation Count:13527 | yes Evaluation Count:13501 |
| 13501-13527 |
| 7837 | int blockSize = qMin(Step, len - allocated); executed (the execution status of this line is deduced): int blockSize = qMin(Step, len - allocated); | - |
| 7838 | str.resize(allocated + blockSize); executed (the execution status of this line is deduced): str.resize(allocated + blockSize); | - |
| 7839 | if (in.readRawData(reinterpret_cast<char *>(str.data()) + allocated * 2, evaluated: in.readRawData(reinterpret_cast<char *>(str.data()) + allocated * 2, blockSize * 2) != blockSize * 2| yes Evaluation Count:14 | yes Evaluation Count:13513 |
| 14-13513 |
| 7840 | blockSize * 2) != blockSize * 2) { evaluated: in.readRawData(reinterpret_cast<char *>(str.data()) + allocated * 2, blockSize * 2) != blockSize * 2| yes Evaluation Count:14 | yes Evaluation Count:13513 |
| 14-13513 |
| 7841 | str.clear(); executed (the execution status of this line is deduced): str.clear(); | - |
| 7842 | in.setStatus(QDataStream::ReadPastEnd); executed (the execution status of this line is deduced): in.setStatus(QDataStream::ReadPastEnd); | - |
| 7843 | return in; executed: return in;Execution Count:14 | 14 |
| 7844 | } | - |
| 7845 | allocated += blockSize; executed (the execution status of this line is deduced): allocated += blockSize; | - |
| 7846 | } executed: }Execution Count:13513 | 13513 |
| 7847 | | - |
| 7848 | if ((in.byteOrder() == QDataStream::BigEndian) partially evaluated: (in.byteOrder() == QDataStream::BigEndian) != (QSysInfo::ByteOrder == QSysInfo::BigEndian)| yes Evaluation Count:13501 | no Evaluation Count:0 |
| 0-13501 |
| 7849 | != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { partially evaluated: (in.byteOrder() == QDataStream::BigEndian) != (QSysInfo::ByteOrder == QSysInfo::BigEndian)| yes Evaluation Count:13501 | no Evaluation Count:0 |
| 0-13501 |
| 7850 | ushort *data = reinterpret_cast<ushort *>(str.data()); executed (the execution status of this line is deduced): ushort *data = reinterpret_cast<ushort *>(str.data()); | - |
| 7851 | while (len--) { evaluated: len--| yes Evaluation Count:12627457 | yes Evaluation Count:13501 |
| 13501-12627457 |
| 7852 | *data = qbswap(*data); executed (the execution status of this line is deduced): *data = qbswap(*data); | - |
| 7853 | ++data; executed (the execution status of this line is deduced): ++data; | - |
| 7854 | } executed: }Execution Count:12627457 | 12627457 |
| 7855 | } executed: }Execution Count:13501 | 13501 |
| 7856 | } else { executed: }Execution Count:13501 | 13501 |
| 7857 | str = QString(QLatin1String("")); executed (the execution status of this line is deduced): str = QString(QLatin1String("")); | - |
| 7858 | } executed: }Execution Count:251 | 251 |
| 7859 | } | - |
| 7860 | return in; executed: return in;Execution Count:13974 | 13974 |
| 7861 | } | - |
| 7862 | #endif // QT_NO_DATASTREAM | - |
| 7863 | | - |
| 7864 | | - |
| 7865 | | - |
| 7866 | | - |
| 7867 | /*! | - |
| 7868 | \class QStringRef | - |
| 7869 | \inmodule QtCore | - |
| 7870 | \since 4.3 | - |
| 7871 | \brief The QStringRef class provides a thin wrapper around QString substrings. | - |
| 7872 | \reentrant | - |
| 7873 | \ingroup tools | - |
| 7874 | \ingroup string-processing | - |
| 7875 | | - |
| 7876 | QStringRef provides a read-only subset of the QString API. | - |
| 7877 | | - |
| 7878 | A string reference explicitly references a portion of a string() | - |
| 7879 | with a given size(), starting at a specific position(). Calling | - |
| 7880 | toString() returns a copy of the data as a real QString instance. | - |
| 7881 | | - |
| 7882 | This class is designed to improve the performance of substring | - |
| 7883 | handling when manipulating substrings obtained from existing QString | - |
| 7884 | instances. QStringRef avoids the memory allocation and reference | - |
| 7885 | counting overhead of a standard QString by simply referencing a | - |
| 7886 | part of the original string. This can prove to be advantageous in | - |
| 7887 | low level code, such as that used in a parser, at the expense of | - |
| 7888 | potentially more complex code. | - |
| 7889 | | - |
| 7890 | For most users, there are no semantic benefits to using QStringRef | - |
| 7891 | instead of QString since QStringRef requires attention to be paid | - |
| 7892 | to memory management issues, potentially making code more complex | - |
| 7893 | to write and maintain. | - |
| 7894 | | - |
| 7895 | \warning A QStringRef is only valid as long as the referenced | - |
| 7896 | string exists. If the original string is deleted, the string | - |
| 7897 | reference points to an invalid memory location. | - |
| 7898 | | - |
| 7899 | We suggest that you only use this class in stable code where profiling | - |
| 7900 | has clearly identified that performance improvements can be made by | - |
| 7901 | replacing standard string operations with the optimized substring | - |
| 7902 | handling provided by this class. | - |
| 7903 | | - |
| 7904 | \sa {Implicitly Shared Classes} | - |
| 7905 | */ | - |
| 7906 | | - |
| 7907 | | - |
| 7908 | /*! | - |
| 7909 | \fn QStringRef::QStringRef() | - |
| 7910 | | - |
| 7911 | Constructs an empty string reference. | - |
| 7912 | */ | - |
| 7913 | | - |
| 7914 | /*! \fn QStringRef::QStringRef(const QString *string, int position, int length) | - |
| 7915 | | - |
| 7916 | Constructs a string reference to the range of characters in the given | - |
| 7917 | \a string specified by the starting \a position and \a length in characters. | - |
| 7918 | | - |
| 7919 | \warning This function exists to improve performance as much as possible, | - |
| 7920 | and performs no bounds checking. For program correctness, \a position and | - |
| 7921 | \a length must describe a valid substring of \a string. | - |
| 7922 | | - |
| 7923 | This means that the starting \a position must be positive or 0 and smaller | - |
| 7924 | than \a string's length, and \a length must be positive or 0 but smaller than | - |
| 7925 | the string's length minus the starting \a position; | - |
| 7926 | i.e, 0 <= position < string->length() and | - |
| 7927 | 0 <= length <= string->length() - position must both be satisfied. | - |
| 7928 | */ | - |
| 7929 | | - |
| 7930 | /*! \fn QStringRef::QStringRef(const QString *string) | - |
| 7931 | | - |
| 7932 | Constructs a string reference to the given \a string. | - |
| 7933 | */ | - |
| 7934 | | - |
| 7935 | /*! \fn QStringRef::QStringRef(const QStringRef &other) | - |
| 7936 | | - |
| 7937 | Constructs a copy of the \a other string reference. | - |
| 7938 | */ | - |
| 7939 | /*! | - |
| 7940 | \fn QStringRef::~QStringRef() | - |
| 7941 | | - |
| 7942 | Destroys the string reference. | - |
| 7943 | | - |
| 7944 | Since this class is only used to refer to string data, and does not take | - |
| 7945 | ownership of it, no memory is freed when instances are destroyed. | - |
| 7946 | */ | - |
| 7947 | | - |
| 7948 | | - |
| 7949 | /*! | - |
| 7950 | \fn int QStringRef::position() const | - |
| 7951 | | - |
| 7952 | Returns the starting position in the referenced string that is referred to | - |
| 7953 | by the string reference. | - |
| 7954 | | - |
| 7955 | \sa size(), string() | - |
| 7956 | */ | - |
| 7957 | | - |
| 7958 | /*! | - |
| 7959 | \fn int QStringRef::size() const | - |
| 7960 | | - |
| 7961 | Returns the number of characters referred to by the string reference. | - |
| 7962 | Equivalent to length() and count(). | - |
| 7963 | | - |
| 7964 | \sa position(), string() | - |
| 7965 | */ | - |
| 7966 | /*! | - |
| 7967 | \fn int QStringRef::count() const | - |
| 7968 | Returns the number of characters referred to by the string reference. | - |
| 7969 | Equivalent to size() and length(). | - |
| 7970 | | - |
| 7971 | \sa position(), string() | - |
| 7972 | */ | - |
| 7973 | /*! | - |
| 7974 | \fn int QStringRef::length() const | - |
| 7975 | Returns the number of characters referred to by the string reference. | - |
| 7976 | Equivalent to size() and count(). | - |
| 7977 | | - |
| 7978 | \sa position(), string() | - |
| 7979 | */ | - |
| 7980 | | - |
| 7981 | | - |
| 7982 | /*! | - |
| 7983 | \fn bool QStringRef::isEmpty() const | - |
| 7984 | | - |
| 7985 | Returns true if the string reference has no characters; otherwise returns | - |
| 7986 | false. | - |
| 7987 | | - |
| 7988 | A string reference is empty if its size is zero. | - |
| 7989 | | - |
| 7990 | \sa size() | - |
| 7991 | */ | - |
| 7992 | | - |
| 7993 | /*! | - |
| 7994 | \fn bool QStringRef::isNull() const | - |
| 7995 | | - |
| 7996 | Returns true if string() returns a null pointer or a pointer to a | - |
| 7997 | null string; otherwise returns true. | - |
| 7998 | | - |
| 7999 | \sa size() | - |
| 8000 | */ | - |
| 8001 | | - |
| 8002 | /*! | - |
| 8003 | \fn const QString *QStringRef::string() const | - |
| 8004 | | - |
| 8005 | Returns a pointer to the string referred to by the string reference, or | - |
| 8006 | 0 if it does not reference a string. | - |
| 8007 | | - |
| 8008 | \sa unicode() | - |
| 8009 | */ | - |
| 8010 | | - |
| 8011 | | - |
| 8012 | /*! | - |
| 8013 | \fn const QChar *QStringRef::unicode() const | - |
| 8014 | | - |
| 8015 | Returns a Unicode representation of the string reference. Since | - |
| 8016 | the data stems directly from the referenced string, it is not | - |
| 8017 | null-terminated unless the string reference includes the string's | - |
| 8018 | null terminator. | - |
| 8019 | | - |
| 8020 | \sa string() | - |
| 8021 | */ | - |
| 8022 | | - |
| 8023 | /*! | - |
| 8024 | \fn const QChar *QStringRef::data() const | - |
| 8025 | | - |
| 8026 | Same as unicode(). | - |
| 8027 | */ | - |
| 8028 | | - |
| 8029 | /*! | - |
| 8030 | \fn const QChar *QStringRef::constData() const | - |
| 8031 | | - |
| 8032 | Same as unicode(). | - |
| 8033 | */ | - |
| 8034 | | - |
| 8035 | /*! | - |
| 8036 | Returns a copy of the string reference as a QString object. | - |
| 8037 | | - |
| 8038 | If the string reference is not a complete reference of the string | - |
| 8039 | (meaning that position() is 0 and size() equals string()->size()), | - |
| 8040 | this function will allocate a new string to return. | - |
| 8041 | | - |
| 8042 | \sa string() | - |
| 8043 | */ | - |
| 8044 | | - |
| 8045 | QString QStringRef::toString() const { | - |
| 8046 | if (!m_string) evaluated: !m_string| yes Evaluation Count:2005 | yes Evaluation Count:85212 |
| 2005-85212 |
| 8047 | return QString(); executed: return QString();Execution Count:2005 | 2005 |
| 8048 | if (m_size && m_position == 0 && m_size == m_string->size()) evaluated: m_size| yes Evaluation Count:85160 | yes Evaluation Count:52 |
evaluated: m_position == 0| yes Evaluation Count:1488 | yes Evaluation Count:83672 |
evaluated: m_size == m_string->size()| yes Evaluation Count:1487 | yes Evaluation Count:1 |
| 1-85160 |
| 8049 | return *m_string; executed: return *m_string;Execution Count:1487 | 1487 |
| 8050 | return QString(m_string->unicode() + m_position, m_size); executed: return QString(m_string->unicode() + m_position, m_size);Execution Count:83725 | 83725 |
| 8051 | } | - |
| 8052 | | - |
| 8053 | | - |
| 8054 | /*! \relates QStringRef | - |
| 8055 | | - |
| 8056 | Returns true if string reference \a s1 is lexically equal to string reference \a s2; otherwise | - |
| 8057 | returns false. | - |
| 8058 | */ | - |
| 8059 | bool operator==(const QStringRef &s1,const QStringRef &s2) | - |
| 8060 | { return (s1.size() == s2.size() && executed: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Execution Count:243003 | 243003 |
| 8061 | qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size())); executed: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Execution Count:243003 | 243003 |
| 8062 | } | - |
| 8063 | | - |
| 8064 | /*! \relates QStringRef | - |
| 8065 | | - |
| 8066 | Returns true if string \a s1 is lexically equal to string reference \a s2; otherwise | - |
| 8067 | returns false. | - |
| 8068 | */ | - |
| 8069 | bool operator==(const QString &s1,const QStringRef &s2) | - |
| 8070 | { return (s1.size() == s2.size() && executed: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Execution Count:55623 | 55623 |
| 8071 | qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size())); executed: return (s1.size() == s2.size() && qMemEquals((const ushort *)s1.unicode(), (const ushort *)s2.unicode(), s1.size()));Execution Count:55623 | 55623 |
| 8072 | } | - |
| 8073 | | - |
| 8074 | /*! \relates QStringRef | - |
| 8075 | | - |
| 8076 | Returns true if string \a s1 is lexically equal to string reference \a s2; otherwise | - |
| 8077 | returns false. | - |
| 8078 | */ | - |
| 8079 | bool operator==(QLatin1String s1, const QStringRef &s2) | - |
| 8080 | { | - |
| 8081 | if (s1.size() != s2.size()) evaluated: s1.size() != s2.size()| yes Evaluation Count:226819 | yes Evaluation Count:25905 |
| 25905-226819 |
| 8082 | return false; executed: return false;Execution Count:226819 | 226819 |
| 8083 | | - |
| 8084 | const ushort *uc = reinterpret_cast<const ushort *>(s2.unicode()); executed (the execution status of this line is deduced): const ushort *uc = reinterpret_cast<const ushort *>(s2.unicode()); | - |
| 8085 | const ushort *e = uc + s2.size(); executed (the execution status of this line is deduced): const ushort *e = uc + s2.size(); | - |
| 8086 | const uchar *c = reinterpret_cast<const uchar *>(s1.latin1()); executed (the execution status of this line is deduced): const uchar *c = reinterpret_cast<const uchar *>(s1.latin1()); | - |
| 8087 | if (!c) partially evaluated: !c| no Evaluation Count:0 | yes Evaluation Count:25905 |
| 0-25905 |
| 8088 | return s2.isEmpty(); never executed: return s2.isEmpty(); | 0 |
| 8089 | | - |
| 8090 | while (*c) { evaluated: *c| yes Evaluation Count:143940 | yes Evaluation Count:22137 |
| 22137-143940 |
| 8091 | if (uc == e || *uc != *c) partially evaluated: uc == e| no Evaluation Count:0 | yes Evaluation Count:143940 |
evaluated: *uc != *c| yes Evaluation Count:3768 | yes Evaluation Count:140172 |
| 0-143940 |
| 8092 | return false; executed: return false;Execution Count:3768 | 3768 |
| 8093 | ++uc; executed (the execution status of this line is deduced): ++uc; | - |
| 8094 | ++c; executed (the execution status of this line is deduced): ++c; | - |
| 8095 | } executed: }Execution Count:140172 | 140172 |
| 8096 | return (uc == e); executed: return (uc == e);Execution Count:22137 | 22137 |
| 8097 | } | - |
| 8098 | | - |
| 8099 | /*! | - |
| 8100 | \relates QStringRef | - |
| 8101 | | - |
| 8102 | Returns true if string reference \a s1 is lexically less than | - |
| 8103 | string reference \a s2; otherwise returns false. | - |
| 8104 | | - |
| 8105 | The comparison is based exclusively on the numeric Unicode values | - |
| 8106 | of the characters and is very fast, but is not what a human would | - |
| 8107 | expect. Consider sorting user-interface strings using the | - |
| 8108 | QString::localeAwareCompare() function. | - |
| 8109 | */ | - |
| 8110 | bool operator<(const QStringRef &s1,const QStringRef &s2) | - |
| 8111 | { | - |
| 8112 | return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0; executed: return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;Execution Count:411 | 411 |
| 8113 | } | - |
| 8114 | | - |
| 8115 | /*!\fn bool operator<=(const QStringRef &s1,const QStringRef &s2) | - |
| 8116 | | - |
| 8117 | \relates QStringRef | - |
| 8118 | | - |
| 8119 | Returns true if string reference \a s1 is lexically less than | - |
| 8120 | or equal to string reference \a s2; otherwise returns false. | - |
| 8121 | | - |
| 8122 | The comparison is based exclusively on the numeric Unicode values | - |
| 8123 | of the characters and is very fast, but is not what a human would | - |
| 8124 | expect. Consider sorting user-interface strings using the | - |
| 8125 | QString::localeAwareCompare() function. | - |
| 8126 | */ | - |
| 8127 | | - |
| 8128 | /*!\fn bool operator>=(const QStringRef &s1,const QStringRef &s2) | - |
| 8129 | | - |
| 8130 | \relates QStringRef | - |
| 8131 | | - |
| 8132 | Returns true if string reference \a s1 is lexically greater than | - |
| 8133 | or equal to string reference \a s2; otherwise returns false. | - |
| 8134 | | - |
| 8135 | The comparison is based exclusively on the numeric Unicode values | - |
| 8136 | of the characters and is very fast, but is not what a human would | - |
| 8137 | expect. Consider sorting user-interface strings using the | - |
| 8138 | QString::localeAwareCompare() function. | - |
| 8139 | */ | - |
| 8140 | | - |
| 8141 | /*!\fn bool operator>(const QStringRef &s1,const QStringRef &s2) | - |
| 8142 | | - |
| 8143 | \relates QStringRef | - |
| 8144 | | - |
| 8145 | Returns true if string reference \a s1 is lexically greater than | - |
| 8146 | string reference \a s2; otherwise returns false. | - |
| 8147 | | - |
| 8148 | The comparison is based exclusively on the numeric Unicode values | - |
| 8149 | of the characters and is very fast, but is not what a human would | - |
| 8150 | expect. Consider sorting user-interface strings using the | - |
| 8151 | QString::localeAwareCompare() function. | - |
| 8152 | */ | - |
| 8153 | | - |
| 8154 | | - |
| 8155 | /*! | - |
| 8156 | \fn const QChar QStringRef::at(int position) const | - |
| 8157 | | - |
| 8158 | Returns the character at the given index \a position in the | - |
| 8159 | string reference. | - |
| 8160 | | - |
| 8161 | The \a position must be a valid index position in the string | - |
| 8162 | (i.e., 0 <= \a position < size()). | - |
| 8163 | */ | - |
| 8164 | | - |
| 8165 | /*! | - |
| 8166 | \fn void QStringRef::clear() | - |
| 8167 | | - |
| 8168 | Clears the contents of the string reference by making it null and empty. | - |
| 8169 | | - |
| 8170 | \sa isEmpty(), isNull() | - |
| 8171 | */ | - |
| 8172 | | - |
| 8173 | /*! | - |
| 8174 | \fn QStringRef &QStringRef::operator=(const QStringRef &other) | - |
| 8175 | | - |
| 8176 | Assigns the \a other string reference to this string reference, and | - |
| 8177 | returns the result. | - |
| 8178 | */ | - |
| 8179 | | - |
| 8180 | /*! | - |
| 8181 | \fn QStringRef &QStringRef::operator=(const QString *string) | - |
| 8182 | | - |
| 8183 | Constructs a string reference to the given \a string and assigns it to | - |
| 8184 | this string reference, returning the result. | - |
| 8185 | */ | - |
| 8186 | | - |
| 8187 | /*! | - |
| 8188 | \typedef QString::DataPtr | - |
| 8189 | \internal | - |
| 8190 | */ | - |
| 8191 | | - |
| 8192 | /*! | - |
| 8193 | \fn DataPtr & QString::data_ptr() | - |
| 8194 | \internal | - |
| 8195 | */ | - |
| 8196 | | - |
| 8197 | | - |
| 8198 | | - |
| 8199 | /*! Appends the string reference to \a string, and returns a new | - |
| 8200 | reference to the combined string data. | - |
| 8201 | */ | - |
| 8202 | QStringRef QStringRef::appendTo(QString *string) const | - |
| 8203 | { | - |
| 8204 | if (!string) partially evaluated: !string| no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
| 8205 | return QStringRef(); never executed: return QStringRef(); | 0 |
| 8206 | int pos = string->size(); executed (the execution status of this line is deduced): int pos = string->size(); | - |
| 8207 | string->insert(pos, unicode(), size()); executed (the execution status of this line is deduced): string->insert(pos, unicode(), size()); | - |
| 8208 | return QStringRef(string, pos, size()); executed: return QStringRef(string, pos, size());Execution Count:8 | 8 |
| 8209 | } | - |
| 8210 | | - |
| 8211 | /*! | - |
| 8212 | \fn int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) | - |
| 8213 | \since 4.5 | - |
| 8214 | | - |
| 8215 | Compares the string \a s1 with the string \a s2 and returns an | - |
| 8216 | integer less than, equal to, or greater than zero if \a s1 | - |
| 8217 | is less than, equal to, or greater than \a s2. | - |
| 8218 | | - |
| 8219 | If \a cs is Qt::CaseSensitive, the comparison is case sensitive; | - |
| 8220 | otherwise the comparison is case insensitive. | - |
| 8221 | */ | - |
| 8222 | | - |
| 8223 | /*! | - |
| 8224 | \fn int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) | - |
| 8225 | \since 4.5 | - |
| 8226 | \overload | - |
| 8227 | | - |
| 8228 | Compares the string \a s1 with the string \a s2 and returns an | - |
| 8229 | integer less than, equal to, or greater than zero if \a s1 | - |
| 8230 | is less than, equal to, or greater than \a s2. | - |
| 8231 | | - |
| 8232 | If \a cs is Qt::CaseSensitive, the comparison is case sensitive; | - |
| 8233 | otherwise the comparison is case insensitive. | - |
| 8234 | */ | - |
| 8235 | | - |
| 8236 | /*! | - |
| 8237 | \fn int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) | - |
| 8238 | \since 4.5 | - |
| 8239 | \overload | - |
| 8240 | | - |
| 8241 | Compares the string \a s1 with the string \a s2 and returns an | - |
| 8242 | integer less than, equal to, or greater than zero if \a s1 | - |
| 8243 | is less than, equal to, or greater than \a s2. | - |
| 8244 | | - |
| 8245 | If \a cs is Qt::CaseSensitive, the comparison is case sensitive; | - |
| 8246 | otherwise the comparison is case insensitive. | - |
| 8247 | */ | - |
| 8248 | | - |
| 8249 | /*! | - |
| 8250 | \overload | - |
| 8251 | \fn int QStringRef::compare(const QString &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 8252 | \since 4.5 | - |
| 8253 | | - |
| 8254 | Compares this string with the \a other string and returns an | - |
| 8255 | integer less than, equal to, or greater than zero if this string | - |
| 8256 | is less than, equal to, or greater than the \a other string. | - |
| 8257 | | - |
| 8258 | If \a cs is Qt::CaseSensitive, the comparison is case sensitive; | - |
| 8259 | otherwise the comparison is case insensitive. | - |
| 8260 | | - |
| 8261 | Equivalent to \c {compare(*this, other, cs)}. | - |
| 8262 | | - |
| 8263 | \sa QString::compare() | - |
| 8264 | */ | - |
| 8265 | | - |
| 8266 | /*! | - |
| 8267 | \overload | - |
| 8268 | \fn int QStringRef::compare(const QStringRef &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 8269 | \since 4.5 | - |
| 8270 | | - |
| 8271 | Compares this string with the \a other string and returns an | - |
| 8272 | integer less than, equal to, or greater than zero if this string | - |
| 8273 | is less than, equal to, or greater than the \a other string. | - |
| 8274 | | - |
| 8275 | If \a cs is Qt::CaseSensitive, the comparison is case sensitive; | - |
| 8276 | otherwise the comparison is case insensitive. | - |
| 8277 | | - |
| 8278 | Equivalent to \c {compare(*this, other, cs)}. | - |
| 8279 | | - |
| 8280 | \sa QString::compare() | - |
| 8281 | */ | - |
| 8282 | | - |
| 8283 | /*! | - |
| 8284 | \overload | - |
| 8285 | \fn int QStringRef::compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 8286 | \since 4.5 | - |
| 8287 | | - |
| 8288 | Compares this string with the \a other string and returns an | - |
| 8289 | integer less than, equal to, or greater than zero if this string | - |
| 8290 | is less than, equal to, or greater than the \a other string. | - |
| 8291 | | - |
| 8292 | If \a cs is Qt::CaseSensitive, the comparison is case sensitive; | - |
| 8293 | otherwise the comparison is case insensitive. | - |
| 8294 | | - |
| 8295 | Equivalent to \c {compare(*this, other, cs)}. | - |
| 8296 | | - |
| 8297 | \sa QString::compare() | - |
| 8298 | */ | - |
| 8299 | | - |
| 8300 | /*! | - |
| 8301 | \fn int QStringRef::localeAwareCompare(const QStringRef &s1, const QString & s2) | - |
| 8302 | \since 4.5 | - |
| 8303 | | - |
| 8304 | Compares \a s1 with \a s2 and returns an integer less than, equal | - |
| 8305 | to, or greater than zero if \a s1 is less than, equal to, or | - |
| 8306 | greater than \a s2. | - |
| 8307 | | - |
| 8308 | The comparison is performed in a locale- and also | - |
| 8309 | platform-dependent manner. Use this function to present sorted | - |
| 8310 | lists of strings to the user. | - |
| 8311 | | - |
| 8312 | On Mac OS X, this function compares according the | - |
| 8313 | "Order for sorted lists" setting in the International prefereces panel. | - |
| 8314 | | - |
| 8315 | \sa compare(), QTextCodec::locale() | - |
| 8316 | */ | - |
| 8317 | | - |
| 8318 | /*! | - |
| 8319 | \fn int QStringRef::localeAwareCompare(const QStringRef &s1, const QStringRef & s2) | - |
| 8320 | \since 4.5 | - |
| 8321 | \overload | - |
| 8322 | | - |
| 8323 | Compares \a s1 with \a s2 and returns an integer less than, equal | - |
| 8324 | to, or greater than zero if \a s1 is less than, equal to, or | - |
| 8325 | greater than \a s2. | - |
| 8326 | | - |
| 8327 | The comparison is performed in a locale- and also | - |
| 8328 | platform-dependent manner. Use this function to present sorted | - |
| 8329 | lists of strings to the user. | - |
| 8330 | | - |
| 8331 | */ | - |
| 8332 | | - |
| 8333 | /*! | - |
| 8334 | \fn int QStringRef::localeAwareCompare(const QString &other) const | - |
| 8335 | \since 4.5 | - |
| 8336 | \overload | - |
| 8337 | | - |
| 8338 | Compares this string with the \a other string and returns an | - |
| 8339 | integer less than, equal to, or greater than zero if this string | - |
| 8340 | is less than, equal to, or greater than the \a other string. | - |
| 8341 | | - |
| 8342 | The comparison is performed in a locale- and also | - |
| 8343 | platform-dependent manner. Use this function to present sorted | - |
| 8344 | lists of strings to the user. | - |
| 8345 | */ | - |
| 8346 | | - |
| 8347 | /*! | - |
| 8348 | \fn int QStringRef::localeAwareCompare(const QStringRef &other) const | - |
| 8349 | \since 4.5 | - |
| 8350 | \overload | - |
| 8351 | | - |
| 8352 | Compares this string with the \a other string and returns an | - |
| 8353 | integer less than, equal to, or greater than zero if this string | - |
| 8354 | is less than, equal to, or greater than the \a other string. | - |
| 8355 | | - |
| 8356 | The comparison is performed in a locale- and also | - |
| 8357 | platform-dependent manner. Use this function to present sorted | - |
| 8358 | lists of strings to the user. | - |
| 8359 | */ | - |
| 8360 | | - |
| 8361 | /*! | - |
| 8362 | \fn QString &QString::append(const QStringRef &reference) | - |
| 8363 | \since 4.4 | - |
| 8364 | | - |
| 8365 | Appends the given string \a reference to this string and returns the result. | - |
| 8366 | */ | - |
| 8367 | QString &QString::append(const QStringRef &str) | - |
| 8368 | { | - |
| 8369 | if (str.string() == this) { never evaluated: str.string() == this | 0 |
| 8370 | str.appendTo(this); never executed (the execution status of this line is deduced): str.appendTo(this); | - |
| 8371 | } else if (str.string()) { never executed: } never evaluated: str.string() | 0 |
| 8372 | int oldSize = size(); never executed (the execution status of this line is deduced): int oldSize = size(); | - |
| 8373 | resize(oldSize + str.size()); never executed (the execution status of this line is deduced): resize(oldSize + str.size()); | - |
| 8374 | memcpy(data() + oldSize, str.unicode(), str.size() * sizeof(QChar)); never executed (the execution status of this line is deduced): memcpy(data() + oldSize, str.unicode(), str.size() * sizeof(QChar)); | - |
| 8375 | } | 0 |
| 8376 | return *this; never executed: return *this; | 0 |
| 8377 | } | - |
| 8378 | | - |
| 8379 | /*! | - |
| 8380 | \since 4.4 | - |
| 8381 | | - |
| 8382 | Returns a substring reference to the \a n leftmost characters | - |
| 8383 | of the string. | - |
| 8384 | | - |
| 8385 | If \a n is greater than size() or less than zero, a reference to the entire | - |
| 8386 | string is returned. | - |
| 8387 | | - |
| 8388 | \snippet qstring/main.cpp leftRef | - |
| 8389 | | - |
| 8390 | \sa left(), rightRef(), midRef(), startsWith() | - |
| 8391 | */ | - |
| 8392 | QStringRef QString::leftRef(int n) const | - |
| 8393 | { | - |
| 8394 | if (n >= d->size || n < 0) evaluated: n >= d->size| yes Evaluation Count:2300 | yes Evaluation Count:73 |
evaluated: n < 0| yes Evaluation Count:1 | yes Evaluation Count:72 |
| 1-2300 |
| 8395 | n = d->size; executed: n = d->size;Execution Count:2301 | 2301 |
| 8396 | return QStringRef(this, 0, n); executed: return QStringRef(this, 0, n);Execution Count:2373 | 2373 |
| 8397 | } | - |
| 8398 | | - |
| 8399 | /*! | - |
| 8400 | \since 4.4 | - |
| 8401 | | - |
| 8402 | Returns a substring reference to the \a n rightmost characters | - |
| 8403 | of the string. | - |
| 8404 | | - |
| 8405 | If \a n is greater than size() or less than zero, a reference to the entire | - |
| 8406 | string is returned. | - |
| 8407 | | - |
| 8408 | \snippet qstring/main.cpp rightRef | - |
| 8409 | | - |
| 8410 | \sa right(), leftRef(), midRef(), endsWith() | - |
| 8411 | */ | - |
| 8412 | QStringRef QString::rightRef(int n) const | - |
| 8413 | { | - |
| 8414 | if (n >= d->size || n < 0) evaluated: n >= d->size| yes Evaluation Count:3 | yes Evaluation Count:3 |
evaluated: n < 0| yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-3 |
| 8415 | n = d->size; executed: n = d->size;Execution Count:4 | 4 |
| 8416 | return QStringRef(this, d->size - n, n); executed: return QStringRef(this, d->size - n, n);Execution Count:6 | 6 |
| 8417 | } | - |
| 8418 | | - |
| 8419 | /*! | - |
| 8420 | \since 4.4 | - |
| 8421 | | - |
| 8422 | Returns a substring reference to \a n characters of this string, | - |
| 8423 | starting at the specified \a position. | - |
| 8424 | | - |
| 8425 | If the \a position exceeds the length of the string, a null | - |
| 8426 | reference is returned. | - |
| 8427 | | - |
| 8428 | If there are less than \a n characters available in the string, | - |
| 8429 | starting at the given \a position, or if \a n is -1 (default), the | - |
| 8430 | function returns all characters from the specified \a position | - |
| 8431 | onwards. | - |
| 8432 | | - |
| 8433 | Example: | - |
| 8434 | | - |
| 8435 | \snippet qstring/main.cpp midRef | - |
| 8436 | | - |
| 8437 | \sa mid(), leftRef(), rightRef() | - |
| 8438 | */ | - |
| 8439 | | - |
| 8440 | QStringRef QString::midRef(int position, int n) const | - |
| 8441 | { | - |
| 8442 | if (position > d->size) evaluated: position > d->size| yes Evaluation Count:16 | yes Evaluation Count:562 |
| 16-562 |
| 8443 | return QStringRef(); executed: return QStringRef();Execution Count:16 | 16 |
| 8444 | if (position < 0) { evaluated: position < 0| yes Evaluation Count:33 | yes Evaluation Count:529 |
| 33-529 |
| 8445 | if (n < 0 || n + position >= d->size) evaluated: n < 0| yes Evaluation Count:6 | yes Evaluation Count:27 |
evaluated: n + position >= d->size| yes Evaluation Count:12 | yes Evaluation Count:15 |
| 6-27 |
| 8446 | return QStringRef(this, 0, d->size); executed: return QStringRef(this, 0, d->size);Execution Count:18 | 18 |
| 8447 | if (n + position <= 0) evaluated: n + position <= 0| yes Evaluation Count:11 | yes Evaluation Count:4 |
| 4-11 |
| 8448 | return QStringRef(); executed: return QStringRef();Execution Count:11 | 11 |
| 8449 | | - |
| 8450 | n += position; executed (the execution status of this line is deduced): n += position; | - |
| 8451 | position = 0; executed (the execution status of this line is deduced): position = 0; | - |
| 8452 | } else if (n < 0 || n > d->size - position) executed: }Execution Count:4 evaluated: n < 0| yes Evaluation Count:12 | yes Evaluation Count:517 |
evaluated: n > d->size - position| yes Evaluation Count:9 | yes Evaluation Count:508 |
| 4-517 |
| 8453 | n = d->size - position; executed: n = d->size - position;Execution Count:21 | 21 |
| 8454 | return QStringRef(this, position, n); executed: return QStringRef(this, position, n);Execution Count:533 | 533 |
| 8455 | } | - |
| 8456 | | - |
| 8457 | /*! | - |
| 8458 | \since 4.8 | - |
| 8459 | | - |
| 8460 | Returns the index position of the first occurrence of the string \a | - |
| 8461 | str in this string reference, searching forward from index position | - |
| 8462 | \a from. Returns -1 if \a str is not found. | - |
| 8463 | | - |
| 8464 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8465 | sensitive; otherwise the search is case insensitive. | - |
| 8466 | | - |
| 8467 | If \a from is -1, the search starts at the last character; if it is | - |
| 8468 | -2, at the next to last character and so on. | - |
| 8469 | | - |
| 8470 | \sa QString::indexOf(), lastIndexOf(), contains(), count() | - |
| 8471 | */ | - |
| 8472 | int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - |
| 8473 | { | - |
| 8474 | return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); executed: return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs);Execution Count:197 | 197 |
| 8475 | } | - |
| 8476 | | - |
| 8477 | /*! | - |
| 8478 | \since 4.8 | - |
| 8479 | \overload indexOf() | - |
| 8480 | | - |
| 8481 | Returns the index position of the first occurrence of the | - |
| 8482 | character \a ch in the string reference, searching forward from | - |
| 8483 | index position \a from. Returns -1 if \a ch could not be found. | - |
| 8484 | | - |
| 8485 | \sa QString::indexOf(), lastIndexOf(), contains(), count() | - |
| 8486 | */ | - |
| 8487 | int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - |
| 8488 | { | - |
| 8489 | return findChar(unicode(), length(), ch, from, cs); executed: return findChar(unicode(), length(), ch, from, cs);Execution Count:79 | 79 |
| 8490 | } | - |
| 8491 | | - |
| 8492 | /*! | - |
| 8493 | \since 4.8 | - |
| 8494 | | - |
| 8495 | Returns the index position of the first occurrence of the string \a | - |
| 8496 | str in this string reference, searching forward from index position | - |
| 8497 | \a from. Returns -1 if \a str is not found. | - |
| 8498 | | - |
| 8499 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8500 | sensitive; otherwise the search is case insensitive. | - |
| 8501 | | - |
| 8502 | If \a from is -1, the search starts at the last character; if it is | - |
| 8503 | -2, at the next to last character and so on. | - |
| 8504 | | - |
| 8505 | \sa QString::indexOf(), lastIndexOf(), contains(), count() | - |
| 8506 | */ | - |
| 8507 | int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - |
| 8508 | { | - |
| 8509 | return qt_find_latin1_string(unicode(), size(), str, from, cs); never executed: return qt_find_latin1_string(unicode(), size(), str, from, cs); | 0 |
| 8510 | } | - |
| 8511 | | - |
| 8512 | /*! | - |
| 8513 | \since 4.8 | - |
| 8514 | | - |
| 8515 | \overload indexOf() | - |
| 8516 | | - |
| 8517 | Returns the index position of the first occurrence of the string | - |
| 8518 | reference \a str in this string reference, searching forward from | - |
| 8519 | index position \a from. Returns -1 if \a str is not found. | - |
| 8520 | | - |
| 8521 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8522 | sensitive; otherwise the search is case insensitive. | - |
| 8523 | | - |
| 8524 | \sa QString::indexOf(), lastIndexOf(), contains(), count() | - |
| 8525 | */ | - |
| 8526 | int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - |
| 8527 | { | - |
| 8528 | return qFindString(unicode(), size(), from, str.unicode(), str.size(), cs); executed: return qFindString(unicode(), size(), from, str.unicode(), str.size(), cs);Execution Count:196 | 196 |
| 8529 | } | - |
| 8530 | | - |
| 8531 | /*! | - |
| 8532 | \since 4.8 | - |
| 8533 | | - |
| 8534 | Returns the index position of the last occurrence of the string \a | - |
| 8535 | str in this string reference, searching backward from index position | - |
| 8536 | \a from. If \a from is -1 (default), the search starts at the last | - |
| 8537 | character; if \a from is -2, at the next to last character and so | - |
| 8538 | on. Returns -1 if \a str is not found. | - |
| 8539 | | - |
| 8540 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8541 | sensitive; otherwise the search is case insensitive. | - |
| 8542 | | - |
| 8543 | \sa QString::lastIndexOf(), indexOf(), contains(), count() | - |
| 8544 | */ | - |
| 8545 | int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const | - |
| 8546 | { | - |
| 8547 | const int sl = str.size(); executed (the execution status of this line is deduced): const int sl = str.size(); | - |
| 8548 | if (sl == 1) evaluated: sl == 1| yes Evaluation Count:53 | yes Evaluation Count:50 |
| 50-53 |
| 8549 | return lastIndexOf(str.at(0), from, cs); executed: return lastIndexOf(str.at(0), from, cs);Execution Count:53 | 53 |
| 8550 | | - |
| 8551 | const int l = size();; executed (the execution status of this line is deduced): const int l = size();; | - |
| 8552 | if (from < 0) evaluated: from < 0| yes Evaluation Count:43 | yes Evaluation Count:7 |
| 7-43 |
| 8553 | from += l; executed: from += l;Execution Count:43 | 43 |
| 8554 | int delta = l - sl; executed (the execution status of this line is deduced): int delta = l - sl; | - |
| 8555 | if (from == l && sl == 0) evaluated: from == l| yes Evaluation Count:2 | yes Evaluation Count:48 |
evaluated: sl == 0| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-48 |
| 8556 | return from; executed: return from;Execution Count:1 | 1 |
| 8557 | if (from < 0 || from >= l || delta < 0) evaluated: from < 0| yes Evaluation Count:6 | yes Evaluation Count:43 |
evaluated: from >= l| yes Evaluation Count:2 | yes Evaluation Count:41 |
evaluated: delta < 0| yes Evaluation Count:7 | yes Evaluation Count:34 |
| 2-43 |
| 8558 | return -1; executed: return -1;Execution Count:15 | 15 |
| 8559 | if (from > delta) evaluated: from > delta| yes Evaluation Count:29 | yes Evaluation Count:5 |
| 5-29 |
| 8560 | from = delta; executed: from = delta;Execution Count:29 | 29 |
| 8561 | | - |
| 8562 | return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, executed: return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);Execution Count:34 | 34 |
| 8563 | reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs); executed: return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);Execution Count:34 | 34 |
| 8564 | } | - |
| 8565 | | - |
| 8566 | /*! | - |
| 8567 | \since 4.8 | - |
| 8568 | \overload lastIndexOf() | - |
| 8569 | | - |
| 8570 | Returns the index position of the last occurrence of the character | - |
| 8571 | \a ch, searching backward from position \a from. | - |
| 8572 | | - |
| 8573 | \sa QString::lastIndexOf(), indexOf(), contains(), count() | - |
| 8574 | */ | - |
| 8575 | int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const | - |
| 8576 | { | - |
| 8577 | return qt_last_index_of(unicode(), size(), ch, from, cs); executed: return qt_last_index_of(unicode(), size(), ch, from, cs);Execution Count:136 | 136 |
| 8578 | } | - |
| 8579 | | - |
| 8580 | /*! | - |
| 8581 | \since 4.8 | - |
| 8582 | \overload lastIndexOf() | - |
| 8583 | | - |
| 8584 | Returns the index position of the last occurrence of the string \a | - |
| 8585 | str in this string reference, searching backward from index position | - |
| 8586 | \a from. If \a from is -1 (default), the search starts at the last | - |
| 8587 | character; if \a from is -2, at the next to last character and so | - |
| 8588 | on. Returns -1 if \a str is not found. | - |
| 8589 | | - |
| 8590 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8591 | sensitive; otherwise the search is case insensitive. | - |
| 8592 | | - |
| 8593 | \sa QString::lastIndexOf(), indexOf(), contains(), count() | - |
| 8594 | */ | - |
| 8595 | int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const | - |
| 8596 | { | - |
| 8597 | const int sl = str.size(); never executed (the execution status of this line is deduced): const int sl = str.size(); | - |
| 8598 | if (sl == 1) | 0 |
| 8599 | return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs); never executed: return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs); | 0 |
| 8600 | | - |
| 8601 | const int l = size(); never executed (the execution status of this line is deduced): const int l = size(); | - |
| 8602 | if (from < 0) never evaluated: from < 0 | 0 |
| 8603 | from += l; never executed: from += l; | 0 |
| 8604 | int delta = l - sl; never executed (the execution status of this line is deduced): int delta = l - sl; | - |
| 8605 | if (from == l && sl == 0) never evaluated: from == l never evaluated: sl == 0 | 0 |
| 8606 | return from; never executed: return from; | 0 |
| 8607 | if (from < 0 || from >= l || delta < 0) never evaluated: from < 0 never evaluated: from >= l never evaluated: delta < 0 | 0 |
| 8608 | return -1; never executed: return -1; | 0 |
| 8609 | if (from > delta) never evaluated: from > delta | 0 |
| 8610 | from = delta; never executed: from = delta; | 0 |
| 8611 | | - |
| 8612 | QVarLengthArray<ushort> s(sl); never executed (the execution status of this line is deduced): QVarLengthArray<ushort> s(sl); | - |
| 8613 | for (int i = 0; i < sl; ++i) | 0 |
| 8614 | s[i] = str.latin1()[i]; never executed: s[i] = str.latin1()[i]; | 0 |
| 8615 | | - |
| 8616 | return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, s.data(), sl, cs); never executed: return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, s.data(), sl, cs); | 0 |
| 8617 | } | - |
| 8618 | | - |
| 8619 | /*! | - |
| 8620 | \since 4.8 | - |
| 8621 | \overload lastIndexOf() | - |
| 8622 | | - |
| 8623 | Returns the index position of the last occurrence of the string | - |
| 8624 | reference \a str in this string reference, searching backward from | - |
| 8625 | index position \a from. If \a from is -1 (default), the search | - |
| 8626 | starts at the last character; if \a from is -2, at the next to last | - |
| 8627 | character and so on. Returns -1 if \a str is not found. | - |
| 8628 | | - |
| 8629 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8630 | sensitive; otherwise the search is case insensitive. | - |
| 8631 | | - |
| 8632 | \sa QString::lastIndexOf(), indexOf(), contains(), count() | - |
| 8633 | */ | - |
| 8634 | int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const | - |
| 8635 | { | - |
| 8636 | const int sl = str.size(); executed (the execution status of this line is deduced): const int sl = str.size(); | - |
| 8637 | if (sl == 1) evaluated: sl == 1| yes Evaluation Count:53 | yes Evaluation Count:50 |
| 50-53 |
| 8638 | return lastIndexOf(str.at(0), from, cs); executed: return lastIndexOf(str.at(0), from, cs);Execution Count:53 | 53 |
| 8639 | | - |
| 8640 | const int l = size(); executed (the execution status of this line is deduced): const int l = size(); | - |
| 8641 | if (from < 0) evaluated: from < 0| yes Evaluation Count:43 | yes Evaluation Count:7 |
| 7-43 |
| 8642 | from += l; executed: from += l;Execution Count:43 | 43 |
| 8643 | int delta = l - sl; executed (the execution status of this line is deduced): int delta = l - sl; | - |
| 8644 | if (from == l && sl == 0) evaluated: from == l| yes Evaluation Count:2 | yes Evaluation Count:48 |
evaluated: sl == 0| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-48 |
| 8645 | return from; executed: return from;Execution Count:1 | 1 |
| 8646 | if (from < 0 || from >= l || delta < 0) evaluated: from < 0| yes Evaluation Count:6 | yes Evaluation Count:43 |
evaluated: from >= l| yes Evaluation Count:2 | yes Evaluation Count:41 |
evaluated: delta < 0| yes Evaluation Count:7 | yes Evaluation Count:34 |
| 2-43 |
| 8647 | return -1; executed: return -1;Execution Count:15 | 15 |
| 8648 | if (from > delta) evaluated: from > delta| yes Evaluation Count:29 | yes Evaluation Count:5 |
| 5-29 |
| 8649 | from = delta; executed: from = delta;Execution Count:29 | 29 |
| 8650 | | - |
| 8651 | return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, executed: return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);Execution Count:34 | 34 |
| 8652 | reinterpret_cast<const ushort*>(str.unicode()), executed: return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);Execution Count:34 | 34 |
| 8653 | str.size(), cs); executed: return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);Execution Count:34 | 34 |
| 8654 | } | - |
| 8655 | | - |
| 8656 | /*! | - |
| 8657 | \since 4.8 | - |
| 8658 | Returns the number of (potentially overlapping) occurrences of | - |
| 8659 | the string \a str in this string reference. | - |
| 8660 | | - |
| 8661 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8662 | case sensitive; otherwise the search is case insensitive. | - |
| 8663 | | - |
| 8664 | \sa QString::count(), contains(), indexOf() | - |
| 8665 | */ | - |
| 8666 | int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const | - |
| 8667 | { | - |
| 8668 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); executed: return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);Execution Count:4 | 4 |
| 8669 | } | - |
| 8670 | | - |
| 8671 | /*! | - |
| 8672 | \since 4.8 | - |
| 8673 | \overload count() | - |
| 8674 | | - |
| 8675 | Returns the number of occurrences of the character \a ch in the | - |
| 8676 | string reference. | - |
| 8677 | | - |
| 8678 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8679 | case sensitive; otherwise the search is case insensitive. | - |
| 8680 | | - |
| 8681 | \sa QString::count(), contains(), indexOf() | - |
| 8682 | */ | - |
| 8683 | int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const | - |
| 8684 | { | - |
| 8685 | return qt_string_count(unicode(), size(), ch, cs); executed: return qt_string_count(unicode(), size(), ch, cs);Execution Count:5 | 5 |
| 8686 | } | - |
| 8687 | | - |
| 8688 | /*! | - |
| 8689 | \since 4.8 | - |
| 8690 | \overload count() | - |
| 8691 | | - |
| 8692 | Returns the number of (potentially overlapping) occurrences of the | - |
| 8693 | string reference \a str in this string reference. | - |
| 8694 | | - |
| 8695 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8696 | case sensitive; otherwise the search is case insensitive. | - |
| 8697 | | - |
| 8698 | \sa QString::count(), contains(), indexOf() | - |
| 8699 | */ | - |
| 8700 | int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs) const | - |
| 8701 | { | - |
| 8702 | return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); never executed: return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); | 0 |
| 8703 | } | - |
| 8704 | | - |
| 8705 | /*! | - |
| 8706 | \since 4.8 | - |
| 8707 | | - |
| 8708 | Returns true if the string reference starts with \a str; otherwise | - |
| 8709 | returns false. | - |
| 8710 | | - |
| 8711 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8712 | case sensitive; otherwise the search is case insensitive. | - |
| 8713 | | - |
| 8714 | \sa QString::startsWith(), endsWith() | - |
| 8715 | */ | - |
| 8716 | bool QStringRef::startsWith(const QString &str, Qt::CaseSensitivity cs) const | - |
| 8717 | { | - |
| 8718 | return qt_starts_with(isNull() ? 0 : unicode(), size(), executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs);Execution Count:25 | 25 |
| 8719 | str.isNull() ? 0 : str.unicode(), str.size(), cs); executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs);Execution Count:25 | 25 |
| 8720 | } | - |
| 8721 | | - |
| 8722 | /*! | - |
| 8723 | \since 4.8 | - |
| 8724 | \overload startsWith() | - |
| 8725 | \sa QString::startsWith(), endsWith() | - |
| 8726 | */ | - |
| 8727 | bool QStringRef::startsWith(QLatin1String str, Qt::CaseSensitivity cs) const | - |
| 8728 | { | - |
| 8729 | return qt_starts_with(isNull() ? 0 : unicode(), size(), str, cs); executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), str, cs);Execution Count:25 | 25 |
| 8730 | } | - |
| 8731 | | - |
| 8732 | /*! | - |
| 8733 | \since 4.8 | - |
| 8734 | \overload startsWith() | - |
| 8735 | \sa QString::startsWith(), endsWith() | - |
| 8736 | */ | - |
| 8737 | bool QStringRef::startsWith(const QStringRef &str, Qt::CaseSensitivity cs) const | - |
| 8738 | { | - |
| 8739 | return qt_starts_with(isNull() ? 0 : unicode(), size(), never executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs); | 0 |
| 8740 | str.isNull() ? 0 : str.unicode(), str.size(), cs); never executed: return qt_starts_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs); | 0 |
| 8741 | } | - |
| 8742 | | - |
| 8743 | /*! | - |
| 8744 | \since 4.8 | - |
| 8745 | \overload startsWith() | - |
| 8746 | | - |
| 8747 | Returns true if the string reference starts with \a ch; otherwise | - |
| 8748 | returns false. | - |
| 8749 | | - |
| 8750 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8751 | sensitive; otherwise the search is case insensitive. | - |
| 8752 | | - |
| 8753 | \sa QString::startsWith(), endsWith() | - |
| 8754 | */ | - |
| 8755 | bool QStringRef::startsWith(QChar ch, Qt::CaseSensitivity cs) const | - |
| 8756 | { | - |
| 8757 | if (!isEmpty()) { evaluated: !isEmpty()| yes Evaluation Count:19 | yes Evaluation Count:6 |
| 6-19 |
| 8758 | const ushort *data = reinterpret_cast<const ushort*>(unicode()); executed (the execution status of this line is deduced): const ushort *data = reinterpret_cast<const ushort*>(unicode()); | - |
| 8759 | return (cs == Qt::CaseSensitive executed: return (cs == Qt::CaseSensitive ? data[0] == ch : foldCase(data[0]) == foldCase(ch.unicode()));Execution Count:19 | 19 |
| 8760 | ? data[0] == ch executed: return (cs == Qt::CaseSensitive ? data[0] == ch : foldCase(data[0]) == foldCase(ch.unicode()));Execution Count:19 | 19 |
| 8761 | : foldCase(data[0]) == foldCase(ch.unicode())); executed: return (cs == Qt::CaseSensitive ? data[0] == ch : foldCase(data[0]) == foldCase(ch.unicode()));Execution Count:19 | 19 |
| 8762 | } else { | - |
| 8763 | return false; executed: return false;Execution Count:6 | 6 |
| 8764 | } | - |
| 8765 | } | - |
| 8766 | | - |
| 8767 | /*! | - |
| 8768 | \since 4.8 | - |
| 8769 | Returns true if the string reference ends with \a str; otherwise | - |
| 8770 | returns false. | - |
| 8771 | | - |
| 8772 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8773 | sensitive; otherwise the search is case insensitive. | - |
| 8774 | | - |
| 8775 | \sa QString::endsWith(), startsWith() | - |
| 8776 | */ | - |
| 8777 | bool QStringRef::endsWith(const QString &str, Qt::CaseSensitivity cs) const | - |
| 8778 | { | - |
| 8779 | return qt_ends_with(isNull() ? 0 : unicode(), size(), executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs);Execution Count:25 | 25 |
| 8780 | str.isNull() ? 0 : str.unicode(), str.size(), cs); executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs);Execution Count:25 | 25 |
| 8781 | } | - |
| 8782 | | - |
| 8783 | /*! | - |
| 8784 | \since 4.8 | - |
| 8785 | \overload endsWith() | - |
| 8786 | | - |
| 8787 | Returns true if the string reference ends with \a ch; otherwise | - |
| 8788 | returns false. | - |
| 8789 | | - |
| 8790 | If \a cs is Qt::CaseSensitive (default), the search is case | - |
| 8791 | sensitive; otherwise the search is case insensitive. | - |
| 8792 | | - |
| 8793 | \sa QString::endsWith(), endsWith() | - |
| 8794 | */ | - |
| 8795 | bool QStringRef::endsWith(QChar ch, Qt::CaseSensitivity cs) const | - |
| 8796 | { | - |
| 8797 | if (!isEmpty()) { evaluated: !isEmpty()| yes Evaluation Count:19 | yes Evaluation Count:6 |
| 6-19 |
| 8798 | const ushort *data = reinterpret_cast<const ushort*>(unicode()); executed (the execution status of this line is deduced): const ushort *data = reinterpret_cast<const ushort*>(unicode()); | - |
| 8799 | const int size = length(); executed (the execution status of this line is deduced): const int size = length(); | - |
| 8800 | return (cs == Qt::CaseSensitive executed: return (cs == Qt::CaseSensitive ? data[size - 1] == ch : foldCase(data[size - 1]) == foldCase(ch.unicode()));Execution Count:19 | 19 |
| 8801 | ? data[size - 1] == ch executed: return (cs == Qt::CaseSensitive ? data[size - 1] == ch : foldCase(data[size - 1]) == foldCase(ch.unicode()));Execution Count:19 | 19 |
| 8802 | : foldCase(data[size - 1]) == foldCase(ch.unicode())); executed: return (cs == Qt::CaseSensitive ? data[size - 1] == ch : foldCase(data[size - 1]) == foldCase(ch.unicode()));Execution Count:19 | 19 |
| 8803 | } else { | - |
| 8804 | return false; executed: return false;Execution Count:6 | 6 |
| 8805 | } | - |
| 8806 | } | - |
| 8807 | | - |
| 8808 | /*! | - |
| 8809 | \since 4.8 | - |
| 8810 | \overload endsWith() | - |
| 8811 | \sa QString::endsWith(), endsWith() | - |
| 8812 | */ | - |
| 8813 | bool QStringRef::endsWith(QLatin1String str, Qt::CaseSensitivity cs) const | - |
| 8814 | { | - |
| 8815 | return qt_ends_with(isNull() ? 0 : unicode(), size(), str, cs); executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), str, cs);Execution Count:25 | 25 |
| 8816 | } | - |
| 8817 | | - |
| 8818 | /*! | - |
| 8819 | \since 4.8 | - |
| 8820 | \overload endsWith() | - |
| 8821 | \sa QString::endsWith(), endsWith() | - |
| 8822 | */ | - |
| 8823 | bool QStringRef::endsWith(const QStringRef &str, Qt::CaseSensitivity cs) const | - |
| 8824 | { | - |
| 8825 | return qt_ends_with(isNull() ? 0 : unicode(), size(), never executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs); | 0 |
| 8826 | str.isNull() ? 0 : str.unicode(), str.size(), cs); never executed: return qt_ends_with(isNull() ? 0 : unicode(), size(), str.isNull() ? 0 : str.unicode(), str.size(), cs); | 0 |
| 8827 | } | - |
| 8828 | | - |
| 8829 | | - |
| 8830 | /*! \fn bool QStringRef::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 8831 | | - |
| 8832 | \since 4.8 | - |
| 8833 | Returns true if this string reference contains an occurrence of | - |
| 8834 | the string \a str; otherwise returns false. | - |
| 8835 | | - |
| 8836 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8837 | case sensitive; otherwise the search is case insensitive. | - |
| 8838 | | - |
| 8839 | \sa indexOf(), count() | - |
| 8840 | */ | - |
| 8841 | | - |
| 8842 | /*! \fn bool QStringRef::contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 8843 | | - |
| 8844 | \overload contains() | - |
| 8845 | \since 4.8 | - |
| 8846 | | - |
| 8847 | Returns true if this string contains an occurrence of the | - |
| 8848 | character \a ch; otherwise returns false. | - |
| 8849 | | - |
| 8850 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8851 | case sensitive; otherwise the search is case insensitive. | - |
| 8852 | | - |
| 8853 | */ | - |
| 8854 | | - |
| 8855 | /*! \fn bool QStringRef::contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const | - |
| 8856 | \overload contains() | - |
| 8857 | \since 4.8 | - |
| 8858 | | - |
| 8859 | Returns true if this string reference contains an occurrence of | - |
| 8860 | the string reference \a str; otherwise returns false. | - |
| 8861 | | - |
| 8862 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8863 | case sensitive; otherwise the search is case insensitive. | - |
| 8864 | | - |
| 8865 | \sa indexOf(), count() | - |
| 8866 | */ | - |
| 8867 | | - |
| 8868 | /*! \fn bool QStringRef::contains(QLatin1String str, Qt::CaseSensitivity cs) const | - |
| 8869 | \since 4,8 | - |
| 8870 | \overload contains() | - |
| 8871 | | - |
| 8872 | Returns true if this string reference contains an occurrence of | - |
| 8873 | the string \a str; otherwise returns false. | - |
| 8874 | | - |
| 8875 | If \a cs is Qt::CaseSensitive (default), the search is | - |
| 8876 | case sensitive; otherwise the search is case insensitive. | - |
| 8877 | | - |
| 8878 | \sa indexOf(), count() | - |
| 8879 | */ | - |
| 8880 | | - |
| 8881 | static inline int qt_last_index_of(const QChar *haystack, int haystackLen, QChar needle, | - |
| 8882 | int from, Qt::CaseSensitivity cs) | - |
| 8883 | { | - |
| 8884 | ushort c = needle.unicode(); executed (the execution status of this line is deduced): ushort c = needle.unicode(); | - |
| 8885 | if (from < 0) evaluated: from < 0| yes Evaluation Count:21568 | yes Evaluation Count:4665 |
| 4665-21568 |
| 8886 | from += haystackLen; executed: from += haystackLen;Execution Count:21568 | 21568 |
| 8887 | if (from < 0 || from >= haystackLen) evaluated: from < 0| yes Evaluation Count:115 | yes Evaluation Count:26108 |
evaluated: from >= haystackLen| yes Evaluation Count:19 | yes Evaluation Count:26104 |
| 19-26108 |
| 8888 | return -1; executed: return -1;Execution Count:134 | 134 |
| 8889 | if (from >= 0) { partially evaluated: from >= 0| yes Evaluation Count:26128 | no Evaluation Count:0 |
| 0-26128 |
| 8890 | const ushort *b = reinterpret_cast<const ushort*>(haystack); executed (the execution status of this line is deduced): const ushort *b = reinterpret_cast<const ushort*>(haystack); | - |
| 8891 | const ushort *n = b + from; executed (the execution status of this line is deduced): const ushort *n = b + from; | - |
| 8892 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:26090 | yes Evaluation Count:32 |
| 32-26090 |
| 8893 | for (; n >= b; --n) evaluated: n >= b| yes Evaluation Count:196431 | yes Evaluation Count:10518 |
| 10518-196431 |
| 8894 | if (*n == c) evaluated: *n == c| yes Evaluation Count:15599 | yes Evaluation Count:180939 |
| 15599-180939 |
| 8895 | return n - b; executed: return n - b;Execution Count:15601 | 15601 |
| 8896 | } else { executed: }Execution Count:10518 | 10518 |
| 8897 | c = foldCase(c); executed (the execution status of this line is deduced): c = foldCase(c); | - |
| 8898 | for (; n >= b; --n) evaluated: n >= b| yes Evaluation Count:56 | yes Evaluation Count:8 |
| 8-56 |
| 8899 | if (foldCase(*n) == c) evaluated: foldCase(*n) == c| yes Evaluation Count:24 | yes Evaluation Count:32 |
| 24-32 |
| 8900 | return n - b; executed: return n - b;Execution Count:24 | 24 |
| 8901 | } executed: }Execution Count:8 | 8 |
| 8902 | } | - |
| 8903 | return -1; executed: return -1;Execution Count:10526 | 10526 |
| 8904 | | - |
| 8905 | | - |
| 8906 | } | - |
| 8907 | | - |
| 8908 | static inline int qt_string_count(const QChar *haystack, int haystackLen, | - |
| 8909 | const QChar *needle, int needleLen, | - |
| 8910 | Qt::CaseSensitivity cs) | - |
| 8911 | { | - |
| 8912 | int num = 0; executed (the execution status of this line is deduced): int num = 0; | - |
| 8913 | int i = -1; executed (the execution status of this line is deduced): int i = -1; | - |
| 8914 | if (haystackLen > 500 && needleLen > 5) { evaluated: haystackLen > 500| yes Evaluation Count:2 | yes Evaluation Count:18 |
partially evaluated: needleLen > 5| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-18 |
| 8915 | QStringMatcher matcher(needle, needleLen, cs); never executed (the execution status of this line is deduced): QStringMatcher matcher(needle, needleLen, cs); | - |
| 8916 | while ((i = matcher.indexIn(haystack, haystackLen, i + 1)) != -1) never evaluated: (i = matcher.indexIn(haystack, haystackLen, i + 1)) != -1 | 0 |
| 8917 | ++num; | 0 |
| 8918 | } else { | 0 |
| 8919 | while ((i = qFindString(haystack, haystackLen, i + 1, needle, needleLen, cs)) != -1) evaluated: (i = qFindString(haystack, haystackLen, i + 1, needle, needleLen, cs)) != -1| yes Evaluation Count:20628 | yes Evaluation Count:20 |
| 20-20628 |
| 8920 | ++num; executed: ++num;Execution Count:20628 | 20628 |
| 8921 | } executed: }Execution Count:20 | 20 |
| 8922 | return num; executed: return num;Execution Count:20 | 20 |
| 8923 | } | - |
| 8924 | | - |
| 8925 | static inline int qt_string_count(const QChar *unicode, int size, QChar ch, | - |
| 8926 | Qt::CaseSensitivity cs) | - |
| 8927 | { | - |
| 8928 | ushort c = ch.unicode(); executed (the execution status of this line is deduced): ushort c = ch.unicode(); | - |
| 8929 | int num = 0; executed (the execution status of this line is deduced): int num = 0; | - |
| 8930 | const ushort *b = reinterpret_cast<const ushort*>(unicode); executed (the execution status of this line is deduced): const ushort *b = reinterpret_cast<const ushort*>(unicode); | - |
| 8931 | const ushort *i = b + size; executed (the execution status of this line is deduced): const ushort *i = b + size; | - |
| 8932 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:3592 | yes Evaluation Count:2 |
| 2-3592 |
| 8933 | while (i != b) evaluated: i != b| yes Evaluation Count:55773 | yes Evaluation Count:3592 |
| 3592-55773 |
| 8934 | if (*--i == c) evaluated: *--i == c| yes Evaluation Count:2327 | yes Evaluation Count:53446 |
| 2327-53446 |
| 8935 | ++num; executed: ++num;Execution Count:2327 | 2327 |
| 8936 | } else { executed: }Execution Count:3592 | 3592 |
| 8937 | c = foldCase(c); executed (the execution status of this line is deduced): c = foldCase(c); | - |
| 8938 | while (i != b) evaluated: i != b| yes Evaluation Count:30 | yes Evaluation Count:2 |
| 2-30 |
| 8939 | if (foldCase(*(--i)) == c) evaluated: foldCase(*(--i)) == c| yes Evaluation Count:6 | yes Evaluation Count:24 |
| 6-24 |
| 8940 | ++num; executed: ++num;Execution Count:6 | 6 |
| 8941 | } executed: }Execution Count:2 | 2 |
| 8942 | return num; executed: return num;Execution Count:3594 | 3594 |
| 8943 | } | - |
| 8944 | | - |
| 8945 | static inline int qt_find_latin1_string(const QChar *haystack, int size, | - |
| 8946 | QLatin1String needle, | - |
| 8947 | int from, Qt::CaseSensitivity cs) | - |
| 8948 | { | - |
| 8949 | const char *latin1 = needle.latin1(); executed (the execution status of this line is deduced): const char *latin1 = needle.latin1(); | - |
| 8950 | int len = needle.size(); executed (the execution status of this line is deduced): int len = needle.size(); | - |
| 8951 | QVarLengthArray<ushort> s(len); executed (the execution status of this line is deduced): QVarLengthArray<ushort> s(len); | - |
| 8952 | for (int i = 0; i < len; ++i) evaluated: i < len| yes Evaluation Count:19501 | yes Evaluation Count:2528 |
| 2528-19501 |
| 8953 | s[i] = latin1[i]; executed: s[i] = latin1[i];Execution Count:19501 | 19501 |
| 8954 | | - |
| 8955 | return qFindString(haystack, size, from, executed: return qFindString(haystack, size, from, reinterpret_cast<const QChar*>(s.constData()), len, cs);Execution Count:2528 | 2528 |
| 8956 | reinterpret_cast<const QChar*>(s.constData()), len, cs); executed: return qFindString(haystack, size, from, reinterpret_cast<const QChar*>(s.constData()), len, cs);Execution Count:2528 | 2528 |
| 8957 | } | - |
| 8958 | | - |
| 8959 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - |
| 8960 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs) | - |
| 8961 | { | - |
| 8962 | if (!haystack) evaluated: !haystack| yes Evaluation Count:260 | yes Evaluation Count:71809 |
| 260-71809 |
| 8963 | return !needle; executed: return !needle;Execution Count:260 | 260 |
| 8964 | if (haystackLen == 0) evaluated: haystackLen == 0| yes Evaluation Count:10 | yes Evaluation Count:71799 |
| 10-71799 |
| 8965 | return needleLen == 0; executed: return needleLen == 0;Execution Count:10 | 10 |
| 8966 | if (needleLen > haystackLen) evaluated: needleLen > haystackLen| yes Evaluation Count:14927 | yes Evaluation Count:56872 |
| 14927-56872 |
| 8967 | return false; executed: return false;Execution Count:14927 | 14927 |
| 8968 | | - |
| 8969 | const ushort *h = reinterpret_cast<const ushort*>(haystack); executed (the execution status of this line is deduced): const ushort *h = reinterpret_cast<const ushort*>(haystack); | - |
| 8970 | const ushort *n = reinterpret_cast<const ushort*>(needle); executed (the execution status of this line is deduced): const ushort *n = reinterpret_cast<const ushort*>(needle); | - |
| 8971 | | - |
| 8972 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:55368 | yes Evaluation Count:1504 |
| 1504-55368 |
| 8973 | return qMemEquals(h, n, needleLen); executed: return qMemEquals(h, n, needleLen);Execution Count:55368 | 55368 |
| 8974 | } else { | - |
| 8975 | uint last = 0; executed (the execution status of this line is deduced): uint last = 0; | - |
| 8976 | uint olast = 0; executed (the execution status of this line is deduced): uint olast = 0; | - |
| 8977 | for (int i = 0; i < needleLen; ++i) evaluated: i < needleLen| yes Evaluation Count:2030 | yes Evaluation Count:228 |
| 228-2030 |
| 8978 | if (foldCase(h[i], last) != foldCase(n[i], olast)) evaluated: foldCase(h[i], last) != foldCase(n[i], olast)| yes Evaluation Count:1276 | yes Evaluation Count:754 |
| 754-1276 |
| 8979 | return false; executed: return false;Execution Count:1276 | 1276 |
| 8980 | } executed: }Execution Count:228 | 228 |
| 8981 | return true; executed: return true;Execution Count:228 | 228 |
| 8982 | } | - |
| 8983 | | - |
| 8984 | static inline bool qt_starts_with(const QChar *haystack, int haystackLen, | - |
| 8985 | QLatin1String needle, Qt::CaseSensitivity cs) | - |
| 8986 | { | - |
| 8987 | if (!haystack) evaluated: !haystack| yes Evaluation Count:3152 | yes Evaluation Count:663161 |
| 3152-663161 |
| 8988 | return !needle.latin1(); executed: return !needle.latin1();Execution Count:3152 | 3152 |
| 8989 | if (haystackLen == 0) evaluated: haystackLen == 0| yes Evaluation Count:1803 | yes Evaluation Count:661358 |
| 1803-661358 |
| 8990 | return !needle.latin1() || *needle.latin1() == 0; executed: return !needle.latin1() || *needle.latin1() == 0;Execution Count:1803 | 1803 |
| 8991 | const int slen = needle.size(); executed (the execution status of this line is deduced): const int slen = needle.size(); | - |
| 8992 | if (slen > haystackLen) evaluated: slen > haystackLen| yes Evaluation Count:265295 | yes Evaluation Count:396063 |
| 265295-396063 |
| 8993 | return false; executed: return false;Execution Count:265295 | 265295 |
| 8994 | const ushort *data = reinterpret_cast<const ushort*>(haystack); executed (the execution status of this line is deduced): const ushort *data = reinterpret_cast<const ushort*>(haystack); | - |
| 8995 | const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1()); executed (the execution status of this line is deduced): const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1()); | - |
| 8996 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:395935 | yes Evaluation Count:128 |
| 128-395935 |
| 8997 | for (int i = 0; i < slen; ++i) evaluated: i < slen| yes Evaluation Count:573913 | yes Evaluation Count:105791 |
| 105791-573913 |
| 8998 | if (data[i] != latin[i]) evaluated: data[i] != latin[i]| yes Evaluation Count:290144 | yes Evaluation Count:283769 |
| 283769-290144 |
| 8999 | return false; executed: return false;Execution Count:290144 | 290144 |
| 9000 | } else { executed: }Execution Count:105791 | 105791 |
| 9001 | for (int i = 0; i < slen; ++i) evaluated: i < slen| yes Evaluation Count:144 | yes Evaluation Count:19 |
| 19-144 |
| 9002 | if (foldCase(data[i]) != foldCase((ushort)latin[i])) evaluated: foldCase(data[i]) != foldCase((ushort)latin[i])| yes Evaluation Count:109 | yes Evaluation Count:35 |
| 35-109 |
| 9003 | return false; executed: return false;Execution Count:109 | 109 |
| 9004 | } executed: }Execution Count:19 | 19 |
| 9005 | return true; executed: return true;Execution Count:105810 | 105810 |
| 9006 | } | - |
| 9007 | | - |
| 9008 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - |
| 9009 | const QChar *needle, int needleLen, Qt::CaseSensitivity cs) | - |
| 9010 | { | - |
| 9011 | if (!haystack) evaluated: !haystack| yes Evaluation Count:6 | yes Evaluation Count:3484 |
| 6-3484 |
| 9012 | return !needle; executed: return !needle;Execution Count:6 | 6 |
| 9013 | if (haystackLen == 0) evaluated: haystackLen == 0| yes Evaluation Count:6 | yes Evaluation Count:3478 |
| 6-3478 |
| 9014 | return needleLen == 0; executed: return needleLen == 0;Execution Count:6 | 6 |
| 9015 | const int pos = haystackLen - needleLen; executed (the execution status of this line is deduced): const int pos = haystackLen - needleLen; | - |
| 9016 | if (pos < 0) evaluated: pos < 0| yes Evaluation Count:125 | yes Evaluation Count:3353 |
| 125-3353 |
| 9017 | return false; executed: return false;Execution Count:125 | 125 |
| 9018 | | - |
| 9019 | const ushort *h = reinterpret_cast<const ushort*>(haystack); executed (the execution status of this line is deduced): const ushort *h = reinterpret_cast<const ushort*>(haystack); | - |
| 9020 | const ushort *n = reinterpret_cast<const ushort*>(needle); executed (the execution status of this line is deduced): const ushort *n = reinterpret_cast<const ushort*>(needle); | - |
| 9021 | | - |
| 9022 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:3334 | yes Evaluation Count:19 |
| 19-3334 |
| 9023 | return qMemEquals(h + pos, n, needleLen); executed: return qMemEquals(h + pos, n, needleLen);Execution Count:3334 | 3334 |
| 9024 | } else { | - |
| 9025 | uint last = 0; executed (the execution status of this line is deduced): uint last = 0; | - |
| 9026 | uint olast = 0; executed (the execution status of this line is deduced): uint olast = 0; | - |
| 9027 | for (int i = 0; i < needleLen; i++) evaluated: i < needleLen| yes Evaluation Count:17 | yes Evaluation Count:13 |
| 13-17 |
| 9028 | if (foldCase(h[pos+i], last) != foldCase(n[i], olast)) evaluated: foldCase(h[pos+i], last) != foldCase(n[i], olast)| yes Evaluation Count:6 | yes Evaluation Count:11 |
| 6-11 |
| 9029 | return false; executed: return false;Execution Count:6 | 6 |
| 9030 | } executed: }Execution Count:13 | 13 |
| 9031 | return true; executed: return true;Execution Count:13 | 13 |
| 9032 | } | - |
| 9033 | | - |
| 9034 | | - |
| 9035 | static inline bool qt_ends_with(const QChar *haystack, int haystackLen, | - |
| 9036 | QLatin1String needle, Qt::CaseSensitivity cs) | - |
| 9037 | { | - |
| 9038 | if (!haystack) evaluated: !haystack| yes Evaluation Count:189 | yes Evaluation Count:5374 |
| 189-5374 |
| 9039 | return !needle.latin1(); executed: return !needle.latin1();Execution Count:189 | 189 |
| 9040 | if (haystackLen == 0) evaluated: haystackLen == 0| yes Evaluation Count:6 | yes Evaluation Count:5368 |
| 6-5368 |
| 9041 | return !needle.latin1() || *needle.latin1() == 0; executed: return !needle.latin1() || *needle.latin1() == 0;Execution Count:6 | 6 |
| 9042 | const int slen = needle.size(); executed (the execution status of this line is deduced): const int slen = needle.size(); | - |
| 9043 | int pos = haystackLen - slen; executed (the execution status of this line is deduced): int pos = haystackLen - slen; | - |
| 9044 | if (pos < 0) evaluated: pos < 0| yes Evaluation Count:1420 | yes Evaluation Count:3948 |
| 1420-3948 |
| 9045 | return false; executed: return false;Execution Count:1420 | 1420 |
| 9046 | const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1()); executed (the execution status of this line is deduced): const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1()); | - |
| 9047 | const ushort *data = reinterpret_cast<const ushort*>(haystack); executed (the execution status of this line is deduced): const ushort *data = reinterpret_cast<const ushort*>(haystack); | - |
| 9048 | if (cs == Qt::CaseSensitive) { evaluated: cs == Qt::CaseSensitive| yes Evaluation Count:3650 | yes Evaluation Count:298 |
| 298-3650 |
| 9049 | for (int i = 0; i < slen; i++) evaluated: i < slen| yes Evaluation Count:5807 | yes Evaluation Count:839 |
| 839-5807 |
| 9050 | if (data[pos+i] != latin[i]) evaluated: data[pos+i] != latin[i]| yes Evaluation Count:2811 | yes Evaluation Count:2996 |
| 2811-2996 |
| 9051 | return false; executed: return false;Execution Count:2811 | 2811 |
| 9052 | } else { executed: }Execution Count:839 | 839 |
| 9053 | for (int i = 0; i < slen; i++) evaluated: i < slen| yes Evaluation Count:595 | yes Evaluation Count:271 |
| 271-595 |
| 9054 | if (foldCase(data[pos+i]) != foldCase((ushort)latin[i])) evaluated: foldCase(data[pos+i]) != foldCase((ushort)latin[i])| yes Evaluation Count:27 | yes Evaluation Count:568 |
| 27-568 |
| 9055 | return false; executed: return false;Execution Count:27 | 27 |
| 9056 | } executed: }Execution Count:271 | 271 |
| 9057 | return true; executed: return true;Execution Count:1110 | 1110 |
| 9058 | } | - |
| 9059 | | - |
| 9060 | /*! | - |
| 9061 | \since 4.8 | - |
| 9062 | | - |
| 9063 | Returns a Latin-1 representation of the string as a QByteArray. | - |
| 9064 | | - |
| 9065 | The returned byte array is undefined if the string contains non-Latin1 | - |
| 9066 | characters. Those characters may be suppressed or replaced with a | - |
| 9067 | question mark. | - |
| 9068 | | - |
| 9069 | \sa toUtf8(), toLocal8Bit(), QTextCodec | - |
| 9070 | */ | - |
| 9071 | QByteArray QStringRef::toLatin1() const | - |
| 9072 | { | - |
| 9073 | return toLatin1_helper(unicode(), length()); executed: return toLatin1_helper(unicode(), length());Execution Count:16 | 16 |
| 9074 | } | - |
| 9075 | | - |
| 9076 | /*! | - |
| 9077 | \fn QByteArray QStringRef::toAscii() const | - |
| 9078 | \since 4.8 | - |
| 9079 | \deprecated | - |
| 9080 | | - |
| 9081 | Returns an 8-bit representation of the string as a QByteArray. | - |
| 9082 | | - |
| 9083 | This function does the same as toLatin1(). | - |
| 9084 | | - |
| 9085 | Note that, despite the name, this function does not necessarily return an US-ASCII | - |
| 9086 | (ANSI X3.4-1986) string and its result may not be US-ASCII compatible. | - |
| 9087 | | - |
| 9088 | \sa toLatin1(), toUtf8(), toLocal8Bit(), QTextCodec | - |
| 9089 | */ | - |
| 9090 | | - |
| 9091 | /*! | - |
| 9092 | \since 4.8 | - |
| 9093 | | - |
| 9094 | Returns the local 8-bit representation of the string as a | - |
| 9095 | QByteArray. The returned byte array is undefined if the string | - |
| 9096 | contains characters not supported by the local 8-bit encoding. | - |
| 9097 | | - |
| 9098 | QTextCodec::codecForLocale() is used to perform the conversion from | - |
| 9099 | Unicode. If the locale encoding could not be determined, this function | - |
| 9100 | does the same as toLatin1(). | - |
| 9101 | | - |
| 9102 | If this string contains any characters that cannot be encoded in the | - |
| 9103 | locale, the returned byte array is undefined. Those characters may be | - |
| 9104 | suppressed or replaced by another. | - |
| 9105 | | - |
| 9106 | \sa toLatin1(), toUtf8(), QTextCodec | - |
| 9107 | */ | - |
| 9108 | QByteArray QStringRef::toLocal8Bit() const | - |
| 9109 | { | - |
| 9110 | #ifndef QT_NO_TEXTCODEC | - |
| 9111 | QTextCodec *localeCodec = QTextCodec::codecForLocale(); executed (the execution status of this line is deduced): QTextCodec *localeCodec = QTextCodec::codecForLocale(); | - |
| 9112 | if (localeCodec) partially evaluated: localeCodec| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 9113 | return localeCodec->fromUnicode(unicode(), length()); executed: return localeCodec->fromUnicode(unicode(), length());Execution Count:5 | 5 |
| 9114 | #endif // QT_NO_TEXTCODEC | - |
| 9115 | return toLatin1(); never executed: return toLatin1(); | 0 |
| 9116 | } | - |
| 9117 | | - |
| 9118 | /*! | - |
| 9119 | \since 4.8 | - |
| 9120 | | - |
| 9121 | Returns a UTF-8 representation of the string as a QByteArray. | - |
| 9122 | | - |
| 9123 | UTF-8 is a Unicode codec and can represent all characters in a Unicode | - |
| 9124 | string like QString. | - |
| 9125 | | - |
| 9126 | However, in the Unicode range, there are certain codepoints that are not | - |
| 9127 | considered characters. The Unicode standard reserves the last two | - |
| 9128 | codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, | - |
| 9129 | U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF, | - |
| 9130 | inclusive, as non-characters. If any of those appear in the string, they | - |
| 9131 | may be discarded and will not appear in the UTF-8 representation, or they | - |
| 9132 | may be replaced by one or more replacement characters. | - |
| 9133 | | - |
| 9134 | \sa toLatin1(), toLocal8Bit(), QTextCodec | - |
| 9135 | */ | - |
| 9136 | QByteArray QStringRef::toUtf8() const | - |
| 9137 | { | - |
| 9138 | if (isNull()) partially evaluated: isNull()| no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
| 9139 | return QByteArray(); never executed: return QByteArray(); | 0 |
| 9140 | | - |
| 9141 | return QUtf8::convertFromUnicode(constData(), length(), 0); executed: return QUtf8::convertFromUnicode(constData(), length(), 0);Execution Count:5 | 5 |
| 9142 | } | - |
| 9143 | | - |
| 9144 | /*! | - |
| 9145 | \since 4.8 | - |
| 9146 | | - |
| 9147 | Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>. | - |
| 9148 | | - |
| 9149 | UCS-4 is a Unicode codec and is lossless. All characters from this string | - |
| 9150 | can be encoded in UCS-4. | - |
| 9151 | | - |
| 9152 | \sa toUtf8(), toLatin1(), toLocal8Bit(), QTextCodec | - |
| 9153 | */ | - |
| 9154 | QVector<uint> QStringRef::toUcs4() const | - |
| 9155 | { | - |
| 9156 | QVector<uint> v(length()); never executed (the execution status of this line is deduced): QVector<uint> v(length()); | - |
| 9157 | uint *a = v.data(); never executed (the execution status of this line is deduced): uint *a = v.data(); | - |
| 9158 | int len = QString::toUcs4_helper(reinterpret_cast<const ushort *>(unicode()), length(), a); never executed (the execution status of this line is deduced): int len = QString::toUcs4_helper(reinterpret_cast<const ushort *>(unicode()), length(), a); | - |
| 9159 | v.resize(len); never executed (the execution status of this line is deduced): v.resize(len); | - |
| 9160 | return v; never executed: return v; | 0 |
| 9161 | } | - |
| 9162 | | - |
| 9163 | | - |
| 9164 | /*! | - |
| 9165 | \obsolete | - |
| 9166 | \fn QString Qt::escape(const QString &plain) | - |
| 9167 | | - |
| 9168 | \sa QString::toHtmlEscaped() | - |
| 9169 | */ | - |
| 9170 | | - |
| 9171 | /*! | - |
| 9172 | Converts a plain text string to an HTML string with | - |
| 9173 | HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML | - |
| 9174 | entities. | - |
| 9175 | | - |
| 9176 | Example: | - |
| 9177 | | - |
| 9178 | \snippet code/src_corelib_tools_qstring.cpp 7 | - |
| 9179 | */ | - |
| 9180 | QString QString::toHtmlEscaped() const | - |
| 9181 | { | - |
| 9182 | QString rich; executed (the execution status of this line is deduced): QString rich; | - |
| 9183 | const int len = length(); executed (the execution status of this line is deduced): const int len = length(); | - |
| 9184 | rich.reserve(int(len * 1.1)); executed (the execution status of this line is deduced): rich.reserve(int(len * 1.1)); | - |
| 9185 | for (int i = 0; i < len; ++i) { evaluated: i < len| yes Evaluation Count:1729 | yes Evaluation Count:261 |
| 261-1729 |
| 9186 | if (at(i) == QLatin1Char('<')) evaluated: at(i) == QLatin1Char('<')| yes Evaluation Count:7 | yes Evaluation Count:1722 |
| 7-1722 |
| 9187 | rich += QLatin1String("<"); executed: rich += QLatin1String("<");Execution Count:7 | 7 |
| 9188 | else if (at(i) == QLatin1Char('>')) evaluated: at(i) == QLatin1Char('>')| yes Evaluation Count:7 | yes Evaluation Count:1715 |
| 7-1715 |
| 9189 | rich += QLatin1String(">"); executed: rich += QLatin1String(">");Execution Count:7 | 7 |
| 9190 | else if (at(i) == QLatin1Char('&')) evaluated: at(i) == QLatin1Char('&')| yes Evaluation Count:5 | yes Evaluation Count:1710 |
| 5-1710 |
| 9191 | rich += QLatin1String("&"); executed: rich += QLatin1String("&");Execution Count:5 | 5 |
| 9192 | else if (at(i) == QLatin1Char('"')) evaluated: at(i) == QLatin1Char('"')| yes Evaluation Count:6 | yes Evaluation Count:1704 |
| 6-1704 |
| 9193 | rich += QLatin1String("""); executed: rich += QLatin1String(""");Execution Count:6 | 6 |
| 9194 | else | - |
| 9195 | rich += at(i); executed: rich += at(i);Execution Count:1704 | 1704 |
| 9196 | } | - |
| 9197 | rich.squeeze(); executed (the execution status of this line is deduced): rich.squeeze(); | - |
| 9198 | return rich; executed: return rich;Execution Count:261 | 261 |
| 9199 | } | - |
| 9200 | | - |
| 9201 | /*! | - |
| 9202 | \macro QStringLiteral(str) | - |
| 9203 | \relates QString | - |
| 9204 | | - |
| 9205 | The macro generates the data for a QString out of \a str at compile time if the compiler supports it. | - |
| 9206 | Creating a QString from it is free in this case, and the generated string data is stored in | - |
| 9207 | the read-only segment of the compiled object file. | - |
| 9208 | | - |
| 9209 | For compilers not supporting the creation of compile time strings, QStringLiteral will fall back to | - |
| 9210 | QLatin1String. | - |
| 9211 | | - |
| 9212 | The result of the QStringLiteral expression can be cast into a QString. | - |
| 9213 | | - |
| 9214 | If you have code looking like: | - |
| 9215 | \code | - |
| 9216 | if (node.hasAttribute("http-contents-length")) //... | - |
| 9217 | \endcode | - |
| 9218 | One temporary QString will be created to be passed as the hasAttribute function parameter. | - |
| 9219 | This can be quite expensive, as it involves a memory allocation and the copy and the conversion | - |
| 9220 | of the data into QString's internal encoding. | - |
| 9221 | | - |
| 9222 | This can be avoided by doing | - |
| 9223 | \code | - |
| 9224 | if (node.hasAttribute(QStringLiteral("http-contents-length"))) //... | - |
| 9225 | \endcode | - |
| 9226 | Then the QString's internal data will be generated at compile time and no conversion or allocation | - |
| 9227 | will occur at runtime | - |
| 9228 | | - |
| 9229 | Using QStringLiteral instead of a double quoted ascii literal can significantly speed up creation | - |
| 9230 | of QString's from data known at compile time. | - |
| 9231 | | - |
| 9232 | If the compiler is C++11 enabled the string \a str can actually contain unicode data. | - |
| 9233 | | - |
| 9234 | \note There are still a few cases in which QLatin1String is more efficient than QStringLiteral: | - |
| 9235 | If it is passed to a function that has an overload that takes the QLatin1String directly, without | - |
| 9236 | conversion to QString. For instance, this is the case of QString::operator== | - |
| 9237 | \code | - |
| 9238 | if (attribute.name() == QLatin1String("http-contents-length")) //... | - |
| 9239 | \endcode | - |
| 9240 | */ | - |
| 9241 | | - |
| 9242 | QT_END_NAMESPACE | - |
| 9243 | | - |
| | |