|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtCore module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QSTRING_H |
|
43 #define QSTRING_H |
|
44 |
|
45 #include <QtCore/qchar.h> |
|
46 #include <QtCore/qbytearray.h> |
|
47 #include <QtCore/qatomic.h> |
|
48 #include <QtCore/qnamespace.h> |
|
49 #ifdef QT_INCLUDE_COMPAT |
|
50 #include <Qt3Support/q3cstring.h> |
|
51 #endif |
|
52 |
|
53 #ifndef QT_NO_STL |
|
54 # if defined (Q_CC_MSVC_NET) && _MSC_VER < 1310 // Avoids nasty warning for xlocale, line 450 |
|
55 # pragma warning (push) |
|
56 # pragma warning (disable : 4189) |
|
57 # include <string> |
|
58 # pragma warning (pop) |
|
59 # else |
|
60 # include <string> |
|
61 # endif |
|
62 |
|
63 # ifndef QT_NO_STL_WCHAR |
|
64 // workaround for some headers not typedef'ing std::wstring |
|
65 typedef std::basic_string<wchar_t> QStdWString; |
|
66 # endif // QT_NO_STL_WCHAR |
|
67 |
|
68 #endif // QT_NO_STL |
|
69 |
|
70 #include <stdarg.h> |
|
71 |
|
72 #ifdef truncate |
|
73 #error qstring.h must be included before any header file that defines truncate |
|
74 #endif |
|
75 |
|
76 QT_BEGIN_HEADER |
|
77 |
|
78 QT_BEGIN_NAMESPACE |
|
79 |
|
80 QT_MODULE(Core) |
|
81 |
|
82 class QCharRef; |
|
83 class QRegExp; |
|
84 class QStringList; |
|
85 class QTextCodec; |
|
86 class QLatin1String; |
|
87 class QStringRef; |
|
88 template <typename T> class QVector; |
|
89 |
|
90 class Q_CORE_EXPORT QString |
|
91 { |
|
92 public: |
|
93 inline QString(); |
|
94 QString(const QChar *unicode, int size); |
|
95 QString(QChar c); |
|
96 QString(int size, QChar c); |
|
97 inline QString(const QLatin1String &latin1); |
|
98 inline QString(const QString &); |
|
99 inline ~QString(); |
|
100 QString &operator=(QChar c); |
|
101 QString &operator=(const QString &); |
|
102 inline QString &operator=(const QLatin1String &); |
|
103 |
|
104 inline int size() const { return d->size; } |
|
105 inline int count() const { return d->size; } |
|
106 inline int length() const; |
|
107 inline bool isEmpty() const; |
|
108 void resize(int size); |
|
109 |
|
110 QString &fill(QChar c, int size = -1); |
|
111 void truncate(int pos); |
|
112 void chop(int n); |
|
113 |
|
114 int capacity() const; |
|
115 inline void reserve(int size); |
|
116 inline void squeeze() { if (d->size < d->alloc || d->ref != 1) realloc(); d->capacity = 0;} |
|
117 |
|
118 inline const QChar *unicode() const; |
|
119 inline QChar *data(); |
|
120 inline const QChar *data() const; |
|
121 inline const QChar *constData() const; |
|
122 |
|
123 inline void detach(); |
|
124 inline bool isDetached() const; |
|
125 void clear(); |
|
126 |
|
127 inline const QChar at(int i) const; |
|
128 const QChar operator[](int i) const; |
|
129 QCharRef operator[](int i); |
|
130 const QChar operator[](uint i) const; |
|
131 QCharRef operator[](uint i); |
|
132 |
|
133 QString arg(qlonglong a, int fieldwidth=0, int base=10, |
|
134 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
135 QString arg(qulonglong a, int fieldwidth=0, int base=10, |
|
136 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
137 QString arg(long a, int fieldwidth=0, int base=10, |
|
138 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
139 QString arg(ulong a, int fieldwidth=0, int base=10, |
|
140 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
141 QString arg(int a, int fieldWidth = 0, int base = 10, |
|
142 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
143 QString arg(uint a, int fieldWidth = 0, int base = 10, |
|
144 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
145 QString arg(short a, int fieldWidth = 0, int base = 10, |
|
146 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
147 QString arg(ushort a, int fieldWidth = 0, int base = 10, |
|
148 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
149 QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1, |
|
150 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
151 QString arg(char a, int fieldWidth = 0, |
|
152 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
153 QString arg(QChar a, int fieldWidth = 0, |
|
154 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
155 QString arg(const QString &a, int fieldWidth = 0, |
|
156 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; |
|
157 QString arg(const QString &a1, const QString &a2) const Q_REQUIRED_RESULT; |
|
158 QString arg(const QString &a1, const QString &a2, const QString &a3) const Q_REQUIRED_RESULT; |
|
159 QString arg(const QString &a1, const QString &a2, const QString &a3, |
|
160 const QString &a4) const Q_REQUIRED_RESULT; |
|
161 QString arg(const QString &a1, const QString &a2, const QString &a3, |
|
162 const QString &a4, const QString &a5) const Q_REQUIRED_RESULT; |
|
163 QString arg(const QString &a1, const QString &a2, const QString &a3, |
|
164 const QString &a4, const QString &a5, const QString &a6) const Q_REQUIRED_RESULT; |
|
165 QString arg(const QString &a1, const QString &a2, const QString &a3, |
|
166 const QString &a4, const QString &a5, const QString &a6, |
|
167 const QString &a7) const Q_REQUIRED_RESULT; |
|
168 QString arg(const QString &a1, const QString &a2, const QString &a3, |
|
169 const QString &a4, const QString &a5, const QString &a6, |
|
170 const QString &a7, const QString &a8) const Q_REQUIRED_RESULT; |
|
171 QString arg(const QString &a1, const QString &a2, const QString &a3, |
|
172 const QString &a4, const QString &a5, const QString &a6, |
|
173 const QString &a7, const QString &a8, const QString &a9) const Q_REQUIRED_RESULT; |
|
174 |
|
175 QString &vsprintf(const char *format, va_list ap) |
|
176 #if defined(Q_CC_GNU) && !defined(__INSURE__) |
|
177 __attribute__ ((format (printf, 2, 0))) |
|
178 #endif |
|
179 ; |
|
180 QString &sprintf(const char *format, ...) |
|
181 #if defined(Q_CC_GNU) && !defined(__INSURE__) |
|
182 __attribute__ ((format (printf, 2, 3))) |
|
183 #endif |
|
184 ; |
|
185 |
|
186 int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
187 int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
188 int indexOf(const QLatin1String &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
189 int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
190 int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
191 int lastIndexOf(const QLatin1String &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
192 |
|
193 inline QBool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
194 inline QBool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
195 int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
196 int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
197 |
|
198 #ifndef QT_NO_REGEXP |
|
199 int indexOf(const QRegExp &, int from = 0) const; |
|
200 int lastIndexOf(const QRegExp &, int from = -1) const; |
|
201 inline QBool contains(const QRegExp &rx) const { return QBool(indexOf(rx) != -1); } |
|
202 int count(const QRegExp &) const; |
|
203 |
|
204 int indexOf(QRegExp &, int from = 0) const; |
|
205 int lastIndexOf(QRegExp &, int from = -1) const; |
|
206 inline QBool contains(QRegExp &rx) const { return QBool(indexOf(rx) != -1); } |
|
207 #endif |
|
208 |
|
209 enum SectionFlag { |
|
210 SectionDefault = 0x00, |
|
211 SectionSkipEmpty = 0x01, |
|
212 SectionIncludeLeadingSep = 0x02, |
|
213 SectionIncludeTrailingSep = 0x04, |
|
214 SectionCaseInsensitiveSeps = 0x08 |
|
215 }; |
|
216 Q_DECLARE_FLAGS(SectionFlags, SectionFlag) |
|
217 |
|
218 QString section(QChar sep, int start, int end = -1, SectionFlags flags = SectionDefault) const; |
|
219 QString section(const QString &in_sep, int start, int end = -1, SectionFlags flags = SectionDefault) const; |
|
220 #ifndef QT_NO_REGEXP |
|
221 QString section(const QRegExp ®, int start, int end = -1, SectionFlags flags = SectionDefault) const; |
|
222 #endif |
|
223 |
|
224 QString left(int n) const Q_REQUIRED_RESULT; |
|
225 QString right(int n) const Q_REQUIRED_RESULT; |
|
226 QString mid(int position, int n = -1) const Q_REQUIRED_RESULT; |
|
227 QStringRef leftRef(int n) const Q_REQUIRED_RESULT; |
|
228 QStringRef rightRef(int n) const Q_REQUIRED_RESULT; |
|
229 QStringRef midRef(int position, int n = -1) const Q_REQUIRED_RESULT; |
|
230 |
|
231 bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
232 bool startsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
233 bool startsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
234 bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
235 bool endsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
236 bool endsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
237 |
|
238 QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; |
|
239 QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; |
|
240 |
|
241 QString toLower() const Q_REQUIRED_RESULT; |
|
242 QString toUpper() const Q_REQUIRED_RESULT; |
|
243 QString toCaseFolded() const Q_REQUIRED_RESULT; |
|
244 |
|
245 QString trimmed() const Q_REQUIRED_RESULT; |
|
246 QString simplified() const Q_REQUIRED_RESULT; |
|
247 |
|
248 QString &insert(int i, QChar c); |
|
249 QString &insert(int i, const QChar *uc, int len); |
|
250 inline QString &insert(int i, const QString &s) { return insert(i, s.constData(), s.length()); } |
|
251 QString &insert(int i, const QLatin1String &s); |
|
252 QString &append(QChar c); |
|
253 QString &append(const QString &s); |
|
254 QString &append(const QStringRef &s); |
|
255 QString &append(const QLatin1String &s); |
|
256 inline QString &prepend(QChar c) { return insert(0, c); } |
|
257 inline QString &prepend(const QString &s) { return insert(0, s); } |
|
258 inline QString &prepend(const QLatin1String &s) { return insert(0, s); } |
|
259 |
|
260 inline QString &operator+=(QChar c) { |
|
261 if (d->ref != 1 || d->size + 1 > d->alloc) |
|
262 realloc(grow(d->size + 1)); |
|
263 d->data[d->size++] = c.unicode(); |
|
264 d->data[d->size] = '\0'; |
|
265 return *this; |
|
266 } |
|
267 |
|
268 inline QString &operator+=(QChar::SpecialCharacter c) { return append(QChar(c)); } |
|
269 inline QString &operator+=(const QString &s) { return append(s); } |
|
270 inline QString &operator+=(const QStringRef &s) { return append(s); } |
|
271 inline QString &operator+=(const QLatin1String &s) { return append(s); } |
|
272 |
|
273 QString &remove(int i, int len); |
|
274 QString &remove(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
275 QString &remove(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
276 QString &replace(int i, int len, QChar after); |
|
277 QString &replace(int i, int len, const QChar *s, int slen); |
|
278 QString &replace(int i, int len, const QString &after); |
|
279 QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
280 QString &replace(const QChar *before, int blen, const QChar *after, int alen, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
281 QString &replace(const QLatin1String &before, const QLatin1String &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
282 QString &replace(const QLatin1String &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
283 QString &replace(const QString &before, const QLatin1String &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
284 QString &replace(const QString &before, const QString &after, |
|
285 Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
286 QString &replace(QChar c, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
287 QString &replace(QChar c, const QLatin1String &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
288 #ifndef QT_NO_REGEXP |
|
289 QString &replace(const QRegExp &rx, const QString &after); |
|
290 inline QString &remove(const QRegExp &rx) |
|
291 { return replace(rx, QString()); } |
|
292 #endif |
|
293 |
|
294 enum SplitBehavior { KeepEmptyParts, SkipEmptyParts }; |
|
295 |
|
296 QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts, |
|
297 Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; |
|
298 QStringList split(const QChar &sep, SplitBehavior behavior = KeepEmptyParts, |
|
299 Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; |
|
300 #ifndef QT_NO_REGEXP |
|
301 QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; |
|
302 #endif |
|
303 |
|
304 enum NormalizationForm { |
|
305 NormalizationForm_D, |
|
306 NormalizationForm_C, |
|
307 NormalizationForm_KD, |
|
308 NormalizationForm_KC |
|
309 }; |
|
310 QString normalized(NormalizationForm mode) const Q_REQUIRED_RESULT; |
|
311 QString normalized(NormalizationForm mode, QChar::UnicodeVersion version) const Q_REQUIRED_RESULT; |
|
312 |
|
313 QString repeated(int times) const; |
|
314 |
|
315 const ushort *utf16() const; |
|
316 |
|
317 QByteArray toAscii() const Q_REQUIRED_RESULT; |
|
318 QByteArray toLatin1() const Q_REQUIRED_RESULT; |
|
319 QByteArray toUtf8() const Q_REQUIRED_RESULT; |
|
320 QByteArray toLocal8Bit() const Q_REQUIRED_RESULT; |
|
321 QVector<uint> toUcs4() const Q_REQUIRED_RESULT; |
|
322 |
|
323 static QString fromAscii(const char *, int size = -1); |
|
324 static QString fromLatin1(const char *, int size = -1); |
|
325 static QString fromUtf8(const char *, int size = -1); |
|
326 static QString fromLocal8Bit(const char *, int size = -1); |
|
327 static QString fromUtf16(const ushort *, int size = -1); |
|
328 static QString fromUcs4(const uint *, int size = -1); |
|
329 static QString fromRawData(const QChar *, int size); |
|
330 |
|
331 int toWCharArray(wchar_t *array) const; |
|
332 static QString fromWCharArray(const wchar_t *, int size = -1); |
|
333 |
|
334 QString &setUnicode(const QChar *unicode, int size); |
|
335 inline QString &setUtf16(const ushort *utf16, int size); |
|
336 |
|
337 // ### Qt 5: merge these two functions |
|
338 int compare(const QString &s) const; |
|
339 int compare(const QString &s, Qt::CaseSensitivity cs) const; |
|
340 |
|
341 int compare(const QLatin1String &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
342 |
|
343 // ### Qt 5: merge these two functions |
|
344 static inline int compare(const QString &s1, const QString &s2) |
|
345 { return s1.compare(s2); } |
|
346 static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs) |
|
347 { return s1.compare(s2, cs); } |
|
348 |
|
349 static inline int compare(const QString& s1, const QLatin1String &s2, |
|
350 Qt::CaseSensitivity cs = Qt::CaseSensitive) |
|
351 { return s1.compare(s2, cs); } |
|
352 static inline int compare(const QLatin1String& s1, const QString &s2, |
|
353 Qt::CaseSensitivity cs = Qt::CaseSensitive) |
|
354 { return -s2.compare(s1, cs); } |
|
355 |
|
356 int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
357 static int compare(const QString &s1, const QStringRef &s2, |
|
358 Qt::CaseSensitivity = Qt::CaseSensitive); |
|
359 |
|
360 int localeAwareCompare(const QString& s) const; |
|
361 static int localeAwareCompare(const QString& s1, const QString& s2) |
|
362 { return s1.localeAwareCompare(s2); } |
|
363 |
|
364 int localeAwareCompare(const QStringRef &s) const; |
|
365 static int localeAwareCompare(const QString& s1, const QStringRef& s2); |
|
366 |
|
367 short toShort(bool *ok=0, int base=10) const; |
|
368 ushort toUShort(bool *ok=0, int base=10) const; |
|
369 int toInt(bool *ok=0, int base=10) const; |
|
370 uint toUInt(bool *ok=0, int base=10) const; |
|
371 long toLong(bool *ok=0, int base=10) const; |
|
372 ulong toULong(bool *ok=0, int base=10) const; |
|
373 qlonglong toLongLong(bool *ok=0, int base=10) const; |
|
374 qulonglong toULongLong(bool *ok=0, int base=10) const; |
|
375 float toFloat(bool *ok=0) const; |
|
376 double toDouble(bool *ok=0) const; |
|
377 |
|
378 QString &setNum(short, int base=10); |
|
379 QString &setNum(ushort, int base=10); |
|
380 QString &setNum(int, int base=10); |
|
381 QString &setNum(uint, int base=10); |
|
382 QString &setNum(long, int base=10); |
|
383 QString &setNum(ulong, int base=10); |
|
384 QString &setNum(qlonglong, int base=10); |
|
385 QString &setNum(qulonglong, int base=10); |
|
386 QString &setNum(float, char f='g', int prec=6); |
|
387 QString &setNum(double, char f='g', int prec=6); |
|
388 |
|
389 static QString number(int, int base=10); |
|
390 static QString number(uint, int base=10); |
|
391 static QString number(long, int base=10); |
|
392 static QString number(ulong, int base=10); |
|
393 static QString number(qlonglong, int base=10); |
|
394 static QString number(qulonglong, int base=10); |
|
395 static QString number(double, char f='g', int prec=6); |
|
396 |
|
397 bool operator==(const QString &s) const; |
|
398 bool operator<(const QString &s) const; |
|
399 inline bool operator>(const QString &s) const { return s < *this; } |
|
400 inline bool operator!=(const QString &s) const { return !operator==(s); } |
|
401 inline bool operator<=(const QString &s) const { return !operator>(s); } |
|
402 inline bool operator>=(const QString &s) const { return !operator<(s); } |
|
403 |
|
404 bool operator==(const QLatin1String &s) const; |
|
405 bool operator<(const QLatin1String &s) const; |
|
406 bool operator>(const QLatin1String &s) const; |
|
407 inline bool operator!=(const QLatin1String &s) const { return !operator==(s); } |
|
408 inline bool operator<=(const QLatin1String &s) const { return !operator>(s); } |
|
409 inline bool operator>=(const QLatin1String &s) const { return !operator<(s); } |
|
410 |
|
411 // ASCII compatibility |
|
412 #ifndef QT_NO_CAST_FROM_ASCII |
|
413 inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const char *ch) : d(fromAscii_helper(ch)) |
|
414 {} |
|
415 inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const QByteArray &a) |
|
416 : d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size()))) |
|
417 {} |
|
418 inline QT_ASCII_CAST_WARN QString &operator=(const char *ch) |
|
419 { return (*this = fromAscii(ch)); } |
|
420 inline QT_ASCII_CAST_WARN QString &operator=(const QByteArray &a) |
|
421 { return (*this = fromAscii(a.constData(), qstrnlen(a.constData(), a.size()))); } |
|
422 inline QT_ASCII_CAST_WARN QString &operator=(char c) |
|
423 { return (*this = QChar::fromAscii(c)); } |
|
424 |
|
425 // these are needed, so it compiles with STL support enabled |
|
426 inline QT_ASCII_CAST_WARN QString &prepend(const char *s) |
|
427 { return prepend(QString::fromAscii(s)); } |
|
428 inline QT_ASCII_CAST_WARN QString &prepend(const QByteArray &s) |
|
429 { return prepend(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); } |
|
430 inline QT_ASCII_CAST_WARN QString &append(const char *s) |
|
431 { return append(QString::fromAscii(s)); } |
|
432 inline QT_ASCII_CAST_WARN QString &append(const QByteArray &s) |
|
433 { return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); } |
|
434 inline QT_ASCII_CAST_WARN QString &operator+=(const char *s) |
|
435 { return append(QString::fromAscii(s)); } |
|
436 inline QT_ASCII_CAST_WARN QString &operator+=(const QByteArray &s) |
|
437 { return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); } |
|
438 inline QT_ASCII_CAST_WARN QString &operator+=(char c) |
|
439 { return append(QChar::fromAscii(c)); } |
|
440 |
|
441 inline QT_ASCII_CAST_WARN bool operator==(const char *s) const; |
|
442 inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const; |
|
443 inline QT_ASCII_CAST_WARN bool operator<(const char *s) const; |
|
444 inline QT_ASCII_CAST_WARN bool operator<=(const char *s2) const; |
|
445 inline QT_ASCII_CAST_WARN bool operator>(const char *s2) const; |
|
446 inline QT_ASCII_CAST_WARN bool operator>=(const char *s2) const; |
|
447 |
|
448 inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &s) const; |
|
449 inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &s) const; |
|
450 inline QT_ASCII_CAST_WARN bool operator<(const QByteArray &s) const |
|
451 { return *this < QString::fromAscii(s.constData(), s.size()); } |
|
452 inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const |
|
453 { return *this > QString::fromAscii(s.constData(), s.size()); } |
|
454 inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const |
|
455 { return *this <= QString::fromAscii(s.constData(), s.size()); } |
|
456 inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const |
|
457 { return *this >= QString::fromAscii(s.constData(), s.size()); } |
|
458 #endif |
|
459 |
|
460 typedef QChar *iterator; |
|
461 typedef const QChar *const_iterator; |
|
462 typedef iterator Iterator; |
|
463 typedef const_iterator ConstIterator; |
|
464 iterator begin(); |
|
465 const_iterator begin() const; |
|
466 const_iterator constBegin() const; |
|
467 iterator end(); |
|
468 const_iterator end() const; |
|
469 const_iterator constEnd() const; |
|
470 |
|
471 // STL compatibility |
|
472 inline void push_back(QChar c) { append(c); } |
|
473 inline void push_back(const QString &s) { append(s); } |
|
474 inline void push_front(QChar c) { prepend(c); } |
|
475 inline void push_front(const QString &s) { prepend(s); } |
|
476 |
|
477 #ifndef QT_NO_STL |
|
478 static inline QString fromStdString(const std::string &s); |
|
479 inline std::string toStdString() const; |
|
480 # ifdef qdoc |
|
481 static inline QString fromStdWString(const std::wstring &s); |
|
482 inline std::wstring toStdWString() const; |
|
483 # else |
|
484 # ifndef QT_NO_STL_WCHAR |
|
485 static inline QString fromStdWString(const QStdWString &s); |
|
486 inline QStdWString toStdWString() const; |
|
487 # endif // QT_NO_STL_WCHAR |
|
488 # endif // qdoc |
|
489 #endif |
|
490 |
|
491 // compatibility |
|
492 struct Null { }; |
|
493 static const Null null; |
|
494 inline QString(const Null &): d(&shared_null) { d->ref.ref(); } |
|
495 inline QString &operator=(const Null &) { *this = QString(); return *this; } |
|
496 inline bool isNull() const { return d == &shared_null; } |
|
497 |
|
498 #ifdef QT3_SUPPORT |
|
499 inline QT3_SUPPORT const char *ascii() const { return ascii_helper(); } |
|
500 inline QT3_SUPPORT const char *latin1() const { return latin1_helper(); } |
|
501 inline QT3_SUPPORT QByteArray utf8() const { return toUtf8(); } |
|
502 inline QT3_SUPPORT QByteArray local8Bit() const{ return toLocal8Bit(); } |
|
503 inline QT3_SUPPORT void setLength(int nl) { resize(nl); } |
|
504 inline QT3_SUPPORT QString copy() const { return *this; } |
|
505 inline QT3_SUPPORT QString &remove(QChar c, bool cs) |
|
506 { return remove(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
507 inline QT3_SUPPORT QString &remove(const QString &s, bool cs) |
|
508 { return remove(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
509 inline QT3_SUPPORT QString &replace(QChar c, const QString &after, bool cs) |
|
510 { return replace(c, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
511 inline QT3_SUPPORT QString &replace(const QString &before, const QString &after, bool cs) |
|
512 { return replace(before, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
513 #ifndef QT_NO_CAST_FROM_ASCII |
|
514 inline QT3_SUPPORT QString &replace(char c, const QString &after, bool cs) |
|
515 { return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); } |
|
516 // strange overload, required to avoid GCC 3.3 error |
|
517 inline QT3_SUPPORT QString &replace(char c, const QString &after, Qt::CaseSensitivity cs) |
|
518 { return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); } |
|
519 #endif |
|
520 inline QT3_SUPPORT int find(QChar c, int i = 0, bool cs = true) const |
|
521 { return indexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
522 inline QT3_SUPPORT int find(const QString &s, int i = 0, bool cs = true) const |
|
523 { return indexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
524 inline QT3_SUPPORT int findRev(QChar c, int i = -1, bool cs = true) const |
|
525 { return lastIndexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
526 inline QT3_SUPPORT int findRev(const QString &s, int i = -1, bool cs = true) const |
|
527 { return lastIndexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
528 #ifndef QT_NO_REGEXP |
|
529 inline QT3_SUPPORT int find(const QRegExp &rx, int i=0) const |
|
530 { return indexOf(rx, i); } |
|
531 inline QT3_SUPPORT int findRev(const QRegExp &rx, int i=-1) const |
|
532 { return lastIndexOf(rx, i); } |
|
533 inline QT3_SUPPORT int find(QRegExp &rx, int i=0) const |
|
534 { return indexOf(rx, i); } |
|
535 inline QT3_SUPPORT int findRev(QRegExp &rx, int i=-1) const |
|
536 { return lastIndexOf(rx, i); } |
|
537 #endif |
|
538 inline QT3_SUPPORT QBool contains(QChar c, bool cs) const |
|
539 { return contains(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
540 inline QT3_SUPPORT QBool contains(const QString &s, bool cs) const |
|
541 { return contains(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
542 inline QT3_SUPPORT bool startsWith(const QString &s, bool cs) const |
|
543 { return startsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
544 inline QT3_SUPPORT bool endsWith(const QString &s, bool cs) const |
|
545 { return endsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); } |
|
546 inline QT3_SUPPORT QChar constref(uint i) const |
|
547 { return at(i); } |
|
548 QT3_SUPPORT QChar &ref(uint i); |
|
549 inline QT3_SUPPORT QString leftJustify(int width, QChar aFill = QLatin1Char(' '), bool trunc=false) const |
|
550 { return leftJustified(width, aFill, trunc); } |
|
551 inline QT3_SUPPORT QString rightJustify(int width, QChar aFill = QLatin1Char(' '), bool trunc=false) const |
|
552 { return rightJustified(width, aFill, trunc); } |
|
553 inline QT3_SUPPORT QString lower() const { return toLower(); } |
|
554 inline QT3_SUPPORT QString upper() const { return toUpper(); } |
|
555 inline QT3_SUPPORT QString stripWhiteSpace() const { return trimmed(); } |
|
556 inline QT3_SUPPORT QString simplifyWhiteSpace() const { return simplified(); } |
|
557 inline QT3_SUPPORT QString &setUnicodeCodes(const ushort *unicode_as_ushorts, int aSize) |
|
558 { return setUtf16(unicode_as_ushorts, aSize); } |
|
559 inline QT3_SUPPORT const ushort *ucs2() const { return utf16(); } |
|
560 inline static QT3_SUPPORT QString fromUcs2(const ushort *unicode, int size = -1) |
|
561 { return fromUtf16(unicode, size); } |
|
562 inline QT3_SUPPORT QString &setAscii(const char *str, int len = -1) |
|
563 { *this = fromAscii(str, len); return *this; } |
|
564 inline QT3_SUPPORT QString &setLatin1(const char *str, int len = -1) |
|
565 { *this = fromLatin1(str, len); return *this; } |
|
566 protected: |
|
567 friend class QObject; |
|
568 const char *ascii_helper() const; |
|
569 const char *latin1_helper() const; |
|
570 public: |
|
571 #ifndef QT_NO_CAST_TO_ASCII |
|
572 inline QT3_SUPPORT operator const char *() const { return ascii_helper(); } |
|
573 private: |
|
574 QT3_SUPPORT operator QNoImplicitBoolCast() const; |
|
575 public: |
|
576 #endif |
|
577 #endif |
|
578 |
|
579 bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; } |
|
580 bool isRightToLeft() const { if (!d->clean) updateProperties(); return d->righttoleft; } |
|
581 |
|
582 QString(int size, Qt::Initialization); |
|
583 |
|
584 private: |
|
585 #if defined(QT_NO_CAST_FROM_ASCII) && !defined(Q_NO_DECLARED_NOT_DEFINED) |
|
586 QString &operator+=(const char *s); |
|
587 QString &operator+=(const QByteArray &s); |
|
588 QString(const char *ch); |
|
589 QString(const QByteArray &a); |
|
590 QString &operator=(const char *ch); |
|
591 QString &operator=(const QByteArray &a); |
|
592 #endif |
|
593 |
|
594 struct Data { |
|
595 QBasicAtomicInt ref; |
|
596 int alloc, size; |
|
597 ushort *data; |
|
598 ushort clean : 1; |
|
599 ushort simpletext : 1; |
|
600 ushort righttoleft : 1; |
|
601 ushort asciiCache : 1; |
|
602 ushort capacity : 1; |
|
603 ushort reserved : 11; |
|
604 ushort array[1]; |
|
605 }; |
|
606 static Data shared_null; |
|
607 static Data shared_empty; |
|
608 Data *d; |
|
609 QString(Data *dd, int /*dummy*/) : d(dd) {} |
|
610 #ifndef QT_NO_TEXTCODEC |
|
611 static QTextCodec *codecForCStrings; |
|
612 #endif |
|
613 static int grow(int); |
|
614 static void free(Data *); |
|
615 void realloc(); |
|
616 void realloc(int alloc); |
|
617 void expand(int i); |
|
618 void updateProperties() const; |
|
619 QString multiArg(int numArgs, const QString **args) const; |
|
620 static int compare_helper(const QChar *data1, int length1, |
|
621 const QChar *data2, int length2, |
|
622 Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
623 static int compare_helper(const QChar *data1, int length1, |
|
624 QLatin1String s2, |
|
625 Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
626 static int localeAwareCompare_helper(const QChar *data1, int length1, |
|
627 const QChar *data2, int length2); |
|
628 static Data *fromLatin1_helper(const char *str, int size = -1); |
|
629 static Data *fromAscii_helper(const char *str, int size = -1); |
|
630 void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen); |
|
631 friend class QCharRef; |
|
632 friend class QTextCodec; |
|
633 friend class QStringRef; |
|
634 friend inline bool qStringComparisonHelper(const QString &s1, const char *s2); |
|
635 friend inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2); |
|
636 public: |
|
637 typedef Data * DataPtr; |
|
638 inline DataPtr &data_ptr() { return d; } |
|
639 }; |
|
640 |
|
641 |
|
642 class Q_CORE_EXPORT QLatin1String |
|
643 { |
|
644 public: |
|
645 inline explicit QLatin1String(const char *s) : chars(s) {} |
|
646 inline QLatin1String &operator=(const QLatin1String &other) |
|
647 { chars = other.chars; return *this; } |
|
648 |
|
649 inline const char *latin1() const { return chars; } |
|
650 |
|
651 inline bool operator==(const QString &s) const |
|
652 { return s == *this; } |
|
653 inline bool operator!=(const QString &s) const |
|
654 { return s != *this; } |
|
655 inline bool operator>(const QString &s) const |
|
656 { return s < *this; } |
|
657 inline bool operator<(const QString &s) const |
|
658 { return s > *this; } |
|
659 inline bool operator>=(const QString &s) const |
|
660 { return s <= *this; } |
|
661 inline bool operator<=(const QString &s) const |
|
662 { return s >= *this; } |
|
663 |
|
664 inline QT_ASCII_CAST_WARN bool operator==(const char *s) const |
|
665 { return QString::fromAscii(s) == *this; } |
|
666 inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const |
|
667 { return QString::fromAscii(s) != *this; } |
|
668 inline QT_ASCII_CAST_WARN bool operator<(const char *s) const |
|
669 { return QString::fromAscii(s) > *this; } |
|
670 inline QT_ASCII_CAST_WARN bool operator>(const char *s) const |
|
671 { return QString::fromAscii(s) < *this; } |
|
672 inline QT_ASCII_CAST_WARN bool operator<=(const char *s) const |
|
673 { return QString::fromAscii(s) >= *this; } |
|
674 inline QT_ASCII_CAST_WARN bool operator>=(const char *s) const |
|
675 { return QString::fromAscii(s) <= *this; } |
|
676 private: |
|
677 const char *chars; |
|
678 }; |
|
679 |
|
680 |
|
681 |
|
682 inline QString::QString(const QLatin1String &aLatin1) : d(fromLatin1_helper(aLatin1.latin1())) |
|
683 { } |
|
684 inline int QString::length() const |
|
685 { return d->size; } |
|
686 inline const QChar QString::at(int i) const |
|
687 { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } |
|
688 inline const QChar QString::operator[](int i) const |
|
689 { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; } |
|
690 inline const QChar QString::operator[](uint i) const |
|
691 { Q_ASSERT(i < uint(size())); return d->data[i]; } |
|
692 inline bool QString::isEmpty() const |
|
693 { return d->size == 0; } |
|
694 inline const QChar *QString::unicode() const |
|
695 { return reinterpret_cast<const QChar*>(d->data); } |
|
696 inline const QChar *QString::data() const |
|
697 { return reinterpret_cast<const QChar*>(d->data); } |
|
698 inline QChar *QString::data() |
|
699 { detach(); return reinterpret_cast<QChar*>(d->data); } |
|
700 inline const QChar *QString::constData() const |
|
701 { return reinterpret_cast<const QChar*>(d->data); } |
|
702 inline void QString::detach() |
|
703 { if (d->ref != 1 || d->data != d->array) realloc(); } |
|
704 inline bool QString::isDetached() const |
|
705 { return d->ref == 1; } |
|
706 inline QString &QString::operator=(const QLatin1String &s) |
|
707 { |
|
708 *this = fromLatin1(s.latin1()); |
|
709 return *this; |
|
710 } |
|
711 inline void QString::clear() |
|
712 { if (!isNull()) *this = QString(); } |
|
713 inline QString::QString(const QString &other) : d(other.d) |
|
714 { Q_ASSERT(&other != this); d->ref.ref(); } |
|
715 inline int QString::capacity() const |
|
716 { return d->alloc; } |
|
717 inline QString &QString::setNum(short n, int base) |
|
718 { return setNum(qlonglong(n), base); } |
|
719 inline QString &QString::setNum(ushort n, int base) |
|
720 { return setNum(qulonglong(n), base); } |
|
721 inline QString &QString::setNum(int n, int base) |
|
722 { return setNum(qlonglong(n), base); } |
|
723 inline QString &QString::setNum(uint n, int base) |
|
724 { return setNum(qulonglong(n), base); } |
|
725 inline QString &QString::setNum(long n, int base) |
|
726 { return setNum(qlonglong(n), base); } |
|
727 inline QString &QString::setNum(ulong n, int base) |
|
728 { return setNum(qulonglong(n), base); } |
|
729 inline QString &QString::setNum(float n, char f, int prec) |
|
730 { return setNum(double(n),f,prec); } |
|
731 inline QString QString::arg(int a, int fieldWidth, int base, const QChar &fillChar) const |
|
732 { return arg(qlonglong(a), fieldWidth, base, fillChar); } |
|
733 inline QString QString::arg(uint a, int fieldWidth, int base, const QChar &fillChar) const |
|
734 { return arg(qulonglong(a), fieldWidth, base, fillChar); } |
|
735 inline QString QString::arg(long a, int fieldWidth, int base, const QChar &fillChar) const |
|
736 { return arg(qlonglong(a), fieldWidth, base, fillChar); } |
|
737 inline QString QString::arg(ulong a, int fieldWidth, int base, const QChar &fillChar) const |
|
738 { return arg(qulonglong(a), fieldWidth, base, fillChar); } |
|
739 inline QString QString::arg(short a, int fieldWidth, int base, const QChar &fillChar) const |
|
740 { return arg(qlonglong(a), fieldWidth, base, fillChar); } |
|
741 inline QString QString::arg(ushort a, int fieldWidth, int base, const QChar &fillChar) const |
|
742 { return arg(qulonglong(a), fieldWidth, base, fillChar); } |
|
743 inline QString QString::arg(const QString &a1, const QString &a2) const |
|
744 { const QString *args[2] = { &a1, &a2 }; return multiArg(2, args); } |
|
745 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3) const |
|
746 { const QString *args[3] = { &a1, &a2, &a3 }; return multiArg(3, args); } |
|
747 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3, |
|
748 const QString &a4) const |
|
749 { const QString *args[4] = { &a1, &a2, &a3, &a4 }; return multiArg(4, args); } |
|
750 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3, |
|
751 const QString &a4, const QString &a5) const |
|
752 { const QString *args[5] = { &a1, &a2, &a3, &a4, &a5 }; return multiArg(5, args); } |
|
753 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3, |
|
754 const QString &a4, const QString &a5, const QString &a6) const |
|
755 { const QString *args[6] = { &a1, &a2, &a3, &a4, &a5, &a6 }; return multiArg(6, args); } |
|
756 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3, |
|
757 const QString &a4, const QString &a5, const QString &a6, |
|
758 const QString &a7) const |
|
759 { const QString *args[7] = { &a1, &a2, &a3, &a4, &a5, &a6, &a7 }; return multiArg(7, args); } |
|
760 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3, |
|
761 const QString &a4, const QString &a5, const QString &a6, |
|
762 const QString &a7, const QString &a8) const |
|
763 { const QString *args[8] = { &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8 }; return multiArg(8, args); } |
|
764 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3, |
|
765 const QString &a4, const QString &a5, const QString &a6, |
|
766 const QString &a7, const QString &a8, const QString &a9) const |
|
767 { const QString *args[9] = { &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9 }; return multiArg(9, args); } |
|
768 |
|
769 inline QString QString::section(QChar asep, int astart, int aend, SectionFlags aflags) const |
|
770 { return section(QString(asep), astart, aend, aflags); } |
|
771 |
|
772 |
|
773 class Q_CORE_EXPORT QCharRef { |
|
774 QString &s; |
|
775 int i; |
|
776 inline QCharRef(QString &str, int idx) |
|
777 : s(str),i(idx) {} |
|
778 friend class QString; |
|
779 public: |
|
780 |
|
781 // most QChar operations repeated here |
|
782 |
|
783 // all this is not documented: We just say "like QChar" and let it be. |
|
784 inline operator QChar() const |
|
785 { return i < s.d->size ? s.d->data[i] : 0; } |
|
786 inline QCharRef &operator=(const QChar &c) |
|
787 { if (i >= s.d->size) s.expand(i); else s.detach(); |
|
788 s.d->data[i] = c.unicode(); return *this; } |
|
789 |
|
790 // An operator= for each QChar cast constructors |
|
791 #ifndef QT_NO_CAST_FROM_ASCII |
|
792 inline QT_ASCII_CAST_WARN QCharRef &operator=(char c) |
|
793 { return operator=(QChar::fromAscii(c)); } |
|
794 inline QT_ASCII_CAST_WARN QCharRef &operator=(uchar c) |
|
795 { return operator=(QChar::fromAscii(c)); } |
|
796 #endif |
|
797 inline QCharRef &operator=(const QCharRef &c) { return operator=(QChar(c)); } |
|
798 inline QCharRef &operator=(ushort rc) { return operator=(QChar(rc)); } |
|
799 inline QCharRef &operator=(short rc) { return operator=(QChar(rc)); } |
|
800 inline QCharRef &operator=(uint rc) { return operator=(QChar(rc)); } |
|
801 inline QCharRef &operator=(int rc) { return operator=(QChar(rc)); } |
|
802 |
|
803 // each function... |
|
804 inline bool isNull() const { return QChar(*this).isNull(); } |
|
805 inline bool isPrint() const { return QChar(*this).isPrint(); } |
|
806 inline bool isPunct() const { return QChar(*this).isPunct(); } |
|
807 inline bool isSpace() const { return QChar(*this).isSpace(); } |
|
808 inline bool isMark() const { return QChar(*this).isMark(); } |
|
809 inline bool isLetter() const { return QChar(*this).isLetter(); } |
|
810 inline bool isNumber() const { return QChar(*this).isNumber(); } |
|
811 inline bool isLetterOrNumber() { return QChar(*this).isLetterOrNumber(); } |
|
812 inline bool isDigit() const { return QChar(*this).isDigit(); } |
|
813 inline bool isLower() const { return QChar(*this).isLower(); } |
|
814 inline bool isUpper() const { return QChar(*this).isUpper(); } |
|
815 inline bool isTitleCase() const { return QChar(*this).isTitleCase(); } |
|
816 |
|
817 inline int digitValue() const { return QChar(*this).digitValue(); } |
|
818 QChar toLower() const { return QChar(*this).toLower(); } |
|
819 QChar toUpper() const { return QChar(*this).toUpper(); } |
|
820 QChar toTitleCase () const { return QChar(*this).toTitleCase(); } |
|
821 |
|
822 QChar::Category category() const { return QChar(*this).category(); } |
|
823 QChar::Direction direction() const { return QChar(*this).direction(); } |
|
824 QChar::Joining joining() const { return QChar(*this).joining(); } |
|
825 bool hasMirrored() const { return QChar(*this).hasMirrored(); } |
|
826 QChar mirroredChar() const { return QChar(*this).mirroredChar(); } |
|
827 QString decomposition() const { return QChar(*this).decomposition(); } |
|
828 QChar::Decomposition decompositionTag() const { return QChar(*this).decompositionTag(); } |
|
829 uchar combiningClass() const { return QChar(*this).combiningClass(); } |
|
830 |
|
831 QChar::UnicodeVersion unicodeVersion() const { return QChar(*this).unicodeVersion(); } |
|
832 |
|
833 inline uchar cell() const { return QChar(*this).cell(); } |
|
834 inline uchar row() const { return QChar(*this).row(); } |
|
835 inline void setCell(uchar cell); |
|
836 inline void setRow(uchar row); |
|
837 |
|
838 #ifdef Q_COMPILER_MANGLES_RETURN_TYPE |
|
839 const char toAscii() const { return QChar(*this).toAscii(); } |
|
840 const char toLatin1() const { return QChar(*this).toLatin1(); } |
|
841 const ushort unicode() const { return QChar(*this).unicode(); } |
|
842 #else |
|
843 char toAscii() const { return QChar(*this).toAscii(); } |
|
844 char toLatin1() const { return QChar(*this).toLatin1(); } |
|
845 ushort unicode() const { return QChar(*this).unicode(); } |
|
846 #endif |
|
847 ushort& unicode() { return s.data()[i].unicode(); } |
|
848 |
|
849 #ifdef QT3_SUPPORT |
|
850 inline QT3_SUPPORT bool mirrored() const { return hasMirrored(); } |
|
851 inline QT3_SUPPORT QChar lower() const { return QChar(*this).toLower(); } |
|
852 inline QT3_SUPPORT QChar upper() const { return QChar(*this).toUpper(); } |
|
853 #ifdef Q_COMPILER_MANGLES_RETURN_TYPE |
|
854 const QT3_SUPPORT char latin1() const { return QChar(*this).toLatin1(); } |
|
855 const QT3_SUPPORT char ascii() const { return QChar(*this).toAscii(); } |
|
856 #else |
|
857 QT3_SUPPORT char latin1() const { return QChar(*this).toLatin1(); } |
|
858 QT3_SUPPORT char ascii() const { return QChar(*this).toAscii(); } |
|
859 #endif |
|
860 #endif |
|
861 }; |
|
862 |
|
863 inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); } |
|
864 inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); } |
|
865 |
|
866 |
|
867 inline QString::QString() : d(&shared_null) { d->ref.ref(); } |
|
868 inline QString::~QString() { if (!d->ref.deref()) free(d); } |
|
869 inline void QString::reserve(int asize) { if (d->ref != 1 || asize > d->alloc) realloc(asize); d->capacity = 1;} |
|
870 inline QString &QString::setUtf16(const ushort *autf16, int asize) |
|
871 { return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); } |
|
872 inline QCharRef QString::operator[](int i) |
|
873 { Q_ASSERT(i >= 0); return QCharRef(*this, i); } |
|
874 inline QCharRef QString::operator[](uint i) |
|
875 { return QCharRef(*this, i); } |
|
876 inline QString::iterator QString::begin() |
|
877 { detach(); return reinterpret_cast<QChar*>(d->data); } |
|
878 inline QString::const_iterator QString::begin() const |
|
879 { return reinterpret_cast<const QChar*>(d->data); } |
|
880 inline QString::const_iterator QString::constBegin() const |
|
881 { return reinterpret_cast<const QChar*>(d->data); } |
|
882 inline QString::iterator QString::end() |
|
883 { detach(); return reinterpret_cast<QChar*>(d->data + d->size); } |
|
884 inline QString::const_iterator QString::end() const |
|
885 { return reinterpret_cast<const QChar*>(d->data + d->size); } |
|
886 inline QString::const_iterator QString::constEnd() const |
|
887 { return reinterpret_cast<const QChar*>(d->data + d->size); } |
|
888 inline QBool QString::contains(const QString &s, Qt::CaseSensitivity cs) const |
|
889 { return QBool(indexOf(s, 0, cs) != -1); } |
|
890 inline QBool QString::contains(QChar c, Qt::CaseSensitivity cs) const |
|
891 { return QBool(indexOf(c, 0, cs) != -1); } |
|
892 |
|
893 |
|
894 inline bool operator==(QString::Null, QString::Null) { return true; } |
|
895 inline bool operator==(QString::Null, const QString &s) { return s.isNull(); } |
|
896 inline bool operator==(const QString &s, QString::Null) { return s.isNull(); } |
|
897 inline bool operator!=(QString::Null, QString::Null) { return false; } |
|
898 inline bool operator!=(QString::Null, const QString &s) { return !s.isNull(); } |
|
899 inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); } |
|
900 |
|
901 #ifndef QT_NO_CAST_FROM_ASCII |
|
902 inline bool qStringComparisonHelper(const QString &s1, const char *s2) |
|
903 { |
|
904 # ifndef QT_NO_TEXTCODEC |
|
905 if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2)); |
|
906 # endif |
|
907 return (s1 == QLatin1String(s2)); |
|
908 } |
|
909 inline bool QString::operator==(const char *s) const |
|
910 { return qStringComparisonHelper(*this, s); } |
|
911 inline bool QString::operator!=(const char *s) const |
|
912 { return !qStringComparisonHelper(*this, s); } |
|
913 inline bool QString::operator<(const char *s) const |
|
914 { return *this < QString::fromAscii(s); } |
|
915 inline bool QString::operator>(const char *s) const |
|
916 { return *this > QString::fromAscii(s); } |
|
917 inline bool QString::operator<=(const char *s) const |
|
918 { return *this <= QString::fromAscii(s); } |
|
919 inline bool QString::operator>=(const char *s) const |
|
920 { return *this >= QString::fromAscii(s); } |
|
921 |
|
922 inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QString &s2) |
|
923 { return qStringComparisonHelper(s2, s1); } |
|
924 inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QString &s2) |
|
925 { return !qStringComparisonHelper(s2, s1); } |
|
926 inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QString &s2) |
|
927 { return (QString::fromAscii(s1) < s2); } |
|
928 inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2) |
|
929 { return (QString::fromAscii(s1) > s2); } |
|
930 inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2) |
|
931 { return (QString::fromAscii(s1) <= s2); } |
|
932 inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2) |
|
933 { return (QString::fromAscii(s1) >= s2); } |
|
934 |
|
935 inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QLatin1String &s2) |
|
936 { return QString::fromAscii(s1) == s2; } |
|
937 inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QLatin1String &s2) |
|
938 { return QString::fromAscii(s1) != s2; } |
|
939 inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QLatin1String &s2) |
|
940 { return (QString::fromAscii(s1) < s2); } |
|
941 inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QLatin1String &s2) |
|
942 { return (QString::fromAscii(s1) > s2); } |
|
943 inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QLatin1String &s2) |
|
944 { return (QString::fromAscii(s1) <= s2); } |
|
945 inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QLatin1String &s2) |
|
946 { return (QString::fromAscii(s1) >= s2); } |
|
947 |
|
948 inline bool operator==(const QLatin1String &s1, const QLatin1String &s2) |
|
949 { return (qstrcmp(s1.latin1(), s2.latin1()) == 0); } |
|
950 inline bool operator!=(const QLatin1String &s1, const QLatin1String &s2) |
|
951 { return (qstrcmp(s1.latin1(), s2.latin1()) != 0); } |
|
952 inline bool operator<(const QLatin1String &s1, const QLatin1String &s2) |
|
953 { return (qstrcmp(s1.latin1(), s2.latin1()) < 0); } |
|
954 inline bool operator<=(const QLatin1String &s1, const QLatin1String &s2) |
|
955 { return (qstrcmp(s1.latin1(), s2.latin1()) <= 0); } |
|
956 inline bool operator>(const QLatin1String &s1, const QLatin1String &s2) |
|
957 { return (qstrcmp(s1.latin1(), s2.latin1()) > 0); } |
|
958 inline bool operator>=(const QLatin1String &s1, const QLatin1String &s2) |
|
959 { return (qstrcmp(s1.latin1(), s2.latin1()) >= 0); } |
|
960 |
|
961 |
|
962 inline bool QString::operator==(const QByteArray &s) const |
|
963 { return qStringComparisonHelper(*this, s.constData()); } |
|
964 inline bool QString::operator!=(const QByteArray &s) const |
|
965 { return !qStringComparisonHelper(*this, s.constData()); } |
|
966 |
|
967 inline bool QByteArray::operator==(const QString &s) const |
|
968 { return qStringComparisonHelper(s, constData()); } |
|
969 inline bool QByteArray::operator!=(const QString &s) const |
|
970 { return !qStringComparisonHelper(s, constData()); } |
|
971 inline bool QByteArray::operator<(const QString &s) const |
|
972 { return QString::fromAscii(constData(), size()) < s; } |
|
973 inline bool QByteArray::operator>(const QString &s) const |
|
974 { return QString::fromAscii(constData(), size()) > s; } |
|
975 inline bool QByteArray::operator<=(const QString &s) const |
|
976 { return QString::fromAscii(constData(), size()) <= s; } |
|
977 inline bool QByteArray::operator>=(const QString &s) const |
|
978 { return QString::fromAscii(constData(), size()) >= s; } |
|
979 #endif // QT_NO_CAST_FROM_ASCII |
|
980 |
|
981 #ifndef QT_NO_CAST_TO_ASCII |
|
982 inline QByteArray &QByteArray::append(const QString &s) |
|
983 { return append(s.toAscii()); } |
|
984 inline QByteArray &QByteArray::insert(int i, const QString &s) |
|
985 { return insert(i, s.toAscii()); } |
|
986 inline QByteArray &QByteArray::replace(char c, const QString &after) |
|
987 { return replace(c, after.toAscii()); } |
|
988 inline QByteArray &QByteArray::replace(const QString &before, const char *after) |
|
989 { return replace(before.toAscii(), after); } |
|
990 inline QByteArray &QByteArray::replace(const QString &before, const QByteArray &after) |
|
991 { return replace(before.toAscii(), after); } |
|
992 inline QByteArray &QByteArray::operator+=(const QString &s) |
|
993 { return operator+=(s.toAscii()); } |
|
994 inline int QByteArray::indexOf(const QString &s, int from) const |
|
995 { return indexOf(s.toAscii(), from); } |
|
996 inline int QByteArray::lastIndexOf(const QString &s, int from) const |
|
997 { return lastIndexOf(s.toAscii(), from); } |
|
998 # ifdef QT3_SUPPORT |
|
999 inline int QByteArray::find(const QString &s, int from) const |
|
1000 { return indexOf(s.toAscii(), from); } |
|
1001 inline int QByteArray::findRev(const QString &s, int from) const |
|
1002 { return lastIndexOf(s.toAscii(), from); } |
|
1003 # endif // QT3_SUPPORT |
|
1004 #endif // QT_NO_CAST_TO_ASCII |
|
1005 |
|
1006 #ifndef QT_USE_FAST_OPERATOR_PLUS |
|
1007 # ifndef QT_USE_FAST_CONCATENATION |
|
1008 inline const QString operator+(const QString &s1, const QString &s2) |
|
1009 { QString t(s1); t += s2; return t; } |
|
1010 inline const QString operator+(const QString &s1, QChar s2) |
|
1011 { QString t(s1); t += s2; return t; } |
|
1012 inline const QString operator+(QChar s1, const QString &s2) |
|
1013 { QString t(s1); t += s2; return t; } |
|
1014 # ifndef QT_NO_CAST_FROM_ASCII |
|
1015 inline QT_ASCII_CAST_WARN const QString operator+(const QString &s1, const char *s2) |
|
1016 { QString t(s1); t += QString::fromAscii(s2); return t; } |
|
1017 inline QT_ASCII_CAST_WARN const QString operator+(const char *s1, const QString &s2) |
|
1018 { QString t = QString::fromAscii(s1); t += s2; return t; } |
|
1019 inline QT_ASCII_CAST_WARN const QString operator+(char c, const QString &s) |
|
1020 { QString t = s; t.prepend(QChar::fromAscii(c)); return t; } |
|
1021 inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, char c) |
|
1022 { QString t = s; t += QChar::fromAscii(c); return t; } |
|
1023 inline QT_ASCII_CAST_WARN const QString operator+(const QByteArray &ba, const QString &s) |
|
1024 { QString t = QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); t += s; return t; } |
|
1025 inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, const QByteArray &ba) |
|
1026 { QString t(s); t += QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); return t; } |
|
1027 # endif // QT_NO_CAST_FROM_ASCII |
|
1028 # endif // QT_USE_FAST_CONCATENATION |
|
1029 #endif // QT_USE_FAST_OPERATOR_PLUS |
|
1030 |
|
1031 #ifndef QT_NO_STL |
|
1032 inline std::string QString::toStdString() const |
|
1033 { const QByteArray asc = toAscii(); return std::string(asc.constData(), asc.length()); } |
|
1034 |
|
1035 inline QString QString::fromStdString(const std::string &s) |
|
1036 { return fromAscii(s.data(), int(s.size())); } |
|
1037 |
|
1038 # ifndef QT_NO_STL_WCHAR |
|
1039 inline QStdWString QString::toStdWString() const |
|
1040 { |
|
1041 QStdWString str; |
|
1042 str.resize(length()); |
|
1043 |
|
1044 #if defined(_MSC_VER) && _MSC_VER >= 1400 |
|
1045 // VS2005 crashes if the string is empty |
|
1046 if (!length()) |
|
1047 return str; |
|
1048 #endif |
|
1049 |
|
1050 str.resize(toWCharArray(&(*str.begin()))); |
|
1051 return str; |
|
1052 } |
|
1053 inline QString QString::fromStdWString(const QStdWString &s) |
|
1054 { return fromWCharArray(s.data(), int(s.size())); } |
|
1055 # endif |
|
1056 #endif |
|
1057 |
|
1058 #ifdef QT3_SUPPORT |
|
1059 inline QChar &QString::ref(uint i) |
|
1060 { |
|
1061 if (int(i) > d->size || d->ref != 1) |
|
1062 resize(qMax(int(i), d->size)); |
|
1063 return reinterpret_cast<QChar&>(d->data[i]); |
|
1064 } |
|
1065 #endif |
|
1066 |
|
1067 #ifndef QT_NO_DATASTREAM |
|
1068 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QString &); |
|
1069 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &); |
|
1070 #endif |
|
1071 |
|
1072 #ifdef QT3_SUPPORT |
|
1073 class QConstString : public QString |
|
1074 { |
|
1075 public: |
|
1076 inline QT3_SUPPORT_CONSTRUCTOR QConstString(const QChar *aUnicode, int aSize) |
|
1077 :QString(aUnicode, aSize){} // cannot use fromRawData() due to changed semantics |
|
1078 inline QT3_SUPPORT const QString &string() const { return *this; } |
|
1079 }; |
|
1080 #endif |
|
1081 |
|
1082 Q_DECLARE_TYPEINFO(QString, Q_MOVABLE_TYPE); |
|
1083 Q_DECLARE_SHARED(QString) |
|
1084 Q_DECLARE_OPERATORS_FOR_FLAGS(QString::SectionFlags) |
|
1085 |
|
1086 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) |
|
1087 extern Q_CORE_EXPORT QByteArray qt_winQString2MB(const QString& s, int len=-1); |
|
1088 extern Q_CORE_EXPORT QByteArray qt_winQString2MB(const QChar *ch, int len); |
|
1089 extern Q_CORE_EXPORT QString qt_winMB2QString(const char* mb, int len=-1); |
|
1090 #endif |
|
1091 |
|
1092 |
|
1093 class Q_CORE_EXPORT QStringRef { |
|
1094 const QString *m_string; |
|
1095 int m_position; |
|
1096 int m_size; |
|
1097 public: |
|
1098 inline QStringRef():m_string(0), m_position(0), m_size(0){} |
|
1099 inline QStringRef(const QString *string, int position, int size); |
|
1100 inline QStringRef(const QString *string); |
|
1101 inline QStringRef(const QStringRef &other) |
|
1102 :m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) |
|
1103 {} |
|
1104 |
|
1105 inline ~QStringRef(){} |
|
1106 inline const QString *string() const { return m_string; } |
|
1107 inline int position() const { return m_position; } |
|
1108 inline int size() const { return m_size; } |
|
1109 inline int count() const { return m_size; } |
|
1110 inline int length() const { return m_size; } |
|
1111 |
|
1112 inline QStringRef &operator=(const QStringRef &other) { |
|
1113 m_string = other.m_string; m_position = other.m_position; |
|
1114 m_size = other.m_size; return *this; |
|
1115 } |
|
1116 |
|
1117 inline QStringRef &operator=(const QString *string); |
|
1118 |
|
1119 inline const QChar *unicode() const { |
|
1120 if (!m_string) |
|
1121 return reinterpret_cast<const QChar *>(QString::shared_null.data); |
|
1122 return m_string->unicode() + m_position; |
|
1123 } |
|
1124 inline const QChar *data() const { return unicode(); } |
|
1125 inline const QChar *constData() const { return unicode(); } |
|
1126 |
|
1127 inline void clear() { m_string = 0; m_position = m_size = 0; } |
|
1128 QString toString() const; |
|
1129 inline bool isEmpty() const { return m_size == 0; } |
|
1130 inline bool isNull() const { return m_string == 0 || m_string->isNull(); } |
|
1131 |
|
1132 QStringRef appendTo(QString *string) const; |
|
1133 |
|
1134 inline const QChar at(int i) const |
|
1135 { Q_ASSERT(i >= 0 && i < size()); return m_string->at(i + m_position); } |
|
1136 |
|
1137 int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
1138 int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
1139 int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; |
|
1140 static int compare(const QStringRef &s1, const QString &s2, |
|
1141 Qt::CaseSensitivity = Qt::CaseSensitive); |
|
1142 static int compare(const QStringRef &s1, const QStringRef &s2, |
|
1143 Qt::CaseSensitivity = Qt::CaseSensitive); |
|
1144 static int compare(const QStringRef &s1, QLatin1String s2, |
|
1145 Qt::CaseSensitivity cs = Qt::CaseSensitive); |
|
1146 |
|
1147 int localeAwareCompare(const QString &s) const; |
|
1148 int localeAwareCompare(const QStringRef &s) const; |
|
1149 static int localeAwareCompare(const QStringRef &s1, const QString &s2); |
|
1150 static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2); |
|
1151 }; |
|
1152 |
|
1153 inline QStringRef &QStringRef::operator=(const QString *aString) |
|
1154 { m_string = aString; m_position = 0; m_size = aString?aString->size():0; return *this; } |
|
1155 |
|
1156 inline QStringRef::QStringRef(const QString *aString, int aPosition, int aSize) |
|
1157 :m_string(aString), m_position(aPosition), m_size(aSize){} |
|
1158 |
|
1159 inline QStringRef::QStringRef(const QString *aString) |
|
1160 :m_string(aString), m_position(0), m_size(aString?aString->size() : 0){} |
|
1161 |
|
1162 Q_CORE_EXPORT bool operator==(const QStringRef &s1,const QStringRef &s2); |
|
1163 inline bool operator!=(const QStringRef &s1,const QStringRef &s2) |
|
1164 { return !(s1 == s2); } |
|
1165 Q_CORE_EXPORT bool operator==(const QString &s1,const QStringRef &s2); |
|
1166 inline bool operator!=(const QString &s1,const QStringRef &s2) |
|
1167 { return !(s1 == s2); } |
|
1168 inline bool operator==(const QStringRef &s1,const QString &s2) |
|
1169 { return s2 == s1; } |
|
1170 inline bool operator!=(const QStringRef &s1,const QString &s2) |
|
1171 { return s2 != s1; } |
|
1172 Q_CORE_EXPORT bool operator==(const QLatin1String &s1, const QStringRef &s2); |
|
1173 inline bool operator!=(const QLatin1String &s1,const QStringRef &s2) |
|
1174 { return !(s1 == s2); } |
|
1175 inline bool operator==(const QStringRef &s1,const QLatin1String &s2) |
|
1176 { return s2 == s1; } |
|
1177 inline bool operator!=(const QStringRef &s1,const QLatin1String &s2) |
|
1178 { return s2 != s1; } |
|
1179 |
|
1180 Q_CORE_EXPORT bool operator<(const QStringRef &s1,const QStringRef &s2); |
|
1181 inline bool operator>(const QStringRef &s1, const QStringRef &s2) |
|
1182 { return s2 < s1; } |
|
1183 inline bool operator<=(const QStringRef &s1, const QStringRef &s2) |
|
1184 { return !(s1 > s2); } |
|
1185 inline bool operator>=(const QStringRef &s1, const QStringRef &s2) |
|
1186 { return !(s1 < s2); } |
|
1187 |
|
1188 inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2) |
|
1189 { |
|
1190 # ifndef QT_NO_TEXTCODEC |
|
1191 if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2)); |
|
1192 # endif |
|
1193 return (s1 == QLatin1String(s2)); |
|
1194 } |
|
1195 |
|
1196 inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QStringRef &s2) |
|
1197 { return qStringComparisonHelper(s2, s1); } |
|
1198 inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &s1, const char *s2) |
|
1199 { return qStringComparisonHelper(s1, s2); } |
|
1200 inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QStringRef &s2) |
|
1201 { return !qStringComparisonHelper(s2, s1); } |
|
1202 inline QT_ASCII_CAST_WARN bool operator!=(const QStringRef &s1, const char *s2) |
|
1203 { return !qStringComparisonHelper(s1, s2); } |
|
1204 |
|
1205 inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const |
|
1206 { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } |
|
1207 inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) |
|
1208 { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } |
|
1209 inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const |
|
1210 { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } |
|
1211 inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const |
|
1212 { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); } |
|
1213 inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const |
|
1214 { return QString::compare_helper(constData(), length(), s, cs); } |
|
1215 inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) |
|
1216 { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } |
|
1217 inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) |
|
1218 { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); } |
|
1219 inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) |
|
1220 { return QString::compare_helper(s1.constData(), s1.length(), s2, cs); } |
|
1221 |
|
1222 inline int QString::localeAwareCompare(const QStringRef &s) const |
|
1223 { return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); } |
|
1224 inline int QString::localeAwareCompare(const QString& s1, const QStringRef& s2) |
|
1225 { return localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); } |
|
1226 inline int QStringRef::localeAwareCompare(const QString &s) const |
|
1227 { return QString::localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); } |
|
1228 inline int QStringRef::localeAwareCompare(const QStringRef &s) const |
|
1229 { return QString::localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); } |
|
1230 inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QString &s2) |
|
1231 { return QString::localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); } |
|
1232 inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QStringRef &s2) |
|
1233 { return QString::localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); } |
|
1234 |
|
1235 |
|
1236 QT_END_NAMESPACE |
|
1237 |
|
1238 QT_END_HEADER |
|
1239 |
|
1240 #ifdef QT_USE_FAST_CONCATENATION |
|
1241 #include <QtCore/qstringbuilder.h> |
|
1242 #endif |
|
1243 |
|
1244 #endif // QSTRING_H |