Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qtextstream.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | static const int QTEXTSTREAM_BUFFERSIZE = 16384; | - | ||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | - | |||||||||||||
13 | - | |||||||||||||
14 | - | |||||||||||||
15 | QTextStreamPrivate::QTextStreamPrivate(QTextStream *q_ptr) | - | ||||||||||||
16 | : | - | ||||||||||||
17 | - | |||||||||||||
18 | readConverterSavedState(0), | - | ||||||||||||
19 | - | |||||||||||||
20 | readConverterSavedStateOffset(0), | - | ||||||||||||
21 | locale(QLocale::c()) | - | ||||||||||||
22 | { | - | ||||||||||||
23 | this->q_ptr = q_ptr; | - | ||||||||||||
24 | reset(); | - | ||||||||||||
25 | } | - | ||||||||||||
26 | - | |||||||||||||
27 | - | |||||||||||||
28 | - | |||||||||||||
29 | - | |||||||||||||
30 | QTextStreamPrivate::~QTextStreamPrivate() | - | ||||||||||||
31 | { | - | ||||||||||||
32 | if (deleteDevice) { | - | ||||||||||||
33 | - | |||||||||||||
34 | device->blockSignals(true); | - | ||||||||||||
35 | - | |||||||||||||
36 | delete device; | - | ||||||||||||
37 | } | - | ||||||||||||
38 | - | |||||||||||||
39 | delete readConverterSavedState; | - | ||||||||||||
40 | - | |||||||||||||
41 | } | - | ||||||||||||
42 | - | |||||||||||||
43 | - | |||||||||||||
44 | static void resetCodecConverterStateHelper(QTextCodec::ConverterState *state) | - | ||||||||||||
45 | { | - | ||||||||||||
46 | state->~ConverterState(); | - | ||||||||||||
47 | new (state) QTextCodec::ConverterState; | - | ||||||||||||
48 | } | - | ||||||||||||
49 | - | |||||||||||||
50 | static void copyConverterStateHelper(QTextCodec::ConverterState *dest, | - | ||||||||||||
51 | const QTextCodec::ConverterState *src) | - | ||||||||||||
52 | { | - | ||||||||||||
53 | - | |||||||||||||
54 | - | |||||||||||||
55 | ((!(!src->d)) ? qt_assert("!src->d",__FILE__,362369) : qt_noop()); | - | ||||||||||||
56 | dest->flags = src->flags; | - | ||||||||||||
57 | dest->invalidChars = src->invalidChars; | - | ||||||||||||
58 | dest->state_data[0] = src->state_data[0]; | - | ||||||||||||
59 | dest->state_data[1] = src->state_data[1]; | - | ||||||||||||
60 | dest->state_data[2] = src->state_data[2]; | - | ||||||||||||
61 | } | - | ||||||||||||
62 | - | |||||||||||||
63 | - | |||||||||||||
64 | void QTextStreamPrivate::Params::reset() | - | ||||||||||||
65 | { | - | ||||||||||||
66 | realNumberPrecision = 6; | - | ||||||||||||
67 | integerBase = 0; | - | ||||||||||||
68 | fieldWidth = 0; | - | ||||||||||||
69 | padChar = QLatin1Char(' '); | - | ||||||||||||
70 | fieldAlignment = QTextStream::AlignRight; | - | ||||||||||||
71 | realNumberNotation = QTextStream::SmartNotation; | - | ||||||||||||
72 | numberFlags = 0; | - | ||||||||||||
73 | } | - | ||||||||||||
74 | - | |||||||||||||
75 | - | |||||||||||||
76 | - | |||||||||||||
77 | - | |||||||||||||
78 | void QTextStreamPrivate::reset() | - | ||||||||||||
79 | { | - | ||||||||||||
80 | params.reset(); | - | ||||||||||||
81 | - | |||||||||||||
82 | device = 0; | - | ||||||||||||
83 | deleteDevice = false; | - | ||||||||||||
84 | string = 0; | - | ||||||||||||
85 | stringOffset = 0; | - | ||||||||||||
86 | stringOpenMode = QIODevice::NotOpen; | - | ||||||||||||
87 | - | |||||||||||||
88 | readBufferOffset = 0; | - | ||||||||||||
89 | readBufferStartDevicePos = 0; | - | ||||||||||||
90 | lastTokenSize = 0; | - | ||||||||||||
91 | - | |||||||||||||
92 | - | |||||||||||||
93 | codec = QTextCodec::codecForLocale(); | - | ||||||||||||
94 | resetCodecConverterStateHelper(&readConverterState); | - | ||||||||||||
95 | resetCodecConverterStateHelper(&writeConverterState); | - | ||||||||||||
96 | delete readConverterSavedState; | - | ||||||||||||
97 | readConverterSavedState = 0; | - | ||||||||||||
98 | writeConverterState.flags |= QTextCodec::IgnoreHeader; | - | ||||||||||||
99 | autoDetectUnicode = true; | - | ||||||||||||
100 | - | |||||||||||||
101 | } | - | ||||||||||||
102 | - | |||||||||||||
103 | - | |||||||||||||
104 | - | |||||||||||||
105 | - | |||||||||||||
106 | bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) | - | ||||||||||||
107 | { | - | ||||||||||||
108 | - | |||||||||||||
109 | - | |||||||||||||
110 | ((!(!string)) ? qt_assert("!string",__FILE__,417424) : qt_noop()); | - | ||||||||||||
111 | ((!(device)) ? qt_assert("device",__FILE__,418425) : qt_noop()); | - | ||||||||||||
112 | - | |||||||||||||
113 | - | |||||||||||||
114 | bool textModeEnabled = device->isTextModeEnabled(); | - | ||||||||||||
115 | if (textModeEnabled) | - | ||||||||||||
116 | device->setTextModeEnabled(false); | - | ||||||||||||
117 | - | |||||||||||||
118 | - | |||||||||||||
119 | char buf[QTEXTSTREAM_BUFFERSIZE]; | - | ||||||||||||
120 | qint64 bytesRead = 0; | - | ||||||||||||
121 | { | - | ||||||||||||
122 | if (maxBytes != -1) | - | ||||||||||||
123 | bytesRead = device->read(buf, qMin<qint64>(sizeof(buf), maxBytes)); | - | ||||||||||||
124 | else | - | ||||||||||||
125 | bytesRead = device->read(buf, sizeof(buf)); | - | ||||||||||||
126 | } | - | ||||||||||||
127 | - | |||||||||||||
128 | - | |||||||||||||
129 | if (textModeEnabled) | - | ||||||||||||
130 | device->setTextModeEnabled(true); | - | ||||||||||||
131 | - | |||||||||||||
132 | if (bytesRead <= 0) | - | ||||||||||||
133 | return false; | - | ||||||||||||
134 | - | |||||||||||||
135 | - | |||||||||||||
136 | - | |||||||||||||
137 | - | |||||||||||||
138 | if (!codec || autoDetectUnicode) { | - | ||||||||||||
139 | autoDetectUnicode = false; | - | ||||||||||||
140 | - | |||||||||||||
141 | codec = QTextCodec::codecForUtfText(QByteArray::fromRawData(buf, bytesRead), codec); | - | ||||||||||||
142 | if (!codec) { | - | ||||||||||||
143 | codec = QTextCodec::codecForLocale(); | - | ||||||||||||
144 | writeConverterState.flags |= QTextCodec::IgnoreHeader; | - | ||||||||||||
145 | } | - | ||||||||||||
146 | } | - | ||||||||||||
147 | int oldReadBufferSize = readBuffer.size(); | - | ||||||||||||
148 | - | |||||||||||||
149 | - | |||||||||||||
150 | readBuffer += __builtin_expect(!!(codec), true) ? codec->toUnicode(buf, bytesRead, &readConverterState) | - | ||||||||||||
151 | : QString::fromLatin1(buf, bytesRead); | - | ||||||||||||
152 | - | |||||||||||||
153 | - | |||||||||||||
154 | - | |||||||||||||
155 | - | |||||||||||||
156 | - | |||||||||||||
157 | if (readBuffer.size() > oldReadBufferSize && textModeEnabled) { | - | ||||||||||||
158 | QChar CR = QLatin1Char('\r'); | - | ||||||||||||
159 | QChar *writePtr = readBuffer.data() + oldReadBufferSize; | - | ||||||||||||
160 | QChar *readPtr = readBuffer.data() + oldReadBufferSize; | - | ||||||||||||
161 | QChar *endPtr = readBuffer.data() + readBuffer.size(); | - | ||||||||||||
162 | - | |||||||||||||
163 | int n = oldReadBufferSize; | - | ||||||||||||
164 | if (readPtr < endPtr) { | - | ||||||||||||
165 | - | |||||||||||||
166 | while (*readPtr++ != CR) { | - | ||||||||||||
167 | ++n; | - | ||||||||||||
168 | if (++writePtr == endPtr) | - | ||||||||||||
169 | break; | - | ||||||||||||
170 | } | - | ||||||||||||
171 | } | - | ||||||||||||
172 | while (readPtr < endPtr) { | - | ||||||||||||
173 | QChar ch = *readPtr++; | - | ||||||||||||
174 | if (ch != CR) { | - | ||||||||||||
175 | *writePtr++ = ch; | - | ||||||||||||
176 | } else { | - | ||||||||||||
177 | if (n < readBufferOffset) | - | ||||||||||||
178 | --readBufferOffset; | - | ||||||||||||
179 | --bytesRead; | - | ||||||||||||
180 | } | - | ||||||||||||
181 | ++n; | - | ||||||||||||
182 | } | - | ||||||||||||
183 | readBuffer.resize(writePtr - readBuffer.data()); | - | ||||||||||||
184 | } | - | ||||||||||||
185 | - | |||||||||||||
186 | - | |||||||||||||
187 | - | |||||||||||||
188 | - | |||||||||||||
189 | - | |||||||||||||
190 | return true; | - | ||||||||||||
191 | } | - | ||||||||||||
192 | - | |||||||||||||
193 | - | |||||||||||||
194 | - | |||||||||||||
195 | - | |||||||||||||
196 | void QTextStreamPrivate::resetReadBuffer() | - | ||||||||||||
197 | { | - | ||||||||||||
198 | readBuffer.clear(); | - | ||||||||||||
199 | readBufferOffset = 0; | - | ||||||||||||
200 | readBufferStartDevicePos = (device ? device->pos() : 0); | - | ||||||||||||
201 | } | - | ||||||||||||
202 | - | |||||||||||||
203 | - | |||||||||||||
204 | - | |||||||||||||
205 | - | |||||||||||||
206 | void QTextStreamPrivate::flushWriteBuffer() | - | ||||||||||||
207 | { | - | ||||||||||||
208 | - | |||||||||||||
209 | - | |||||||||||||
210 | if (string || !device) | - | ||||||||||||
211 | return; | - | ||||||||||||
212 | - | |||||||||||||
213 | - | |||||||||||||
214 | - | |||||||||||||
215 | if (status != QTextStream::Ok) | - | ||||||||||||
216 | return; | - | ||||||||||||
217 | - | |||||||||||||
218 | if (writeBuffer.isEmpty()) | - | ||||||||||||
219 | return; | - | ||||||||||||
220 | if (!codec) | - | ||||||||||||
221 | codec = QTextCodec::codecForLocale(); | - | ||||||||||||
222 | QByteArray data = __builtin_expect(!!(codec), true) ? codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState) | - | ||||||||||||
223 | : writeBuffer.toLatin1(); | - | ||||||||||||
224 | - | |||||||||||||
225 | - | |||||||||||||
226 | - | |||||||||||||
227 | writeBuffer.clear(); | - | ||||||||||||
228 | - | |||||||||||||
229 | - | |||||||||||||
230 | qint64 bytesWritten = device->write(data); | - | ||||||||||||
231 | if (bytesWritten <= 0) { | - | ||||||||||||
232 | status = QTextStream::WriteFailed; | - | ||||||||||||
233 | return; | - | ||||||||||||
234 | } | - | ||||||||||||
235 | - | |||||||||||||
236 | - | |||||||||||||
237 | - | |||||||||||||
238 | QFileDevice *file = qobject_cast<QFileDevice *>(device); | - | ||||||||||||
239 | bool flushed = !file || file->flush(); | - | ||||||||||||
240 | if (!flushed || bytesWritten != qint64(data.size())) | - | ||||||||||||
241 | status = QTextStream::WriteFailed; | - | ||||||||||||
242 | } | - | ||||||||||||
243 | - | |||||||||||||
244 | QString QTextStreamPrivate::read(int maxlen) | - | ||||||||||||
245 | { | - | ||||||||||||
246 | QString ret; | - | ||||||||||||
247 | if (string) { | - | ||||||||||||
248 | lastTokenSize = qMin(maxlen, string->size() - stringOffset); | - | ||||||||||||
249 | ret = string->mid(stringOffset, lastTokenSize); | - | ||||||||||||
250 | } else { | - | ||||||||||||
251 | while (readBuffer.size() - readBufferOffset < maxlen && fillReadBuffer()) ; | - | ||||||||||||
252 | lastTokenSize = qMin(maxlen, readBuffer.size() - readBufferOffset); | - | ||||||||||||
253 | ret = readBuffer.mid(readBufferOffset, lastTokenSize); | - | ||||||||||||
254 | } | - | ||||||||||||
255 | consumeLastToken(); | - | ||||||||||||
256 | - | |||||||||||||
257 | - | |||||||||||||
258 | - | |||||||||||||
259 | - | |||||||||||||
260 | return ret; | - | ||||||||||||
261 | } | - | ||||||||||||
262 | bool QTextStreamPrivate::scan(const QChar **ptr, int *length, int maxlen, TokenDelimiter delimiter) | - | ||||||||||||
263 | { | - | ||||||||||||
264 | int totalSize = 0; | - | ||||||||||||
265 | int delimSize = 0; | - | ||||||||||||
266 | bool consumeDelimiter = false; | - | ||||||||||||
267 | bool foundToken = false; | - | ||||||||||||
268 | int startOffset = device ? readBufferOffset : stringOffset; | - | ||||||||||||
269 | QChar lastChar; | - | ||||||||||||
270 | - | |||||||||||||
271 | bool canStillReadFromDevice = true; | - | ||||||||||||
272 | do { | - | ||||||||||||
273 | int endOffset; | - | ||||||||||||
274 | const QChar *chPtr; | - | ||||||||||||
275 | if (device) { | - | ||||||||||||
276 | chPtr = readBuffer.constData(); | - | ||||||||||||
277 | endOffset = readBuffer.size(); | - | ||||||||||||
278 | } else { | - | ||||||||||||
279 | chPtr = string->constData(); | - | ||||||||||||
280 | endOffset = string->size(); | - | ||||||||||||
281 | } | - | ||||||||||||
282 | chPtr += startOffset; | - | ||||||||||||
283 | - | |||||||||||||
284 | for (; !foundToken && startOffset < endOffset && (!maxlen || totalSize < maxlen); ++startOffset) { | - | ||||||||||||
285 | const QChar ch = *chPtr++; | - | ||||||||||||
286 | ++totalSize; | - | ||||||||||||
287 | - | |||||||||||||
288 | switch (delimiter) { | - | ||||||||||||
289 | case Space: | - | ||||||||||||
290 | if (ch.isSpace()) { | - | ||||||||||||
291 | foundToken = true; | - | ||||||||||||
292 | delimSize = 1; | - | ||||||||||||
293 | } | - | ||||||||||||
294 | break; | - | ||||||||||||
295 | case NotSpace: | - | ||||||||||||
296 | if (!ch.isSpace()) { | - | ||||||||||||
297 | foundToken = true; | - | ||||||||||||
298 | delimSize = 1; | - | ||||||||||||
299 | } | - | ||||||||||||
300 | break; | - | ||||||||||||
301 | case EndOfLine: | - | ||||||||||||
302 | if (ch == QLatin1Char('\n')) { | - | ||||||||||||
303 | foundToken = true; | - | ||||||||||||
304 | delimSize = (lastChar == QLatin1Char('\r')) ? 2 : 1; | - | ||||||||||||
305 | consumeDelimiter = true; | - | ||||||||||||
306 | } | - | ||||||||||||
307 | lastChar = ch; | - | ||||||||||||
308 | break; | - | ||||||||||||
309 | } | - | ||||||||||||
310 | } | - | ||||||||||||
311 | } while (!foundToken | - | ||||||||||||
312 | && (!maxlen || totalSize < maxlen) | - | ||||||||||||
313 | && (device && (canStillReadFromDevice = fillReadBuffer()))); | - | ||||||||||||
314 | - | |||||||||||||
315 | if (totalSize == 0) { | - | ||||||||||||
316 | - | |||||||||||||
317 | - | |||||||||||||
318 | - | |||||||||||||
319 | return false; | - | ||||||||||||
320 | } | - | ||||||||||||
321 | - | |||||||||||||
322 | - | |||||||||||||
323 | - | |||||||||||||
324 | if (delimiter == EndOfLine && totalSize > 0 && !foundToken) { | - | ||||||||||||
325 | if (((string && stringOffset + totalSize == string->size()) || (device && device->atEnd())) | - | ||||||||||||
326 | && lastChar == QLatin1Char('\r')) { | - | ||||||||||||
327 | consumeDelimiter = true; | - | ||||||||||||
328 | ++delimSize; | - | ||||||||||||
329 | } | - | ||||||||||||
330 | } | - | ||||||||||||
331 | - | |||||||||||||
332 | - | |||||||||||||
333 | if (length) | - | ||||||||||||
334 | *length = totalSize - delimSize; | - | ||||||||||||
335 | if (ptr) | - | ||||||||||||
336 | *ptr = readPtr(); | - | ||||||||||||
337 | - | |||||||||||||
338 | - | |||||||||||||
339 | - | |||||||||||||
340 | lastTokenSize = totalSize; | - | ||||||||||||
341 | if (!consumeDelimiter) | - | ||||||||||||
342 | lastTokenSize -= delimSize; | - | ||||||||||||
343 | - | |||||||||||||
344 | - | |||||||||||||
345 | - | |||||||||||||
346 | - | |||||||||||||
347 | - | |||||||||||||
348 | return true; | - | ||||||||||||
349 | } | - | ||||||||||||
350 | - | |||||||||||||
351 | - | |||||||||||||
352 | - | |||||||||||||
353 | - | |||||||||||||
354 | inline const QChar *QTextStreamPrivate::readPtr() const | - | ||||||||||||
355 | { | - | ||||||||||||
356 | ((!(readBufferOffset <= readBuffer.size())) ? qt_assert("readBufferOffset <= readBuffer.size()",__FILE__,737744) : qt_noop()); | - | ||||||||||||
357 | if (string) | - | ||||||||||||
358 | return string->constData() + stringOffset; | - | ||||||||||||
359 | return readBuffer.constData() + readBufferOffset; | - | ||||||||||||
360 | } | - | ||||||||||||
361 | - | |||||||||||||
362 | - | |||||||||||||
363 | - | |||||||||||||
364 | - | |||||||||||||
365 | inline void QTextStreamPrivate::consumeLastToken() | - | ||||||||||||
366 | { | - | ||||||||||||
367 | if (lastTokenSize) | - | ||||||||||||
368 | consume(lastTokenSize); | - | ||||||||||||
369 | lastTokenSize = 0; | - | ||||||||||||
370 | } | - | ||||||||||||
371 | - | |||||||||||||
372 | - | |||||||||||||
373 | - | |||||||||||||
374 | - | |||||||||||||
375 | inline void QTextStreamPrivate::consume(int size) | - | ||||||||||||
376 | { | - | ||||||||||||
377 | - | |||||||||||||
378 | - | |||||||||||||
379 | - | |||||||||||||
380 | if (string) { | - | ||||||||||||
381 | stringOffset += size; | - | ||||||||||||
382 | if (stringOffset > string->size()) | - | ||||||||||||
383 | stringOffset = string->size(); | - | ||||||||||||
384 | } else { | - | ||||||||||||
385 | readBufferOffset += size; | - | ||||||||||||
386 | if (readBufferOffset >= readBuffer.size()) { | - | ||||||||||||
387 | readBufferOffset = 0; | - | ||||||||||||
388 | readBuffer.clear(); | - | ||||||||||||
389 | saveConverterState(device->pos()); | - | ||||||||||||
390 | } else if (readBufferOffset > QTEXTSTREAM_BUFFERSIZE) { | - | ||||||||||||
391 | readBuffer = readBuffer.remove(0,readBufferOffset); | - | ||||||||||||
392 | readConverterSavedStateOffset += readBufferOffset; | - | ||||||||||||
393 | readBufferOffset = 0; | - | ||||||||||||
394 | } | - | ||||||||||||
395 | } | - | ||||||||||||
396 | } | - | ||||||||||||
397 | - | |||||||||||||
398 | - | |||||||||||||
399 | - | |||||||||||||
400 | - | |||||||||||||
401 | inline void QTextStreamPrivate::saveConverterState(qint64 newPos) | - | ||||||||||||
402 | { | - | ||||||||||||
403 | - | |||||||||||||
404 | if (readConverterState.d) { | - | ||||||||||||
405 | - | |||||||||||||
406 | - | |||||||||||||
407 | return; | - | ||||||||||||
408 | } | - | ||||||||||||
409 | - | |||||||||||||
410 | if (!readConverterSavedState) | - | ||||||||||||
411 | readConverterSavedState = new QTextCodec::ConverterState; | - | ||||||||||||
412 | copyConverterStateHelper(readConverterSavedState, &readConverterState); | - | ||||||||||||
413 | - | |||||||||||||
414 | - | |||||||||||||
415 | readBufferStartDevicePos = newPos; | - | ||||||||||||
416 | readConverterSavedStateOffset = 0; | - | ||||||||||||
417 | } | - | ||||||||||||
418 | - | |||||||||||||
419 | - | |||||||||||||
420 | - | |||||||||||||
421 | - | |||||||||||||
422 | inline void QTextStreamPrivate::restoreToSavedConverterState() | - | ||||||||||||
423 | { | - | ||||||||||||
424 | - | |||||||||||||
425 | if (readConverterSavedState) { | - | ||||||||||||
426 | - | |||||||||||||
427 | - | |||||||||||||
428 | copyConverterStateHelper(&readConverterState, readConverterSavedState); | - | ||||||||||||
429 | } else { | - | ||||||||||||
430 | - | |||||||||||||
431 | - | |||||||||||||
432 | resetCodecConverterStateHelper(&readConverterState); | - | ||||||||||||
433 | } | - | ||||||||||||
434 | - | |||||||||||||
435 | } | - | ||||||||||||
436 | - | |||||||||||||
437 | - | |||||||||||||
438 | - | |||||||||||||
439 | - | |||||||||||||
440 | void QTextStreamPrivate::write(const QChar *data, int len) | - | ||||||||||||
441 | { | - | ||||||||||||
442 | if (string) { | - | ||||||||||||
443 | - | |||||||||||||
444 | string->append(data, len); | - | ||||||||||||
445 | } else { | - | ||||||||||||
446 | writeBuffer.append(data, len); | - | ||||||||||||
447 | if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE) | - | ||||||||||||
448 | flushWriteBuffer(); | - | ||||||||||||
449 | } | - | ||||||||||||
450 | } | - | ||||||||||||
451 | - | |||||||||||||
452 | - | |||||||||||||
453 | - | |||||||||||||
454 | - | |||||||||||||
455 | inline void QTextStreamPrivate::write(QChar ch) | - | ||||||||||||
456 | { | - | ||||||||||||
457 | if (string) { | - | ||||||||||||
458 | - | |||||||||||||
459 | string->append(ch); | - | ||||||||||||
460 | } else { | - | ||||||||||||
461 | writeBuffer += ch; | - | ||||||||||||
462 | if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE) | - | ||||||||||||
463 | flushWriteBuffer(); | - | ||||||||||||
464 | } | - | ||||||||||||
465 | } | - | ||||||||||||
466 | - | |||||||||||||
467 | - | |||||||||||||
468 | - | |||||||||||||
469 | - | |||||||||||||
470 | void QTextStreamPrivate::write(QLatin1String data) | - | ||||||||||||
471 | { | - | ||||||||||||
472 | if (string) { | - | ||||||||||||
473 | - | |||||||||||||
474 | string->append(data); | - | ||||||||||||
475 | } else { | - | ||||||||||||
476 | writeBuffer += data; | - | ||||||||||||
477 | if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE) | - | ||||||||||||
478 | flushWriteBuffer(); | - | ||||||||||||
479 | } | - | ||||||||||||
480 | } | - | ||||||||||||
481 | - | |||||||||||||
482 | - | |||||||||||||
483 | - | |||||||||||||
484 | - | |||||||||||||
485 | void QTextStreamPrivate::writePadding(int len) | - | ||||||||||||
486 | { | - | ||||||||||||
487 | if (string
| 72-4406 | ||||||||||||
488 | - | |||||||||||||
489 | string->resize(string->size() + len, params.padChar); | - | ||||||||||||
490 | } executed 72 times by 4 tests: else {end of block Executed by:
| 72 | ||||||||||||
491 | writeBuffer.resize(writeBuffer.size() + len, params.padChar); | - | ||||||||||||
492 | if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE
| 0-4406 | ||||||||||||
493 | flushWriteBuffer(); never executed: flushWriteBuffer(); | 0 | ||||||||||||
494 | } executed 4406 times by 1 test: end of block Executed by:
| 4406 | ||||||||||||
495 | } | - | ||||||||||||
496 | - | |||||||||||||
497 | - | |||||||||||||
498 | - | |||||||||||||
499 | - | |||||||||||||
500 | inline bool QTextStreamPrivate::getChar(QChar *ch) | - | ||||||||||||
501 | { | - | ||||||||||||
502 | if ((string && stringOffset == string->size()) | - | ||||||||||||
503 | || (device && readBuffer.isEmpty() && !fillReadBuffer())) { | - | ||||||||||||
504 | if (ch) | - | ||||||||||||
505 | *ch = 0; | - | ||||||||||||
506 | return false; | - | ||||||||||||
507 | } | - | ||||||||||||
508 | if (ch) | - | ||||||||||||
509 | *ch = *readPtr(); | - | ||||||||||||
510 | consume(1); | - | ||||||||||||
511 | return true; | - | ||||||||||||
512 | } | - | ||||||||||||
513 | - | |||||||||||||
514 | - | |||||||||||||
515 | - | |||||||||||||
516 | - | |||||||||||||
517 | inline void QTextStreamPrivate::ungetChar(QChar ch) | - | ||||||||||||
518 | { | - | ||||||||||||
519 | if (string) { | - | ||||||||||||
520 | if (stringOffset == 0) | - | ||||||||||||
521 | string->prepend(ch); | - | ||||||||||||
522 | else | - | ||||||||||||
523 | (*string)[--stringOffset] = ch; | - | ||||||||||||
524 | return; | - | ||||||||||||
525 | } | - | ||||||||||||
526 | - | |||||||||||||
527 | if (readBufferOffset == 0) { | - | ||||||||||||
528 | readBuffer.prepend(ch); | - | ||||||||||||
529 | return; | - | ||||||||||||
530 | } | - | ||||||||||||
531 | - | |||||||||||||
532 | readBuffer[--readBufferOffset] = ch; | - | ||||||||||||
533 | } | - | ||||||||||||
534 | - | |||||||||||||
535 | - | |||||||||||||
536 | - | |||||||||||||
537 | - | |||||||||||||
538 | inline void QTextStreamPrivate::putChar(QChar ch) | - | ||||||||||||
539 | { | - | ||||||||||||
540 | if (params.fieldWidth > 0) | - | ||||||||||||
541 | putString(&ch, 1); | - | ||||||||||||
542 | else | - | ||||||||||||
543 | write(ch); | - | ||||||||||||
544 | } | - | ||||||||||||
545 | - | |||||||||||||
546 | - | |||||||||||||
547 | - | |||||||||||||
548 | - | |||||||||||||
549 | - | |||||||||||||
550 | QTextStreamPrivate::PaddingResult QTextStreamPrivate::padding(int len) const | - | ||||||||||||
551 | { | - | ||||||||||||
552 | ((!(params.fieldWidth > len)) ? qt_assert("params.fieldWidth > len",__FILE__,918940) : qt_noop()); | - | ||||||||||||
553 | - | |||||||||||||
554 | PaddingResult resultint left = 0, right = 0; | - | ||||||||||||
555 | - | |||||||||||||
556 | const int padSize = params.fieldWidth - len; | - | ||||||||||||
557 | - | |||||||||||||
558 | result.padding.resize(padSize); | - | ||||||||||||
std::fill_n(result.padding.begin(), padSize, params.padChar);switch (params.fieldAlignment) { | ||||||||||||||
559 | case never executed: QTextStream::AlignLeft:case QTextStream::AlignLeft: never executed: case QTextStream::AlignLeft: | 0 | ||||||||||||
560 | result.left = 0; | - | ||||||||||||
result.right = padSize; | ||||||||||||||
561 | break; never executed: break; | 0 | ||||||||||||
562 | case executed 2235 times by 4 tests: QTextStream::AlignRight:case QTextStream::AlignRight: Executed by:
executed 2235 times by 4 tests: case QTextStream::AlignRight: Executed by:
| 2235 | ||||||||||||
563 | case executed 4 times by 1 test: QTextStream::AlignAccountingStyle:case QTextStream::AlignAccountingStyle: Executed by:
executed 4 times by 1 test: case QTextStream::AlignAccountingStyle: Executed by:
| 4 | ||||||||||||
564 | result.left = padSize; | - | ||||||||||||
result.right = 0; | ||||||||||||||
565 | break; executed 2239 times by 4 tests: break; Executed by:
| 2239 | ||||||||||||
566 | case never executed: QTextStream::AlignCenter:case QTextStream::AlignCenter: never executed: case QTextStream::AlignCenter: | 0 | ||||||||||||
567 | result.left = padSize/2; | - | ||||||||||||
568 | result.right = padSize - padSize/2; | - | ||||||||||||
569 | break; never executed: break; | 0 | ||||||||||||
570 | } | - | ||||||||||||
571 | const PaddingResult result = { left, right }; | - | ||||||||||||
572 | return executed 2239 times by 4 tests: result;return result; Executed by:
executed 2239 times by 4 tests: return result; Executed by:
| 2239 | ||||||||||||
573 | } | - | ||||||||||||
574 | - | |||||||||||||
575 | - | |||||||||||||
576 | - | |||||||||||||
577 | - | |||||||||||||
578 | void QTextStreamPrivate::putString(const QChar *data, int len, bool number) | - | ||||||||||||
579 | { | - | ||||||||||||
580 | if (__builtin_expect(!!(params.fieldWidth > len), false)
| 2237-149522 | ||||||||||||
581 | - | |||||||||||||
582 | - | |||||||||||||
583 | - | |||||||||||||
584 | const PaddingResult pad = padding(len); | - | ||||||||||||
585 | - | |||||||||||||
586 | if (params.fieldAlignment == QTextStream::AlignAccountingStyle
| 0-2235 | ||||||||||||
587 | const QChar sign = len > 0
| 0-2 | ||||||||||||
588 | if (sign == locale.negativeSign()
| 0-2 | ||||||||||||
589 | - | |||||||||||||
590 | write(&sign, 1); | - | ||||||||||||
591 | ++data; | - | ||||||||||||
592 | --len; | - | ||||||||||||
593 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
594 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
595 | - | |||||||||||||
596 | writewritePadding(pad.padding.constData(),pad.left); | - | ||||||||||||
597 | write(data, len); | - | ||||||||||||
598 | writewritePadding(pad.padding.constData(),pad.right); | - | ||||||||||||
599 | } executed 2237 times by 4 tests: else {end of block Executed by:
| 2237 | ||||||||||||
600 | write(data, len); | - | ||||||||||||
601 | } executed 149522 times by 86 tests: end of block Executed by:
| 149522 | ||||||||||||
602 | } | - | ||||||||||||
603 | - | |||||||||||||
604 | - | |||||||||||||
605 | - | |||||||||||||
606 | - | |||||||||||||
607 | void QTextStreamPrivate::putString(QLatin1String data, bool number) | - | ||||||||||||
608 | { | - | ||||||||||||
609 | if (__builtin_expect(!!(params.fieldWidth > data.size()), false)
| 2-60790 | ||||||||||||
610 | - | |||||||||||||
611 | - | |||||||||||||
612 | - | |||||||||||||
613 | const PaddingResult pad = padding(data.size()); | - | ||||||||||||
614 | - | |||||||||||||
615 | if (params.fieldAlignment == QTextStream::AlignAccountingStyle
| 0-2 | ||||||||||||
616 | const QChar sign = data.size() > 0
| 0 | ||||||||||||
617 | if (sign == locale.negativeSign()
| 0 | ||||||||||||
618 | - | |||||||||||||
619 | write(&sign, 1); | - | ||||||||||||
620 | data = QLatin1String(data.data() + 1, data.size() - 1); | - | ||||||||||||
621 | } never executed: end of block | 0 | ||||||||||||
622 | } never executed: end of block | 0 | ||||||||||||
623 | - | |||||||||||||
624 | writewritePadding(pad.padding.constData(),pad.left); | - | ||||||||||||
625 | write(data); | - | ||||||||||||
626 | writewritePadding(pad.padding.constData(),pad.right); | - | ||||||||||||
627 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||
628 | write(data); | - | ||||||||||||
629 | } executed 60790 times by 30 tests: end of block Executed by:
| 60790 | ||||||||||||
630 | } | - | ||||||||||||
631 | - | |||||||||||||
632 | - | |||||||||||||
633 | - | |||||||||||||
634 | - | |||||||||||||
635 | - | |||||||||||||
636 | - | |||||||||||||
637 | - | |||||||||||||
638 | QTextStream::QTextStream() | - | ||||||||||||
639 | : d_ptr(new QTextStreamPrivate(this)) | - | ||||||||||||
640 | { | - | ||||||||||||
641 | - | |||||||||||||
642 | - | |||||||||||||
643 | - | |||||||||||||
644 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
645 | d->status = Ok; | - | ||||||||||||
646 | } | - | ||||||||||||
647 | - | |||||||||||||
648 | - | |||||||||||||
649 | - | |||||||||||||
650 | - | |||||||||||||
651 | QTextStream::QTextStream(QIODevice *device) | - | ||||||||||||
652 | : d_ptr(new QTextStreamPrivate(this)) | - | ||||||||||||
653 | { | - | ||||||||||||
654 | - | |||||||||||||
655 | - | |||||||||||||
656 | - | |||||||||||||
657 | - | |||||||||||||
658 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
659 | d->device = device; | - | ||||||||||||
660 | - | |||||||||||||
661 | d->deviceClosedNotifier.setupDevice(this, d->device); | - | ||||||||||||
662 | - | |||||||||||||
663 | d->status = Ok; | - | ||||||||||||
664 | } | - | ||||||||||||
665 | - | |||||||||||||
666 | - | |||||||||||||
667 | - | |||||||||||||
668 | - | |||||||||||||
669 | - | |||||||||||||
670 | QTextStream::QTextStream(QString *string, QIODevice::OpenMode openMode) | - | ||||||||||||
671 | : d_ptr(new QTextStreamPrivate(this)) | - | ||||||||||||
672 | { | - | ||||||||||||
673 | - | |||||||||||||
674 | - | |||||||||||||
675 | - | |||||||||||||
676 | - | |||||||||||||
677 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
678 | d->string = string; | - | ||||||||||||
679 | d->stringOpenMode = openMode; | - | ||||||||||||
680 | d->status = Ok; | - | ||||||||||||
681 | } | - | ||||||||||||
682 | - | |||||||||||||
683 | - | |||||||||||||
684 | - | |||||||||||||
685 | - | |||||||||||||
686 | - | |||||||||||||
687 | - | |||||||||||||
688 | QTextStream::QTextStream(QByteArray *array, QIODevice::OpenMode openMode) | - | ||||||||||||
689 | : d_ptr(new QTextStreamPrivate(this)) | - | ||||||||||||
690 | { | - | ||||||||||||
691 | - | |||||||||||||
692 | - | |||||||||||||
693 | - | |||||||||||||
694 | - | |||||||||||||
695 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
696 | d->device = new QBuffer(array); | - | ||||||||||||
697 | d->device->open(openMode); | - | ||||||||||||
698 | d->deleteDevice = true; | - | ||||||||||||
699 | - | |||||||||||||
700 | d->deviceClosedNotifier.setupDevice(this, d->device); | - | ||||||||||||
701 | - | |||||||||||||
702 | d->status = Ok; | - | ||||||||||||
703 | } | - | ||||||||||||
704 | QTextStream::QTextStream(const QByteArray &array, QIODevice::OpenMode openMode) | - | ||||||||||||
705 | : d_ptr(new QTextStreamPrivate(this)) | - | ||||||||||||
706 | { | - | ||||||||||||
707 | - | |||||||||||||
708 | - | |||||||||||||
709 | - | |||||||||||||
710 | - | |||||||||||||
711 | QBuffer *buffer = new QBuffer; | - | ||||||||||||
712 | buffer->setData(array); | - | ||||||||||||
713 | buffer->open(openMode); | - | ||||||||||||
714 | - | |||||||||||||
715 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
716 | d->device = buffer; | - | ||||||||||||
717 | d->deleteDevice = true; | - | ||||||||||||
718 | - | |||||||||||||
719 | d->deviceClosedNotifier.setupDevice(this, d->device); | - | ||||||||||||
720 | - | |||||||||||||
721 | d->status = Ok; | - | ||||||||||||
722 | } | - | ||||||||||||
723 | QTextStream::QTextStream(FILE *fileHandle, QIODevice::OpenMode openMode) | - | ||||||||||||
724 | : d_ptr(new QTextStreamPrivate(this)) | - | ||||||||||||
725 | { | - | ||||||||||||
726 | - | |||||||||||||
727 | - | |||||||||||||
728 | - | |||||||||||||
729 | - | |||||||||||||
730 | QFile *file = new QFile; | - | ||||||||||||
731 | file->open(fileHandle, openMode); | - | ||||||||||||
732 | - | |||||||||||||
733 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
734 | d->device = file; | - | ||||||||||||
735 | d->deleteDevice = true; | - | ||||||||||||
736 | - | |||||||||||||
737 | d->deviceClosedNotifier.setupDevice(this, d->device); | - | ||||||||||||
738 | - | |||||||||||||
739 | d->status = Ok; | - | ||||||||||||
740 | } | - | ||||||||||||
741 | - | |||||||||||||
742 | - | |||||||||||||
743 | - | |||||||||||||
744 | - | |||||||||||||
745 | - | |||||||||||||
746 | - | |||||||||||||
747 | - | |||||||||||||
748 | QTextStream::~QTextStream() | - | ||||||||||||
749 | { | - | ||||||||||||
750 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
751 | - | |||||||||||||
752 | - | |||||||||||||
753 | - | |||||||||||||
754 | if (!d->writeBuffer.isEmpty()) | - | ||||||||||||
755 | d->flushWriteBuffer(); | - | ||||||||||||
756 | } | - | ||||||||||||
757 | - | |||||||||||||
758 | - | |||||||||||||
759 | - | |||||||||||||
760 | - | |||||||||||||
761 | - | |||||||||||||
762 | - | |||||||||||||
763 | void QTextStream::reset() | - | ||||||||||||
764 | { | - | ||||||||||||
765 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
766 | - | |||||||||||||
767 | d->params.reset(); | - | ||||||||||||
768 | } | - | ||||||||||||
769 | - | |||||||||||||
770 | - | |||||||||||||
771 | - | |||||||||||||
772 | - | |||||||||||||
773 | - | |||||||||||||
774 | - | |||||||||||||
775 | void QTextStream::flush() | - | ||||||||||||
776 | { | - | ||||||||||||
777 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
778 | d->flushWriteBuffer(); | - | ||||||||||||
779 | } | - | ||||||||||||
780 | - | |||||||||||||
781 | - | |||||||||||||
782 | - | |||||||||||||
783 | - | |||||||||||||
784 | - | |||||||||||||
785 | bool QTextStream::seek(qint64 pos) | - | ||||||||||||
786 | { | - | ||||||||||||
787 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
788 | d->lastTokenSize = 0; | - | ||||||||||||
789 | - | |||||||||||||
790 | if (d->device) { | - | ||||||||||||
791 | - | |||||||||||||
792 | d->flushWriteBuffer(); | - | ||||||||||||
793 | if (!d->device->seek(pos)) | - | ||||||||||||
794 | return false; | - | ||||||||||||
795 | d->resetReadBuffer(); | - | ||||||||||||
796 | - | |||||||||||||
797 | - | |||||||||||||
798 | - | |||||||||||||
799 | resetCodecConverterStateHelper(&d->readConverterState); | - | ||||||||||||
800 | resetCodecConverterStateHelper(&d->writeConverterState); | - | ||||||||||||
801 | delete d->readConverterSavedState; | - | ||||||||||||
802 | d->readConverterSavedState = 0; | - | ||||||||||||
803 | d->writeConverterState.flags |= QTextCodec::IgnoreHeader; | - | ||||||||||||
804 | - | |||||||||||||
805 | return true; | - | ||||||||||||
806 | } | - | ||||||||||||
807 | - | |||||||||||||
808 | - | |||||||||||||
809 | if (d->string && pos <= d->string->size()) { | - | ||||||||||||
810 | d->stringOffset = int(pos); | - | ||||||||||||
811 | return true; | - | ||||||||||||
812 | } | - | ||||||||||||
813 | return false; | - | ||||||||||||
814 | } | - | ||||||||||||
815 | qint64 QTextStream::pos() const | - | ||||||||||||
816 | { | - | ||||||||||||
817 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
818 | if (d->device) { | - | ||||||||||||
819 | - | |||||||||||||
820 | if (d->readBuffer.isEmpty()) | - | ||||||||||||
821 | return d->device->pos(); | - | ||||||||||||
822 | if (d->device->isSequential()) | - | ||||||||||||
823 | return 0; | - | ||||||||||||
824 | - | |||||||||||||
825 | - | |||||||||||||
826 | if (!d->device->seek(d->readBufferStartDevicePos)) | - | ||||||||||||
827 | return qint64(-1); | - | ||||||||||||
828 | - | |||||||||||||
829 | - | |||||||||||||
830 | QTextStreamPrivate *thatd = const_cast<QTextStreamPrivate *>(d); | - | ||||||||||||
831 | thatd->readBuffer.clear(); | - | ||||||||||||
832 | - | |||||||||||||
833 | - | |||||||||||||
834 | thatd->restoreToSavedConverterState(); | - | ||||||||||||
835 | if (d->readBufferStartDevicePos == 0) | - | ||||||||||||
836 | thatd->autoDetectUnicode = true; | - | ||||||||||||
837 | - | |||||||||||||
838 | - | |||||||||||||
839 | - | |||||||||||||
840 | - | |||||||||||||
841 | int oldReadBufferOffset = d->readBufferOffset + d->readConverterSavedStateOffset; | - | ||||||||||||
842 | while (d->readBuffer.size() < oldReadBufferOffset) { | - | ||||||||||||
843 | if (!thatd->fillReadBuffer(1)) | - | ||||||||||||
844 | return qint64(-1); | - | ||||||||||||
845 | } | - | ||||||||||||
846 | thatd->readBufferOffset = oldReadBufferOffset; | - | ||||||||||||
847 | thatd->readConverterSavedStateOffset = 0; | - | ||||||||||||
848 | - | |||||||||||||
849 | - | |||||||||||||
850 | return d->device->pos(); | - | ||||||||||||
851 | } | - | ||||||||||||
852 | - | |||||||||||||
853 | if (d->string) | - | ||||||||||||
854 | return d->stringOffset; | - | ||||||||||||
855 | - | |||||||||||||
856 | QMessageLogger(__FILE__, 12671282, __PRETTY_FUNCTION__).warning("QTextStream::pos: no device"); | - | ||||||||||||
857 | return qint64(-1); | - | ||||||||||||
858 | } | - | ||||||||||||
859 | void QTextStream::skipWhiteSpace() | - | ||||||||||||
860 | { | - | ||||||||||||
861 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
862 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 12851300, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return ; } } while (0); | - | ||||||||||||
863 | d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); | - | ||||||||||||
864 | d->consumeLastToken(); | - | ||||||||||||
865 | } | - | ||||||||||||
866 | void QTextStream::setDevice(QIODevice *device) | - | ||||||||||||
867 | { | - | ||||||||||||
868 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
869 | flush(); | - | ||||||||||||
870 | if (d->deleteDevice) { | - | ||||||||||||
871 | - | |||||||||||||
872 | d->deviceClosedNotifier.disconnect(); | - | ||||||||||||
873 | - | |||||||||||||
874 | delete d->device; | - | ||||||||||||
875 | d->deleteDevice = false; | - | ||||||||||||
876 | } | - | ||||||||||||
877 | - | |||||||||||||
878 | d->reset(); | - | ||||||||||||
879 | d->status = Ok; | - | ||||||||||||
880 | d->device = device; | - | ||||||||||||
881 | d->resetReadBuffer(); | - | ||||||||||||
882 | - | |||||||||||||
883 | d->deviceClosedNotifier.setupDevice(this, d->device); | - | ||||||||||||
884 | - | |||||||||||||
885 | } | - | ||||||||||||
886 | - | |||||||||||||
887 | - | |||||||||||||
888 | - | |||||||||||||
889 | - | |||||||||||||
890 | - | |||||||||||||
891 | - | |||||||||||||
892 | - | |||||||||||||
893 | QIODevice *QTextStream::device() const | - | ||||||||||||
894 | { | - | ||||||||||||
895 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
896 | return d->device; | - | ||||||||||||
897 | } | - | ||||||||||||
898 | void QTextStream::setString(QString *string, QIODevice::OpenMode openMode) | - | ||||||||||||
899 | { | - | ||||||||||||
900 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
901 | flush(); | - | ||||||||||||
902 | if (d->deleteDevice) { | - | ||||||||||||
903 | - | |||||||||||||
904 | d->deviceClosedNotifier.disconnect(); | - | ||||||||||||
905 | d->device->blockSignals(true); | - | ||||||||||||
906 | - | |||||||||||||
907 | delete d->device; | - | ||||||||||||
908 | d->deleteDevice = false; | - | ||||||||||||
909 | } | - | ||||||||||||
910 | - | |||||||||||||
911 | d->reset(); | - | ||||||||||||
912 | d->status = Ok; | - | ||||||||||||
913 | d->string = string; | - | ||||||||||||
914 | d->stringOpenMode = openMode; | - | ||||||||||||
915 | } | - | ||||||||||||
916 | - | |||||||||||||
917 | - | |||||||||||||
918 | - | |||||||||||||
919 | - | |||||||||||||
920 | - | |||||||||||||
921 | - | |||||||||||||
922 | - | |||||||||||||
923 | QString *QTextStream::string() const | - | ||||||||||||
924 | { | - | ||||||||||||
925 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
926 | return d->string; | - | ||||||||||||
927 | } | - | ||||||||||||
928 | void QTextStream::setFieldAlignment(FieldAlignment mode) | - | ||||||||||||
929 | { | - | ||||||||||||
930 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
931 | d->params.fieldAlignment = mode; | - | ||||||||||||
932 | } | - | ||||||||||||
933 | - | |||||||||||||
934 | - | |||||||||||||
935 | - | |||||||||||||
936 | - | |||||||||||||
937 | - | |||||||||||||
938 | - | |||||||||||||
939 | QTextStream::FieldAlignment QTextStream::fieldAlignment() const | - | ||||||||||||
940 | { | - | ||||||||||||
941 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
942 | return d->params.fieldAlignment; | - | ||||||||||||
943 | } | - | ||||||||||||
944 | void QTextStream::setPadChar(QChar ch) | - | ||||||||||||
945 | { | - | ||||||||||||
946 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
947 | d->params.padChar = ch; | - | ||||||||||||
948 | } | - | ||||||||||||
949 | - | |||||||||||||
950 | - | |||||||||||||
951 | - | |||||||||||||
952 | - | |||||||||||||
953 | - | |||||||||||||
954 | - | |||||||||||||
955 | QChar QTextStream::padChar() const | - | ||||||||||||
956 | { | - | ||||||||||||
957 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
958 | return d->params.padChar; | - | ||||||||||||
959 | } | - | ||||||||||||
960 | void QTextStream::setFieldWidth(int width) | - | ||||||||||||
961 | { | - | ||||||||||||
962 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
963 | d->params.fieldWidth = width; | - | ||||||||||||
964 | } | - | ||||||||||||
965 | - | |||||||||||||
966 | - | |||||||||||||
967 | - | |||||||||||||
968 | - | |||||||||||||
969 | - | |||||||||||||
970 | - | |||||||||||||
971 | int QTextStream::fieldWidth() const | - | ||||||||||||
972 | { | - | ||||||||||||
973 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
974 | return d->params.fieldWidth; | - | ||||||||||||
975 | } | - | ||||||||||||
976 | void QTextStream::setNumberFlags(NumberFlags flags) | - | ||||||||||||
977 | { | - | ||||||||||||
978 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
979 | d->params.numberFlags = flags; | - | ||||||||||||
980 | } | - | ||||||||||||
981 | - | |||||||||||||
982 | - | |||||||||||||
983 | - | |||||||||||||
984 | - | |||||||||||||
985 | - | |||||||||||||
986 | - | |||||||||||||
987 | QTextStream::NumberFlags QTextStream::numberFlags() const | - | ||||||||||||
988 | { | - | ||||||||||||
989 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
990 | return d->params.numberFlags; | - | ||||||||||||
991 | } | - | ||||||||||||
992 | void QTextStream::setIntegerBase(int base) | - | ||||||||||||
993 | { | - | ||||||||||||
994 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
995 | d->params.integerBase = base; | - | ||||||||||||
996 | } | - | ||||||||||||
997 | - | |||||||||||||
998 | - | |||||||||||||
999 | - | |||||||||||||
1000 | - | |||||||||||||
1001 | - | |||||||||||||
1002 | - | |||||||||||||
1003 | - | |||||||||||||
1004 | int QTextStream::integerBase() const | - | ||||||||||||
1005 | { | - | ||||||||||||
1006 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1007 | return d->params.integerBase; | - | ||||||||||||
1008 | } | - | ||||||||||||
1009 | void QTextStream::setRealNumberNotation(RealNumberNotation notation) | - | ||||||||||||
1010 | { | - | ||||||||||||
1011 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1012 | d->params.realNumberNotation = notation; | - | ||||||||||||
1013 | } | - | ||||||||||||
1014 | - | |||||||||||||
1015 | - | |||||||||||||
1016 | - | |||||||||||||
1017 | - | |||||||||||||
1018 | - | |||||||||||||
1019 | - | |||||||||||||
1020 | QTextStream::RealNumberNotation QTextStream::realNumberNotation() const | - | ||||||||||||
1021 | { | - | ||||||||||||
1022 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1023 | return d->params.realNumberNotation; | - | ||||||||||||
1024 | } | - | ||||||||||||
1025 | void QTextStream::setRealNumberPrecision(int precision) | - | ||||||||||||
1026 | { | - | ||||||||||||
1027 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1028 | if (precision < 0) { | - | ||||||||||||
1029 | QMessageLogger(__FILE__, 15481563, __PRETTY_FUNCTION__).warning("QTextStream::setRealNumberPrecision: Invalid precision (%d)", precision); | - | ||||||||||||
1030 | d->params.realNumberPrecision = 6; | - | ||||||||||||
1031 | return; | - | ||||||||||||
1032 | } | - | ||||||||||||
1033 | d->params.realNumberPrecision = precision; | - | ||||||||||||
1034 | } | - | ||||||||||||
1035 | - | |||||||||||||
1036 | - | |||||||||||||
1037 | - | |||||||||||||
1038 | - | |||||||||||||
1039 | - | |||||||||||||
1040 | - | |||||||||||||
1041 | - | |||||||||||||
1042 | int QTextStream::realNumberPrecision() const | - | ||||||||||||
1043 | { | - | ||||||||||||
1044 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1045 | return d->params.realNumberPrecision; | - | ||||||||||||
1046 | } | - | ||||||||||||
1047 | - | |||||||||||||
1048 | - | |||||||||||||
1049 | - | |||||||||||||
1050 | - | |||||||||||||
1051 | - | |||||||||||||
1052 | - | |||||||||||||
1053 | - | |||||||||||||
1054 | QTextStream::Status QTextStream::status() const | - | ||||||||||||
1055 | { | - | ||||||||||||
1056 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1057 | return d->status; | - | ||||||||||||
1058 | } | - | ||||||||||||
1059 | void QTextStream::resetStatus() | - | ||||||||||||
1060 | { | - | ||||||||||||
1061 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1062 | d->status = Ok; | - | ||||||||||||
1063 | } | - | ||||||||||||
1064 | void QTextStream::setStatus(Status status) | - | ||||||||||||
1065 | { | - | ||||||||||||
1066 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1067 | if (d->status == Ok) | - | ||||||||||||
1068 | d->status = status; | - | ||||||||||||
1069 | } | - | ||||||||||||
1070 | - | |||||||||||||
1071 | - | |||||||||||||
1072 | - | |||||||||||||
1073 | - | |||||||||||||
1074 | - | |||||||||||||
1075 | - | |||||||||||||
1076 | - | |||||||||||||
1077 | bool QTextStream::atEnd() const | - | ||||||||||||
1078 | { | - | ||||||||||||
1079 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1080 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 16181633, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return true; } } while (0); | - | ||||||||||||
1081 | - | |||||||||||||
1082 | if (d->string) | - | ||||||||||||
1083 | return d->string->size() == d->stringOffset; | - | ||||||||||||
1084 | return d->readBuffer.isEmpty() && d->device->atEnd(); | - | ||||||||||||
1085 | } | - | ||||||||||||
1086 | QString QTextStream::readAll() | - | ||||||||||||
1087 | { | - | ||||||||||||
1088 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1089 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 16381653, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return QString(); } } while (0); | - | ||||||||||||
1090 | - | |||||||||||||
1091 | return d->read(2147483647); | - | ||||||||||||
1092 | } | - | ||||||||||||
1093 | QString QTextStream::readLine(qint64 maxlen) | - | ||||||||||||
1094 | { | - | ||||||||||||
1095 | QString line; | - | ||||||||||||
1096 | - | |||||||||||||
1097 | readLineInto(&line, maxlen); | - | ||||||||||||
1098 | return line; | - | ||||||||||||
1099 | } | - | ||||||||||||
1100 | bool QTextStream::readLineInto(QString *line, qint64 maxlen) | - | ||||||||||||
1101 | { | - | ||||||||||||
1102 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1103 | - | |||||||||||||
1104 | if (!d->string && !d->device) { | - | ||||||||||||
1105 | QMessageLogger(__FILE__, 16981713, __PRETTY_FUNCTION__).warning("QTextStream: No device"); | - | ||||||||||||
1106 | if (line && !line->isNull()) | - | ||||||||||||
1107 | line->resize(0); | - | ||||||||||||
1108 | return false; | - | ||||||||||||
1109 | } | - | ||||||||||||
1110 | - | |||||||||||||
1111 | const QChar *readPtr; | - | ||||||||||||
1112 | int length; | - | ||||||||||||
1113 | if (!d->scan(&readPtr, &length, int(maxlen), QTextStreamPrivate::EndOfLine)) { | - | ||||||||||||
1114 | if (line && !line->isNull()) | - | ||||||||||||
1115 | line->resize(0); | - | ||||||||||||
1116 | return false; | - | ||||||||||||
1117 | } | - | ||||||||||||
1118 | - | |||||||||||||
1119 | if (__builtin_expect(!!(line), true)) | - | ||||||||||||
1120 | line->setUnicode(readPtr, length); | - | ||||||||||||
1121 | d->consumeLastToken(); | - | ||||||||||||
1122 | return true; | - | ||||||||||||
1123 | } | - | ||||||||||||
1124 | QString QTextStream::read(qint64 maxlen) | - | ||||||||||||
1125 | { | - | ||||||||||||
1126 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1127 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 17291744, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return QString(); } } while (0); | - | ||||||||||||
1128 | - | |||||||||||||
1129 | if (maxlen <= 0) | - | ||||||||||||
1130 | return QString::fromLatin1(""); | - | ||||||||||||
1131 | - | |||||||||||||
1132 | return d->read(int(maxlen)); | - | ||||||||||||
1133 | } | - | ||||||||||||
1134 | - | |||||||||||||
1135 | - | |||||||||||||
1136 | - | |||||||||||||
1137 | - | |||||||||||||
1138 | QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong *ret) | - | ||||||||||||
1139 | { | - | ||||||||||||
1140 | scan(0, 0, 0, NotSpace); | - | ||||||||||||
1141 | consumeLastToken(); | - | ||||||||||||
1142 | - | |||||||||||||
1143 | - | |||||||||||||
1144 | int base = params.integerBase; | - | ||||||||||||
1145 | if (base == 0) { | - | ||||||||||||
1146 | QChar ch; | - | ||||||||||||
1147 | if (!getChar(&ch)) | - | ||||||||||||
1148 | return npsInvalidPrefix; | - | ||||||||||||
1149 | if (ch == QLatin1Char('0')) { | - | ||||||||||||
1150 | QChar ch2; | - | ||||||||||||
1151 | if (!getChar(&ch2)) { | - | ||||||||||||
1152 | - | |||||||||||||
1153 | *ret = 0; | - | ||||||||||||
1154 | return npsOk; | - | ||||||||||||
1155 | } | - | ||||||||||||
1156 | ch2 = ch2.toLower(); | - | ||||||||||||
1157 | - | |||||||||||||
1158 | if (ch2 == QLatin1Char('x')) { | - | ||||||||||||
1159 | base = 16; | - | ||||||||||||
1160 | } else if (ch2 == QLatin1Char('b')) { | - | ||||||||||||
1161 | base = 2; | - | ||||||||||||
1162 | } else if (ch2.isDigit() && ch2.digitValue() >= 0 && ch2.digitValue() <= 7) { | - | ||||||||||||
1163 | base = 8; | - | ||||||||||||
1164 | } else { | - | ||||||||||||
1165 | base = 10; | - | ||||||||||||
1166 | } | - | ||||||||||||
1167 | ungetChar(ch2); | - | ||||||||||||
1168 | } else if (ch == locale.negativeSign() || ch == locale.positiveSign() || ch.isDigit()) { | - | ||||||||||||
1169 | base = 10; | - | ||||||||||||
1170 | } else { | - | ||||||||||||
1171 | ungetChar(ch); | - | ||||||||||||
1172 | return npsInvalidPrefix; | - | ||||||||||||
1173 | } | - | ||||||||||||
1174 | ungetChar(ch); | - | ||||||||||||
1175 | - | |||||||||||||
1176 | - | |||||||||||||
1177 | - | |||||||||||||
1178 | } | - | ||||||||||||
1179 | - | |||||||||||||
1180 | qulonglong val=0; | - | ||||||||||||
1181 | switch (base) { | - | ||||||||||||
1182 | case 2: { | - | ||||||||||||
1183 | QChar pf1, pf2, dig; | - | ||||||||||||
1184 | - | |||||||||||||
1185 | if (!getChar(&pf1) || pf1 != QLatin1Char('0')) | - | ||||||||||||
1186 | return npsInvalidPrefix; | - | ||||||||||||
1187 | if (!getChar(&pf2) || pf2.toLower() != QLatin1Char('b')) | - | ||||||||||||
1188 | return npsInvalidPrefix; | - | ||||||||||||
1189 | - | |||||||||||||
1190 | int ndigits = 0; | - | ||||||||||||
1191 | while (getChar(&dig)) { | - | ||||||||||||
1192 | int n = dig.toLower().unicode(); | - | ||||||||||||
1193 | if (n == '0' || n == '1') { | - | ||||||||||||
1194 | val <<= 1; | - | ||||||||||||
1195 | val += n - '0'; | - | ||||||||||||
1196 | } else { | - | ||||||||||||
1197 | ungetChar(dig); | - | ||||||||||||
1198 | break; | - | ||||||||||||
1199 | } | - | ||||||||||||
1200 | ndigits++; | - | ||||||||||||
1201 | } | - | ||||||||||||
1202 | if (ndigits == 0) { | - | ||||||||||||
1203 | - | |||||||||||||
1204 | ungetChar(pf2); | - | ||||||||||||
1205 | ungetChar(pf1); | - | ||||||||||||
1206 | return npsMissingDigit; | - | ||||||||||||
1207 | } | - | ||||||||||||
1208 | break; | - | ||||||||||||
1209 | } | - | ||||||||||||
1210 | case 8: { | - | ||||||||||||
1211 | QChar pf, dig; | - | ||||||||||||
1212 | - | |||||||||||||
1213 | if (!getChar(&pf) || pf != QLatin1Char('0')) | - | ||||||||||||
1214 | return npsInvalidPrefix; | - | ||||||||||||
1215 | - | |||||||||||||
1216 | int ndigits = 0; | - | ||||||||||||
1217 | while (getChar(&dig)) { | - | ||||||||||||
1218 | int n = dig.toLower().unicode(); | - | ||||||||||||
1219 | if (n >= '0' && n <= '7') { | - | ||||||||||||
1220 | val *= 8; | - | ||||||||||||
1221 | val += n - '0'; | - | ||||||||||||
1222 | } else { | - | ||||||||||||
1223 | ungetChar(dig); | - | ||||||||||||
1224 | break; | - | ||||||||||||
1225 | } | - | ||||||||||||
1226 | ndigits++; | - | ||||||||||||
1227 | } | - | ||||||||||||
1228 | if (ndigits == 0) { | - | ||||||||||||
1229 | - | |||||||||||||
1230 | ungetChar(pf); | - | ||||||||||||
1231 | return npsMissingDigit; | - | ||||||||||||
1232 | } | - | ||||||||||||
1233 | break; | - | ||||||||||||
1234 | } | - | ||||||||||||
1235 | case 10: { | - | ||||||||||||
1236 | - | |||||||||||||
1237 | QChar sign; | - | ||||||||||||
1238 | int ndigits = 0; | - | ||||||||||||
1239 | if (!getChar(&sign)) | - | ||||||||||||
1240 | return npsMissingDigit; | - | ||||||||||||
1241 | if (sign != locale.negativeSign() && sign != locale.positiveSign()) { | - | ||||||||||||
1242 | if (!sign.isDigit()) { | - | ||||||||||||
1243 | ungetChar(sign); | - | ||||||||||||
1244 | return npsMissingDigit; | - | ||||||||||||
1245 | } | - | ||||||||||||
1246 | val += sign.digitValue(); | - | ||||||||||||
1247 | ndigits++; | - | ||||||||||||
1248 | } | - | ||||||||||||
1249 | - | |||||||||||||
1250 | QChar ch; | - | ||||||||||||
1251 | while (getChar(&ch)) { | - | ||||||||||||
1252 | if (ch.isDigit()) { | - | ||||||||||||
1253 | val *= 10; | - | ||||||||||||
1254 | val += ch.digitValue(); | - | ||||||||||||
1255 | } else if (locale != QLocale::c() && ch == locale.groupSeparator()) { | - | ||||||||||||
1256 | continue; | - | ||||||||||||
1257 | } else { | - | ||||||||||||
1258 | ungetChar(ch); | - | ||||||||||||
1259 | break; | - | ||||||||||||
1260 | } | - | ||||||||||||
1261 | ndigits++; | - | ||||||||||||
1262 | } | - | ||||||||||||
1263 | if (ndigits == 0) | - | ||||||||||||
1264 | return npsMissingDigit; | - | ||||||||||||
1265 | if (sign == locale.negativeSign()) { | - | ||||||||||||
1266 | qlonglong ival = qlonglong(val); | - | ||||||||||||
1267 | if (ival > 0) | - | ||||||||||||
1268 | ival = -ival; | - | ||||||||||||
1269 | val = qulonglong(ival); | - | ||||||||||||
1270 | } | - | ||||||||||||
1271 | break; | - | ||||||||||||
1272 | } | - | ||||||||||||
1273 | case 16: { | - | ||||||||||||
1274 | QChar pf1, pf2, dig; | - | ||||||||||||
1275 | - | |||||||||||||
1276 | if (!getChar(&pf1) || pf1 != QLatin1Char('0')) | - | ||||||||||||
1277 | return npsInvalidPrefix; | - | ||||||||||||
1278 | if (!getChar(&pf2) || pf2.toLower() != QLatin1Char('x')) | - | ||||||||||||
1279 | return npsInvalidPrefix; | - | ||||||||||||
1280 | - | |||||||||||||
1281 | int ndigits = 0; | - | ||||||||||||
1282 | while (getChar(&dig)) { | - | ||||||||||||
1283 | int n = dig.toLower().unicode(); | - | ||||||||||||
1284 | if (n >= '0' && n <= '9') { | - | ||||||||||||
1285 | val <<= 4; | - | ||||||||||||
1286 | val += n - '0'; | - | ||||||||||||
1287 | } else if (n >= 'a' && n <= 'f') { | - | ||||||||||||
1288 | val <<= 4; | - | ||||||||||||
1289 | val += 10 + (n - 'a'); | - | ||||||||||||
1290 | } else { | - | ||||||||||||
1291 | ungetChar(dig); | - | ||||||||||||
1292 | break; | - | ||||||||||||
1293 | } | - | ||||||||||||
1294 | ndigits++; | - | ||||||||||||
1295 | } | - | ||||||||||||
1296 | if (ndigits == 0) { | - | ||||||||||||
1297 | return npsMissingDigit; | - | ||||||||||||
1298 | } | - | ||||||||||||
1299 | break; | - | ||||||||||||
1300 | } | - | ||||||||||||
1301 | default: | - | ||||||||||||
1302 | - | |||||||||||||
1303 | return npsInvalidPrefix; | - | ||||||||||||
1304 | } | - | ||||||||||||
1305 | - | |||||||||||||
1306 | if (ret) | - | ||||||||||||
1307 | *ret = val; | - | ||||||||||||
1308 | return npsOk; | - | ||||||||||||
1309 | } | - | ||||||||||||
1310 | - | |||||||||||||
1311 | - | |||||||||||||
1312 | - | |||||||||||||
1313 | - | |||||||||||||
1314 | - | |||||||||||||
1315 | bool QTextStreamPrivate::getReal(double *f) | - | ||||||||||||
1316 | { | - | ||||||||||||
1317 | - | |||||||||||||
1318 | - | |||||||||||||
1319 | - | |||||||||||||
1320 | enum ParserState { | - | ||||||||||||
1321 | Init = 0, | - | ||||||||||||
1322 | Sign = 1, | - | ||||||||||||
1323 | Mantissa = 2, | - | ||||||||||||
1324 | Dot = 3, | - | ||||||||||||
1325 | Abscissa = 4, | - | ||||||||||||
1326 | ExpMark = 5, | - | ||||||||||||
1327 | ExpSign = 6, | - | ||||||||||||
1328 | Exponent = 7, | - | ||||||||||||
1329 | Nan1 = 8, | - | ||||||||||||
1330 | Nan2 = 9, | - | ||||||||||||
1331 | Inf1 = 10, | - | ||||||||||||
1332 | Inf2 = 11, | - | ||||||||||||
1333 | NanInf = 12, | - | ||||||||||||
1334 | Done = 13 | - | ||||||||||||
1335 | }; | - | ||||||||||||
1336 | enum InputToken { | - | ||||||||||||
1337 | None = 0, | - | ||||||||||||
1338 | InputSign = 1, | - | ||||||||||||
1339 | InputDigit = 2, | - | ||||||||||||
1340 | InputDot = 3, | - | ||||||||||||
1341 | InputExp = 4, | - | ||||||||||||
1342 | InputI = 5, | - | ||||||||||||
1343 | InputN = 6, | - | ||||||||||||
1344 | InputF = 7, | - | ||||||||||||
1345 | InputA = 8, | - | ||||||||||||
1346 | InputT = 9 | - | ||||||||||||
1347 | }; | - | ||||||||||||
1348 | - | |||||||||||||
1349 | static const uchar table[13][10] = { | - | ||||||||||||
1350 | - | |||||||||||||
1351 | { 0, Sign, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 }, | - | ||||||||||||
1352 | { 0, 0, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 }, | - | ||||||||||||
1353 | { Done, Done, Mantissa, Dot, ExpMark, 0, 0, 0, 0, 0 }, | - | ||||||||||||
1354 | { 0, 0, Abscissa, 0, 0, 0, 0, 0, 0, 0 }, | - | ||||||||||||
1355 | { Done, Done, Abscissa, Done, ExpMark, 0, 0, 0, 0, 0 }, | - | ||||||||||||
1356 | { 0, ExpSign, Exponent, 0, 0, 0, 0, 0, 0, 0 }, | - | ||||||||||||
1357 | { 0, 0, Exponent, 0, 0, 0, 0, 0, 0, 0 }, | - | ||||||||||||
1358 | { Done, Done, Exponent, Done, Done, 0, 0, 0, 0, 0 }, | - | ||||||||||||
1359 | { 0, 0, 0, 0, 0, 0, 0, 0, Nan2, 0 }, | - | ||||||||||||
1360 | { 0, 0, 0, 0, 0, 0, NanInf, 0, 0, 0 }, | - | ||||||||||||
1361 | { 0, 0, 0, 0, 0, 0, Inf2, 0, 0, 0 }, | - | ||||||||||||
1362 | { 0, 0, 0, 0, 0, 0, 0, NanInf, 0, 0 }, | - | ||||||||||||
1363 | { Done, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, | - | ||||||||||||
1364 | }; | - | ||||||||||||
1365 | - | |||||||||||||
1366 | ParserState state = Init; | - | ||||||||||||
1367 | InputToken input = None; | - | ||||||||||||
1368 | - | |||||||||||||
1369 | scan(0, 0, 0, NotSpace); | - | ||||||||||||
1370 | consumeLastToken(); | - | ||||||||||||
1371 | - | |||||||||||||
1372 | const int BufferSize = 128; | - | ||||||||||||
1373 | char buf[BufferSize]; | - | ||||||||||||
1374 | int i = 0; | - | ||||||||||||
1375 | - | |||||||||||||
1376 | QChar c; | - | ||||||||||||
1377 | while (getChar(&c)) { | - | ||||||||||||
1378 | switch (c.unicode()) { | - | ||||||||||||
1379 | case '0': case '1': case '2': case '3': case '4': | - | ||||||||||||
1380 | case '5': case '6': case '7': case '8': case '9': | - | ||||||||||||
1381 | input = InputDigit; | - | ||||||||||||
1382 | break; | - | ||||||||||||
1383 | case 'i': case 'I': | - | ||||||||||||
1384 | input = InputI; | - | ||||||||||||
1385 | break; | - | ||||||||||||
1386 | case 'n': case 'N': | - | ||||||||||||
1387 | input = InputN; | - | ||||||||||||
1388 | break; | - | ||||||||||||
1389 | case 'f': case 'F': | - | ||||||||||||
1390 | input = InputF; | - | ||||||||||||
1391 | break; | - | ||||||||||||
1392 | case 'a': case 'A': | - | ||||||||||||
1393 | input = InputA; | - | ||||||||||||
1394 | break; | - | ||||||||||||
1395 | case 't': case 'T': | - | ||||||||||||
1396 | input = InputT; | - | ||||||||||||
1397 | break; | - | ||||||||||||
1398 | default: { | - | ||||||||||||
1399 | QChar lc = c.toLower(); | - | ||||||||||||
1400 | if (lc == locale.decimalPoint().toLower()) | - | ||||||||||||
1401 | input = InputDot; | - | ||||||||||||
1402 | else if (lc == locale.exponential().toLower()) | - | ||||||||||||
1403 | input = InputExp; | - | ||||||||||||
1404 | else if (lc == locale.negativeSign().toLower() | - | ||||||||||||
1405 | || lc == locale.positiveSign().toLower()) | - | ||||||||||||
1406 | input = InputSign; | - | ||||||||||||
1407 | else if (locale != QLocale::c() | - | ||||||||||||
1408 | && lc == locale.groupSeparator().toLower()) | - | ||||||||||||
1409 | input = InputDigit; | - | ||||||||||||
1410 | else | - | ||||||||||||
1411 | input = None; | - | ||||||||||||
1412 | } | - | ||||||||||||
1413 | break; | - | ||||||||||||
1414 | } | - | ||||||||||||
1415 | - | |||||||||||||
1416 | state = ParserState(table[state][input]); | - | ||||||||||||
1417 | - | |||||||||||||
1418 | if (state == Init || state == Done || i > (BufferSize - 5)) { | - | ||||||||||||
1419 | ungetChar(c); | - | ||||||||||||
1420 | if (i > (BufferSize - 5)) { | - | ||||||||||||
1421 | while (getChar(&c)) { | - | ||||||||||||
1422 | if (!c.isDigit()) { | - | ||||||||||||
1423 | ungetChar(c); | - | ||||||||||||
1424 | break; | - | ||||||||||||
1425 | } | - | ||||||||||||
1426 | } | - | ||||||||||||
1427 | } | - | ||||||||||||
1428 | break; | - | ||||||||||||
1429 | } | - | ||||||||||||
1430 | - | |||||||||||||
1431 | buf[i++] = c.toLatin1(); | - | ||||||||||||
1432 | } | - | ||||||||||||
1433 | - | |||||||||||||
1434 | if (i == 0) | - | ||||||||||||
1435 | return false; | - | ||||||||||||
1436 | if (!f) | - | ||||||||||||
1437 | return true; | - | ||||||||||||
1438 | buf[i] = '\0'; | - | ||||||||||||
1439 | - | |||||||||||||
1440 | - | |||||||||||||
1441 | - | |||||||||||||
1442 | - | |||||||||||||
1443 | - | |||||||||||||
1444 | if (!qstricmp(buf, "nan") || !qstricmp(buf, "+nan") || !qstricmp(buf, "-nan")) { | - | ||||||||||||
1445 | *f = qSNaN(); | - | ||||||||||||
1446 | return true; | - | ||||||||||||
1447 | } else if (!qstricmp(buf, "+inf") || !qstricmp(buf, "inf")) { | - | ||||||||||||
1448 | *f = qInf(); | - | ||||||||||||
1449 | return true; | - | ||||||||||||
1450 | } else if (!qstricmp(buf, "-inf")) { | - | ||||||||||||
1451 | *f = -qInf(); | - | ||||||||||||
1452 | return true; | - | ||||||||||||
1453 | } | - | ||||||||||||
1454 | bool ok; | - | ||||||||||||
1455 | *f = locale.toDouble(QString::fromLatin1(buf), &ok); | - | ||||||||||||
1456 | return ok; | - | ||||||||||||
1457 | } | - | ||||||||||||
1458 | QTextStream &QTextStream::operator>>(QChar &c) | - | ||||||||||||
1459 | { | - | ||||||||||||
1460 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1461 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 20742089, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1462 | d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); | - | ||||||||||||
1463 | if (!d->getChar(&c)) | - | ||||||||||||
1464 | setStatus(ReadPastEnd); | - | ||||||||||||
1465 | return *this; | - | ||||||||||||
1466 | } | - | ||||||||||||
1467 | QTextStream &QTextStream::operator>>(char &c) | - | ||||||||||||
1468 | { | - | ||||||||||||
1469 | QChar ch; | - | ||||||||||||
1470 | *this >> ch; | - | ||||||||||||
1471 | c = ch.toLatin1(); | - | ||||||||||||
1472 | return *this; | - | ||||||||||||
1473 | } | - | ||||||||||||
1474 | QTextStream &QTextStream::operator>>(signed short &i) | - | ||||||||||||
1475 | { | - | ||||||||||||
1476 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21242139, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (signed short)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (signed short)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1477 | } | - | ||||||||||||
1478 | - | |||||||||||||
1479 | - | |||||||||||||
1480 | - | |||||||||||||
1481 | - | |||||||||||||
1482 | - | |||||||||||||
1483 | - | |||||||||||||
1484 | QTextStream &QTextStream::operator>>(unsigned short &i) | - | ||||||||||||
1485 | { | - | ||||||||||||
1486 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21342149, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (unsigned short)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (unsigned short)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1487 | } | - | ||||||||||||
1488 | - | |||||||||||||
1489 | - | |||||||||||||
1490 | - | |||||||||||||
1491 | - | |||||||||||||
1492 | - | |||||||||||||
1493 | - | |||||||||||||
1494 | QTextStream &QTextStream::operator>>(signed int &i) | - | ||||||||||||
1495 | { | - | ||||||||||||
1496 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21442159, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (signed int)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (signed int)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1497 | } | - | ||||||||||||
1498 | - | |||||||||||||
1499 | - | |||||||||||||
1500 | - | |||||||||||||
1501 | - | |||||||||||||
1502 | - | |||||||||||||
1503 | - | |||||||||||||
1504 | QTextStream &QTextStream::operator>>(unsigned int &i) | - | ||||||||||||
1505 | { | - | ||||||||||||
1506 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21542169, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (unsigned int)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (unsigned int)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1507 | } | - | ||||||||||||
1508 | - | |||||||||||||
1509 | - | |||||||||||||
1510 | - | |||||||||||||
1511 | - | |||||||||||||
1512 | - | |||||||||||||
1513 | - | |||||||||||||
1514 | QTextStream &QTextStream::operator>>(signed long &i) | - | ||||||||||||
1515 | { | - | ||||||||||||
1516 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21642179, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (signed long)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (signed long)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1517 | } | - | ||||||||||||
1518 | - | |||||||||||||
1519 | - | |||||||||||||
1520 | - | |||||||||||||
1521 | - | |||||||||||||
1522 | - | |||||||||||||
1523 | - | |||||||||||||
1524 | QTextStream &QTextStream::operator>>(unsigned long &i) | - | ||||||||||||
1525 | { | - | ||||||||||||
1526 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21742189, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (unsigned long)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (unsigned long)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1527 | } | - | ||||||||||||
1528 | - | |||||||||||||
1529 | - | |||||||||||||
1530 | - | |||||||||||||
1531 | - | |||||||||||||
1532 | - | |||||||||||||
1533 | - | |||||||||||||
1534 | QTextStream &QTextStream::operator>>(qlonglong &i) | - | ||||||||||||
1535 | { | - | ||||||||||||
1536 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21842199, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (qlonglong)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (qlonglong)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1537 | } | - | ||||||||||||
1538 | - | |||||||||||||
1539 | - | |||||||||||||
1540 | - | |||||||||||||
1541 | - | |||||||||||||
1542 | - | |||||||||||||
1543 | - | |||||||||||||
1544 | QTextStream &QTextStream::operator>>(qulonglong &i) | - | ||||||||||||
1545 | { | - | ||||||||||||
1546 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 21942209, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); qulonglong tmp; switch (d->getNumber(&tmp)) { case QTextStreamPrivate::npsOk: i = (qulonglong)tmp; break; case QTextStreamPrivate::npsMissingDigit: case QTextStreamPrivate::npsInvalidPrefix: i = (qulonglong)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); break; } return *this; } while (0); | - | ||||||||||||
1547 | } | - | ||||||||||||
1548 | QTextStream &QTextStream::operator>>(float &f) | - | ||||||||||||
1549 | { | - | ||||||||||||
1550 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 22102225, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); double tmp; if (d->getReal(&tmp)) { f = (float)tmp; } else { f = (float)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); } return *this; } while (0); | - | ||||||||||||
1551 | } | - | ||||||||||||
1552 | - | |||||||||||||
1553 | - | |||||||||||||
1554 | - | |||||||||||||
1555 | - | |||||||||||||
1556 | - | |||||||||||||
1557 | - | |||||||||||||
1558 | QTextStream &QTextStream::operator>>(double &f) | - | ||||||||||||
1559 | { | - | ||||||||||||
1560 | do { QTextStreamPrivate * const d = d_func(); do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 22202235, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); double tmp; if (d->getReal(&tmp)) { f = (double)tmp; } else { f = (double)0; setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); } return *this; } while (0); | - | ||||||||||||
1561 | } | - | ||||||||||||
1562 | QTextStream &QTextStream::operator>>(QString &str) | - | ||||||||||||
1563 | { | - | ||||||||||||
1564 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1565 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 22332248, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1566 | - | |||||||||||||
1567 | str.clear(); | - | ||||||||||||
1568 | d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); | - | ||||||||||||
1569 | d->consumeLastToken(); | - | ||||||||||||
1570 | - | |||||||||||||
1571 | const QChar *ptr; | - | ||||||||||||
1572 | int length; | - | ||||||||||||
1573 | if (!d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)) { | - | ||||||||||||
1574 | setStatus(ReadPastEnd); | - | ||||||||||||
1575 | return *this; | - | ||||||||||||
1576 | } | - | ||||||||||||
1577 | - | |||||||||||||
1578 | str = QString(ptr, length); | - | ||||||||||||
1579 | d->consumeLastToken(); | - | ||||||||||||
1580 | return *this; | - | ||||||||||||
1581 | } | - | ||||||||||||
1582 | QTextStream &QTextStream::operator>>(QByteArray &array) | - | ||||||||||||
1583 | { | - | ||||||||||||
1584 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1585 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 22612276, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1586 | - | |||||||||||||
1587 | array.clear(); | - | ||||||||||||
1588 | d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); | - | ||||||||||||
1589 | d->consumeLastToken(); | - | ||||||||||||
1590 | - | |||||||||||||
1591 | const QChar *ptr; | - | ||||||||||||
1592 | int length; | - | ||||||||||||
1593 | if (!d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)) { | - | ||||||||||||
1594 | setStatus(ReadPastEnd); | - | ||||||||||||
1595 | return *this; | - | ||||||||||||
1596 | } | - | ||||||||||||
1597 | - | |||||||||||||
1598 | for (int i = 0; i < length; ++i) | - | ||||||||||||
1599 | array += ptr[i].toLatin1(); | - | ||||||||||||
1600 | - | |||||||||||||
1601 | d->consumeLastToken(); | - | ||||||||||||
1602 | return *this; | - | ||||||||||||
1603 | } | - | ||||||||||||
1604 | QTextStream &QTextStream::operator>>(char *c) | - | ||||||||||||
1605 | { | - | ||||||||||||
1606 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1607 | *c = 0; | - | ||||||||||||
1608 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 22982313, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1609 | d->scan(0, 0, 0, QTextStreamPrivate::NotSpace); | - | ||||||||||||
1610 | d->consumeLastToken(); | - | ||||||||||||
1611 | - | |||||||||||||
1612 | const QChar *ptr; | - | ||||||||||||
1613 | int length; | - | ||||||||||||
1614 | if (!d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)) { | - | ||||||||||||
1615 | setStatus(ReadPastEnd); | - | ||||||||||||
1616 | return *this; | - | ||||||||||||
1617 | } | - | ||||||||||||
1618 | - | |||||||||||||
1619 | for (int i = 0; i < length; ++i) | - | ||||||||||||
1620 | *c++ = ptr[i].toLatin1(); | - | ||||||||||||
1621 | *c = '\0'; | - | ||||||||||||
1622 | d->consumeLastToken(); | - | ||||||||||||
1623 | return *this; | - | ||||||||||||
1624 | } | - | ||||||||||||
1625 | - | |||||||||||||
1626 | - | |||||||||||||
1627 | - | |||||||||||||
1628 | - | |||||||||||||
1629 | void QTextStreamPrivate::putNumber(qulonglong number, bool negative) | - | ||||||||||||
1630 | { | - | ||||||||||||
1631 | QString result; | - | ||||||||||||
1632 | - | |||||||||||||
1633 | unsigned flags = 0; | - | ||||||||||||
1634 | const QTextStream::NumberFlags numberFlags = params.numberFlags; | - | ||||||||||||
1635 | if (numberFlags & QTextStream::ShowBase) | - | ||||||||||||
1636 | flags |= QLocaleData::ShowBase; | - | ||||||||||||
1637 | if (numberFlags & QTextStream::ForceSign) | - | ||||||||||||
1638 | flags |= QLocaleData::AlwaysShowSign; | - | ||||||||||||
1639 | if (numberFlags & QTextStream::UppercaseBase) | - | ||||||||||||
1640 | flags |= QLocaleData::UppercaseBase; | - | ||||||||||||
1641 | if (numberFlags & QTextStream::UppercaseDigits) | - | ||||||||||||
1642 | flags |= QLocaleData::CapitalEorX; | - | ||||||||||||
1643 | - | |||||||||||||
1644 | - | |||||||||||||
1645 | - | |||||||||||||
1646 | if (locale != QLocale::c() && !locale.numberOptions().testFlag(QLocale::OmitGroupSeparator)) | - | ||||||||||||
1647 | flags |= QLocaleData::ThousandsGroup; | - | ||||||||||||
1648 | - | |||||||||||||
1649 | const QLocaleData *dd = locale.d->m_data; | - | ||||||||||||
1650 | int base = params.integerBase ? params.integerBase : 10; | - | ||||||||||||
1651 | if (negative && base == 10) { | - | ||||||||||||
1652 | result = dd->longLongToString(-static_cast<qlonglong>(number), -1, | - | ||||||||||||
1653 | base, -1, flags); | - | ||||||||||||
1654 | } else if (negative) { | - | ||||||||||||
1655 | - | |||||||||||||
1656 | - | |||||||||||||
1657 | - | |||||||||||||
1658 | - | |||||||||||||
1659 | result = dd->unsLongLongToString(number, -1, base, -1, flags); | - | ||||||||||||
1660 | result.prepend(locale.negativeSign()); | - | ||||||||||||
1661 | } else { | - | ||||||||||||
1662 | result = dd->unsLongLongToString(number, -1, base, -1, flags); | - | ||||||||||||
1663 | - | |||||||||||||
1664 | - | |||||||||||||
1665 | if (number == 0 && base == 8 && params.numberFlags & QTextStream::ShowBase | - | ||||||||||||
1666 | && result == QLatin1String("0")) { | - | ||||||||||||
1667 | result.prepend(QLatin1Char('0')); | - | ||||||||||||
1668 | } | - | ||||||||||||
1669 | } | - | ||||||||||||
1670 | putString(result, true); | - | ||||||||||||
1671 | } | - | ||||||||||||
1672 | - | |||||||||||||
1673 | - | |||||||||||||
1674 | - | |||||||||||||
1675 | - | |||||||||||||
1676 | - | |||||||||||||
1677 | - | |||||||||||||
1678 | - | |||||||||||||
1679 | QTextStream &QTextStream::operator<<(QChar c) | - | ||||||||||||
1680 | { | - | ||||||||||||
1681 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1682 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 23722387, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1683 | d->putChar(c); | - | ||||||||||||
1684 | return *this; | - | ||||||||||||
1685 | } | - | ||||||||||||
1686 | - | |||||||||||||
1687 | - | |||||||||||||
1688 | - | |||||||||||||
1689 | - | |||||||||||||
1690 | - | |||||||||||||
1691 | - | |||||||||||||
1692 | QTextStream &QTextStream::operator<<(char c) | - | ||||||||||||
1693 | { | - | ||||||||||||
1694 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1695 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 23852400, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1696 | d->putChar(QChar::fromLatin1(c)); | - | ||||||||||||
1697 | return *this; | - | ||||||||||||
1698 | } | - | ||||||||||||
1699 | QTextStream &QTextStream::operator<<(signed short i) | - | ||||||||||||
1700 | { | - | ||||||||||||
1701 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1702 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24012416, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1703 | d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0); | - | ||||||||||||
1704 | return *this; | - | ||||||||||||
1705 | } | - | ||||||||||||
1706 | - | |||||||||||||
1707 | - | |||||||||||||
1708 | - | |||||||||||||
1709 | - | |||||||||||||
1710 | - | |||||||||||||
1711 | - | |||||||||||||
1712 | QTextStream &QTextStream::operator<<(unsigned short i) | - | ||||||||||||
1713 | { | - | ||||||||||||
1714 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1715 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24142429, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1716 | d->putNumber((qulonglong)i, false); | - | ||||||||||||
1717 | return *this; | - | ||||||||||||
1718 | } | - | ||||||||||||
1719 | - | |||||||||||||
1720 | - | |||||||||||||
1721 | - | |||||||||||||
1722 | - | |||||||||||||
1723 | - | |||||||||||||
1724 | - | |||||||||||||
1725 | QTextStream &QTextStream::operator<<(signed int i) | - | ||||||||||||
1726 | { | - | ||||||||||||
1727 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1728 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24272442, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1729 | d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0); | - | ||||||||||||
1730 | return *this; | - | ||||||||||||
1731 | } | - | ||||||||||||
1732 | - | |||||||||||||
1733 | - | |||||||||||||
1734 | - | |||||||||||||
1735 | - | |||||||||||||
1736 | - | |||||||||||||
1737 | - | |||||||||||||
1738 | QTextStream &QTextStream::operator<<(unsigned int i) | - | ||||||||||||
1739 | { | - | ||||||||||||
1740 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1741 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24402455, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1742 | d->putNumber((qulonglong)i, false); | - | ||||||||||||
1743 | return *this; | - | ||||||||||||
1744 | } | - | ||||||||||||
1745 | - | |||||||||||||
1746 | - | |||||||||||||
1747 | - | |||||||||||||
1748 | - | |||||||||||||
1749 | - | |||||||||||||
1750 | - | |||||||||||||
1751 | QTextStream &QTextStream::operator<<(signed long i) | - | ||||||||||||
1752 | { | - | ||||||||||||
1753 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1754 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24532468, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1755 | d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0); | - | ||||||||||||
1756 | return *this; | - | ||||||||||||
1757 | } | - | ||||||||||||
1758 | - | |||||||||||||
1759 | - | |||||||||||||
1760 | - | |||||||||||||
1761 | - | |||||||||||||
1762 | - | |||||||||||||
1763 | - | |||||||||||||
1764 | QTextStream &QTextStream::operator<<(unsigned long i) | - | ||||||||||||
1765 | { | - | ||||||||||||
1766 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1767 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24662481, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1768 | d->putNumber((qulonglong)i, false); | - | ||||||||||||
1769 | return *this; | - | ||||||||||||
1770 | } | - | ||||||||||||
1771 | - | |||||||||||||
1772 | - | |||||||||||||
1773 | - | |||||||||||||
1774 | - | |||||||||||||
1775 | - | |||||||||||||
1776 | - | |||||||||||||
1777 | QTextStream &QTextStream::operator<<(qlonglong i) | - | ||||||||||||
1778 | { | - | ||||||||||||
1779 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1780 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24792494, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1781 | d->putNumber((qulonglong)qAbs(i), i < 0); | - | ||||||||||||
1782 | return *this; | - | ||||||||||||
1783 | } | - | ||||||||||||
1784 | - | |||||||||||||
1785 | - | |||||||||||||
1786 | - | |||||||||||||
1787 | - | |||||||||||||
1788 | - | |||||||||||||
1789 | - | |||||||||||||
1790 | QTextStream &QTextStream::operator<<(qulonglong i) | - | ||||||||||||
1791 | { | - | ||||||||||||
1792 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1793 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 24922507, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1794 | d->putNumber(i, false); | - | ||||||||||||
1795 | return *this; | - | ||||||||||||
1796 | } | - | ||||||||||||
1797 | QTextStream &QTextStream::operator<<(float f) | - | ||||||||||||
1798 | { | - | ||||||||||||
1799 | return *this << double(f); | - | ||||||||||||
1800 | } | - | ||||||||||||
1801 | - | |||||||||||||
1802 | - | |||||||||||||
1803 | - | |||||||||||||
1804 | - | |||||||||||||
1805 | - | |||||||||||||
1806 | - | |||||||||||||
1807 | QTextStream &QTextStream::operator<<(double f) | - | ||||||||||||
1808 | { | - | ||||||||||||
1809 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1810 | do { if (!d->string
never executed: *this;return *this; never executed: } } while (0);return *this; | 0-278 | ||||||||||||
1811 | - | |||||||||||||
1812 | QLocaleData::DoubleForm form = QLocaleData::DFDecimal; | - | ||||||||||||
1813 | switch (realNumberNotation()) { | - | ||||||||||||
1814 | case executed 2 times by 1 test: FixedNotation:case FixedNotation: Executed by:
executed 2 times by 1 test: case FixedNotation: Executed by:
| 2 | ||||||||||||
1815 | form = QLocaleData::DFDecimal; | - | ||||||||||||
1816 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
1817 | case executed 5 times by 1 test: ScientificNotation:case ScientificNotation: Executed by:
executed 5 times by 1 test: case ScientificNotation: Executed by:
| 5 | ||||||||||||
1818 | form = QLocaleData::DFExponent; | - | ||||||||||||
1819 | break; executed 5 times by 1 test: break; Executed by:
| 5 | ||||||||||||
1820 | case executed 299 times by 9 tests: SmartNotation:case SmartNotation: Executed by:
executed 299 times by 9 tests: case SmartNotation: Executed by:
| 299 | ||||||||||||
1821 | form = QLocaleData::DFSignificantDigits; | - | ||||||||||||
1822 | break; executed 299 times by 9 tests: break; Executed by:
| 299 | ||||||||||||
1823 | } | - | ||||||||||||
1824 | - | |||||||||||||
1825 | uint flags = 0; | - | ||||||||||||
1826 | if (numberFlags() & ShowBase
| 0-306 | ||||||||||||
1827 | flags |= QLocaleData::ShowBase; never executed: flags |= QLocaleData::ShowBase; | 0 | ||||||||||||
1828 | if (numberFlags() & ForceSign
| 4-302 | ||||||||||||
1829 | flags |= QLocaleData::AlwaysShowSign; executed 4 times by 1 test: flags |= QLocaleData::AlwaysShowSign; Executed by:
| 4 | ||||||||||||
1830 | if (numberFlags() & UppercaseBase
| 1-305 | ||||||||||||
1831 | flags |= QLocaleData::UppercaseBase; executed 1 time by 1 test: flags |= QLocaleData::UppercaseBase; Executed by:
| 1 | ||||||||||||
1832 | if (numberFlags() & UppercaseDigits
| 7-299 | ||||||||||||
1833 | flags |= QLocaleData::CapitalEorX; executed 7 times by 1 test: flags |= QLocaleData::CapitalEorX; Executed by:
| 7 | ||||||||||||
1834 | if (numberFlags() & ForcePoint
| 6-300 | ||||||||||||
1835 | flags |= QLocaleData::Alternate; executed 6 times by 1 test: flags |= QLocaleData::Alternate; Executed by:
| 6 | ||||||||||||
1836 | if (locale() != QLocale::c()
| 0-294 | ||||||||||||
1837 | flags |= QLocaleData::ThousandsGroup; executed 12 times by 1 test: flags |= QLocaleData::ThousandsGroup; Executed by:
| 12 | ||||||||||||
1838 | if (!(locale().numberOptions() & QLocale::OmitLeadingZeroInExponent)
| 0-306 | ||||||||||||
1839 | flags |= QLocaleData::ZeroPadExponent executed 306 times by 9 tests: flags |= QLocaleData::ZeroPadExponent; Executed by:
executed 306 times by 9 tests: ;flags |= QLocaleData::ZeroPadExponent; Executed by:
executed 306 times by 9 tests: flags |= QLocaleData::ZeroPadExponent; Executed by:
| 306 | ||||||||||||
1840 | - | |||||||||||||
1841 | const QLocaleData *dd = d->locale.d->m_data; | - | ||||||||||||
1842 | QString num = dd->doubleToString(f, d->params.realNumberPrecision, form, -1, flags); | - | ||||||||||||
1843 | d->putString(num, true); | - | ||||||||||||
1844 | return executed 306 times by 9 tests: *this;return *this; Executed by:
executed 306 times by 9 tests: return *this; Executed by:
| 306 | ||||||||||||
1845 | } | - | ||||||||||||
1846 | QTextStream &QTextStream::operator<<(const QString &string) | - | ||||||||||||
1847 | { | - | ||||||||||||
1848 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1849 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 25672584, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1850 | d->putString(string); | - | ||||||||||||
1851 | return *this; | - | ||||||||||||
1852 | } | - | ||||||||||||
1853 | - | |||||||||||||
1854 | - | |||||||||||||
1855 | - | |||||||||||||
1856 | - | |||||||||||||
1857 | - | |||||||||||||
1858 | - | |||||||||||||
1859 | - | |||||||||||||
1860 | QTextStream &QTextStream::operator<<(QLatin1String string) | - | ||||||||||||
1861 | { | - | ||||||||||||
1862 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1863 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 25812598, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1864 | d->putString(string); | - | ||||||||||||
1865 | return *this; | - | ||||||||||||
1866 | } | - | ||||||||||||
1867 | QTextStream &QTextStream::operator<<(const QStringRef &string) | - | ||||||||||||
1868 | { | - | ||||||||||||
1869 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1870 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 25962613, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1871 | d->putString(string.data(), string.size()); | - | ||||||||||||
1872 | return *this; | - | ||||||||||||
1873 | } | - | ||||||||||||
1874 | - | |||||||||||||
1875 | - | |||||||||||||
1876 | - | |||||||||||||
1877 | - | |||||||||||||
1878 | - | |||||||||||||
1879 | - | |||||||||||||
1880 | - | |||||||||||||
1881 | QTextStream &QTextStream::operator<<(const QByteArray &array) | - | ||||||||||||
1882 | { | - | ||||||||||||
1883 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1884 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 26102627, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1885 | d->putString(QString::fromUtf8(array.constData(), array.length())); | - | ||||||||||||
1886 | return *this; | - | ||||||||||||
1887 | } | - | ||||||||||||
1888 | QTextStream &QTextStream::operator<<(const char *string) | - | ||||||||||||
1889 | { | - | ||||||||||||
1890 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1891 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 26312648, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1892 | d->putString(QLatin1String(string)); | - | ||||||||||||
1893 | return *this; | - | ||||||||||||
1894 | } | - | ||||||||||||
1895 | - | |||||||||||||
1896 | - | |||||||||||||
1897 | - | |||||||||||||
1898 | - | |||||||||||||
1899 | - | |||||||||||||
1900 | - | |||||||||||||
1901 | - | |||||||||||||
1902 | QTextStream &QTextStream::operator<<(const void *ptr) | - | ||||||||||||
1903 | { | - | ||||||||||||
1904 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
1905 | do { if (!d->string && !d->device) { QMessageLogger(__FILE__, 26452662, __PRETTY_FUNCTION__).warning("QTextStream: No device"); return *this; } } while (0); | - | ||||||||||||
1906 | const int oldBase = d->params.integerBase; | - | ||||||||||||
1907 | const NumberFlags oldFlags = d->params.numberFlags; | - | ||||||||||||
1908 | d->params.integerBase = 16; | - | ||||||||||||
1909 | d->params.numberFlags |= ShowBase; | - | ||||||||||||
1910 | d->putNumber(reinterpret_cast<quintptr>(ptr), false); | - | ||||||||||||
1911 | d->params.integerBase = oldBase; | - | ||||||||||||
1912 | d->params.numberFlags = oldFlags; | - | ||||||||||||
1913 | return *this; | - | ||||||||||||
1914 | } | - | ||||||||||||
1915 | QTextStream &bin(QTextStream &stream) | - | ||||||||||||
1916 | { | - | ||||||||||||
1917 | stream.setIntegerBase(2); | - | ||||||||||||
1918 | return stream; | - | ||||||||||||
1919 | } | - | ||||||||||||
1920 | QTextStream &oct(QTextStream &stream) | - | ||||||||||||
1921 | { | - | ||||||||||||
1922 | stream.setIntegerBase(8); | - | ||||||||||||
1923 | return stream; | - | ||||||||||||
1924 | } | - | ||||||||||||
1925 | QTextStream &dec(QTextStream &stream) | - | ||||||||||||
1926 | { | - | ||||||||||||
1927 | stream.setIntegerBase(10); | - | ||||||||||||
1928 | return stream; | - | ||||||||||||
1929 | } | - | ||||||||||||
1930 | QTextStream &hex(QTextStream &stream) | - | ||||||||||||
1931 | { | - | ||||||||||||
1932 | stream.setIntegerBase(16); | - | ||||||||||||
1933 | return stream; | - | ||||||||||||
1934 | } | - | ||||||||||||
1935 | QTextStream &showbase(QTextStream &stream) | - | ||||||||||||
1936 | { | - | ||||||||||||
1937 | stream.setNumberFlags(stream.numberFlags() | QTextStream::ShowBase); | - | ||||||||||||
1938 | return stream; | - | ||||||||||||
1939 | } | - | ||||||||||||
1940 | QTextStream &forcesign(QTextStream &stream) | - | ||||||||||||
1941 | { | - | ||||||||||||
1942 | stream.setNumberFlags(stream.numberFlags() | QTextStream::ForceSign); | - | ||||||||||||
1943 | return stream; | - | ||||||||||||
1944 | } | - | ||||||||||||
1945 | QTextStream &forcepoint(QTextStream &stream) | - | ||||||||||||
1946 | { | - | ||||||||||||
1947 | stream.setNumberFlags(stream.numberFlags() | QTextStream::ForcePoint); | - | ||||||||||||
1948 | return stream; | - | ||||||||||||
1949 | } | - | ||||||||||||
1950 | QTextStream &noshowbase(QTextStream &stream) | - | ||||||||||||
1951 | { | - | ||||||||||||
1952 | stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ShowBase); | - | ||||||||||||
1953 | return stream; | - | ||||||||||||
1954 | } | - | ||||||||||||
1955 | QTextStream &noforcesign(QTextStream &stream) | - | ||||||||||||
1956 | { | - | ||||||||||||
1957 | stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ForceSign); | - | ||||||||||||
1958 | return stream; | - | ||||||||||||
1959 | } | - | ||||||||||||
1960 | QTextStream &noforcepoint(QTextStream &stream) | - | ||||||||||||
1961 | { | - | ||||||||||||
1962 | stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ForcePoint); | - | ||||||||||||
1963 | return stream; | - | ||||||||||||
1964 | } | - | ||||||||||||
1965 | QTextStream &uppercasebase(QTextStream &stream) | - | ||||||||||||
1966 | { | - | ||||||||||||
1967 | stream.setNumberFlags(stream.numberFlags() | QTextStream::UppercaseBase); | - | ||||||||||||
1968 | return stream; | - | ||||||||||||
1969 | } | - | ||||||||||||
1970 | QTextStream &uppercasedigits(QTextStream &stream) | - | ||||||||||||
1971 | { | - | ||||||||||||
1972 | stream.setNumberFlags(stream.numberFlags() | QTextStream::UppercaseDigits); | - | ||||||||||||
1973 | return stream; | - | ||||||||||||
1974 | } | - | ||||||||||||
1975 | QTextStream &lowercasebase(QTextStream &stream) | - | ||||||||||||
1976 | { | - | ||||||||||||
1977 | stream.setNumberFlags(stream.numberFlags() & ~QTextStream::UppercaseBase); | - | ||||||||||||
1978 | return stream; | - | ||||||||||||
1979 | } | - | ||||||||||||
1980 | QTextStream &lowercasedigits(QTextStream &stream) | - | ||||||||||||
1981 | { | - | ||||||||||||
1982 | stream.setNumberFlags(stream.numberFlags() & ~QTextStream::UppercaseDigits); | - | ||||||||||||
1983 | return stream; | - | ||||||||||||
1984 | } | - | ||||||||||||
1985 | QTextStream &fixed(QTextStream &stream) | - | ||||||||||||
1986 | { | - | ||||||||||||
1987 | stream.setRealNumberNotation(QTextStream::FixedNotation); | - | ||||||||||||
1988 | return stream; | - | ||||||||||||
1989 | } | - | ||||||||||||
1990 | QTextStream &scientific(QTextStream &stream) | - | ||||||||||||
1991 | { | - | ||||||||||||
1992 | stream.setRealNumberNotation(QTextStream::ScientificNotation); | - | ||||||||||||
1993 | return stream; | - | ||||||||||||
1994 | } | - | ||||||||||||
1995 | QTextStream &left(QTextStream &stream) | - | ||||||||||||
1996 | { | - | ||||||||||||
1997 | stream.setFieldAlignment(QTextStream::AlignLeft); | - | ||||||||||||
1998 | return stream; | - | ||||||||||||
1999 | } | - | ||||||||||||
2000 | QTextStream &right(QTextStream &stream) | - | ||||||||||||
2001 | { | - | ||||||||||||
2002 | stream.setFieldAlignment(QTextStream::AlignRight); | - | ||||||||||||
2003 | return stream; | - | ||||||||||||
2004 | } | - | ||||||||||||
2005 | QTextStream ¢er(QTextStream &stream) | - | ||||||||||||
2006 | { | - | ||||||||||||
2007 | stream.setFieldAlignment(QTextStream::AlignCenter); | - | ||||||||||||
2008 | return stream; | - | ||||||||||||
2009 | } | - | ||||||||||||
2010 | QTextStream &endl(QTextStream &stream) | - | ||||||||||||
2011 | { | - | ||||||||||||
2012 | return stream << QLatin1Char('\n') << flush; | - | ||||||||||||
2013 | } | - | ||||||||||||
2014 | QTextStream &flush(QTextStream &stream) | - | ||||||||||||
2015 | { | - | ||||||||||||
2016 | stream.flush(); | - | ||||||||||||
2017 | return stream; | - | ||||||||||||
2018 | } | - | ||||||||||||
2019 | QTextStream &reset(QTextStream &stream) | - | ||||||||||||
2020 | { | - | ||||||||||||
2021 | stream.reset(); | - | ||||||||||||
2022 | return stream; | - | ||||||||||||
2023 | } | - | ||||||||||||
2024 | QTextStream &ws(QTextStream &stream) | - | ||||||||||||
2025 | { | - | ||||||||||||
2026 | stream.skipWhiteSpace(); | - | ||||||||||||
2027 | return stream; | - | ||||||||||||
2028 | } | - | ||||||||||||
2029 | QTextStream &bom(QTextStream &stream) | - | ||||||||||||
2030 | { | - | ||||||||||||
2031 | stream.setGenerateByteOrderMark(true); | - | ||||||||||||
2032 | return stream; | - | ||||||||||||
2033 | } | - | ||||||||||||
2034 | void QTextStream::setCodec(QTextCodec *codec) | - | ||||||||||||
2035 | { | - | ||||||||||||
2036 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2037 | qint64 seekPos = -1; | - | ||||||||||||
2038 | if (!d->readBuffer.isEmpty()) { | - | ||||||||||||
2039 | if (!d->device->isSequential()) { | - | ||||||||||||
2040 | seekPos = pos(); | - | ||||||||||||
2041 | } | - | ||||||||||||
2042 | } | - | ||||||||||||
2043 | d->codec = codec; | - | ||||||||||||
2044 | if (seekPos >=0 && !d->readBuffer.isEmpty()) | - | ||||||||||||
2045 | seek(seekPos); | - | ||||||||||||
2046 | } | - | ||||||||||||
2047 | void QTextStream::setCodec(const char *codecName) | - | ||||||||||||
2048 | { | - | ||||||||||||
2049 | QTextCodec *codec = QTextCodec::codecForName(codecName); | - | ||||||||||||
2050 | if (codec) | - | ||||||||||||
2051 | setCodec(codec); | - | ||||||||||||
2052 | } | - | ||||||||||||
2053 | - | |||||||||||||
2054 | - | |||||||||||||
2055 | - | |||||||||||||
2056 | - | |||||||||||||
2057 | - | |||||||||||||
2058 | - | |||||||||||||
2059 | QTextCodec *QTextStream::codec() const | - | ||||||||||||
2060 | { | - | ||||||||||||
2061 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2062 | return d->codec; | - | ||||||||||||
2063 | } | - | ||||||||||||
2064 | void QTextStream::setAutoDetectUnicode(bool enabled) | - | ||||||||||||
2065 | { | - | ||||||||||||
2066 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2067 | d->autoDetectUnicode = enabled; | - | ||||||||||||
2068 | } | - | ||||||||||||
2069 | - | |||||||||||||
2070 | - | |||||||||||||
2071 | - | |||||||||||||
2072 | - | |||||||||||||
2073 | - | |||||||||||||
2074 | - | |||||||||||||
2075 | - | |||||||||||||
2076 | bool QTextStream::autoDetectUnicode() const | - | ||||||||||||
2077 | { | - | ||||||||||||
2078 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2079 | return d->autoDetectUnicode; | - | ||||||||||||
2080 | } | - | ||||||||||||
2081 | void QTextStream::setGenerateByteOrderMark(bool generate) | - | ||||||||||||
2082 | { | - | ||||||||||||
2083 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2084 | if (d->writeBuffer.isEmpty()
| 0-3 | ||||||||||||
2085 | if (generate)d->writeConverterState.flags&= ~QTextCodec::IgnoreHeader; | - | ||||||||||||
else | ||||||||||||||
d->writeConverterState.flags |=setFlag(QTextCodec::IgnoreHeader;, !generate); | ||||||||||||||
2086 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
2087 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
2088 | bool QTextStream::generateByteOrderMark() const | - | ||||||||||||
2089 | { | - | ||||||||||||
2090 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2091 | return (d->writeConverterState.flags & QTextCodec::IgnoreHeader) == 0; | - | ||||||||||||
2092 | } | - | ||||||||||||
2093 | void QTextStream::setLocale(const QLocale &locale) | - | ||||||||||||
2094 | { | - | ||||||||||||
2095 | QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2096 | d->locale = locale; | - | ||||||||||||
2097 | } | - | ||||||||||||
2098 | QLocale QTextStream::locale() const | - | ||||||||||||
2099 | { | - | ||||||||||||
2100 | const QTextStreamPrivate * const d = d_func(); | - | ||||||||||||
2101 | return d->locale; | - | ||||||||||||
2102 | } | - | ||||||||||||
2103 | - | |||||||||||||
2104 | - | |||||||||||||
Switch to Source code | Preprocessed file |