io/qtextstream.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42//#define QTEXTSTREAM_DEBUG -
43static const int QTEXTSTREAM_BUFFERSIZE = 16384; -
44 -
45/*! -
46 \class QTextStream -
47 \inmodule QtCore -
48 -
49 \brief The QTextStream class provides a convenient interface for -
50 reading and writing text. -
51 -
52 \ingroup io -
53 \ingroup string-processing -
54 \reentrant -
55 -
56 QTextStream can operate on a QIODevice, a QByteArray or a -
57 QString. Using QTextStream's streaming operators, you can -
58 conveniently read and write words, lines and numbers. For -
59 generating text, QTextStream supports formatting options for field -
60 padding and alignment, and formatting of numbers. Example: -
61 -
62 \snippet code/src_corelib_io_qtextstream.cpp 0 -
63 -
64 It's also common to use QTextStream to read console input and write -
65 console output. QTextStream is locale aware, and will automatically decode -
66 standard input using the correct codec. Example: -
67 -
68 \snippet code/src_corelib_io_qtextstream.cpp 1 -
69 -
70 Besides using QTextStream's constructors, you can also set the -
71 device or string QTextStream operates on by calling setDevice() or -
72 setString(). You can seek to a position by calling seek(), and -
73 atEnd() will return true when there is no data left to be read. If -
74 you call flush(), QTextStream will empty all data from its write -
75 buffer into the device and call flush() on the device. -
76 -
77 Internally, QTextStream uses a Unicode based buffer, and -
78 QTextCodec is used by QTextStream to automatically support -
79 different character sets. By default, QTextCodec::codecForLocale() -
80 is used for reading and writing, but you can also set the codec by -
81 calling setCodec(). Automatic Unicode detection is also -
82 supported. When this feature is enabled (the default behavior), -
83 QTextStream will detect the UTF-16 or the UTF-32 BOM (Byte Order Mark) and -
84 switch to the appropriate UTF codec when reading. QTextStream -
85 does not write a BOM by default, but you can enable this by calling -
86 setGenerateByteOrderMark(true). When QTextStream operates on a QString -
87 directly, the codec is disabled. -
88 -
89 There are three general ways to use QTextStream when reading text -
90 files: -
91 -
92 \list -
93 -
94 \li Chunk by chunk, by calling readLine() or readAll(). -
95 -
96 \li Word by word. QTextStream supports streaming into QStrings, -
97 QByteArrays and char* buffers. Words are delimited by space, and -
98 leading white space is automatically skipped. -
99 -
100 \li Character by character, by streaming into QChar or char types. -
101 This method is often used for convenient input handling when -
102 parsing files, independent of character encoding and end-of-line -
103 semantics. To skip white space, call skipWhiteSpace(). -
104 -
105 \endlist -
106 -
107 Since the text stream uses a buffer, you should not read from -
108 the stream using the implementation of a superclass. For instance, -
109 if you have a QFile and read from it directly using -
110 QFile::readLine() instead of using the stream, the text stream's -
111 internal position will be out of sync with the file's position. -
112 -
113 By default, when reading numbers from a stream of text, -
114 QTextStream will automatically detect the number's base -
115 representation. For example, if the number starts with "0x", it is -
116 assumed to be in hexadecimal form. If it starts with the digits -
117 1-9, it is assumed to be in decimal form, and so on. You can set -
118 the integer base, thereby disabling the automatic detection, by -
119 calling setIntegerBase(). Example: -
120 -
121 \snippet code/src_corelib_io_qtextstream.cpp 2 -
122 -
123 QTextStream supports many formatting options for generating text. -
124 You can set the field width and pad character by calling -
125 setFieldWidth() and setPadChar(). Use setFieldAlignment() to set -
126 the alignment within each field. For real numbers, call -
127 setRealNumberNotation() and setRealNumberPrecision() to set the -
128 notation (SmartNotation, ScientificNotation, FixedNotation) and precision in -
129 digits of the generated number. Some extra number formatting -
130 options are also available through setNumberFlags(). -
131 -
132 \keyword QTextStream manipulators -
133 -
134 Like \c <iostream> in the standard C++ library, QTextStream also -
135 defines several global manipulator functions: -
136 -
137 \table -
138 \header \li Manipulator \li Description -
139 \row \li \c bin \li Same as setIntegerBase(2). -
140 \row \li \c oct \li Same as setIntegerBase(8). -
141 \row \li \c dec \li Same as setIntegerBase(10). -
142 \row \li \c hex \li Same as setIntegerBase(16). -
143 \row \li \c showbase \li Same as setNumberFlags(numberFlags() | ShowBase). -
144 \row \li \c forcesign \li Same as setNumberFlags(numberFlags() | ForceSign). -
145 \row \li \c forcepoint \li Same as setNumberFlags(numberFlags() | ForcePoint). -
146 \row \li \c noshowbase \li Same as setNumberFlags(numberFlags() & ~ShowBase). -
147 \row \li \c noforcesign \li Same as setNumberFlags(numberFlags() & ~ForceSign). -
148 \row \li \c noforcepoint \li Same as setNumberFlags(numberFlags() & ~ForcePoint). -
149 \row \li \c uppercasebase \li Same as setNumberFlags(numberFlags() | UppercaseBase). -
150 \row \li \c uppercasedigits \li Same as setNumberFlags(numberFlags() | UppercaseDigits). -
151 \row \li \c lowercasebase \li Same as setNumberFlags(numberFlags() & ~UppercaseBase). -
152 \row \li \c lowercasedigits \li Same as setNumberFlags(numberFlags() & ~UppercaseDigits). -
153 \row \li \c fixed \li Same as setRealNumberNotation(FixedNotation). -
154 \row \li \c scientific \li Same as setRealNumberNotation(ScientificNotation). -
155 \row \li \c left \li Same as setFieldAlignment(AlignLeft). -
156 \row \li \c right \li Same as setFieldAlignment(AlignRight). -
157 \row \li \c center \li Same as setFieldAlignment(AlignCenter). -
158 \row \li \c endl \li Same as operator<<('\\n') and flush(). -
159 \row \li \c flush \li Same as flush(). -
160 \row \li \c reset \li Same as reset(). -
161 \row \li \c ws \li Same as skipWhiteSpace(). -
162 \row \li \c bom \li Same as setGenerateByteOrderMark(true). -
163 \endtable -
164 -
165 In addition, Qt provides three global manipulators that take a -
166 parameter: qSetFieldWidth(), qSetPadChar(), and -
167 qSetRealNumberPrecision(). -
168 -
169 \sa QDataStream, QIODevice, QFile, QBuffer, QTcpSocket, {Codecs Example} -
170*/ -
171 -
172/*! \enum QTextStream::RealNumberNotation -
173 -
174 This enum specifies which notations to use for expressing \c -
175 float and \c double as strings. -
176 -
177 \value ScientificNotation Scientific notation (\c{printf()}'s \c %e flag). -
178 \value FixedNotation Fixed-point notation (\c{printf()}'s \c %f flag). -
179 \value SmartNotation Scientific or fixed-point notation, depending on which makes most sense (\c{printf()}'s \c %g flag). -
180 -
181 \sa setRealNumberNotation() -
182*/ -
183 -
184/*! \enum QTextStream::FieldAlignment -
185 -
186 This enum specifies how to align text in fields when the field is -
187 wider than the text that occupies it. -
188 -
189 \value AlignLeft Pad on the right side of fields. -
190 \value AlignRight Pad on the left side of fields. -
191 \value AlignCenter Pad on both sides of field. -
192 \value AlignAccountingStyle Same as AlignRight, except that the -
193 sign of a number is flush left. -
194 -
195 \sa setFieldAlignment() -
196*/ -
197 -
198/*! \enum QTextStream::NumberFlag -
199 -
200 This enum specifies various flags that can be set to affect the -
201 output of integers, \c{float}s, and \c{double}s. -
202 -
203 \value ShowBase Show the base as a prefix if the base -
204 is 16 ("0x"), 8 ("0"), or 2 ("0b"). -
205 \value ForcePoint Always put the decimal separator in numbers, even if -
206 there are no decimals. -
207 \value ForceSign Always put the sign in numbers, even for positive numbers. -
208 \value UppercaseBase Use uppercase versions of base prefixes ("0X", "0B"). -
209 \value UppercaseDigits Use uppercase letters for expressing -
210 digits 10 to 35 instead of lowercase. -
211 -
212 \sa setNumberFlags() -
213*/ -
214 -
215/*! \enum QTextStream::Status -
216 -
217 This enum describes the current status of the text stream. -
218 -
219 \value Ok The text stream is operating normally. -
220 \value ReadPastEnd The text stream has read past the end of the -
221 data in the underlying device. -
222 \value ReadCorruptData The text stream has read corrupt data. -
223 \value WriteFailed The text stream cannot write to the underlying device. -
224 -
225 \sa status() -
226*/ -
227 -
228#include "qtextstream.h" -
229#include "qbuffer.h" -
230#include "qfile.h" -
231#include "qnumeric.h" -
232#ifndef QT_NO_TEXTCODEC -
233#include "qtextcodec.h" -
234#endif -
235#ifndef Q_OS_WINCE -
236#include <locale.h> -
237#endif -
238#include "private/qlocale_p.h" -
239 -
240#include <stdlib.h> -
241#include <limits.h> -
242#include <new> -
243 -
244#if defined QTEXTSTREAM_DEBUG -
245#include <ctype.h> -
246 -
247QT_BEGIN_NAMESPACE -
248 -
249// Returns a human readable representation of the first \a len -
250// characters in \a data. -
251static QByteArray qt_prettyDebug(const char *data, int len, int maxSize) -
252{ -
253 if (!data) return "(null)"; -
254 QByteArray out; -
255 for (int i = 0; i < len; ++i) { -
256 char c = data[i]; -
257 if (isprint(int(uchar(c)))) { -
258 out += c; -
259 } else switch (c) { -
260 case '\n': out += "\\n"; break; -
261 case '\r': out += "\\r"; break; -
262 case '\t': out += "\\t"; break; -
263 default: -
264 QString tmp; -
265 tmp.sprintf("\\x%x", (unsigned int)(unsigned char)c); -
266 out += tmp.toLatin1(); -
267 } -
268 } -
269 -
270 if (len < maxSize) -
271 out += "..."; -
272 -
273 return out; -
274} -
275QT_END_NAMESPACE -
276 -
277#endif -
278 -
279// A precondition macro -
280#define Q_VOID -
281#define CHECK_VALID_STREAM(x) do { \ -
282 if (!d->string && !d->device) { \ -
283 qWarning("QTextStream: No device"); \ -
284 return x; \ -
285 } } while (0) -
286 -
287// Base implementations of operator>> for ints and reals -
288#define IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(type) do { \ -
289 Q_D(QTextStream); \ -
290 CHECK_VALID_STREAM(*this); \ -
291 qulonglong tmp; \ -
292 switch (d->getNumber(&tmp)) { \ -
293 case QTextStreamPrivate::npsOk: \ -
294 i = (type)tmp; \ -
295 break; \ -
296 case QTextStreamPrivate::npsMissingDigit: \ -
297 case QTextStreamPrivate::npsInvalidPrefix: \ -
298 i = (type)0; \ -
299 setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); \ -
300 break; \ -
301 } \ -
302 return *this; } while (0) -
303 -
304#define IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR(type) do { \ -
305 Q_D(QTextStream); \ -
306 CHECK_VALID_STREAM(*this); \ -
307 double tmp; \ -
308 if (d->getReal(&tmp)) { \ -
309 f = (type)tmp; \ -
310 } else { \ -
311 f = (type)0; \ -
312 setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); \ -
313 } \ -
314 return *this; } while (0) -
315 -
316QT_BEGIN_NAMESPACE -
317 -
318#ifndef QT_NO_QOBJECT -
319class QDeviceClosedNotifier : public QObject -
320{ -
321 Q_OBJECT -
322public: -
323 inline QDeviceClosedNotifier() -
324 { } -
325 -
326 inline void setupDevice(QTextStream *stream, QIODevice *device) -
327 { -
328 disconnect();
executed (the execution status of this line is deduced): disconnect();
-
329 if (device)
evaluated: device
TRUEFALSE
yes
Evaluation Count:3398
yes
Evaluation Count:1
1-3398
330 connect(device, SIGNAL(aboutToClose()), this, SLOT(flushStream()));
executed: connect(device, "2""aboutToClose()", this, "1""flushStream()");
Execution Count:3398
3398
331 this->stream = stream;
executed (the execution status of this line is deduced): this->stream = stream;
-
332 }
executed: }
Execution Count:3399
3399
333 -
334public Q_SLOTS: -
335 inline void flushStream() { stream->flush(); }
executed: }
Execution Count:230
230
336 -
337private: -
338 QTextStream *stream; -
339}; -
340#endif -
341 -
342//------------------------------------------------------------------- -
343class QTextStreamPrivate -
344{ -
345 Q_DECLARE_PUBLIC(QTextStream) -
346public: -
347 QTextStreamPrivate(QTextStream *q_ptr); -
348 ~QTextStreamPrivate(); -
349 void reset(); -
350 -
351 // device -
352 QIODevice *device; -
353#ifndef QT_NO_QOBJECT -
354 QDeviceClosedNotifier deviceClosedNotifier; -
355#endif -
356 bool deleteDevice; -
357 -
358 // string -
359 QString *string; -
360 int stringOffset; -
361 QIODevice::OpenMode stringOpenMode; -
362 -
363#ifndef QT_NO_TEXTCODEC -
364 // codec -
365 QTextCodec *codec; -
366 QTextCodec::ConverterState readConverterState; -
367 QTextCodec::ConverterState writeConverterState; -
368 QTextCodec::ConverterState *readConverterSavedState; -
369 bool autoDetectUnicode; -
370#endif -
371 -
372 // i/o -
373 enum TokenDelimiter { -
374 Space, -
375 NotSpace, -
376 EndOfLine -
377 }; -
378 -
379 QString read(int maxlen); -
380 bool scan(const QChar **ptr, int *tokenLength, -
381 int maxlen, TokenDelimiter delimiter); -
382 inline const QChar *readPtr() const; -
383 inline void consumeLastToken(); -
384 inline void consume(int nchars); -
385 void saveConverterState(qint64 newPos); -
386 void restoreToSavedConverterState(); -
387 int lastTokenSize; -
388 -
389 // Return value type for getNumber() -
390 enum NumberParsingStatus { -
391 npsOk, -
392 npsMissingDigit, -
393 npsInvalidPrefix -
394 }; -
395 -
396 inline bool getChar(QChar *ch); -
397 inline void ungetChar(QChar ch); -
398 NumberParsingStatus getNumber(qulonglong *l); -
399 bool getReal(double *f); -
400 -
401 inline void write(const QString &data); -
402 inline void putString(const QString &ch, bool number = false); -
403 void putNumber(qulonglong number, bool negative); -
404 -
405 // buffers -
406 bool fillReadBuffer(qint64 maxBytes = -1); -
407 void resetReadBuffer(); -
408 void flushWriteBuffer(); -
409 QString writeBuffer; -
410 QString readBuffer; -
411 int readBufferOffset; -
412 int readConverterSavedStateOffset; //the offset between readBufferStartDevicePos and that start of the buffer -
413 qint64 readBufferStartDevicePos; -
414 -
415 // streaming parameters -
416 int realNumberPrecision; -
417 int integerBase; -
418 int fieldWidth; -
419 QChar padChar; -
420 QTextStream::FieldAlignment fieldAlignment; -
421 QTextStream::RealNumberNotation realNumberNotation; -
422 QTextStream::NumberFlags numberFlags; -
423 -
424 // status -
425 QTextStream::Status status; -
426 -
427 QLocale locale; -
428 -
429 QTextStream *q_ptr; -
430}; -
431 -
432/*! -
433 \internal -
434*/ -
435QTextStreamPrivate::QTextStreamPrivate(QTextStream *q_ptr) -
436 : -
437#ifndef QT_NO_TEXTCODEC -
438 readConverterSavedState(0), -
439#endif -
440 readConverterSavedStateOffset(0), -
441 locale(QLocale::c()) -
442{ -
443 this->q_ptr = q_ptr;
executed (the execution status of this line is deduced): this->q_ptr = q_ptr;
-
444 reset();
executed (the execution status of this line is deduced): reset();
-
445}
executed: }
Execution Count:5122
5122
446 -
447/*! -
448 \internal -
449*/ -
450QTextStreamPrivate::~QTextStreamPrivate() -
451{ -
452 if (deleteDevice) {
evaluated: deleteDevice
TRUEFALSE
yes
Evaluation Count:577
yes
Evaluation Count:4545
577-4545
453#ifndef QT_NO_QOBJECT -
454 device->blockSignals(true);
executed (the execution status of this line is deduced): device->blockSignals(true);
-
455#endif -
456 delete device;
executed (the execution status of this line is deduced): delete device;
-
457 }
executed: }
Execution Count:577
577
458#ifndef QT_NO_TEXTCODEC -
459 delete readConverterSavedState;
executed (the execution status of this line is deduced): delete readConverterSavedState;
-
460#endif -
461}
executed: }
Execution Count:5122
5122
462 -
463#ifndef QT_NO_TEXTCODEC -
464static void resetCodecConverterStateHelper(QTextCodec::ConverterState *state) -
465{ -
466 state->~ConverterState();
executed (the execution status of this line is deduced): state->~ConverterState();
-
467 new (state) QTextCodec::ConverterState;
executed (the execution status of this line is deduced): new (state) QTextCodec::ConverterState;
-
468}
executed: }
Execution Count:440993
440993
469 -
470static void copyConverterStateHelper(QTextCodec::ConverterState *dest, -
471 const QTextCodec::ConverterState *src) -
472{ -
473 // ### QTextCodec::ConverterState's copy constructors and assignments are -
474 // private. This function copies the structure manually. -
475 Q_ASSERT(!src->d);
executed (the execution status of this line is deduced): qt_noop();
-
476 dest->flags = src->flags;
executed (the execution status of this line is deduced): dest->flags = src->flags;
-
477 dest->invalidChars = src->invalidChars;
executed (the execution status of this line is deduced): dest->invalidChars = src->invalidChars;
-
478 dest->state_data[0] = src->state_data[0];
executed (the execution status of this line is deduced): dest->state_data[0] = src->state_data[0];
-
479 dest->state_data[1] = src->state_data[1];
executed (the execution status of this line is deduced): dest->state_data[1] = src->state_data[1];
-
480 dest->state_data[2] = src->state_data[2];
executed (the execution status of this line is deduced): dest->state_data[2] = src->state_data[2];
-
481}
executed: }
Execution Count:2623
2623
482#endif -
483 -
484/*! -
485 \internal -
486*/ -
487void QTextStreamPrivate::reset() -
488{ -
489 realNumberPrecision = 6;
executed (the execution status of this line is deduced): realNumberPrecision = 6;
-
490 integerBase = 0;
executed (the execution status of this line is deduced): integerBase = 0;
-
491 fieldWidth = 0;
executed (the execution status of this line is deduced): fieldWidth = 0;
-
492 padChar = QLatin1Char(' ');
executed (the execution status of this line is deduced): padChar = QLatin1Char(' ');
-
493 fieldAlignment = QTextStream::AlignRight;
executed (the execution status of this line is deduced): fieldAlignment = QTextStream::AlignRight;
-
494 realNumberNotation = QTextStream::SmartNotation;
executed (the execution status of this line is deduced): realNumberNotation = QTextStream::SmartNotation;
-
495 numberFlags = 0;
executed (the execution status of this line is deduced): numberFlags = 0;
-
496 -
497 device = 0;
executed (the execution status of this line is deduced): device = 0;
-
498 deleteDevice = false;
executed (the execution status of this line is deduced): deleteDevice = false;
-
499 string = 0;
executed (the execution status of this line is deduced): string = 0;
-
500 stringOffset = 0;
executed (the execution status of this line is deduced): stringOffset = 0;
-
501 stringOpenMode = QIODevice::NotOpen;
executed (the execution status of this line is deduced): stringOpenMode = QIODevice::NotOpen;
-
502 -
503 readBufferOffset = 0;
executed (the execution status of this line is deduced): readBufferOffset = 0;
-
504 readBufferStartDevicePos = 0;
executed (the execution status of this line is deduced): readBufferStartDevicePos = 0;
-
505 lastTokenSize = 0;
executed (the execution status of this line is deduced): lastTokenSize = 0;
-
506 -
507#ifndef QT_NO_TEXTCODEC -
508 codec = QTextCodec::codecForLocale();
executed (the execution status of this line is deduced): codec = QTextCodec::codecForLocale();
-
509 resetCodecConverterStateHelper(&readConverterState);
executed (the execution status of this line is deduced): resetCodecConverterStateHelper(&readConverterState);
-
510 resetCodecConverterStateHelper(&writeConverterState);
executed (the execution status of this line is deduced): resetCodecConverterStateHelper(&writeConverterState);
-
511 delete readConverterSavedState;
executed (the execution status of this line is deduced): delete readConverterSavedState;
-
512 readConverterSavedState = 0;
executed (the execution status of this line is deduced): readConverterSavedState = 0;
-
513 writeConverterState.flags |= QTextCodec::IgnoreHeader;
executed (the execution status of this line is deduced): writeConverterState.flags |= QTextCodec::IgnoreHeader;
-
514 autoDetectUnicode = true;
executed (the execution status of this line is deduced): autoDetectUnicode = true;
-
515#endif -
516}
executed: }
Execution Count:5138
5138
517 -
518/*! -
519 \internal -
520*/ -
521bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) -
522{ -
523 // no buffer next to the QString itself; this function should only -
524 // be called internally, for devices. -
525 Q_ASSERT(!string);
executed (the execution status of this line is deduced): qt_noop();
-
526 Q_ASSERT(device);
executed (the execution status of this line is deduced): qt_noop();
-
527 -
528 // handle text translation and bypass the Text flag in the device. -
529 bool textModeEnabled = device->isTextModeEnabled();
executed (the execution status of this line is deduced): bool textModeEnabled = device->isTextModeEnabled();
-
530 if (textModeEnabled)
evaluated: textModeEnabled
TRUEFALSE
yes
Evaluation Count:41040032
yes
Evaluation Count:2424
2424-41040032
531 device->setTextModeEnabled(false);
executed: device->setTextModeEnabled(false);
Execution Count:41040032
41040032
532 -
533 // read raw data into a temporary buffer -
534 char buf[QTEXTSTREAM_BUFFERSIZE];
executed (the execution status of this line is deduced): char buf[QTEXTSTREAM_BUFFERSIZE];
-
535 qint64 bytesRead = 0;
executed (the execution status of this line is deduced): qint64 bytesRead = 0;
-
536#if defined(Q_OS_WIN) -
537 // On Windows, there is no non-blocking stdin - so we fall back to reading -
538 // lines instead. If there is no QOBJECT, we read lines for all sequential -
539 // devices; otherwise, we read lines only for stdin. -
540 QFile *file = 0; -
541 Q_UNUSED(file); -
542 if (device->isSequential() -
543#if !defined(QT_NO_QOBJECT) -
544 && (file = qobject_cast<QFile *>(device)) && file->handle() == 0 -
545#endif -
546 ) { -
547 if (maxBytes != -1) -
548 bytesRead = device->readLine(buf, qMin<qint64>(sizeof(buf), maxBytes)); -
549 else -
550 bytesRead = device->readLine(buf, sizeof(buf)); -
551 } else -
552#endif -
553 { -
554 if (maxBytes != -1)
evaluated: maxBytes != -1
TRUEFALSE
yes
Evaluation Count:41035294
yes
Evaluation Count:7162
7162-41035294
555 bytesRead = device->read(buf, qMin<qint64>(sizeof(buf), maxBytes));
executed: bytesRead = device->read(buf, qMin<qint64>(sizeof(buf), maxBytes));
Execution Count:41035294
41035294
556 else -
557 bytesRead = device->read(buf, sizeof(buf));
executed: bytesRead = device->read(buf, sizeof(buf));
Execution Count:7162
7162
558 } -
559 -
560#ifndef QT_NO_TEXTCODEC -
561 // codec auto detection, explicitly defaults to locale encoding if the -
562 // codec has been set to 0. -
563 if (!codec || autoDetectUnicode) {
partially evaluated: !codec
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41042456
evaluated: autoDetectUnicode
TRUEFALSE
yes
Evaluation Count:4493
yes
Evaluation Count:41037963
0-41042456
564 autoDetectUnicode = false;
executed (the execution status of this line is deduced): autoDetectUnicode = false;
-
565 -
566 codec = QTextCodec::codecForUtfText(QByteArray::fromRawData(buf, bytesRead), codec);
executed (the execution status of this line is deduced): codec = QTextCodec::codecForUtfText(QByteArray::fromRawData(buf, bytesRead), codec);
-
567 if (!codec) {
partially evaluated: !codec
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4493
0-4493
568 codec = QTextCodec::codecForLocale();
never executed (the execution status of this line is deduced): codec = QTextCodec::codecForLocale();
-
569 writeConverterState.flags |= QTextCodec::IgnoreHeader;
never executed (the execution status of this line is deduced): writeConverterState.flags |= QTextCodec::IgnoreHeader;
-
570 }
never executed: }
0
571 }
executed: }
Execution Count:4493
4493
572#if defined (QTEXTSTREAM_DEBUG) -
573 qDebug("QTextStreamPrivate::fillReadBuffer(), using %s codec", -
574 codec->name().constData()); -
575#endif -
576#endif -
577 -
578#if defined (QTEXTSTREAM_DEBUG) -
579 qDebug("QTextStreamPrivate::fillReadBuffer(), device->read(\"%s\", %d) == %d", -
580 qt_prettyDebug(buf, qMin(32,int(bytesRead)) , int(bytesRead)).constData(), sizeof(buf), int(bytesRead)); -
581#endif -
582 -
583 if (bytesRead <= 0)
evaluated: bytesRead <= 0
TRUEFALSE
yes
Evaluation Count:2512
yes
Evaluation Count:41039944
2512-41039944
584 return false;
executed: return false;
Execution Count:2512
2512
585 -
586 int oldReadBufferSize = readBuffer.size();
executed (the execution status of this line is deduced): int oldReadBufferSize = readBuffer.size();
-
587#ifndef QT_NO_TEXTCODEC -
588 // convert to unicode -
589 readBuffer += codec->toUnicode(buf, bytesRead, &readConverterState);
executed (the execution status of this line is deduced): readBuffer += codec->toUnicode(buf, bytesRead, &readConverterState);
-
590#else -
591 readBuffer += QString::fromLatin1(QByteArray(buf, bytesRead).constData()); -
592#endif -
593 -
594 // reset the Text flag. -
595 if (textModeEnabled)
evaluated: textModeEnabled
TRUEFALSE
yes
Evaluation Count:41038132
yes
Evaluation Count:1812
1812-41038132
596 device->setTextModeEnabled(true);
executed: device->setTextModeEnabled(true);
Execution Count:41038132
41038132
597 -
598 // remove all '\r\n' in the string. -
599 if (readBuffer.size() > oldReadBufferSize && textModeEnabled) {
evaluated: readBuffer.size() > oldReadBufferSize
TRUEFALSE
yes
Evaluation Count:41039262
yes
Evaluation Count:682
evaluated: textModeEnabled
TRUEFALSE
yes
Evaluation Count:41037806
yes
Evaluation Count:1456
682-41039262
600 QChar CR = QLatin1Char('\r');
executed (the execution status of this line is deduced): QChar CR = QLatin1Char('\r');
-
601 QChar *writePtr = readBuffer.data() + oldReadBufferSize;
executed (the execution status of this line is deduced): QChar *writePtr = readBuffer.data() + oldReadBufferSize;
-
602 QChar *readPtr = readBuffer.data() + oldReadBufferSize;
executed (the execution status of this line is deduced): QChar *readPtr = readBuffer.data() + oldReadBufferSize;
-
603 QChar *endPtr = readBuffer.data() + readBuffer.size();
executed (the execution status of this line is deduced): QChar *endPtr = readBuffer.data() + readBuffer.size();
-
604 -
605 int n = oldReadBufferSize;
executed (the execution status of this line is deduced): int n = oldReadBufferSize;
-
606 if (readPtr < endPtr) {
partially evaluated: readPtr < endPtr
TRUEFALSE
yes
Evaluation Count:41037806
no
Evaluation Count:0
0-41037806
607 // Cut-off to avoid unnecessary self-copying. -
608 while (*readPtr++ != CR) {
evaluated: *readPtr++ != CR
TRUEFALSE
yes
Evaluation Count:63891754
yes
Evaluation Count:110
110-63891754
609 ++n;
executed (the execution status of this line is deduced): ++n;
-
610 if (++writePtr == endPtr)
evaluated: ++writePtr == endPtr
TRUEFALSE
yes
Evaluation Count:41037696
yes
Evaluation Count:22854058
22854058-41037696
611 break;
executed: break;
Execution Count:41037696
41037696
612 }
executed: }
Execution Count:22854058
22854058
613 }
executed: }
Execution Count:41037806
41037806
614 while (readPtr < endPtr) {
evaluated: readPtr < endPtr
TRUEFALSE
yes
Evaluation Count:146620
yes
Evaluation Count:41037806
146620-41037806
615 QChar ch = *readPtr++;
executed (the execution status of this line is deduced): QChar ch = *readPtr++;
-
616 if (ch != CR) {
evaluated: ch != CR
TRUEFALSE
yes
Evaluation Count:124415
yes
Evaluation Count:22205
22205-124415
617 *writePtr++ = ch;
executed (the execution status of this line is deduced): *writePtr++ = ch;
-
618 } else {
executed: }
Execution Count:124415
124415
619 if (n < readBufferOffset)
partially evaluated: n < readBufferOffset
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22205
0-22205
620 --readBufferOffset;
never executed: --readBufferOffset;
0
621 --bytesRead;
executed (the execution status of this line is deduced): --bytesRead;
-
622 }
executed: }
Execution Count:22205
22205
623 ++n;
executed (the execution status of this line is deduced): ++n;
-
624 }
executed: }
Execution Count:146620
146620
625 readBuffer.resize(writePtr - readBuffer.data());
executed (the execution status of this line is deduced): readBuffer.resize(writePtr - readBuffer.data());
-
626 }
executed: }
Execution Count:41037806
41037806
627 -
628#if defined (QTEXTSTREAM_DEBUG) -
629 qDebug("QTextStreamPrivate::fillReadBuffer() read %d bytes from device. readBuffer = [%s]", int(bytesRead), -
630 qt_prettyDebug(readBuffer.toLatin1(), readBuffer.size(), readBuffer.size()).data()); -
631#endif -
632 return true;
executed: return true;
Execution Count:41039944
41039944
633} -
634 -
635/*! -
636 \internal -
637*/ -
638void QTextStreamPrivate::resetReadBuffer() -
639{ -
640 readBuffer.clear();
executed (the execution status of this line is deduced): readBuffer.clear();
-
641 readBufferOffset = 0;
executed (the execution status of this line is deduced): readBufferOffset = 0;
-
642 readBufferStartDevicePos = (device ? device->pos() : 0);
evaluated: device
TRUEFALSE
yes
Evaluation Count:214479
yes
Evaluation Count:1
1-214479
643}
executed: }
Execution Count:214480
214480
644 -
645/*! -
646 \internal -
647*/ -
648void QTextStreamPrivate::flushWriteBuffer() -
649{ -
650 // no buffer next to the QString itself; this function should only -
651 // be called internally, for devices. -
652 if (string || !device)
evaluated: string
TRUEFALSE
yes
Evaluation Count:15360
yes
Evaluation Count:249715
evaluated: !device
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:249702
13-249715
653 return;
executed: return;
Execution Count:15373
15373
654 -
655 // Stream went bye-bye already. Appending further data may succeed again, -
656 // but would create a corrupted stream anyway. -
657 if (status != QTextStream::Ok)
evaluated: status != QTextStream::Ok
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:249699
3-249699
658 return;
executed: return;
Execution Count:3
3
659 -
660 if (writeBuffer.isEmpty())
evaluated: writeBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:214758
yes
Evaluation Count:34941
34941-214758
661 return;
executed: return;
Execution Count:214758
214758
662 -
663#if defined (Q_OS_WIN) -
664 // handle text translation and bypass the Text flag in the device. -
665 bool textModeEnabled = device->isTextModeEnabled(); -
666 if (textModeEnabled) { -
667 device->setTextModeEnabled(false); -
668 writeBuffer.replace(QLatin1Char('\n'), QLatin1String("\r\n")); -
669 } -
670#endif -
671 -
672#ifndef QT_NO_TEXTCODEC -
673 if (!codec)
partially evaluated: !codec
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34941
0-34941
674 codec = QTextCodec::codecForLocale();
never executed: codec = QTextCodec::codecForLocale();
0
675#if defined (QTEXTSTREAM_DEBUG) -
676 qDebug("QTextStreamPrivate::flushWriteBuffer(), using %s codec (%s generating BOM)", -
677 codec->name().constData(), writeConverterState.flags & QTextCodec::IgnoreHeader ? "not" : ""); -
678#endif -
679 -
680 // convert from unicode to raw data -
681 QByteArray data = codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState);
executed (the execution status of this line is deduced): QByteArray data = codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState);
-
682#else -
683 QByteArray data = writeBuffer.toLocal8Bit(); -
684#endif -
685 writeBuffer.clear();
executed (the execution status of this line is deduced): writeBuffer.clear();
-
686 -
687 // write raw data to the device -
688 qint64 bytesWritten = device->write(data);
executed (the execution status of this line is deduced): qint64 bytesWritten = device->write(data);
-
689#if defined (QTEXTSTREAM_DEBUG) -
690 qDebug("QTextStreamPrivate::flushWriteBuffer(), device->write(\"%s\") == %d", -
691 qt_prettyDebug(data.constData(), qMin(data.size(),32), data.size()).constData(), int(bytesWritten)); -
692#endif -
693 if (bytesWritten <= 0) {
evaluated: bytesWritten <= 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:34939
2-34939
694 status = QTextStream::WriteFailed;
executed (the execution status of this line is deduced): status = QTextStream::WriteFailed;
-
695 return;
executed: return;
Execution Count:2
2
696 } -
697 -
698#if defined (Q_OS_WIN) -
699 // replace the text flag -
700 if (textModeEnabled) -
701 device->setTextModeEnabled(true); -
702#endif -
703 -
704 // flush the file -
705#ifndef QT_NO_QOBJECT -
706 QFileDevice *file = qobject_cast<QFileDevice *>(device);
executed (the execution status of this line is deduced): QFileDevice *file = qobject_cast<QFileDevice *>(device);
-
707 bool flushed = !file || file->flush();
evaluated: !file
TRUEFALSE
yes
Evaluation Count:20972
yes
Evaluation Count:13967
partially evaluated: file->flush()
TRUEFALSE
yes
Evaluation Count:13967
no
Evaluation Count:0
0-20972
708#else -
709 bool flushed = true; -
710#endif -
711 -
712#if defined (QTEXTSTREAM_DEBUG) -
713 qDebug("QTextStreamPrivate::flushWriteBuffer() wrote %d bytes", -
714 int(bytesWritten)); -
715#endif -
716 if (!flushed || bytesWritten != qint64(data.size()))
partially evaluated: !flushed
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34939
partially evaluated: bytesWritten != qint64(data.size())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34939
0-34939
717 status = QTextStream::WriteFailed;
never executed: status = QTextStream::WriteFailed;
0
718}
executed: }
Execution Count:34939
34939
719 -
720QString QTextStreamPrivate::read(int maxlen) -
721{ -
722 QString ret;
executed (the execution status of this line is deduced): QString ret;
-
723 if (string) {
evaluated: string
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1866
5-1866
724 lastTokenSize = qMin(maxlen, string->size() - stringOffset);
executed (the execution status of this line is deduced): lastTokenSize = qMin(maxlen, string->size() - stringOffset);
-
725 ret = string->mid(stringOffset, lastTokenSize);
executed (the execution status of this line is deduced): ret = string->mid(stringOffset, lastTokenSize);
-
726 } else {
executed: }
Execution Count:5
5
727 while (readBuffer.size() - readBufferOffset < maxlen && fillReadBuffer()) ;
executed: ;
Execution Count:1862
evaluated: readBuffer.size() - readBufferOffset < maxlen
TRUEFALSE
yes
Evaluation Count:3721
yes
Evaluation Count:7
evaluated: fillReadBuffer()
TRUEFALSE
yes
Evaluation Count:1862
yes
Evaluation Count:1859
7-3721
728 lastTokenSize = qMin(maxlen, readBuffer.size() - readBufferOffset);
executed (the execution status of this line is deduced): lastTokenSize = qMin(maxlen, readBuffer.size() - readBufferOffset);
-
729 ret = readBuffer.mid(readBufferOffset, lastTokenSize);
executed (the execution status of this line is deduced): ret = readBuffer.mid(readBufferOffset, lastTokenSize);
-
730 }
executed: }
Execution Count:1866
1866
731 consumeLastToken();
executed (the execution status of this line is deduced): consumeLastToken();
-
732 -
733#if defined (QTEXTSTREAM_DEBUG) -
734 qDebug("QTextStreamPrivate::read() maxlen = %d, token length = %d", maxlen, ret.length()); -
735#endif -
736 return ret;
executed: return ret;
Execution Count:1871
1871
737} -
738 -
739/*! -
740 \internal -
741 -
742 Scans no more than \a maxlen QChars in the current buffer for the -
743 first \a delimiter. Stores a pointer to the start offset of the -
744 token in \a ptr, and the length in QChars in \a length. -
745*/ -
746bool QTextStreamPrivate::scan(const QChar **ptr, int *length, int maxlen, TokenDelimiter delimiter) -
747{ -
748 int totalSize = 0;
executed (the execution status of this line is deduced): int totalSize = 0;
-
749 int delimSize = 0;
executed (the execution status of this line is deduced): int delimSize = 0;
-
750 bool consumeDelimiter = false;
executed (the execution status of this line is deduced): bool consumeDelimiter = false;
-
751 bool foundToken = false;
executed (the execution status of this line is deduced): bool foundToken = false;
-
752 int startOffset = device ? readBufferOffset : stringOffset;
evaluated: device
TRUEFALSE
yes
Evaluation Count:152301
yes
Evaluation Count:128
128-152301
753 QChar lastChar;
executed (the execution status of this line is deduced): QChar lastChar;
-
754 -
755 bool canStillReadFromDevice = true;
executed (the execution status of this line is deduced): bool canStillReadFromDevice = true;
-
756 do { -
757 int endOffset;
executed (the execution status of this line is deduced): int endOffset;
-
758 const QChar *chPtr;
executed (the execution status of this line is deduced): const QChar *chPtr;
-
759 if (device) {
evaluated: device
TRUEFALSE
yes
Evaluation Count:155088
yes
Evaluation Count:128
128-155088
760 chPtr = readBuffer.constData();
executed (the execution status of this line is deduced): chPtr = readBuffer.constData();
-
761 endOffset = readBuffer.size();
executed (the execution status of this line is deduced): endOffset = readBuffer.size();
-
762 } else {
executed: }
Execution Count:155088
155088
763 chPtr = string->constData();
executed (the execution status of this line is deduced): chPtr = string->constData();
-
764 endOffset = string->size();
executed (the execution status of this line is deduced): endOffset = string->size();
-
765 }
executed: }
Execution Count:128
128
766 chPtr += startOffset;
executed (the execution status of this line is deduced): chPtr += startOffset;
-
767 -
768 for (; !foundToken && startOffset < endOffset && (!maxlen || totalSize < maxlen); ++startOffset) {
evaluated: !foundToken
TRUEFALSE
yes
Evaluation Count:2588096
yes
Evaluation Count:152158
evaluated: startOffset < endOffset
TRUEFALSE
yes
Evaluation Count:2585048
yes
Evaluation Count:3048
evaluated: !maxlen
TRUEFALSE
yes
Evaluation Count:2533832
yes
Evaluation Count:51216
evaluated: totalSize < maxlen
TRUEFALSE
yes
Evaluation Count:51206
yes
Evaluation Count:10
10-2588096
769 const QChar ch = *chPtr++;
executed (the execution status of this line is deduced): const QChar ch = *chPtr++;
-
770 ++totalSize;
executed (the execution status of this line is deduced): ++totalSize;
-
771 -
772 switch (delimiter) { -
773 case Space: -
774 if (ch.isSpace()) {
evaluated: ch.isSpace()
TRUEFALSE
yes
Evaluation Count:424
yes
Evaluation Count:5558
424-5558
775 foundToken = true;
executed (the execution status of this line is deduced): foundToken = true;
-
776 delimSize = 1;
executed (the execution status of this line is deduced): delimSize = 1;
-
777 }
executed: }
Execution Count:424
424
778 break;
executed: break;
Execution Count:5982
5982
779 case NotSpace: -
780 if (!ch.isSpace()) {
evaluated: !ch.isSpace()
TRUEFALSE
yes
Evaluation Count:22943
yes
Evaluation Count:40913
22943-40913
781 foundToken = true;
executed (the execution status of this line is deduced): foundToken = true;
-
782 delimSize = 1;
executed (the execution status of this line is deduced): delimSize = 1;
-
783 }
executed: }
Execution Count:22943
22943
784 break;
executed: break;
Execution Count:63856
63856
785 case EndOfLine: -
786 if (ch == QLatin1Char('\n')) {
evaluated: ch == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:128791
yes
Evaluation Count:2386409
128791-2386409
787 foundToken = true;
executed (the execution status of this line is deduced): foundToken = true;
-
788 delimSize = (lastChar == QLatin1Char('\r')) ? 2 : 1;
evaluated: (lastChar == QLatin1Char('\r'))
TRUEFALSE
yes
Evaluation Count:45246
yes
Evaluation Count:83545
45246-83545
789 consumeDelimiter = true;
executed (the execution status of this line is deduced): consumeDelimiter = true;
-
790 }
executed: }
Execution Count:128791
128791
791 lastChar = ch;
executed (the execution status of this line is deduced): lastChar = ch;
-
792 break;
executed: break;
Execution Count:2515200
2515200
793 } -
794 }
executed: }
Execution Count:2585038
2585038
795 } while (!foundToken
executed: }
Execution Count:155216
evaluated: !foundToken
TRUEFALSE
yes
Evaluation Count:3058
yes
Evaluation Count:152158
3058-155216
796 && (!maxlen || totalSize < maxlen)
evaluated: !maxlen
TRUEFALSE
yes
Evaluation Count:3030
yes
Evaluation Count:28
evaluated: totalSize < maxlen
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:12
12-3030
797 && (device && (canStillReadFromDevice = fillReadBuffer())));
evaluated: device
TRUEFALSE
yes
Evaluation Count:3024
yes
Evaluation Count:22
evaluated: (canStillReadFromDevice = fillReadBuffer())
TRUEFALSE
yes
Evaluation Count:2787
yes
Evaluation Count:237
22-3024
798 -
799 // if the token was not found, but we reached the end of input, -
800 // then we accept what we got. if we are not at the end of input, -
801 // we return false. -
802 if (!foundToken && (!maxlen || totalSize < maxlen)
evaluated: !foundToken
TRUEFALSE
yes
Evaluation Count:271
yes
Evaluation Count:152158
evaluated: !maxlen
TRUEFALSE
yes
Evaluation Count:253
yes
Evaluation Count:18
evaluated: totalSize < maxlen
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:12
6-152158
803 && (totalSize == 0
evaluated: totalSize == 0
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:185
74-185
804 || (string && stringOffset + totalSize < string->size())
evaluated: string
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:165
partially evaluated: stringOffset + totalSize < string->size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-165
805 || (device && !device->atEnd() && canStillReadFromDevice))) {
evaluated: device
TRUEFALSE
yes
Evaluation Count:165
yes
Evaluation Count:20
partially evaluated: !device->atEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:165
never evaluated: canStillReadFromDevice
0-165
806#if defined (QTEXTSTREAM_DEBUG) -
807 qDebug("QTextStreamPrivate::scan() did not find the token."); -
808#endif -
809 return false;
executed: return false;
Execution Count:74
74
810 } -
811 -
812 // if we find a '\r' at the end of the data when reading lines, -
813 // don't make it part of the line. -
814 if (delimiter == EndOfLine && totalSize > 0 && !foundToken) {
evaluated: delimiter == EndOfLine
TRUEFALSE
yes
Evaluation Count:128860
yes
Evaluation Count:23495
partially evaluated: totalSize > 0
TRUEFALSE
yes
Evaluation Count:128860
no
Evaluation Count:0
evaluated: !foundToken
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:128791
0-128860
815 if (((string && stringOffset + totalSize == string->size()) || (device && device->atEnd()))
evaluated: string
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:54
evaluated: stringOffset + totalSize == string->size()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:5
evaluated: device
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:5
evaluated: device->atEnd()
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:2
2-54
816 && lastChar == QLatin1Char('\r')) {
evaluated: lastChar == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:51
11-51
817 consumeDelimiter = true;
executed (the execution status of this line is deduced): consumeDelimiter = true;
-
818 ++delimSize;
executed (the execution status of this line is deduced): ++delimSize;
-
819 }
executed: }
Execution Count:11
11
820 }
executed: }
Execution Count:69
69
821 -
822 // set the read offset and length of the token -
823 if (length)
evaluated: length
TRUEFALSE
yes
Evaluation Count:129313
yes
Evaluation Count:23042
23042-129313
824 *length = totalSize - delimSize;
executed: *length = totalSize - delimSize;
Execution Count:129313
129313
825 if (ptr)
evaluated: ptr
TRUEFALSE
yes
Evaluation Count:129313
yes
Evaluation Count:23042
23042-129313
826 *ptr = readPtr();
executed: *ptr = readPtr();
Execution Count:129313
129313
827 -
828 // update last token size. the callee will call consumeLastToken() when -
829 // done. -
830 lastTokenSize = totalSize;
executed (the execution status of this line is deduced): lastTokenSize = totalSize;
-
831 if (!consumeDelimiter)
evaluated: !consumeDelimiter
TRUEFALSE
yes
Evaluation Count:23553
yes
Evaluation Count:128802
23553-128802
832 lastTokenSize -= delimSize;
executed: lastTokenSize -= delimSize;
Execution Count:23553
23553
833 -
834#if defined (QTEXTSTREAM_DEBUG) -
835 qDebug("QTextStreamPrivate::scan(%p, %p, %d, %x) token length = %d, delimiter = %d", -
836 ptr, length, maxlen, (int)delimiter, totalSize - delimSize, delimSize); -
837#endif -
838 return true;
executed: return true;
Execution Count:152355
152355
839} -
840 -
841/*! -
842 \internal -
843*/ -
844inline const QChar *QTextStreamPrivate::readPtr() const -
845{ -
846 Q_ASSERT(readBufferOffset <= readBuffer.size());
executed (the execution status of this line is deduced): qt_noop();
-
847 if (string)
evaluated: string
TRUEFALSE
yes
Evaluation Count:289
yes
Evaluation Count:198649
289-198649
848 return string->constData() + stringOffset;
executed: return string->constData() + stringOffset;
Execution Count:289
289
849 return readBuffer.constData() + readBufferOffset;
executed: return readBuffer.constData() + readBufferOffset;
Execution Count:198649
198649
850} -
851 -
852/*! -
853 \internal -
854*/ -
855inline void QTextStreamPrivate::consumeLastToken() -
856{ -
857 if (lastTokenSize)
evaluated: lastTokenSize
TRUEFALSE
yes
Evaluation Count:152574
yes
Evaluation Count:868
868-152574
858 consume(lastTokenSize);
executed: consume(lastTokenSize);
Execution Count:152574
152574
859 lastTokenSize = 0;
executed (the execution status of this line is deduced): lastTokenSize = 0;
-
860}
executed: }
Execution Count:153442
153442
861 -
862/*! -
863 \internal -
864*/ -
865inline void QTextStreamPrivate::consume(int size) -
866{ -
867#if defined (QTEXTSTREAM_DEBUG) -
868 qDebug("QTextStreamPrivate::consume(%d)", size); -
869#endif -
870 if (string) {
evaluated: string
TRUEFALSE
yes
Evaluation Count:333
yes
Evaluation Count:221866
333-221866
871 stringOffset += size;
executed (the execution status of this line is deduced): stringOffset += size;
-
872 if (stringOffset > string->size())
partially evaluated: stringOffset > string->size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333
0-333
873 stringOffset = string->size();
never executed: stringOffset = string->size();
0
874 } else {
executed: }
Execution Count:333
333
875 readBufferOffset += size;
executed (the execution status of this line is deduced): readBufferOffset += size;
-
876 if (readBufferOffset >= readBuffer.size()) {
evaluated: readBufferOffset >= readBuffer.size()
TRUEFALSE
yes
Evaluation Count:2623
yes
Evaluation Count:219243
2623-219243
877 readBufferOffset = 0;
executed (the execution status of this line is deduced): readBufferOffset = 0;
-
878 readBuffer.clear();
executed (the execution status of this line is deduced): readBuffer.clear();
-
879 saveConverterState(device->pos());
executed (the execution status of this line is deduced): saveConverterState(device->pos());
-
880 } else if (readBufferOffset > QTEXTSTREAM_BUFFERSIZE) {
executed: }
Execution Count:2623
evaluated: readBufferOffset > QTEXTSTREAM_BUFFERSIZE
TRUEFALSE
yes
Evaluation Count:1221
yes
Evaluation Count:218022
1221-218022
881 readBuffer = readBuffer.remove(0,readBufferOffset);
executed (the execution status of this line is deduced): readBuffer = readBuffer.remove(0,readBufferOffset);
-
882 readConverterSavedStateOffset += readBufferOffset;
executed (the execution status of this line is deduced): readConverterSavedStateOffset += readBufferOffset;
-
883 readBufferOffset = 0;
executed (the execution status of this line is deduced): readBufferOffset = 0;
-
884 }
executed: }
Execution Count:1221
1221
885 } -
886} -
887 -
888/*! -
889 \internal -
890*/ -
891inline void QTextStreamPrivate::saveConverterState(qint64 newPos) -
892{ -
893#ifndef QT_NO_TEXTCODEC -
894 if (readConverterState.d) {
partially evaluated: readConverterState.d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2623
0-2623
895 // converter cannot be copied, so don't save anything -
896 // don't update readBufferStartDevicePos either -
897 return;
never executed: return;
0
898 } -
899 -
900 if (!readConverterSavedState)
evaluated: !readConverterSavedState
TRUEFALSE
yes
Evaluation Count:2593
yes
Evaluation Count:30
30-2593
901 readConverterSavedState = new QTextCodec::ConverterState;
executed: readConverterSavedState = new QTextCodec::ConverterState;
Execution Count:2593
2593
902 copyConverterStateHelper(readConverterSavedState, &readConverterState);
executed (the execution status of this line is deduced): copyConverterStateHelper(readConverterSavedState, &readConverterState);
-
903#endif -
904 -
905 readBufferStartDevicePos = newPos;
executed (the execution status of this line is deduced): readBufferStartDevicePos = newPos;
-
906 readConverterSavedStateOffset = 0;
executed (the execution status of this line is deduced): readConverterSavedStateOffset = 0;
-
907}
executed: }
Execution Count:2623
2623
908 -
909/*! -
910 \internal -
911*/ -
912inline void QTextStreamPrivate::restoreToSavedConverterState() -
913{ -
914#ifndef QT_NO_TEXTCODEC -
915 if (readConverterSavedState) {
partially evaluated: readConverterSavedState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1775
0-1775
916 // we have a saved state -
917 // that means the converter can be copied -
918 copyConverterStateHelper(&readConverterState, readConverterSavedState);
never executed (the execution status of this line is deduced): copyConverterStateHelper(&readConverterState, readConverterSavedState);
-
919 } else {
never executed: }
0
920 // the only state we could save was the initial -
921 // so reset to that -
922 resetCodecConverterStateHelper(&readConverterState);
executed (the execution status of this line is deduced): resetCodecConverterStateHelper(&readConverterState);
-
923 }
executed: }
Execution Count:1775
1775
924#endif -
925} -
926 -
927/*! -
928 \internal -
929*/ -
930inline void QTextStreamPrivate::write(const QString &data) -
931{ -
932 if (string) {
evaluated: string
TRUEFALSE
yes
Evaluation Count:191914
yes
Evaluation Count:302604
191914-302604
933 // ### What about seek()?? -
934 string->append(data);
executed (the execution status of this line is deduced): string->append(data);
-
935 } else {
executed: }
Execution Count:191914
191914
936 writeBuffer += data;
executed (the execution status of this line is deduced): writeBuffer += data;
-
937 if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE)
evaluated: writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:302598
6-302598
938 flushWriteBuffer();
executed: flushWriteBuffer();
Execution Count:6
6
939 }
executed: }
Execution Count:302604
302604
940} -
941 -
942/*! -
943 \internal -
944*/ -
945inline bool QTextStreamPrivate::getChar(QChar *ch) -
946{ -
947 if ((string && stringOffset == string->size())
evaluated: string
TRUEFALSE
yes
Evaluation Count:250
yes
Evaluation Count:69802
evaluated: stringOffset == string->size()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:239
11-69802
948 || (device && readBuffer.isEmpty() && !fillReadBuffer())) {
evaluated: device
TRUEFALSE
yes
Evaluation Count:69802
yes
Evaluation Count:239
evaluated: readBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:417
yes
Evaluation Count:69385
evaluated: !fillReadBuffer()
TRUEFALSE
yes
Evaluation Count:416
yes
Evaluation Count:1
1-69802
949 if (ch)
partially evaluated: ch
TRUEFALSE
yes
Evaluation Count:427
no
Evaluation Count:0
0-427
950 *ch = 0;
executed: *ch = 0;
Execution Count:427
427
951 return false;
executed: return false;
Execution Count:427
427
952 } -
953 if (ch)
partially evaluated: ch
TRUEFALSE
yes
Evaluation Count:69625
no
Evaluation Count:0
0-69625
954 *ch = *readPtr();
executed: *ch = *readPtr();
Execution Count:69625
69625
955 consume(1);
executed (the execution status of this line is deduced): consume(1);
-
956 return true;
executed: return true;
Execution Count:69625
69625
957} -
958 -
959/*! -
960 \internal -
961*/ -
962inline void QTextStreamPrivate::ungetChar(QChar ch) -
963{ -
964 if (string) {
evaluated: string
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:39055
51-39055
965 if (stringOffset == 0)
partially evaluated: stringOffset == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:51
0-51
966 string->prepend(ch);
never executed: string->prepend(ch);
0
967 else -
968 (*string)[--stringOffset] = ch;
executed: (*string)[--stringOffset] = ch;
Execution Count:51
51
969 return;
executed: return;
Execution Count:51
51
970 } -
971 -
972 if (readBufferOffset == 0) {
evaluated: readBufferOffset == 0
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:39009
46-39009
973 readBuffer.prepend(ch);
executed (the execution status of this line is deduced): readBuffer.prepend(ch);
-
974 return;
executed: return;
Execution Count:46
46
975 } -
976 -
977 readBuffer[--readBufferOffset] = ch;
executed (the execution status of this line is deduced): readBuffer[--readBufferOffset] = ch;
-
978}
executed: }
Execution Count:39009
39009
979 -
980/*! -
981 \internal -
982*/ -
983inline void QTextStreamPrivate::putString(const QString &s, bool number) -
984{ -
985 QString tmp = s;
executed (the execution status of this line is deduced): QString tmp = s;
-
986 -
987 // handle padding -
988 int padSize = fieldWidth - s.size();
executed (the execution status of this line is deduced): int padSize = fieldWidth - s.size();
-
989 if (padSize > 0) {
evaluated: padSize > 0
TRUEFALSE
yes
Evaluation Count:2235
yes
Evaluation Count:492283
2235-492283
990 QString pad(padSize, padChar);
executed (the execution status of this line is deduced): QString pad(padSize, padChar);
-
991 if (fieldAlignment == QTextStream::AlignLeft) {
partially evaluated: fieldAlignment == QTextStream::AlignLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2235
0-2235
992 tmp.append(QString(padSize, padChar));
never executed (the execution status of this line is deduced): tmp.append(QString(padSize, padChar));
-
993 } else if (fieldAlignment == QTextStream::AlignRight
never executed: }
evaluated: fieldAlignment == QTextStream::AlignRight
TRUEFALSE
yes
Evaluation Count:2231
yes
Evaluation Count:4
0-2231
994 || fieldAlignment == QTextStream::AlignAccountingStyle) {
partially evaluated: fieldAlignment == QTextStream::AlignAccountingStyle
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
995 tmp.prepend(QString(padSize, padChar));
executed (the execution status of this line is deduced): tmp.prepend(QString(padSize, padChar));
-
996 if (fieldAlignment == QTextStream::AlignAccountingStyle && number) {
evaluated: fieldAlignment == QTextStream::AlignAccountingStyle
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2231
evaluated: number
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2-2231
997 const QChar sign = s.size() > 0 ? s.at(0) : QChar();
partially evaluated: s.size() > 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
998 if (sign == locale.negativeSign() || sign == locale.positiveSign()) {
partially evaluated: sign == locale.negativeSign()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
never evaluated: sign == locale.positiveSign()
0-2
999 QChar *data = tmp.data();
executed (the execution status of this line is deduced): QChar *data = tmp.data();
-
1000 data[padSize] = tmp.at(0);
executed (the execution status of this line is deduced): data[padSize] = tmp.at(0);
-
1001 data[0] = sign;
executed (the execution status of this line is deduced): data[0] = sign;
-
1002 }
executed: }
Execution Count:2
2
1003 }
executed: }
Execution Count:2
2
1004 } else if (fieldAlignment == QTextStream::AlignCenter) {
executed: }
Execution Count:2235
never evaluated: fieldAlignment == QTextStream::AlignCenter
0-2235
1005 tmp.prepend(QString(padSize/2, padChar));
never executed (the execution status of this line is deduced): tmp.prepend(QString(padSize/2, padChar));
-
1006 tmp.append(QString(padSize - padSize/2, padChar));
never executed (the execution status of this line is deduced): tmp.append(QString(padSize - padSize/2, padChar));
-
1007 }
never executed: }
0
1008 } -
1009 -
1010#if defined (QTEXTSTREAM_DEBUG) -
1011 QByteArray a = s.toUtf8(); -
1012 QByteArray b = tmp.toUtf8(); -
1013 qDebug("QTextStreamPrivate::putString(\"%s\") calls write(\"%s\")", -
1014 qt_prettyDebug(a.constData(), a.size(), qMax(16, a.size())).constData(), -
1015 qt_prettyDebug(b.constData(), b.size(), qMax(16, b.size())).constData()); -
1016#endif -
1017 write(tmp);
executed (the execution status of this line is deduced): write(tmp);
-
1018}
executed: }
Execution Count:494518
494518
1019 -
1020/*! -
1021 Constructs a QTextStream. Before you can use it for reading or -
1022 writing, you must assign a device or a string. -
1023 -
1024 \sa setDevice(), setString() -
1025*/ -
1026QTextStream::QTextStream() -
1027 : d_ptr(new QTextStreamPrivate(this)) -
1028{ -
1029#if defined (QTEXTSTREAM_DEBUG) -
1030 qDebug("QTextStream::QTextStream()"); -
1031#endif -
1032 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1033 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1034}
executed: }
Execution Count:15
15
1035 -
1036/*! -
1037 Constructs a QTextStream that operates on \a device. -
1038*/ -
1039QTextStream::QTextStream(QIODevice *device) -
1040 : d_ptr(new QTextStreamPrivate(this)) -
1041{ -
1042#if defined (QTEXTSTREAM_DEBUG) -
1043 qDebug("QTextStream::QTextStream(QIODevice *device == *%p)", -
1044 device); -
1045#endif -
1046 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1047 d->device = device;
executed (the execution status of this line is deduced): d->device = device;
-
1048#ifndef QT_NO_QOBJECT -
1049 d->deviceClosedNotifier.setupDevice(this, d->device);
executed (the execution status of this line is deduced): d->deviceClosedNotifier.setupDevice(this, d->device);
-
1050#endif -
1051 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1052}
executed: }
Execution Count:2813
2813
1053 -
1054/*! -
1055 Constructs a QTextStream that operates on \a string, using \a -
1056 openMode to define the open mode. -
1057*/ -
1058QTextStream::QTextStream(QString *string, QIODevice::OpenMode openMode) -
1059 : d_ptr(new QTextStreamPrivate(this)) -
1060{ -
1061#if defined (QTEXTSTREAM_DEBUG) -
1062 qDebug("QTextStream::QTextStream(QString *string == *%p, openMode = %d)", -
1063 string, int(openMode)); -
1064#endif -
1065 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1066 d->string = string;
executed (the execution status of this line is deduced): d->string = string;
-
1067 d->stringOpenMode = openMode;
executed (the execution status of this line is deduced): d->stringOpenMode = openMode;
-
1068 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1069}
executed: }
Execution Count:1717
1717
1070 -
1071/*! -
1072 Constructs a QTextStream that operates on \a array, using \a -
1073 openMode to define the open mode. Internally, the array is wrapped -
1074 by a QBuffer. -
1075*/ -
1076QTextStream::QTextStream(QByteArray *array, QIODevice::OpenMode openMode) -
1077 : d_ptr(new QTextStreamPrivate(this)) -
1078{ -
1079#if defined (QTEXTSTREAM_DEBUG) -
1080 qDebug("QTextStream::QTextStream(QByteArray *array == *%p, openMode = %d)", -
1081 array, int(openMode)); -
1082#endif -
1083 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1084 d->device = new QBuffer(array);
executed (the execution status of this line is deduced): d->device = new QBuffer(array);
-
1085 d->device->open(openMode);
executed (the execution status of this line is deduced): d->device->open(openMode);
-
1086 d->deleteDevice = true;
executed (the execution status of this line is deduced): d->deleteDevice = true;
-
1087#ifndef QT_NO_QOBJECT -
1088 d->deviceClosedNotifier.setupDevice(this, d->device);
executed (the execution status of this line is deduced): d->deviceClosedNotifier.setupDevice(this, d->device);
-
1089#endif -
1090 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1091}
executed: }
Execution Count:564
564
1092 -
1093/*! -
1094 Constructs a QTextStream that operates on \a array, using \a -
1095 openMode to define the open mode. The array is accessed as -
1096 read-only, regardless of the values in \a openMode. -
1097 -
1098 This constructor is convenient for working on constant -
1099 strings. Example: -
1100 -
1101 \snippet code/src_corelib_io_qtextstream.cpp 3 -
1102*/ -
1103QTextStream::QTextStream(const QByteArray &array, QIODevice::OpenMode openMode) -
1104 : d_ptr(new QTextStreamPrivate(this)) -
1105{ -
1106#if defined (QTEXTSTREAM_DEBUG) -
1107 qDebug("QTextStream::QTextStream(const QByteArray &array == *(%p), openMode = %d)", -
1108 &array, int(openMode)); -
1109#endif -
1110 QBuffer *buffer = new QBuffer;
executed (the execution status of this line is deduced): QBuffer *buffer = new QBuffer;
-
1111 buffer->setData(array);
executed (the execution status of this line is deduced): buffer->setData(array);
-
1112 buffer->open(openMode);
executed (the execution status of this line is deduced): buffer->open(openMode);
-
1113 -
1114 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1115 d->device = buffer;
executed (the execution status of this line is deduced): d->device = buffer;
-
1116 d->deleteDevice = true;
executed (the execution status of this line is deduced): d->deleteDevice = true;
-
1117#ifndef QT_NO_QOBJECT -
1118 d->deviceClosedNotifier.setupDevice(this, d->device);
executed (the execution status of this line is deduced): d->deviceClosedNotifier.setupDevice(this, d->device);
-
1119#endif -
1120 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1121}
executed: }
Execution Count:13
13
1122 -
1123/*! -
1124 Constructs a QTextStream that operates on \a fileHandle, using \a -
1125 openMode to define the open mode. Internally, a QFile is created -
1126 to handle the FILE pointer. -
1127 -
1128 This constructor is useful for working directly with the common -
1129 FILE based input and output streams: stdin, stdout and stderr. Example: -
1130 -
1131 \snippet code/src_corelib_io_qtextstream.cpp 4 -
1132*/ -
1133 -
1134QTextStream::QTextStream(FILE *fileHandle, QIODevice::OpenMode openMode) -
1135 : d_ptr(new QTextStreamPrivate(this)) -
1136{ -
1137#if defined (QTEXTSTREAM_DEBUG) -
1138 qDebug("QTextStream::QTextStream(FILE *fileHandle = %p, openMode = %d)", -
1139 fileHandle, int(openMode)); -
1140#endif -
1141 QFile *file = new QFile;
never executed (the execution status of this line is deduced): QFile *file = new QFile;
-
1142 file->open(fileHandle, openMode);
never executed (the execution status of this line is deduced): file->open(fileHandle, openMode);
-
1143 -
1144 Q_D(QTextStream);
never executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1145 d->device = file;
never executed (the execution status of this line is deduced): d->device = file;
-
1146 d->deleteDevice = true;
never executed (the execution status of this line is deduced): d->deleteDevice = true;
-
1147#ifndef QT_NO_QOBJECT -
1148 d->deviceClosedNotifier.setupDevice(this, d->device);
never executed (the execution status of this line is deduced): d->deviceClosedNotifier.setupDevice(this, d->device);
-
1149#endif -
1150 d->status = Ok;
never executed (the execution status of this line is deduced): d->status = Ok;
-
1151}
never executed: }
0
1152 -
1153/*! -
1154 Destroys the QTextStream. -
1155 -
1156 If the stream operates on a device, flush() will be called -
1157 implicitly. Otherwise, the device is unaffected. -
1158*/ -
1159QTextStream::~QTextStream() -
1160{ -
1161 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1162#if defined (QTEXTSTREAM_DEBUG) -
1163 qDebug("QTextStream::~QTextStream()"); -
1164#endif -
1165 if (!d->writeBuffer.isEmpty())
evaluated: !d->writeBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:5116
6-5116
1166 d->flushWriteBuffer();
executed: d->flushWriteBuffer();
Execution Count:6
6
1167}
executed: }
Execution Count:5122
5122
1168 -
1169/*! -
1170 Resets QTextStream's formatting options, bringing it back to its -
1171 original constructed state. The device, string and any buffered -
1172 data is left untouched. -
1173*/ -
1174void QTextStream::reset() -
1175{ -
1176 Q_D(QTextStream);
never executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1177 -
1178 d->realNumberPrecision = 6;
never executed (the execution status of this line is deduced): d->realNumberPrecision = 6;
-
1179 d->integerBase = 0;
never executed (the execution status of this line is deduced): d->integerBase = 0;
-
1180 d->fieldWidth = 0;
never executed (the execution status of this line is deduced): d->fieldWidth = 0;
-
1181 d->padChar = QLatin1Char(' ');
never executed (the execution status of this line is deduced): d->padChar = QLatin1Char(' ');
-
1182 d->fieldAlignment = QTextStream::AlignRight;
never executed (the execution status of this line is deduced): d->fieldAlignment = QTextStream::AlignRight;
-
1183 d->realNumberNotation = QTextStream::SmartNotation;
never executed (the execution status of this line is deduced): d->realNumberNotation = QTextStream::SmartNotation;
-
1184 d->numberFlags = 0;
never executed (the execution status of this line is deduced): d->numberFlags = 0;
-
1185}
never executed: }
0
1186 -
1187/*! -
1188 Flushes any buffered data waiting to be written to the device. -
1189 -
1190 If QTextStream operates on a string, this function does nothing. -
1191*/ -
1192void QTextStream::flush() -
1193{ -
1194 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1195 d->flushWriteBuffer();
executed (the execution status of this line is deduced): d->flushWriteBuffer();
-
1196}
executed: }
Execution Count:50592
50592
1197 -
1198/*! -
1199 Seeks to the position \a pos in the device. Returns true on -
1200 success; otherwise returns false. -
1201*/ -
1202bool QTextStream::seek(qint64 pos) -
1203{ -
1204 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1205 d->lastTokenSize = 0;
executed (the execution status of this line is deduced): d->lastTokenSize = 0;
-
1206 -
1207 if (d->device) {
evaluated: d->device
TRUEFALSE
yes
Evaluation Count:214471
yes
Evaluation Count:47
47-214471
1208 // Empty the write buffer -
1209 d->flushWriteBuffer();
executed (the execution status of this line is deduced): d->flushWriteBuffer();
-
1210 if (!d->device->seek(pos))
partially evaluated: !d->device->seek(pos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:214471
0-214471
1211 return false;
never executed: return false;
0
1212 d->resetReadBuffer();
executed (the execution status of this line is deduced): d->resetReadBuffer();
-
1213 -
1214#ifndef QT_NO_TEXTCODEC -
1215 // Reset the codec converter states. -
1216 resetCodecConverterStateHelper(&d->readConverterState);
executed (the execution status of this line is deduced): resetCodecConverterStateHelper(&d->readConverterState);
-
1217 resetCodecConverterStateHelper(&d->writeConverterState);
executed (the execution status of this line is deduced): resetCodecConverterStateHelper(&d->writeConverterState);
-
1218 delete d->readConverterSavedState;
executed (the execution status of this line is deduced): delete d->readConverterSavedState;
-
1219 d->readConverterSavedState = 0;
executed (the execution status of this line is deduced): d->readConverterSavedState = 0;
-
1220 d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
executed (the execution status of this line is deduced): d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
-
1221#endif -
1222 return true;
executed: return true;
Execution Count:214471
214471
1223 } -
1224 -
1225 // string -
1226 if (d->string && pos <= d->string->size()) {
partially evaluated: d->string
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
partially evaluated: pos <= d->string->size()
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
0-47
1227 d->stringOffset = int(pos);
executed (the execution status of this line is deduced): d->stringOffset = int(pos);
-
1228 return true;
executed: return true;
Execution Count:47
47
1229 } -
1230 return false;
never executed: return false;
0
1231} -
1232 -
1233/*! -
1234 \since 4.2 -
1235 -
1236 Returns the device position corresponding to the current position of the -
1237 stream, or -1 if an error occurs (e.g., if there is no device or string, -
1238 or if there's a device error). -
1239 -
1240 Because QTextStream is buffered, this function may have to -
1241 seek the device to reconstruct a valid device position. This -
1242 operation can be expensive, so you may want to avoid calling this -
1243 function in a tight loop. -
1244 -
1245 \sa seek() -
1246*/ -
1247qint64 QTextStream::pos() const -
1248{ -
1249 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1250 if (d->device) {
evaluated: d->device
TRUEFALSE
yes
Evaluation Count:216444
yes
Evaluation Count:36
36-216444
1251 // Cutoff -
1252 if (d->readBuffer.isEmpty())
evaluated: d->readBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:214669
yes
Evaluation Count:1775
1775-214669
1253 return d->device->pos();
executed: return d->device->pos();
Execution Count:214669
214669
1254 if (d->device->isSequential())
partially evaluated: d->device->isSequential()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1775
0-1775
1255 return 0;
never executed: return 0;
0
1256 -
1257 // Seek the device -
1258 if (!d->device->seek(d->readBufferStartDevicePos))
partially evaluated: !d->device->seek(d->readBufferStartDevicePos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1775
0-1775
1259 return qint64(-1);
never executed: return qint64(-1);
0
1260 -
1261 // Reset the read buffer -
1262 QTextStreamPrivate *thatd = const_cast<QTextStreamPrivate *>(d);
executed (the execution status of this line is deduced): QTextStreamPrivate *thatd = const_cast<QTextStreamPrivate *>(d);
-
1263 thatd->readBuffer.clear();
executed (the execution status of this line is deduced): thatd->readBuffer.clear();
-
1264 -
1265#ifndef QT_NO_TEXTCODEC -
1266 thatd->restoreToSavedConverterState();
executed (the execution status of this line is deduced): thatd->restoreToSavedConverterState();
-
1267 if (d->readBufferStartDevicePos == 0)
evaluated: d->readBufferStartDevicePos == 0
TRUEFALSE
yes
Evaluation Count:1760
yes
Evaluation Count:15
15-1760
1268 thatd->autoDetectUnicode = true;
executed: thatd->autoDetectUnicode = true;
Execution Count:1760
1760
1269#endif -
1270 -
1271 // Rewind the device to get to the current position Ensure that -
1272 // readBufferOffset is unaffected by fillReadBuffer() -
1273 int oldReadBufferOffset = d->readBufferOffset + d->readConverterSavedStateOffset;
executed (the execution status of this line is deduced): int oldReadBufferOffset = d->readBufferOffset + d->readConverterSavedStateOffset;
-
1274 while (d->readBuffer.size() < oldReadBufferOffset) {
evaluated: d->readBuffer.size() < oldReadBufferOffset
TRUEFALSE
yes
Evaluation Count:41035294
yes
Evaluation Count:1775
1775-41035294
1275 if (!thatd->fillReadBuffer(1))
partially evaluated: !thatd->fillReadBuffer(1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41035294
0-41035294
1276 return qint64(-1);
never executed: return qint64(-1);
0
1277 }
executed: }
Execution Count:41035294
41035294
1278 thatd->readBufferOffset = oldReadBufferOffset;
executed (the execution status of this line is deduced): thatd->readBufferOffset = oldReadBufferOffset;
-
1279 thatd->readConverterSavedStateOffset = 0;
executed (the execution status of this line is deduced): thatd->readConverterSavedStateOffset = 0;
-
1280 -
1281 // Return the device position. -
1282 return d->device->pos();
executed: return d->device->pos();
Execution Count:1775
1775
1283 } -
1284 -
1285 if (d->string)
partially evaluated: d->string
TRUEFALSE
yes
Evaluation Count:36
no
Evaluation Count:0
0-36
1286 return d->stringOffset;
executed: return d->stringOffset;
Execution Count:36
36
1287 -
1288 qWarning("QTextStream::pos: no device");
never executed (the execution status of this line is deduced): QMessageLogger("io/qtextstream.cpp", 1288, __PRETTY_FUNCTION__).warning("QTextStream::pos: no device");
-
1289 return qint64(-1);
never executed: return qint64(-1);
0
1290} -
1291 -
1292/*! -
1293 Reads and discards whitespace from the stream until either a -
1294 non-space character is detected, or until atEnd() returns -
1295 true. This function is useful when reading a stream character by -
1296 character. -
1297 -
1298 Whitespace characters are all characters for which -
1299 QChar::isSpace() returns true. -
1300 -
1301 \sa operator>>() -
1302*/ -
1303void QTextStream::skipWhiteSpace() -
1304{ -
1305 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1306 CHECK_VALID_STREAM(Q_VOID);
never executed: return ;
executed: }
Execution Count:408
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:408
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:405
yes
Evaluation Count:3
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:405
0-408
1307 d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
executed (the execution status of this line is deduced): d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
-
1308 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
1309}
executed: }
Execution Count:408
408
1310 -
1311/*! -
1312 Sets the current device to \a device. If a device has already been -
1313 assigned, QTextStream will call flush() before the old device is -
1314 replaced. -
1315 -
1316 \note This function resets locale to the default locale ('C') -
1317 and codec to the default codec, QTextCodec::codecForLocale(). -
1318 -
1319 \sa device(), setString() -
1320*/ -
1321void QTextStream::setDevice(QIODevice *device) -
1322{ -
1323 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1324 flush();
executed (the execution status of this line is deduced): flush();
-
1325 if (d->deleteDevice) {
partially evaluated: d->deleteDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
1326#ifndef QT_NO_QOBJECT -
1327 d->deviceClosedNotifier.disconnect();
never executed (the execution status of this line is deduced): d->deviceClosedNotifier.disconnect();
-
1328#endif -
1329 delete d->device;
never executed (the execution status of this line is deduced): delete d->device;
-
1330 d->deleteDevice = false;
never executed (the execution status of this line is deduced): d->deleteDevice = false;
-
1331 }
never executed: }
0
1332 -
1333 d->reset();
executed (the execution status of this line is deduced): d->reset();
-
1334 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1335 d->device = device;
executed (the execution status of this line is deduced): d->device = device;
-
1336 d->resetReadBuffer();
executed (the execution status of this line is deduced): d->resetReadBuffer();
-
1337#ifndef QT_NO_QOBJECT -
1338 d->deviceClosedNotifier.setupDevice(this, d->device);
executed (the execution status of this line is deduced): d->deviceClosedNotifier.setupDevice(this, d->device);
-
1339#endif -
1340}
executed: }
Execution Count:9
9
1341 -
1342/*! -
1343 Returns the current device associated with the QTextStream, -
1344 or 0 if no device has been assigned. -
1345 -
1346 \sa setDevice(), string() -
1347*/ -
1348QIODevice *QTextStream::device() const -
1349{ -
1350 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1351 return d->device;
executed: return d->device;
Execution Count:3
3
1352} -
1353 -
1354/*! -
1355 Sets the current string to \a string, using the given \a -
1356 openMode. If a device has already been assigned, QTextStream will -
1357 call flush() before replacing it. -
1358 -
1359 \sa string(), setDevice() -
1360*/ -
1361void QTextStream::setString(QString *string, QIODevice::OpenMode openMode) -
1362{ -
1363 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1364 flush();
executed (the execution status of this line is deduced): flush();
-
1365 if (d->deleteDevice) {
partially evaluated: d->deleteDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1366#ifndef QT_NO_QOBJECT -
1367 d->deviceClosedNotifier.disconnect();
never executed (the execution status of this line is deduced): d->deviceClosedNotifier.disconnect();
-
1368 d->device->blockSignals(true);
never executed (the execution status of this line is deduced): d->device->blockSignals(true);
-
1369#endif -
1370 delete d->device;
never executed (the execution status of this line is deduced): delete d->device;
-
1371 d->deleteDevice = false;
never executed (the execution status of this line is deduced): d->deleteDevice = false;
-
1372 }
never executed: }
0
1373 -
1374 d->reset();
executed (the execution status of this line is deduced): d->reset();
-
1375 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1376 d->string = string;
executed (the execution status of this line is deduced): d->string = string;
-
1377 d->stringOpenMode = openMode;
executed (the execution status of this line is deduced): d->stringOpenMode = openMode;
-
1378}
executed: }
Execution Count:7
7
1379 -
1380/*! -
1381 Returns the current string assigned to the QTextStream, or 0 if no -
1382 string has been assigned. -
1383 -
1384 \sa setString(), device() -
1385*/ -
1386QString *QTextStream::string() const -
1387{ -
1388 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1389 return d->string;
executed: return d->string;
Execution Count:1
1
1390} -
1391 -
1392/*! -
1393 Sets the field alignment to \a mode. When used together with -
1394 setFieldWidth(), this function allows you to generate formatted -
1395 output with text aligned to the left, to the right or center -
1396 aligned. -
1397 -
1398 \sa fieldAlignment(), setFieldWidth() -
1399*/ -
1400void QTextStream::setFieldAlignment(FieldAlignment mode) -
1401{ -
1402 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1403 d->fieldAlignment = mode;
executed (the execution status of this line is deduced): d->fieldAlignment = mode;
-
1404}
executed: }
Execution Count:8
8
1405 -
1406/*! -
1407 Returns the current field alignment. -
1408 -
1409 \sa setFieldAlignment(), fieldWidth() -
1410*/ -
1411QTextStream::FieldAlignment QTextStream::fieldAlignment() const -
1412{ -
1413 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1414 return d->fieldAlignment;
executed: return d->fieldAlignment;
Execution Count:4
4
1415} -
1416 -
1417/*! -
1418 Sets the pad character to \a ch. The default value is the ASCII -
1419 space character (' '), or QChar(0x20). This character is used to -
1420 fill in the space in fields when generating text. -
1421 -
1422 Example: -
1423 -
1424 \snippet code/src_corelib_io_qtextstream.cpp 5 -
1425 -
1426 The string \c s contains: -
1427 -
1428 \snippet code/src_corelib_io_qtextstream.cpp 6 -
1429 -
1430 \sa padChar(), setFieldWidth() -
1431*/ -
1432void QTextStream::setPadChar(QChar ch) -
1433{ -
1434 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1435 d->padChar = ch;
executed (the execution status of this line is deduced): d->padChar = ch;
-
1436}
executed: }
Execution Count:6
6
1437 -
1438/*! -
1439 Returns the current pad character. -
1440 -
1441 \sa setPadChar(), setFieldWidth() -
1442*/ -
1443QChar QTextStream::padChar() const -
1444{ -
1445 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1446 return d->padChar;
executed: return d->padChar;
Execution Count:2
2
1447} -
1448 -
1449/*! -
1450 Sets the current field width to \a width. If \a width is 0 (the -
1451 default), the field width is equal to the length of the generated -
1452 text. -
1453 -
1454 \note The field width applies to every element appended to this -
1455 stream after this function has been called (e.g., it also pads -
1456 endl). This behavior is different from similar classes in the STL, -
1457 where the field width only applies to the next element. -
1458 -
1459 \sa fieldWidth(), setPadChar() -
1460*/ -
1461void QTextStream::setFieldWidth(int width) -
1462{ -
1463 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1464 d->fieldWidth = width;
executed (the execution status of this line is deduced): d->fieldWidth = width;
-
1465}
executed: }
Execution Count:29
29
1466 -
1467/*! -
1468 Returns the current field width. -
1469 -
1470 \sa setFieldWidth() -
1471*/ -
1472int QTextStream::fieldWidth() const -
1473{ -
1474 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1475 return d->fieldWidth;
executed: return d->fieldWidth;
Execution Count:3
3
1476} -
1477 -
1478/*! -
1479 Sets the current number flags to \a flags. \a flags is a set of -
1480 flags from the NumberFlag enum, and describes options for -
1481 formatting generated code (e.g., whether or not to always write -
1482 the base or sign of a number). -
1483 -
1484 \sa numberFlags(), setIntegerBase(), setRealNumberNotation() -
1485*/ -
1486void QTextStream::setNumberFlags(NumberFlags flags) -
1487{ -
1488 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1489 d->numberFlags = flags;
executed (the execution status of this line is deduced): d->numberFlags = flags;
-
1490}
executed: }
Execution Count:88
88
1491 -
1492/*! -
1493 Returns the current number flags. -
1494 -
1495 \sa setNumberFlags(), integerBase(), realNumberNotation() -
1496*/ -
1497QTextStream::NumberFlags QTextStream::numberFlags() const -
1498{ -
1499 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1500 return d->numberFlags;
executed: return d->numberFlags;
Execution Count:699
699
1501} -
1502 -
1503/*! -
1504 Sets the base of integers to \a base, both for reading and for -
1505 generating numbers. \a base can be either 2 (binary), 8 (octal), -
1506 10 (decimal) or 16 (hexadecimal). If \a base is 0, QTextStream -
1507 will attempt to detect the base by inspecting the data on the -
1508 stream. When generating numbers, QTextStream assumes base is 10 -
1509 unless the base has been set explicitly. -
1510 -
1511 \sa integerBase(), QString::number(), setNumberFlags() -
1512*/ -
1513void QTextStream::setIntegerBase(int base) -
1514{ -
1515 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1516 d->integerBase = base;
executed (the execution status of this line is deduced): d->integerBase = base;
-
1517}
executed: }
Execution Count:56
56
1518 -
1519/*! -
1520 Returns the current base of integers. 0 means that the base is -
1521 detected when reading, or 10 (decimal) when generating numbers. -
1522 -
1523 \sa setIntegerBase(), QString::number(), numberFlags() -
1524*/ -
1525int QTextStream::integerBase() const -
1526{ -
1527 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1528 return d->integerBase;
executed: return d->integerBase;
Execution Count:3
3
1529} -
1530 -
1531/*! -
1532 Sets the real number notation to \a notation (SmartNotation, -
1533 FixedNotation, ScientificNotation). When reading and generating -
1534 numbers, QTextStream uses this value to detect the formatting of -
1535 real numbers. -
1536 -
1537 \sa realNumberNotation(), setRealNumberPrecision(), setNumberFlags(), setIntegerBase() -
1538*/ -
1539void QTextStream::setRealNumberNotation(RealNumberNotation notation) -
1540{ -
1541 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1542 d->realNumberNotation = notation;
executed (the execution status of this line is deduced): d->realNumberNotation = notation;
-
1543}
executed: }
Execution Count:9
9
1544 -
1545/*! -
1546 Returns the current real number notation. -
1547 -
1548 \sa setRealNumberNotation(), realNumberPrecision(), numberFlags(), integerBase() -
1549*/ -
1550QTextStream::RealNumberNotation QTextStream::realNumberNotation() const -
1551{ -
1552 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1553 return d->realNumberNotation;
executed: return d->realNumberNotation;
Execution Count:127
127
1554} -
1555 -
1556/*! -
1557 Sets the precision of real numbers to \a precision. This value -
1558 describes the number of fraction digits QTextStream should -
1559 write when generating real numbers. -
1560 -
1561 The precision cannot be a negative value. The default value is 6. -
1562 -
1563 \sa realNumberPrecision(), setRealNumberNotation() -
1564*/ -
1565void QTextStream::setRealNumberPrecision(int precision) -
1566{ -
1567 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1568 if (precision < 0) {
evaluated: precision < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10
2-10
1569 qWarning("QTextStream::setRealNumberPrecision: Invalid precision (%d)", precision);
executed (the execution status of this line is deduced): QMessageLogger("io/qtextstream.cpp", 1569, __PRETTY_FUNCTION__).warning("QTextStream::setRealNumberPrecision: Invalid precision (%d)", precision);
-
1570 d->realNumberPrecision = 6;
executed (the execution status of this line is deduced): d->realNumberPrecision = 6;
-
1571 return;
executed: return;
Execution Count:2
2
1572 } -
1573 d->realNumberPrecision = precision;
executed (the execution status of this line is deduced): d->realNumberPrecision = precision;
-
1574}
executed: }
Execution Count:10
10
1575 -
1576/*! -
1577 Returns the current real number precision, or the number of fraction -
1578 digits QTextStream will write when generating real numbers. -
1579 -
1580 \sa setRealNumberNotation(), realNumberNotation(), numberFlags(), integerBase() -
1581*/ -
1582int QTextStream::realNumberPrecision() const -
1583{ -
1584 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1585 return d->realNumberPrecision;
executed: return d->realNumberPrecision;
Execution Count:3
3
1586} -
1587 -
1588/*! -
1589 Returns the status of the text stream. -
1590 -
1591 \sa QTextStream::Status, setStatus(), resetStatus() -
1592*/ -
1593 -
1594QTextStream::Status QTextStream::status() const -
1595{ -
1596 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1597 return d->status;
executed: return d->status;
Execution Count:17098
17098
1598} -
1599 -
1600/*! -
1601 \since 4.1 -
1602 -
1603 Resets the status of the text stream. -
1604 -
1605 \sa QTextStream::Status, status(), setStatus() -
1606*/ -
1607void QTextStream::resetStatus() -
1608{ -
1609 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1610 d->status = Ok;
executed (the execution status of this line is deduced): d->status = Ok;
-
1611}
executed: }
Execution Count:3
3
1612 -
1613/*! -
1614 \since 4.1 -
1615 -
1616 Sets the status of the text stream to the \a status given. -
1617 -
1618 Subsequent calls to setStatus() are ignored until resetStatus() -
1619 is called. -
1620 -
1621 \sa Status, status(), resetStatus() -
1622*/ -
1623void QTextStream::setStatus(Status status) -
1624{ -
1625 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1626 if (d->status == Ok)
partially evaluated: d->status == Ok
TRUEFALSE
yes
Evaluation Count:79
no
Evaluation Count:0
0-79
1627 d->status = status;
executed: d->status = status;
Execution Count:79
79
1628}
executed: }
Execution Count:79
79
1629 -
1630/*! -
1631 Returns true if there is no more data to be read from the -
1632 QTextStream; otherwise returns false. This is similar to, but not -
1633 the same as calling QIODevice::atEnd(), as QTextStream also takes -
1634 into account its internal Unicode buffer. -
1635*/ -
1636bool QTextStream::atEnd() const -
1637{ -
1638 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
1639 CHECK_VALID_STREAM(true);
executed: return true;
Execution Count:1
executed: }
Execution Count:112534
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:112534
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:112490
yes
Evaluation Count:45
evaluated: !d->device
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:112489
0-112534
1640 -
1641 if (d->string)
evaluated: d->string
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:112489
45-112489
1642 return d->string->size() == d->stringOffset;
executed: return d->string->size() == d->stringOffset;
Execution Count:45
45
1643 return d->readBuffer.isEmpty() && d->device->atEnd();
executed: return d->readBuffer.isEmpty() && d->device->atEnd();
Execution Count:112489
112489
1644} -
1645 -
1646/*! -
1647 Reads the entire content of the stream, and returns it as a -
1648 QString. Avoid this function when working on large files, as it -
1649 will consume a significant amount of memory. -
1650 -
1651 Calling readLine() is better if you do not know how much data is -
1652 available. -
1653 -
1654 \sa readLine() -
1655*/ -
1656QString QTextStream::readAll() -
1657{ -
1658 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1659 CHECK_VALID_STREAM(QString());
executed: return QString();
Execution Count:1
executed: }
Execution Count:1864
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1864
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:1860
yes
Evaluation Count:5
evaluated: !d->device
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1859
0-1864
1660 -
1661 return d->read(INT_MAX);
executed: return d->read(2147483647);
Execution Count:1864
1864
1662} -
1663 -
1664/*! -
1665 Reads one line of text from the stream, and returns it as a -
1666 QString. The maximum allowed line length is set to \a maxlen. If -
1667 the stream contains lines longer than this, then the lines will be -
1668 split after \a maxlen characters and returned in parts. -
1669 -
1670 If \a maxlen is 0, the lines can be of any length. A common value -
1671 for \a maxlen is 75. -
1672 -
1673 The returned line has no trailing end-of-line characters ("\\n" -
1674 or "\\r\\n"), so calling QString::trimmed() is unnecessary. -
1675 -
1676 If the stream has read to the end of the file, readLine() will return a -
1677 null QString. For strings, or for devices that support it, you can -
1678 explicitly test for the end of the stream using atEnd(). -
1679 -
1680 \sa readAll(), QIODevice::readLine() -
1681*/ -
1682QString QTextStream::readLine(qint64 maxlen) -
1683{ -
1684 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1685 CHECK_VALID_STREAM(QString());
never executed: return QString();
executed: }
Execution Count:128869
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:128869
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:128829
yes
Evaluation Count:40
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:128829
0-128869
1686 -
1687 const QChar *readPtr;
executed (the execution status of this line is deduced): const QChar *readPtr;
-
1688 int length;
executed (the execution status of this line is deduced): int length;
-
1689 if (!d->scan(&readPtr, &length, int(maxlen), QTextStreamPrivate::EndOfLine))
evaluated: !d->scan(&readPtr, &length, int(maxlen), QTextStreamPrivate::EndOfLine)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:128860
9-128860
1690 return QString();
executed: return QString();
Execution Count:9
9
1691 -
1692 QString tmp = QString(readPtr, length);
executed (the execution status of this line is deduced): QString tmp = QString(readPtr, length);
-
1693 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
1694 return tmp;
executed: return tmp;
Execution Count:128860
128860
1695} -
1696 -
1697/*! -
1698 \since 4.1 -
1699 -
1700 Reads at most \a maxlen characters from the stream, and returns the data -
1701 read as a QString. -
1702 -
1703 \sa readAll(), readLine(), QIODevice::read() -
1704*/ -
1705QString QTextStream::read(qint64 maxlen) -
1706{ -
1707 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
1708 CHECK_VALID_STREAM(QString());
never executed: return QString();
executed: }
Execution Count:8
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1709 -
1710 if (maxlen <= 0)
evaluated: maxlen <= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
1711 return QString::fromLatin1(""); // empty, not null
executed: return QString::fromLatin1("");
Execution Count:1
1
1712 -
1713 return d->read(int(maxlen));
executed: return d->read(int(maxlen));
Execution Count:7
7
1714} -
1715 -
1716/*! -
1717 \internal -
1718*/ -
1719QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong *ret) -
1720{ -
1721 scan(0, 0, 0, NotSpace);
executed (the execution status of this line is deduced): scan(0, 0, 0, NotSpace);
-
1722 consumeLastToken();
executed (the execution status of this line is deduced): consumeLastToken();
-
1723 -
1724 // detect int encoding -
1725 int base = integerBase;
executed (the execution status of this line is deduced): int base = integerBase;
-
1726 if (base == 0) {
evaluated: base == 0
TRUEFALSE
yes
Evaluation Count:16443
yes
Evaluation Count:4875
4875-16443
1727 QChar ch;
executed (the execution status of this line is deduced): QChar ch;
-
1728 if (!getChar(&ch))
evaluated: !getChar(&ch)
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:16417
26-16417
1729 return npsInvalidPrefix;
executed: return npsInvalidPrefix;
Execution Count:26
26
1730 if (ch == QLatin1Char('0')) {
evaluated: ch == QLatin1Char('0')
TRUEFALSE
yes
Evaluation Count:1733
yes
Evaluation Count:14684
1733-14684
1731 QChar ch2;
executed (the execution status of this line is deduced): QChar ch2;
-
1732 if (!getChar(&ch2)) {
evaluated: !getChar(&ch2)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1727
6-1727
1733 // Result is the number 0 -
1734 *ret = 0;
executed (the execution status of this line is deduced): *ret = 0;
-
1735 return npsOk;
executed: return npsOk;
Execution Count:6
6
1736 } -
1737 ch2 = ch2.toLower();
executed (the execution status of this line is deduced): ch2 = ch2.toLower();
-
1738 -
1739 if (ch2 == QLatin1Char('x')) {
evaluated: ch2 == QLatin1Char('x')
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:1667
60-1667
1740 base = 16;
executed (the execution status of this line is deduced): base = 16;
-
1741 } else if (ch2 == QLatin1Char('b')) {
executed: }
Execution Count:60
evaluated: ch2 == QLatin1Char('b')
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:1625
42-1625
1742 base = 2;
executed (the execution status of this line is deduced): base = 2;
-
1743 } else if (ch2.isDigit() && ch2.digitValue() >= 0 && ch2.digitValue() <= 7) {
executed: }
Execution Count:42
evaluated: ch2.isDigit()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:1601
partially evaluated: ch2.digitValue() >= 0
TRUEFALSE
yes
Evaluation Count:24
no
Evaluation Count:0
partially evaluated: ch2.digitValue() <= 7
TRUEFALSE
yes
Evaluation Count:24
no
Evaluation Count:0
0-1601
1744 base = 8;
executed (the execution status of this line is deduced): base = 8;
-
1745 } else {
executed: }
Execution Count:24
24
1746 base = 10;
executed (the execution status of this line is deduced): base = 10;
-
1747 }
executed: }
Execution Count:1601
1601
1748 ungetChar(ch2);
executed (the execution status of this line is deduced): ungetChar(ch2);
-
1749 } else if (ch == locale.negativeSign() || ch == locale.positiveSign() || ch.isDigit()) {
executed: }
Execution Count:1727
evaluated: ch == locale.negativeSign()
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:14580
evaluated: ch == locale.positiveSign()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:14578
evaluated: ch.isDigit()
TRUEFALSE
yes
Evaluation Count:14570
yes
Evaluation Count:8
2-14580
1750 base = 10;
executed (the execution status of this line is deduced): base = 10;
-
1751 } else {
executed: }
Execution Count:14676
14676
1752 ungetChar(ch);
executed (the execution status of this line is deduced): ungetChar(ch);
-
1753 return npsInvalidPrefix;
executed: return npsInvalidPrefix;
Execution Count:8
8
1754 } -
1755 ungetChar(ch);
executed (the execution status of this line is deduced): ungetChar(ch);
-
1756 // State of the stream is now the same as on entry -
1757 // (cursor is at prefix), -
1758 // and local variable 'base' has been set appropriately. -
1759 }
executed: }
Execution Count:16403
16403
1760 -
1761 qulonglong val=0;
executed (the execution status of this line is deduced): qulonglong val=0;
-
1762 switch (base) { -
1763 case 2: { -
1764 QChar pf1, pf2, dig;
executed (the execution status of this line is deduced): QChar pf1, pf2, dig;
-
1765 // Parse prefix '0b' -
1766 if (!getChar(&pf1) || pf1 != QLatin1Char('0'))
partially evaluated: !getChar(&pf1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
partially evaluated: pf1 != QLatin1Char('0')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
1767 return npsInvalidPrefix;
never executed: return npsInvalidPrefix;
0
1768 if (!getChar(&pf2) || pf2.toLower() != QLatin1Char('b'))
partially evaluated: !getChar(&pf2)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
partially evaluated: pf2.toLower() != QLatin1Char('b')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
1769 return npsInvalidPrefix;
never executed: return npsInvalidPrefix;
0
1770 // Parse digits -
1771 int ndigits = 0;
executed (the execution status of this line is deduced): int ndigits = 0;
-
1772 while (getChar(&dig)) {
evaluated: getChar(&dig)
TRUEFALSE
yes
Evaluation Count:156
yes
Evaluation Count:30
30-156
1773 int n = dig.toLower().unicode();
executed (the execution status of this line is deduced): int n = dig.toLower().unicode();
-
1774 if (n == '0' || n == '1') {
evaluated: n == '0'
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:84
evaluated: n == '1'
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:12
12-84
1775 val <<= 1;
executed (the execution status of this line is deduced): val <<= 1;
-
1776 val += n - '0';
executed (the execution status of this line is deduced): val += n - '0';
-
1777 } else {
executed: }
Execution Count:144
144
1778 ungetChar(dig);
executed (the execution status of this line is deduced): ungetChar(dig);
-
1779 break;
executed: break;
Execution Count:12
12
1780 } -
1781 ndigits++;
executed (the execution status of this line is deduced): ndigits++;
-
1782 }
executed: }
Execution Count:144
144
1783 if (ndigits == 0) {
partially evaluated: ndigits == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
1784 // Unwind the prefix and abort -
1785 ungetChar(pf2);
never executed (the execution status of this line is deduced): ungetChar(pf2);
-
1786 ungetChar(pf1);
never executed (the execution status of this line is deduced): ungetChar(pf1);
-
1787 return npsMissingDigit;
never executed: return npsMissingDigit;
0
1788 } -
1789 break;
executed: break;
Execution Count:42
42
1790 } -
1791 case 8: { -
1792 QChar pf, dig;
executed (the execution status of this line is deduced): QChar pf, dig;
-
1793 // Parse prefix '0' -
1794 if (!getChar(&pf) || pf != QLatin1Char('0'))
partially evaluated: !getChar(&pf)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
partially evaluated: pf != QLatin1Char('0')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
1795 return npsInvalidPrefix;
never executed: return npsInvalidPrefix;
0
1796 // Parse digits -
1797 int ndigits = 0;
executed (the execution status of this line is deduced): int ndigits = 0;
-
1798 while (getChar(&dig)) {
evaluated: getChar(&dig)
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:12
12-72
1799 int n = dig.toLower().unicode();
executed (the execution status of this line is deduced): int n = dig.toLower().unicode();
-
1800 if (n >= '0' && n <= '7') {
partially evaluated: n >= '0'
TRUEFALSE
yes
Evaluation Count:72
no
Evaluation Count:0
evaluated: n <= '7'
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:12
0-72
1801 val *= 8;
executed (the execution status of this line is deduced): val *= 8;
-
1802 val += n - '0';
executed (the execution status of this line is deduced): val += n - '0';
-
1803 } else {
executed: }
Execution Count:60
60
1804 ungetChar(dig);
executed (the execution status of this line is deduced): ungetChar(dig);
-
1805 break;
executed: break;
Execution Count:12
12
1806 } -
1807 ndigits++;
executed (the execution status of this line is deduced): ndigits++;
-
1808 }
executed: }
Execution Count:60
60
1809 if (ndigits == 0) {
partially evaluated: ndigits == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
1810 // Unwind the prefix and abort -
1811 ungetChar(pf);
never executed (the execution status of this line is deduced): ungetChar(pf);
-
1812 return npsMissingDigit;
never executed: return npsMissingDigit;
0
1813 } -
1814 break;
executed: break;
Execution Count:24
24
1815 } -
1816 case 10: { -
1817 // Parse sign (or first digit) -
1818 QChar sign;
executed (the execution status of this line is deduced): QChar sign;
-
1819 int ndigits = 0;
executed (the execution status of this line is deduced): int ndigits = 0;
-
1820 if (!getChar(&sign))
partially evaluated: !getChar(&sign)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21152
0-21152
1821 return npsMissingDigit;
never executed: return npsMissingDigit;
0
1822 if (sign != locale.negativeSign() && sign != locale.positiveSign()) {
evaluated: sign != locale.negativeSign()
TRUEFALSE
yes
Evaluation Count:21048
yes
Evaluation Count:104
evaluated: sign != locale.positiveSign()
TRUEFALSE
yes
Evaluation Count:21046
yes
Evaluation Count:2
2-21048
1823 if (!sign.isDigit()) {
partially evaluated: !sign.isDigit()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21046
0-21046
1824 ungetChar(sign);
never executed (the execution status of this line is deduced): ungetChar(sign);
-
1825 return npsMissingDigit;
never executed: return npsMissingDigit;
0
1826 } -
1827 val += sign.digitValue();
executed (the execution status of this line is deduced): val += sign.digitValue();
-
1828 ndigits++;
executed (the execution status of this line is deduced): ndigits++;
-
1829 }
executed: }
Execution Count:21046
21046
1830 // Parse digits -
1831 QChar ch;
executed (the execution status of this line is deduced): QChar ch;
-
1832 while (getChar(&ch)) {
evaluated: getChar(&ch)
TRUEFALSE
yes
Evaluation Count:28450
yes
Evaluation Count:260
260-28450
1833 if (ch.isDigit()) {
evaluated: ch.isDigit()
TRUEFALSE
yes
Evaluation Count:7557
yes
Evaluation Count:20893
7557-20893
1834 val *= 10;
executed (the execution status of this line is deduced): val *= 10;
-
1835 val += ch.digitValue();
executed (the execution status of this line is deduced): val += ch.digitValue();
-
1836 } else if (locale != QLocale::c() && ch == locale.groupSeparator()) {
executed: }
Execution Count:7557
evaluated: locale != QLocale::c()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:20892
partially evaluated: ch == locale.groupSeparator()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-20892
1837 continue;
executed: continue;
Execution Count:1
1
1838 } else { -
1839 ungetChar(ch);
executed (the execution status of this line is deduced): ungetChar(ch);
-
1840 break;
executed: break;
Execution Count:20892
20892
1841 } -
1842 ndigits++;
executed (the execution status of this line is deduced): ndigits++;
-
1843 }
executed: }
Execution Count:7557
7557
1844 if (ndigits == 0)
partially evaluated: ndigits == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21152
0-21152
1845 return npsMissingDigit;
never executed: return npsMissingDigit;
0
1846 if (sign == locale.negativeSign()) {
evaluated: sign == locale.negativeSign()
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:21048
104-21048
1847 qlonglong ival = qlonglong(val);
executed (the execution status of this line is deduced): qlonglong ival = qlonglong(val);
-
1848 if (ival > 0)
evaluated: ival > 0
TRUEFALSE
yes
Evaluation Count:98
yes
Evaluation Count:6
6-98
1849 ival = -ival;
executed: ival = -ival;
Execution Count:98
98
1850 val = qulonglong(ival);
executed (the execution status of this line is deduced): val = qulonglong(ival);
-
1851 }
executed: }
Execution Count:104
104
1852 break;
executed: break;
Execution Count:21152
21152
1853 } -
1854 case 16: { -
1855 QChar pf1, pf2, dig;
executed (the execution status of this line is deduced): QChar pf1, pf2, dig;
-
1856 // Parse prefix ' 0x' -
1857 if (!getChar(&pf1) || pf1 != QLatin1Char('0'))
partially evaluated: !getChar(&pf1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
partially evaluated: pf1 != QLatin1Char('0')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
0-60
1858 return npsInvalidPrefix;
never executed: return npsInvalidPrefix;
0
1859 if (!getChar(&pf2) || pf2.toLower() != QLatin1Char('x'))
partially evaluated: !getChar(&pf2)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
partially evaluated: pf2.toLower() != QLatin1Char('x')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
0-60
1860 return npsInvalidPrefix;
never executed: return npsInvalidPrefix;
0
1861 // Parse digits -
1862 int ndigits = 0;
executed (the execution status of this line is deduced): int ndigits = 0;
-
1863 while (getChar(&dig)) {
evaluated: getChar(&dig)
TRUEFALSE
yes
Evaluation Count:318
yes
Evaluation Count:48
48-318
1864 int n = dig.toLower().unicode();
executed (the execution status of this line is deduced): int n = dig.toLower().unicode();
-
1865 if (n >= '0' && n <= '9') {
partially evaluated: n >= '0'
TRUEFALSE
yes
Evaluation Count:318
no
Evaluation Count:0
evaluated: n <= '9'
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:306
0-318
1866 val <<= 4;
executed (the execution status of this line is deduced): val <<= 4;
-
1867 val += n - '0';
executed (the execution status of this line is deduced): val += n - '0';
-
1868 } else if (n >= 'a' && n <= 'f') {
executed: }
Execution Count:12
partially evaluated: n >= 'a'
TRUEFALSE
yes
Evaluation Count:306
no
Evaluation Count:0
evaluated: n <= 'f'
TRUEFALSE
yes
Evaluation Count:294
yes
Evaluation Count:12
0-306
1869 val <<= 4;
executed (the execution status of this line is deduced): val <<= 4;
-
1870 val += 10 + (n - 'a');
executed (the execution status of this line is deduced): val += 10 + (n - 'a');
-
1871 } else {
executed: }
Execution Count:294
294
1872 ungetChar(dig);
executed (the execution status of this line is deduced): ungetChar(dig);
-
1873 break;
executed: break;
Execution Count:12
12
1874 } -
1875 ndigits++;
executed (the execution status of this line is deduced): ndigits++;
-
1876 }
executed: }
Execution Count:306
306
1877 if (ndigits == 0) {
evaluated: ndigits == 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:54
6-54
1878 return npsMissingDigit;
executed: return npsMissingDigit;
Execution Count:6
6
1879 } -
1880 break;
executed: break;
Execution Count:54
54
1881 } -
1882 default: -
1883 // Unsupported integerBase -
1884 return npsInvalidPrefix;
never executed: return npsInvalidPrefix;
0
1885 } -
1886 -
1887 if (ret)
partially evaluated: ret
TRUEFALSE
yes
Evaluation Count:21272
no
Evaluation Count:0
0-21272
1888 *ret = val;
executed: *ret = val;
Execution Count:21272
21272
1889 return npsOk;
executed: return npsOk;
Execution Count:21272
21272
1890} -
1891 -
1892/*! -
1893 \internal -
1894 (hihi) -
1895*/ -
1896bool QTextStreamPrivate::getReal(double *f) -
1897{ -
1898 // We use a table-driven FSM to parse floating point numbers -
1899 // strtod() cannot be used directly since we may be reading from a -
1900 // QIODevice. -
1901 enum ParserState {
executed (the execution status of this line is deduced): enum ParserState {
-
1902 Init = 0,
executed (the execution status of this line is deduced): Init = 0,
-
1903 Sign = 1,
executed (the execution status of this line is deduced): Sign = 1,
-
1904 Mantissa = 2,
executed (the execution status of this line is deduced): Mantissa = 2,
-
1905 Dot = 3,
executed (the execution status of this line is deduced): Dot = 3,
-
1906 Abscissa = 4,
executed (the execution status of this line is deduced): Abscissa = 4,
-
1907 ExpMark = 5,
executed (the execution status of this line is deduced): ExpMark = 5,
-
1908 ExpSign = 6,
executed (the execution status of this line is deduced): ExpSign = 6,
-
1909 Exponent = 7,
executed (the execution status of this line is deduced): Exponent = 7,
-
1910 Nan1 = 8,
executed (the execution status of this line is deduced): Nan1 = 8,
-
1911 Nan2 = 9,
executed (the execution status of this line is deduced): Nan2 = 9,
-
1912 Inf1 = 10,
executed (the execution status of this line is deduced): Inf1 = 10,
-
1913 Inf2 = 11,
executed (the execution status of this line is deduced): Inf2 = 11,
-
1914 NanInf = 12,
executed (the execution status of this line is deduced): NanInf = 12,
-
1915 Done = 13
executed (the execution status of this line is deduced): Done = 13
-
1916 };
executed (the execution status of this line is deduced): };
-
1917 enum InputToken {
executed (the execution status of this line is deduced): enum InputToken {
-
1918 None = 0,
executed (the execution status of this line is deduced): None = 0,
-
1919 InputSign = 1,
executed (the execution status of this line is deduced): InputSign = 1,
-
1920 InputDigit = 2,
executed (the execution status of this line is deduced): InputDigit = 2,
-
1921 InputDot = 3,
executed (the execution status of this line is deduced): InputDot = 3,
-
1922 InputExp = 4,
executed (the execution status of this line is deduced): InputExp = 4,
-
1923 InputI = 5,
executed (the execution status of this line is deduced): InputI = 5,
-
1924 InputN = 6,
executed (the execution status of this line is deduced): InputN = 6,
-
1925 InputF = 7,
executed (the execution status of this line is deduced): InputF = 7,
-
1926 InputA = 8,
executed (the execution status of this line is deduced): InputA = 8,
-
1927 InputT = 9
executed (the execution status of this line is deduced): InputT = 9
-
1928 };
executed (the execution status of this line is deduced): };
-
1929 -
1930 static const uchar table[13][10] = { -
1931 // None InputSign InputDigit InputDot InputExp InputI InputN InputF InputA InputT -
1932 { 0, Sign, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 }, // 0 Init -
1933 { 0, 0, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 }, // 1 Sign -
1934 { Done, Done, Mantissa, Dot, ExpMark, 0, 0, 0, 0, 0 }, // 2 Mantissa -
1935 { 0, 0, Abscissa, 0, 0, 0, 0, 0, 0, 0 }, // 3 Dot -
1936 { Done, Done, Abscissa, Done, ExpMark, 0, 0, 0, 0, 0 }, // 4 Abscissa -
1937 { 0, ExpSign, Exponent, 0, 0, 0, 0, 0, 0, 0 }, // 5 ExpMark -
1938 { 0, 0, Exponent, 0, 0, 0, 0, 0, 0, 0 }, // 6 ExpSign -
1939 { Done, Done, Exponent, Done, Done, 0, 0, 0, 0, 0 }, // 7 Exponent -
1940 { 0, 0, 0, 0, 0, 0, 0, 0, Nan2, 0 }, // 8 Nan1 -
1941 { 0, 0, 0, 0, 0, 0, NanInf, 0, 0, 0 }, // 9 Nan2 -
1942 { 0, 0, 0, 0, 0, 0, Inf2, 0, 0, 0 }, // 10 Inf1 -
1943 { 0, 0, 0, 0, 0, 0, 0, NanInf, 0, 0 }, // 11 Inf2 -
1944 { Done, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 11 NanInf -
1945 }; -
1946 -
1947 ParserState state = Init;
executed (the execution status of this line is deduced): ParserState state = Init;
-
1948 InputToken input = None;
executed (the execution status of this line is deduced): InputToken input = None;
-
1949 -
1950 scan(0, 0, 0, NotSpace);
executed (the execution status of this line is deduced): scan(0, 0, 0, NotSpace);
-
1951 consumeLastToken();
executed (the execution status of this line is deduced): consumeLastToken();
-
1952 -
1953 const int BufferSize = 128;
executed (the execution status of this line is deduced): const int BufferSize = 128;
-
1954 char buf[BufferSize];
executed (the execution status of this line is deduced): char buf[BufferSize];
-
1955 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1956 -
1957 QChar c;
executed (the execution status of this line is deduced): QChar c;
-
1958 while (getChar(&c)) {
evaluated: getChar(&c)
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:29
29-282
1959 switch (c.unicode()) { -
1960 case '0': case '1': case '2': case '3': case '4': -
1961 case '5': case '6': case '7': case '8': case '9': -
1962 input = InputDigit;
executed (the execution status of this line is deduced): input = InputDigit;
-
1963 break;
executed: break;
Execution Count:77
77
1964 case 'i': case 'I': -
1965 input = InputI;
executed (the execution status of this line is deduced): input = InputI;
-
1966 break;
executed: break;
Execution Count:18
18
1967 case 'n': case 'N': -
1968 input = InputN;
executed (the execution status of this line is deduced): input = InputN;
-
1969 break;
executed: break;
Execution Count:54
54
1970 case 'f': case 'F': -
1971 input = InputF;
executed (the execution status of this line is deduced): input = InputF;
-
1972 break;
executed: break;
Execution Count:18
18
1973 case 'a': case 'A': -
1974 input = InputA;
executed (the execution status of this line is deduced): input = InputA;
-
1975 break;
executed: break;
Execution Count:21
21
1976 case 't': case 'T': -
1977 input = InputT;
never executed (the execution status of this line is deduced): input = InputT;
-
1978 break;
never executed: break;
0
1979 default: { -
1980 QChar lc = c.toLower();
executed (the execution status of this line is deduced): QChar lc = c.toLower();
-
1981 if (lc == locale.decimalPoint().toLower())
evaluated: lc == locale.decimalPoint().toLower()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:81
13-81
1982 input = InputDot;
executed: input = InputDot;
Execution Count:13
13
1983 else if (lc == locale.exponential().toLower())
evaluated: lc == locale.exponential().toLower()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:73
8-73
1984 input = InputExp;
executed: input = InputExp;
Execution Count:8
8
1985 else if (lc == locale.negativeSign().toLower()
evaluated: lc == locale.negativeSign().toLower()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:53
20-53
1986 || lc == locale.positiveSign().toLower())
evaluated: lc == locale.positiveSign().toLower()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:37
16-37
1987 input = InputSign;
executed: input = InputSign;
Execution Count:36
36
1988 else if (locale != QLocale::c() // backward-compatibility
partially evaluated: locale != QLocale::c()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
1989 && lc == locale.groupSeparator().toLower())
never evaluated: lc == locale.groupSeparator().toLower()
0
1990 input = InputDigit; // well, it isn't a digit, but no one cares.
never executed: input = InputDigit;
0
1991 else -
1992 input = None;
executed: input = None;
Execution Count:37
37
1993 } -
1994 break;
executed: break;
Execution Count:94
94
1995 } -
1996 -
1997 state = ParserState(table[state][input]);
executed (the execution status of this line is deduced): state = ParserState(table[state][input]);
-
1998 -
1999 if (state == Init || state == Done || i > (BufferSize - 5)) {
evaluated: state == Init
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:279
evaluated: state == Done
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:242
partially evaluated: i > (BufferSize - 5)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:242
0-279
2000 ungetChar(c);
executed (the execution status of this line is deduced): ungetChar(c);
-
2001 if (i > (BufferSize - 5)) { // ignore rest of digits
partially evaluated: i > (BufferSize - 5)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-40
2002 while (getChar(&c)) {
never evaluated: getChar(&c)
0
2003 if (!c.isDigit()) {
never evaluated: !c.isDigit()
0
2004 ungetChar(c);
never executed (the execution status of this line is deduced): ungetChar(c);
-
2005 break;
never executed: break;
0
2006 } -
2007 }
never executed: }
0
2008 }
never executed: }
0
2009 break;
executed: break;
Execution Count:40
40
2010 } -
2011 -
2012 buf[i++] = c.toLatin1();
executed (the execution status of this line is deduced): buf[i++] = c.toLatin1();
-
2013 }
executed: }
Execution Count:242
242
2014 -
2015 if (i == 0)
evaluated: i == 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:59
10-59
2016 return false;
executed: return false;
Execution Count:10
10
2017 if (!f)
partially evaluated: !f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:59
0-59
2018 return true;
never executed: return true;
0
2019 buf[i] = '\0';
executed (the execution status of this line is deduced): buf[i] = '\0';
-
2020 -
2021 // backward-compatibility. Old implementation supported +nan/-nan -
2022 // for some reason. QLocale only checks for lower-case -
2023 // nan/+inf/-inf, so here we also check for uppercase and mixed -
2024 // case versions. -
2025 if (!qstricmp(buf, "nan") || !qstricmp(buf, "+nan") || !qstricmp(buf, "-nan")) {
evaluated: !qstricmp(buf, "nan")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:53
evaluated: !qstricmp(buf, "+nan")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:47
evaluated: !qstricmp(buf, "-nan")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:41
6-53
2026 *f = qSNaN();
executed (the execution status of this line is deduced): *f = qSNaN();
-
2027 return true;
executed: return true;
Execution Count:18
18
2028 } else if (!qstricmp(buf, "+inf") || !qstricmp(buf, "inf")) {
evaluated: !qstricmp(buf, "+inf")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:35
evaluated: !qstricmp(buf, "inf")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:29
6-35
2029 *f = qInf();
executed (the execution status of this line is deduced): *f = qInf();
-
2030 return true;
executed: return true;
Execution Count:12
12
2031 } else if (!qstricmp(buf, "-inf")) {
evaluated: !qstricmp(buf, "-inf")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:23
6-23
2032 *f = -qInf();
executed (the execution status of this line is deduced): *f = -qInf();
-
2033 return true;
executed: return true;
Execution Count:6
6
2034 } -
2035 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
2036 *f = locale.toDouble(QString::fromLatin1(buf), &ok);
executed (the execution status of this line is deduced): *f = locale.toDouble(QString::fromLatin1(buf), &ok);
-
2037 return ok;
executed: return ok;
Execution Count:23
23
2038} -
2039 -
2040/*! -
2041 Reads a character from the stream and stores it in \a c. Returns a -
2042 reference to the QTextStream, so several operators can be -
2043 nested. Example: -
2044 -
2045 \snippet code/src_corelib_io_qtextstream.cpp 7 -
2046 -
2047 Whitespace is \e not skipped. -
2048*/ -
2049 -
2050QTextStream &QTextStream::operator>>(QChar &c) -
2051{ -
2052 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2053 CHECK_VALID_STREAM(*this);
executed: return *this;
Execution Count:1
executed: }
Execution Count:839
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:839
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:830
yes
Evaluation Count:10
evaluated: !d->device
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:829
0-839
2054 d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
executed (the execution status of this line is deduced): d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
-
2055 if (!d->getChar(&c))
evaluated: !d->getChar(&c)
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:823
16-823
2056 setStatus(ReadPastEnd);
executed: setStatus(ReadPastEnd);
Execution Count:16
16
2057 return *this;
executed: return *this;
Execution Count:839
839
2058} -
2059 -
2060/*! -
2061 \overload -
2062 -
2063 Reads a character from the stream and stores it in \a c. The -
2064 character from the stream is converted to ISO-5589-1 before it is -
2065 stored. -
2066 -
2067 \sa QChar::toLatin1() -
2068*/ -
2069QTextStream &QTextStream::operator>>(char &c) -
2070{ -
2071 QChar ch;
executed (the execution status of this line is deduced): QChar ch;
-
2072 *this >> ch;
executed (the execution status of this line is deduced): *this >> ch;
-
2073 c = ch.toLatin1();
executed (the execution status of this line is deduced): c = ch.toLatin1();
-
2074 return *this;
executed: return *this;
Execution Count:19
19
2075} -
2076 -
2077/*! -
2078 Reads an integer from the stream and stores it in \a i, then -
2079 returns a reference to the QTextStream. The number is cast to -
2080 the correct type before it is stored. If no number was detected on -
2081 the stream, \a i is set to 0. -
2082 -
2083 By default, QTextStream will attempt to detect the base of the -
2084 number using the following rules: -
2085 -
2086 \table -
2087 \header \li Prefix \li Base -
2088 \row \li "0b" or "0B" \li 2 (binary) -
2089 \row \li "0" followed by "0-7" \li 8 (octal) -
2090 \row \li "0" otherwise \li 10 (decimal) -
2091 \row \li "0x" or "0X" \li 16 (hexadecimal) -
2092 \row \li "1" to "9" \li 10 (decimal) -
2093 \endtable -
2094 -
2095 By calling setIntegerBase(), you can specify the integer base -
2096 explicitly. This will disable the auto-detection, and speed up -
2097 QTextStream slightly. -
2098 -
2099 Leading whitespace is skipped. -
2100*/ -
2101QTextStream &QTextStream::operator>>(signed short &i) -
2102{ -
2103 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(signed short);
never executed: return *this;
executed: }
Execution Count:69
executed: break;
Execution Count:63
executed: break;
Execution Count:6
executed: return *this;
Execution Count:69
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
never evaluated: 0
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
0-69
2104}
never executed: }
0
2105 -
2106/*! -
2107 \overload -
2108 -
2109 Stores the integer in the unsigned short \a i. -
2110*/ -
2111QTextStream &QTextStream::operator>>(unsigned short &i) -
2112{ -
2113 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(unsigned short);
never executed: return *this;
executed: }
Execution Count:69
executed: break;
Execution Count:63
executed: break;
Execution Count:6
executed: return *this;
Execution Count:69
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
never evaluated: 0
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
0-69
2114}
never executed: }
0
2115 -
2116/*! -
2117 \overload -
2118 -
2119 Stores the integer in the signed int \a i. -
2120*/ -
2121QTextStream &QTextStream::operator>>(signed int &i) -
2122{ -
2123 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(signed int);
never executed: return *this;
executed: }
Execution Count:20973
executed: break;
Execution Count:20963
executed: break;
Execution Count:10
executed: return *this;
Execution Count:20973
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20973
never evaluated: 0
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:20961
yes
Evaluation Count:12
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20961
0-20973
2124}
never executed: }
0
2125 -
2126/*! -
2127 \overload -
2128 -
2129 Stores the integer in the unsigned int \a i. -
2130*/ -
2131QTextStream &QTextStream::operator>>(unsigned int &i) -
2132{ -
2133 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(unsigned int);
never executed: return *this;
executed: }
Execution Count:69
executed: break;
Execution Count:63
executed: break;
Execution Count:6
executed: return *this;
Execution Count:69
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
never evaluated: 0
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
0-69
2134}
never executed: }
0
2135 -
2136/*! -
2137 \overload -
2138 -
2139 Stores the integer in the signed long \a i. -
2140*/ -
2141QTextStream &QTextStream::operator>>(signed long &i) -
2142{ -
2143 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(signed long);
never executed: return *this;
never executed: }
never executed: break;
never executed: break;
never executed: return *this;
never evaluated: 0
never evaluated: 0
never evaluated: !d->string
never evaluated: !d->device
0
2144}
never executed: }
0
2145 -
2146/*! -
2147 \overload -
2148 -
2149 Stores the integer in the unsigned long \a i. -
2150*/ -
2151QTextStream &QTextStream::operator>>(unsigned long &i) -
2152{ -
2153 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(unsigned long);
never executed: return *this;
never executed: }
never executed: break;
never executed: break;
never executed: return *this;
never evaluated: 0
never evaluated: 0
never evaluated: !d->string
never evaluated: !d->device
0
2154}
never executed: }
0
2155 -
2156/*! -
2157 \overload -
2158 -
2159 Stores the integer in the qlonglong \a i. -
2160*/ -
2161QTextStream &QTextStream::operator>>(qlonglong &i) -
2162{ -
2163 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(qlonglong);
never executed: return *this;
executed: }
Execution Count:69
executed: break;
Execution Count:63
executed: break;
Execution Count:6
executed: return *this;
Execution Count:69
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
never evaluated: 0
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
0-69
2164}
never executed: }
0
2165 -
2166/*! -
2167 \overload -
2168 -
2169 Stores the integer in the qulonglong \a i. -
2170*/ -
2171QTextStream &QTextStream::operator>>(qulonglong &i) -
2172{ -
2173 IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(qulonglong);
never executed: return *this;
executed: }
Execution Count:69
executed: break;
Execution Count:63
executed: break;
Execution Count:6
executed: return *this;
Execution Count:69
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
never evaluated: 0
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:69
no
Evaluation Count:0
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
0-69
2174}
never executed: }
0
2175 -
2176/*! -
2177 Reads a real number from the stream and stores it in \a f, then -
2178 returns a reference to the QTextStream. The number is cast to -
2179 the correct type. If no real number is detect on the stream, \a f -
2180 is set to 0.0. -
2181 -
2182 As a special exception, QTextStream allows the strings "nan" and "inf" to -
2183 represent NAN and INF floats or doubles. -
2184 -
2185 Leading whitespace is skipped. -
2186*/ -
2187QTextStream &QTextStream::operator>>(float &f) -
2188{ -
2189 IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR(float);
never executed: return *this;
executed: }
Execution Count:32
executed: }
Execution Count:28
executed: }
Execution Count:4
executed: return *this;
Execution Count:32
evaluated: d->getReal(&tmp)
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:4
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
never evaluated: 0
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:18
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-32
2190}
never executed: }
0
2191 -
2192/*! -
2193 \overload -
2194 -
2195 Stores the real number in the double \a f. -
2196*/ -
2197QTextStream &QTextStream::operator>>(double &f) -
2198{ -
2199 IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR(double);
never executed: return *this;
executed: }
Execution Count:37
executed: }
Execution Count:31
executed: }
Execution Count:6
executed: return *this;
Execution Count:37
evaluated: d->getReal(&tmp)
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:6
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
never evaluated: 0
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:21
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-37
2200}
never executed: }
0
2201 -
2202/*! -
2203 Reads a word from the stream and stores it in \a str, then returns -
2204 a reference to the stream. Words are separated by whitespace -
2205 (i.e., all characters for which QChar::isSpace() returns true). -
2206 -
2207 Leading whitespace is skipped. -
2208*/ -
2209QTextStream &QTextStream::operator>>(QString &str) -
2210{ -
2211 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2212 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:437
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:437
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:425
yes
Evaluation Count:12
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:425
0-437
2213 -
2214 str.clear();
executed (the execution status of this line is deduced): str.clear();
-
2215 d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
executed (the execution status of this line is deduced): d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
-
2216 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
2217 -
2218 const QChar *ptr;
executed (the execution status of this line is deduced): const QChar *ptr;
-
2219 int length;
executed (the execution status of this line is deduced): int length;
-
2220 if (!d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)) {
evaluated: !d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:433
4-433
2221 setStatus(ReadPastEnd);
executed (the execution status of this line is deduced): setStatus(ReadPastEnd);
-
2222 return *this;
executed: return *this;
Execution Count:4
4
2223 } -
2224 -
2225 str = QString(ptr, length);
executed (the execution status of this line is deduced): str = QString(ptr, length);
-
2226 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
2227 return *this;
executed: return *this;
Execution Count:433
433
2228} -
2229 -
2230/*! -
2231 \overload -
2232 -
2233 Converts the word to ISO-8859-1, then stores it in \a array. -
2234 -
2235 \sa QString::toLatin1() -
2236*/ -
2237QTextStream &QTextStream::operator>>(QByteArray &array) -
2238{ -
2239 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2240 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:14
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
2241 -
2242 array.clear();
executed (the execution status of this line is deduced): array.clear();
-
2243 d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
executed (the execution status of this line is deduced): d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
-
2244 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
2245 -
2246 const QChar *ptr;
executed (the execution status of this line is deduced): const QChar *ptr;
-
2247 int length;
executed (the execution status of this line is deduced): int length;
-
2248 if (!d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)) {
evaluated: !d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:11
3-11
2249 setStatus(ReadPastEnd);
executed (the execution status of this line is deduced): setStatus(ReadPastEnd);
-
2250 return *this;
executed: return *this;
Execution Count:3
3
2251 } -
2252 -
2253 for (int i = 0; i < length; ++i)
evaluated: i < length
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:11
11-20
2254 array += ptr[i].toLatin1();
executed: array += ptr[i].toLatin1();
Execution Count:20
20
2255 -
2256 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
2257 return *this;
executed: return *this;
Execution Count:11
11
2258} -
2259 -
2260/*! -
2261 \overload -
2262 -
2263 Stores the word in \a c, terminated by a '\\0' character. If no word is -
2264 available, only the '\\0' character is stored. -
2265 -
2266 Warning: Although convenient, this operator is dangerous and must -
2267 be used with care. QTextStream assumes that \a c points to a -
2268 buffer with enough space to hold the word. If the buffer is too -
2269 small, your application may crash. -
2270 -
2271 If possible, use the QByteArray operator instead. -
2272*/ -
2273QTextStream &QTextStream::operator>>(char *c) -
2274{ -
2275 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2276 *c = 0;
executed (the execution status of this line is deduced): *c = 0;
-
2277 CHECK_VALID_STREAM(*this);
executed: return *this;
Execution Count:1
executed: }
Execution Count:12
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
evaluated: !d->device
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
0-13
2278 d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
executed (the execution status of this line is deduced): d->scan(0, 0, 0, QTextStreamPrivate::NotSpace);
-
2279 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
2280 -
2281 const QChar *ptr;
executed (the execution status of this line is deduced): const QChar *ptr;
-
2282 int length;
executed (the execution status of this line is deduced): int length;
-
2283 if (!d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)) {
evaluated: !d->scan(&ptr, &length, 0, QTextStreamPrivate::Space)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:9
3-9
2284 setStatus(ReadPastEnd);
executed (the execution status of this line is deduced): setStatus(ReadPastEnd);
-
2285 return *this;
executed: return *this;
Execution Count:3
3
2286 } -
2287 -
2288 for (int i = 0; i < length; ++i)
evaluated: i < length
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:9
9-14
2289 *c++ = ptr[i].toLatin1();
executed: *c++ = ptr[i].toLatin1();
Execution Count:14
14
2290 *c = '\0';
executed (the execution status of this line is deduced): *c = '\0';
-
2291 d->consumeLastToken();
executed (the execution status of this line is deduced): d->consumeLastToken();
-
2292 return *this;
executed: return *this;
Execution Count:9
9
2293} -
2294 -
2295/*! -
2296 \internal -
2297 */ -
2298void QTextStreamPrivate::putNumber(qulonglong number, bool negative) -
2299{ -
2300 QString result;
executed (the execution status of this line is deduced): QString result;
-
2301 -
2302 unsigned flags = 0;
executed (the execution status of this line is deduced): unsigned flags = 0;
-
2303 if (numberFlags & QTextStream::ShowBase)
evaluated: numberFlags & QTextStream::ShowBase
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:4999
94-4999
2304 flags |= QLocalePrivate::ShowBase;
executed: flags |= QLocalePrivate::ShowBase;
Execution Count:94
94
2305 if (numberFlags & QTextStream::ForceSign)
evaluated: numberFlags & QTextStream::ForceSign
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5090
3-5090
2306 flags |= QLocalePrivate::AlwaysShowSign;
executed: flags |= QLocalePrivate::AlwaysShowSign;
Execution Count:3
3
2307 if (numberFlags & QTextStream::UppercaseBase)
evaluated: numberFlags & QTextStream::UppercaseBase
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:5086
7-5086
2308 flags |= QLocalePrivate::UppercaseBase;
executed: flags |= QLocalePrivate::UppercaseBase;
Execution Count:7
7
2309 if (numberFlags & QTextStream::UppercaseDigits)
evaluated: numberFlags & QTextStream::UppercaseDigits
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:5084
9-5084
2310 flags |= QLocalePrivate::CapitalEorX;
executed: flags |= QLocalePrivate::CapitalEorX;
Execution Count:9
9
2311 -
2312 // add thousands group separators. For backward compatibility we -
2313 // don't add a group separator for C locale. -
2314 if (locale != QLocale::c())
evaluated: locale != QLocale::c()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5090
3-5090
2315 flags |= QLocalePrivate::ThousandsGroup;
executed: flags |= QLocalePrivate::ThousandsGroup;
Execution Count:3
3
2316 -
2317 const QLocalePrivate *dd = locale.d;
executed (the execution status of this line is deduced): const QLocalePrivate *dd = locale.d;
-
2318 int base = integerBase ? integerBase : 10;
evaluated: integerBase
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:4992
101-4992
2319 if (negative && base == 10) {
evaluated: negative
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:5042
evaluated: base == 10
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:4
4-5042
2320 result = dd->longLongToString(-static_cast<qlonglong>(number), -1,
executed (the execution status of this line is deduced): result = dd->longLongToString(-static_cast<qlonglong>(number), -1,
-
2321 base, -1, flags);
executed (the execution status of this line is deduced): base, -1, flags);
-
2322 } else if (negative) {
executed: }
Execution Count:47
evaluated: negative
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5042
4-5042
2323 // Workaround for backward compatibility for writing negative -
2324 // numbers in octal and hex: -
2325 // QTextStream(result) << showbase << hex << -1 << oct << -1 -
2326 // should output: -0x1 -0b1 -
2327 result = dd->unsLongLongToString(number, -1, base, -1, flags);
executed (the execution status of this line is deduced): result = dd->unsLongLongToString(number, -1, base, -1, flags);
-
2328 result.prepend(locale.negativeSign());
executed (the execution status of this line is deduced): result.prepend(locale.negativeSign());
-
2329 } else {
executed: }
Execution Count:4
4
2330 result = dd->unsLongLongToString(number, -1, base, -1, flags);
executed (the execution status of this line is deduced): result = dd->unsLongLongToString(number, -1, base, -1, flags);
-
2331 // workaround for backward compatibility - in octal form with -
2332 // ShowBase flag set zero should be written as '00' -
2333 if (number == 0 && base == 8 && numberFlags & QTextStream::ShowBase
evaluated: number == 0
TRUEFALSE
yes
Evaluation Count:264
yes
Evaluation Count:4778
evaluated: base == 8
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:263
partially evaluated: numberFlags & QTextStream::ShowBase
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-4778
2334 && result == QLatin1String("0")) {
partially evaluated: result == QLatin1String("0")
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2335 result.prepend(QLatin1Char('0'));
executed (the execution status of this line is deduced): result.prepend(QLatin1Char('0'));
-
2336 }
executed: }
Execution Count:1
1
2337 }
executed: }
Execution Count:5042
5042
2338 putString(result, true);
executed (the execution status of this line is deduced): putString(result, true);
-
2339}
executed: }
Execution Count:5093
5093
2340 -
2341/*! -
2342 Writes the character \a c to the stream, then returns a reference -
2343 to the QTextStream. -
2344 -
2345 \sa setFieldWidth() -
2346*/ -
2347QTextStream &QTextStream::operator<<(QChar c) -
2348{ -
2349 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2350 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:50129
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50129
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:34770
yes
Evaluation Count:15359
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34770
0-50129
2351 d->putString(QString(c));
executed (the execution status of this line is deduced): d->putString(QString(c));
-
2352 return *this;
executed: return *this;
Execution Count:50129
50129
2353} -
2354 -
2355/*! -
2356 \overload -
2357 -
2358 Converts \a c from ASCII to a QChar, then writes it to the stream. -
2359*/ -
2360QTextStream &QTextStream::operator<<(char c) -
2361{ -
2362 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2363 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:159310
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:159310
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:97726
yes
Evaluation Count:61584
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:97726
0-159310
2364 d->putString(QString(QChar::fromLatin1(c)));
executed (the execution status of this line is deduced): d->putString(QString(QChar::fromLatin1(c)));
-
2365 return *this;
executed: return *this;
Execution Count:159310
159310
2366} -
2367 -
2368/*! -
2369 Writes the integer number \a i to the stream, then returns a -
2370 reference to the QTextStream. By default, the number is stored in -
2371 decimal form, but you can also set the base by calling -
2372 setIntegerBase(). -
2373 -
2374 \sa setFieldWidth(), setNumberFlags() -
2375*/ -
2376QTextStream &QTextStream::operator<<(signed short i) -
2377{ -
2378 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2379 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:10
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-10
2380 d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0);
executed (the execution status of this line is deduced): d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0);
-
2381 return *this;
executed: return *this;
Execution Count:10
10
2382} -
2383 -
2384/*! -
2385 \overload -
2386 -
2387 Writes the unsigned short \a i to the stream. -
2388*/ -
2389QTextStream &QTextStream::operator<<(unsigned short i) -
2390{ -
2391 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2392 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:35
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:26
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-35
2393 d->putNumber((qulonglong)i, false);
executed (the execution status of this line is deduced): d->putNumber((qulonglong)i, false);
-
2394 return *this;
executed: return *this;
Execution Count:35
35
2395} -
2396 -
2397/*! -
2398 \overload -
2399 -
2400 Writes the signed int \a i to the stream. -
2401*/ -
2402QTextStream &QTextStream::operator<<(signed int i) -
2403{ -
2404 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2405 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:4816
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4816
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:3191
yes
Evaluation Count:1625
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3191
0-4816
2406 d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0);
executed (the execution status of this line is deduced): d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0);
-
2407 return *this;
executed: return *this;
Execution Count:4816
4816
2408} -
2409 -
2410/*! -
2411 \overload -
2412 -
2413 Writes the unsigned int \a i to the stream. -
2414*/ -
2415QTextStream &QTextStream::operator<<(unsigned int i) -
2416{ -
2417 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2418 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:16
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-16
2419 d->putNumber((qulonglong)i, false);
executed (the execution status of this line is deduced): d->putNumber((qulonglong)i, false);
-
2420 return *this;
executed: return *this;
Execution Count:16
16
2421} -
2422 -
2423/*! -
2424 \overload -
2425 -
2426 Writes the signed long \a i to the stream. -
2427*/ -
2428QTextStream &QTextStream::operator<<(signed long i) -
2429{ -
2430 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2431 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:1
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: !d->string
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: !d->device
0-1
2432 d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0);
executed (the execution status of this line is deduced): d->putNumber((qulonglong)qAbs(qlonglong(i)), i < 0);
-
2433 return *this;
executed: return *this;
Execution Count:1
1
2434} -
2435 -
2436/*! -
2437 \overload -
2438 -
2439 Writes the unsigned long \a i to the stream. -
2440*/ -
2441QTextStream &QTextStream::operator<<(unsigned long i) -
2442{ -
2443 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2444 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:1
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: !d->string
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: !d->device
0-1
2445 d->putNumber((qulonglong)i, false);
executed (the execution status of this line is deduced): d->putNumber((qulonglong)i, false);
-
2446 return *this;
executed: return *this;
Execution Count:1
1
2447} -
2448 -
2449/*! -
2450 \overload -
2451 -
2452 Writes the qlonglong \a i to the stream. -
2453*/ -
2454QTextStream &QTextStream::operator<<(qlonglong i) -
2455{ -
2456 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2457 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:136
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:136
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:96
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:40
0-136
2458 d->putNumber((qulonglong)qAbs(i), i < 0);
executed (the execution status of this line is deduced): d->putNumber((qulonglong)qAbs(i), i < 0);
-
2459 return *this;
executed: return *this;
Execution Count:136
136
2460} -
2461 -
2462/*! -
2463 \overload -
2464 -
2465 Writes the qulonglong \a i to the stream. -
2466*/ -
2467QTextStream &QTextStream::operator<<(qulonglong i) -
2468{ -
2469 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2470 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:29
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:10
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-29
2471 d->putNumber(i, false);
executed (the execution status of this line is deduced): d->putNumber(i, false);
-
2472 return *this;
executed: return *this;
Execution Count:29
29
2473} -
2474 -
2475/*! -
2476 Writes the real number \a f to the stream, then returns a -
2477 reference to the QTextStream. By default, QTextStream stores it -
2478 using SmartNotation, with up to 6 digits of precision. You can -
2479 change the textual representation QTextStream will use for real -
2480 numbers by calling setRealNumberNotation(), -
2481 setRealNumberPrecision() and setNumberFlags(). -
2482 -
2483 \sa setFieldWidth(), setRealNumberNotation(), -
2484 setRealNumberPrecision(), setNumberFlags() -
2485*/ -
2486QTextStream &QTextStream::operator<<(float f) -
2487{ -
2488 return *this << double(f);
executed: return *this << double(f);
Execution Count:40
40
2489} -
2490 -
2491/*! -
2492 \overload -
2493 -
2494 Writes the double \a f to the stream. -
2495*/ -
2496QTextStream &QTextStream::operator<<(double f) -
2497{ -
2498 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2499 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:124
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:124
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:110
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-124
2500 -
2501 QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal;
executed (the execution status of this line is deduced): QLocalePrivate::DoubleForm form = QLocalePrivate::DFDecimal;
-
2502 switch (realNumberNotation()) { -
2503 case FixedNotation: -
2504 form = QLocalePrivate::DFDecimal;
executed (the execution status of this line is deduced): form = QLocalePrivate::DFDecimal;
-
2505 break;
executed: break;
Execution Count:2
2
2506 case ScientificNotation: -
2507 form = QLocalePrivate::DFExponent;
executed (the execution status of this line is deduced): form = QLocalePrivate::DFExponent;
-
2508 break;
executed: break;
Execution Count:5
5
2509 case SmartNotation: -
2510 form = QLocalePrivate::DFSignificantDigits;
executed (the execution status of this line is deduced): form = QLocalePrivate::DFSignificantDigits;
-
2511 break;
executed: break;
Execution Count:117
117
2512 } -
2513 -
2514 uint flags = 0;
executed (the execution status of this line is deduced): uint flags = 0;
-
2515 if (numberFlags() & ShowBase)
partially evaluated: numberFlags() & ShowBase
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:124
0-124
2516 flags |= QLocalePrivate::ShowBase;
never executed: flags |= QLocalePrivate::ShowBase;
0
2517 if (numberFlags() & ForceSign)
evaluated: numberFlags() & ForceSign
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:120
4-120
2518 flags |= QLocalePrivate::AlwaysShowSign;
executed: flags |= QLocalePrivate::AlwaysShowSign;
Execution Count:4
4
2519 if (numberFlags() & UppercaseBase)
evaluated: numberFlags() & UppercaseBase
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:123
1-123
2520 flags |= QLocalePrivate::UppercaseBase;
executed: flags |= QLocalePrivate::UppercaseBase;
Execution Count:1
1
2521 if (numberFlags() & UppercaseDigits)
evaluated: numberFlags() & UppercaseDigits
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:117
7-117
2522 flags |= QLocalePrivate::CapitalEorX;
executed: flags |= QLocalePrivate::CapitalEorX;
Execution Count:7
7
2523 if (numberFlags() & ForcePoint)
evaluated: numberFlags() & ForcePoint
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:118
6-118
2524 flags |= QLocalePrivate::Alternate;
executed: flags |= QLocalePrivate::Alternate;
Execution Count:6
6
2525 -
2526 const QLocalePrivate *dd = d->locale.d;
executed (the execution status of this line is deduced): const QLocalePrivate *dd = d->locale.d;
-
2527 QString num = dd->doubleToString(f, d->realNumberPrecision, form, -1, flags);
executed (the execution status of this line is deduced): QString num = dd->doubleToString(f, d->realNumberPrecision, form, -1, flags);
-
2528 d->putString(num, true);
executed (the execution status of this line is deduced): d->putString(num, true);
-
2529 return *this;
executed: return *this;
Execution Count:124
124
2530} -
2531 -
2532/*! -
2533 Writes the string \a string to the stream, and returns a reference -
2534 to the QTextStream. The string is first encoded using the assigned -
2535 codec (the default codec is QTextCodec::codecForLocale()) before -
2536 it is written to the stream. -
2537 -
2538 \sa setFieldWidth(), setCodec() -
2539*/ -
2540QTextStream &QTextStream::operator<<(const QString &string) -
2541{ -
2542 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2543 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:211832
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:211832
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:122439
yes
Evaluation Count:89393
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:122439
0-211832
2544 d->putString(string);
executed (the execution status of this line is deduced): d->putString(string);
-
2545 return *this;
executed: return *this;
Execution Count:211832
211832
2546} -
2547 -
2548/*! -
2549 \overload -
2550 -
2551 Writes \a string to the stream, and returns a reference to the -
2552 QTextStream. The contents of \a string are converted with the -
2553 QString constructor that takes a QLatin1String as argument. -
2554*/ -
2555QTextStream &QTextStream::operator<<(QLatin1String string) -
2556{ -
2557 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2558 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:6
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-6
2559 d->putString(QString(string));
executed (the execution status of this line is deduced): d->putString(QString(string));
-
2560 return *this;
executed: return *this;
Execution Count:6
6
2561} -
2562 -
2563/*! -
2564 \overload -
2565 -
2566 Writes \a array to the stream. The contents of \a array are -
2567 converted with QString::fromUtf8(). -
2568*/ -
2569QTextStream &QTextStream::operator<<(const QByteArray &array) -
2570{ -
2571 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2572 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:69
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:4
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:65
0-69
2573 d->putString(QString::fromUtf8(array.constData(), array.length()));
executed (the execution status of this line is deduced): d->putString(QString::fromUtf8(array.constData(), array.length()));
-
2574 return *this;
executed: return *this;
Execution Count:69
69
2575} -
2576 -
2577/*! -
2578 \overload -
2579 -
2580 Writes the constant string pointed to by \a string to the stream. \a -
2581 string is assumed to be in ISO-8859-1 encoding. This operator -
2582 is convenient when working with constant string data. Example: -
2583 -
2584 \snippet code/src_corelib_io_qtextstream.cpp 8 -
2585 -
2586 Warning: QTextStream assumes that \a string points to a string of -
2587 text, terminated by a '\\0' character. If there is no terminating -
2588 '\\0' character, your application may crash. -
2589*/ -
2590QTextStream &QTextStream::operator<<(const char *string) -
2591{ -
2592 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2593 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:67955
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:67955
evaluated: !d->string
TRUEFALSE
yes
Evaluation Count:44304
yes
Evaluation Count:23651
partially evaluated: !d->device
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44304
0-67955
2594 d->putString(QLatin1String(string));
executed (the execution status of this line is deduced): d->putString(QLatin1String(string));
-
2595 return *this;
executed: return *this;
Execution Count:67955
67955
2596} -
2597 -
2598/*! -
2599 \overload -
2600 -
2601 Writes \a ptr to the stream as a hexadecimal number with a base. -
2602*/ -
2603 -
2604QTextStream &QTextStream::operator<<(const void *ptr) -
2605{ -
2606 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2607 CHECK_VALID_STREAM(*this);
never executed: return *this;
executed: }
Execution Count:49
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49
partially evaluated: !d->string
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49
never evaluated: !d->device
0-49
2608 int oldBase = d->integerBase;
executed (the execution status of this line is deduced): int oldBase = d->integerBase;
-
2609 NumberFlags oldFlags = d->numberFlags;
executed (the execution status of this line is deduced): NumberFlags oldFlags = d->numberFlags;
-
2610 d->integerBase = 16;
executed (the execution status of this line is deduced): d->integerBase = 16;
-
2611 d->numberFlags |= ShowBase;
executed (the execution status of this line is deduced): d->numberFlags |= ShowBase;
-
2612 d->putNumber(reinterpret_cast<quintptr>(ptr), false);
executed (the execution status of this line is deduced): d->putNumber(reinterpret_cast<quintptr>(ptr), false);
-
2613 d->integerBase = oldBase;
executed (the execution status of this line is deduced): d->integerBase = oldBase;
-
2614 d->numberFlags = oldFlags;
executed (the execution status of this line is deduced): d->numberFlags = oldFlags;
-
2615 return *this;
executed: return *this;
Execution Count:49
49
2616} -
2617 -
2618/*! -
2619 \relates QTextStream -
2620 -
2621 Calls QTextStream::setIntegerBase(2) on \a stream and returns \a -
2622 stream. -
2623 -
2624 \sa oct(), dec(), hex(), {QTextStream manipulators} -
2625*/ -
2626QTextStream &bin(QTextStream &stream) -
2627{ -
2628 stream.setIntegerBase(2);
executed (the execution status of this line is deduced): stream.setIntegerBase(2);
-
2629 return stream;
executed: return stream;
Execution Count:15
15
2630} -
2631 -
2632/*! -
2633 \relates QTextStream -
2634 -
2635 Calls QTextStream::setIntegerBase(8) on \a stream and returns \a -
2636 stream. -
2637 -
2638 \sa bin(), dec(), hex(), {QTextStream manipulators} -
2639*/ -
2640QTextStream &oct(QTextStream &stream) -
2641{ -
2642 stream.setIntegerBase(8);
executed (the execution status of this line is deduced): stream.setIntegerBase(8);
-
2643 return stream;
executed: return stream;
Execution Count:3
3
2644} -
2645 -
2646/*! -
2647 \relates QTextStream -
2648 -
2649 Calls QTextStream::setIntegerBase(10) on \a stream and returns \a -
2650 stream. -
2651 -
2652 \sa bin(), oct(), hex(), {QTextStream manipulators} -
2653*/ -
2654QTextStream &dec(QTextStream &stream) -
2655{ -
2656 stream.setIntegerBase(10);
never executed (the execution status of this line is deduced): stream.setIntegerBase(10);
-
2657 return stream;
never executed: return stream;
0
2658} -
2659 -
2660/*! -
2661 \relates QTextStream -
2662 -
2663 Calls QTextStream::setIntegerBase(16) on \a stream and returns \a -
2664 stream. -
2665 -
2666 \note The hex modifier can only be used for writing to streams. -
2667 \sa bin(), oct(), dec(), {QTextStream manipulators} -
2668*/ -
2669QTextStream &hex(QTextStream &stream) -
2670{ -
2671 stream.setIntegerBase(16);
executed (the execution status of this line is deduced): stream.setIntegerBase(16);
-
2672 return stream;
executed: return stream;
Execution Count:34
34
2673} -
2674 -
2675/*! -
2676 \relates QTextStream -
2677 -
2678 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | -
2679 QTextStream::ShowBase) on \a stream and returns \a stream. -
2680 -
2681 \sa noshowbase(), forcesign(), forcepoint(), {QTextStream manipulators} -
2682*/ -
2683QTextStream &showbase(QTextStream &stream) -
2684{ -
2685 stream.setNumberFlags(stream.numberFlags() | QTextStream::ShowBase);
executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() | QTextStream::ShowBase);
-
2686 return stream;
executed: return stream;
Execution Count:45
45
2687} -
2688 -
2689/*! -
2690 \relates QTextStream -
2691 -
2692 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | -
2693 QTextStream::ForceSign) on \a stream and returns \a stream. -
2694 -
2695 \sa noforcesign(), forcepoint(), showbase(), {QTextStream manipulators} -
2696*/ -
2697QTextStream &forcesign(QTextStream &stream) -
2698{ -
2699 stream.setNumberFlags(stream.numberFlags() | QTextStream::ForceSign);
executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() | QTextStream::ForceSign);
-
2700 return stream;
executed: return stream;
Execution Count:1
1
2701} -
2702 -
2703/*! -
2704 \relates QTextStream -
2705 -
2706 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | -
2707 QTextStream::ForcePoint) on \a stream and returns \a stream. -
2708 -
2709 \sa noforcepoint(), forcesign(), showbase(), {QTextStream manipulators} -
2710*/ -
2711QTextStream &forcepoint(QTextStream &stream) -
2712{ -
2713 stream.setNumberFlags(stream.numberFlags() | QTextStream::ForcePoint);
executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() | QTextStream::ForcePoint);
-
2714 return stream;
executed: return stream;
Execution Count:3
3
2715} -
2716 -
2717/*! -
2718 \relates QTextStream -
2719 -
2720 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & -
2721 ~QTextStream::ShowBase) on \a stream and returns \a stream. -
2722 -
2723 \sa showbase(), noforcesign(), noforcepoint(), {QTextStream manipulators} -
2724*/ -
2725QTextStream &noshowbase(QTextStream &stream) -
2726{ -
2727 stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ShowBase);
never executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ShowBase);
-
2728 return stream;
never executed: return stream;
0
2729} -
2730 -
2731/*! -
2732 \relates QTextStream -
2733 -
2734 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & -
2735 ~QTextStream::ForceSign) on \a stream and returns \a stream. -
2736 -
2737 \sa forcesign(), noforcepoint(), noshowbase(), {QTextStream manipulators} -
2738*/ -
2739QTextStream &noforcesign(QTextStream &stream) -
2740{ -
2741 stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ForceSign);
never executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ForceSign);
-
2742 return stream;
never executed: return stream;
0
2743} -
2744 -
2745/*! -
2746 \relates QTextStream -
2747 -
2748 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & -
2749 ~QTextStream::ForcePoint) on \a stream and returns \a stream. -
2750 -
2751 \sa forcepoint(), noforcesign(), noshowbase(), {QTextStream manipulators} -
2752*/ -
2753QTextStream &noforcepoint(QTextStream &stream) -
2754{ -
2755 stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ForcePoint);
never executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() &= ~QTextStream::ForcePoint);
-
2756 return stream;
never executed: return stream;
0
2757} -
2758 -
2759/*! -
2760 \relates QTextStream -
2761 -
2762 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | -
2763 QTextStream::UppercaseBase) on \a stream and returns \a stream. -
2764 -
2765 \sa lowercasebase(), uppercasedigits(), {QTextStream manipulators} -
2766*/ -
2767QTextStream &uppercasebase(QTextStream &stream) -
2768{ -
2769 stream.setNumberFlags(stream.numberFlags() | QTextStream::UppercaseBase);
executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() | QTextStream::UppercaseBase);
-
2770 return stream;
executed: return stream;
Execution Count:7
7
2771} -
2772 -
2773/*! -
2774 \relates QTextStream -
2775 -
2776 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | -
2777 QTextStream::UppercaseDigits) on \a stream and returns \a stream. -
2778 -
2779 \sa lowercasedigits(), uppercasebase(), {QTextStream manipulators} -
2780*/ -
2781QTextStream &uppercasedigits(QTextStream &stream) -
2782{ -
2783 stream.setNumberFlags(stream.numberFlags() | QTextStream::UppercaseDigits);
executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() | QTextStream::UppercaseDigits);
-
2784 return stream;
executed: return stream;
Execution Count:10
10
2785} -
2786 -
2787/*! -
2788 \relates QTextStream -
2789 -
2790 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & -
2791 ~QTextStream::UppercaseBase) on \a stream and returns \a stream. -
2792 -
2793 \sa uppercasebase(), lowercasedigits(), {QTextStream manipulators} -
2794*/ -
2795QTextStream &lowercasebase(QTextStream &stream) -
2796{ -
2797 stream.setNumberFlags(stream.numberFlags() & ~QTextStream::UppercaseBase);
executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() & ~QTextStream::UppercaseBase);
-
2798 return stream;
executed: return stream;
Execution Count:5
5
2799} -
2800 -
2801/*! -
2802 \relates QTextStream -
2803 -
2804 Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & -
2805 ~QTextStream::UppercaseDigits) on \a stream and returns \a stream. -
2806 -
2807 \sa uppercasedigits(), lowercasebase(), {QTextStream manipulators} -
2808*/ -
2809QTextStream &lowercasedigits(QTextStream &stream) -
2810{ -
2811 stream.setNumberFlags(stream.numberFlags() & ~QTextStream::UppercaseDigits);
executed (the execution status of this line is deduced): stream.setNumberFlags(stream.numberFlags() & ~QTextStream::UppercaseDigits);
-
2812 return stream;
executed: return stream;
Execution Count:3
3
2813} -
2814 -
2815/*! -
2816 \relates QTextStream -
2817 -
2818 Calls QTextStream::setRealNumberNotation(QTextStream::FixedNotation) -
2819 on \a stream and returns \a stream. -
2820 -
2821 \sa scientific(), {QTextStream manipulators} -
2822*/ -
2823QTextStream &fixed(QTextStream &stream) -
2824{ -
2825 stream.setRealNumberNotation(QTextStream::FixedNotation);
executed (the execution status of this line is deduced): stream.setRealNumberNotation(QTextStream::FixedNotation);
-
2826 return stream;
executed: return stream;
Execution Count:1
1
2827} -
2828 -
2829/*! -
2830 \relates QTextStream -
2831 -
2832 Calls QTextStream::setRealNumberNotation(QTextStream::ScientificNotation) -
2833 on \a stream and returns \a stream. -
2834 -
2835 \sa fixed(), {QTextStream manipulators} -
2836*/ -
2837QTextStream &scientific(QTextStream &stream) -
2838{ -
2839 stream.setRealNumberNotation(QTextStream::ScientificNotation);
executed (the execution status of this line is deduced): stream.setRealNumberNotation(QTextStream::ScientificNotation);
-
2840 return stream;
executed: return stream;
Execution Count:1
1
2841} -
2842 -
2843/*! -
2844 \relates QTextStream -
2845 -
2846 Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) -
2847 on \a stream and returns \a stream. -
2848 -
2849 \sa right(), center(), {QTextStream manipulators} -
2850*/ -
2851QTextStream &left(QTextStream &stream) -
2852{ -
2853 stream.setFieldAlignment(QTextStream::AlignLeft);
never executed (the execution status of this line is deduced): stream.setFieldAlignment(QTextStream::AlignLeft);
-
2854 return stream;
never executed: return stream;
0
2855} -
2856 -
2857/*! -
2858 \relates QTextStream -
2859 -
2860 Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) -
2861 on \a stream and returns \a stream. -
2862 -
2863 \sa left(), center(), {QTextStream manipulators} -
2864*/ -
2865QTextStream &right(QTextStream &stream) -
2866{ -
2867 stream.setFieldAlignment(QTextStream::AlignRight);
never executed (the execution status of this line is deduced): stream.setFieldAlignment(QTextStream::AlignRight);
-
2868 return stream;
never executed: return stream;
0
2869} -
2870 -
2871/*! -
2872 \relates QTextStream -
2873 -
2874 Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) -
2875 on \a stream and returns \a stream. -
2876 -
2877 \sa left(), right(), {QTextStream manipulators} -
2878*/ -
2879QTextStream &center(QTextStream &stream) -
2880{ -
2881 stream.setFieldAlignment(QTextStream::AlignCenter);
never executed (the execution status of this line is deduced): stream.setFieldAlignment(QTextStream::AlignCenter);
-
2882 return stream;
never executed: return stream;
0
2883} -
2884 -
2885/*! -
2886 \relates QTextStream -
2887 -
2888 Writes '\\n' to the \a stream and flushes the stream. -
2889 -
2890 Equivalent to -
2891 -
2892 \snippet code/src_corelib_io_qtextstream.cpp 9 -
2893 -
2894 Note: On Windows, all '\\n' characters are written as '\\r\\n' if -
2895 QTextStream's device or string is opened using the QIODevice::Text flag. -
2896 -
2897 \sa flush(), reset(), {QTextStream manipulators} -
2898*/ -
2899QTextStream &endl(QTextStream &stream) -
2900{ -
2901 return stream << QLatin1Char('\n') << flush;
executed: return stream << QLatin1Char('\n') << flush;
Execution Count:50118
50118
2902} -
2903 -
2904/*! -
2905 \relates QTextStream -
2906 -
2907 Calls QTextStream::flush() on \a stream and returns \a stream. -
2908 -
2909 \sa endl(), reset(), {QTextStream manipulators} -
2910*/ -
2911QTextStream &flush(QTextStream &stream) -
2912{ -
2913 stream.flush();
executed (the execution status of this line is deduced): stream.flush();
-
2914 return stream;
executed: return stream;
Execution Count:50120
50120
2915} -
2916 -
2917/*! -
2918 \relates QTextStream -
2919 -
2920 Calls QTextStream::reset() on \a stream and returns \a stream. -
2921 -
2922 \sa flush(), {QTextStream manipulators} -
2923*/ -
2924QTextStream &reset(QTextStream &stream) -
2925{ -
2926 stream.reset();
never executed (the execution status of this line is deduced): stream.reset();
-
2927 return stream;
never executed: return stream;
0
2928} -
2929 -
2930/*! -
2931 \relates QTextStream -
2932 -
2933 Calls skipWhiteSpace() on \a stream and returns \a stream. -
2934 -
2935 \sa {QTextStream manipulators} -
2936*/ -
2937QTextStream &ws(QTextStream &stream) -
2938{ -
2939 stream.skipWhiteSpace();
executed (the execution status of this line is deduced): stream.skipWhiteSpace();
-
2940 return stream;
executed: return stream;
Execution Count:3
3
2941} -
2942 -
2943/*! -
2944 \fn QTextStreamManipulator qSetFieldWidth(int width) -
2945 \relates QTextStream -
2946 -
2947 Equivalent to QTextStream::setFieldWidth(\a width). -
2948*/ -
2949 -
2950/*! -
2951 \fn QTextStreamManipulator qSetPadChar(QChar ch) -
2952 \relates QTextStream -
2953 -
2954 Equivalent to QTextStream::setPadChar(\a ch). -
2955*/ -
2956 -
2957/*! -
2958 \fn QTextStreamManipulator qSetRealNumberPrecision(int precision) -
2959 \relates QTextStream -
2960 -
2961 Equivalent to QTextStream::setRealNumberPrecision(\a precision). -
2962*/ -
2963 -
2964#ifndef QT_NO_TEXTCODEC -
2965/*! -
2966 \relates QTextStream -
2967 -
2968 Toggles insertion of the Byte Order Mark on \a stream when QTextStream is -
2969 used with a UTF codec. -
2970 -
2971 \sa QTextStream::setGenerateByteOrderMark(), {QTextStream manipulators} -
2972*/ -
2973QTextStream &bom(QTextStream &stream) -
2974{ -
2975 stream.setGenerateByteOrderMark(true);
executed (the execution status of this line is deduced): stream.setGenerateByteOrderMark(true);
-
2976 return stream;
executed: return stream;
Execution Count:1
1
2977} -
2978 -
2979/*! -
2980 Sets the codec for this stream to \a codec. The codec is used for -
2981 decoding any data that is read from the assigned device, and for -
2982 encoding any data that is written. By default, -
2983 QTextCodec::codecForLocale() is used, and automatic unicode -
2984 detection is enabled. -
2985 -
2986 If QTextStream operates on a string, this function does nothing. -
2987 -
2988 \warning If you call this function while the text stream is reading -
2989 from an open sequential socket, the internal buffer may still contain -
2990 text decoded using the old codec. -
2991 -
2992 \sa codec(), setAutoDetectUnicode(), setLocale() -
2993*/ -
2994void QTextStream::setCodec(QTextCodec *codec) -
2995{ -
2996 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
2997 qint64 seekPos = -1;
executed (the execution status of this line is deduced): qint64 seekPos = -1;
-
2998 if (!d->readBuffer.isEmpty()) {
evaluated: !d->readBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2255
1-2255
2999 if (!d->device->isSequential()) {
partially evaluated: !d->device->isSequential()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
3000 seekPos = pos();
executed (the execution status of this line is deduced): seekPos = pos();
-
3001 }
executed: }
Execution Count:1
1
3002 }
executed: }
Execution Count:1
1
3003 d->codec = codec;
executed (the execution status of this line is deduced): d->codec = codec;
-
3004 if (seekPos >=0 && !d->readBuffer.isEmpty())
evaluated: seekPos >=0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2255
partially evaluated: !d->readBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-2255
3005 seek(seekPos);
executed: seek(seekPos);
Execution Count:1
1
3006}
executed: }
Execution Count:2256
2256
3007 -
3008/*! -
3009 Sets the codec for this stream to the QTextCodec for the encoding -
3010 specified by \a codecName. Common values for \c codecName include -
3011 "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't -
3012 recognized, nothing happens. -
3013 -
3014 Example: -
3015 -
3016 \snippet code/src_corelib_io_qtextstream.cpp 10 -
3017 -
3018 \sa QTextCodec::codecForName(), setLocale() -
3019*/ -
3020void QTextStream::setCodec(const char *codecName) -
3021{ -
3022 QTextCodec *codec = QTextCodec::codecForName(codecName);
executed (the execution status of this line is deduced): QTextCodec *codec = QTextCodec::codecForName(codecName);
-
3023 if (codec)
partially evaluated: codec
TRUEFALSE
yes
Evaluation Count:1928
no
Evaluation Count:0
0-1928
3024 setCodec(codec);
executed: setCodec(codec);
Execution Count:1928
1928
3025}
executed: }
Execution Count:1928
1928
3026 -
3027/*! -
3028 Returns the codec that is current assigned to the stream. -
3029 -
3030 \sa setCodec(), setAutoDetectUnicode(), locale() -
3031*/ -
3032QTextCodec *QTextStream::codec() const -
3033{ -
3034 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
3035 return d->codec;
executed: return d->codec;
Execution Count:44508
44508
3036} -
3037 -
3038/*! -
3039 If \a enabled is true, QTextStream will attempt to detect Unicode -
3040 encoding by peeking into the stream data to see if it can find the -
3041 UTF-16 or UTF-32 BOM (Byte Order Mark). If this mark is found, QTextStream -
3042 will replace the current codec with the UTF codec. -
3043 -
3044 This function can be used together with setCodec(). It is common -
3045 to set the codec to UTF-8, and then enable UTF-16 detection. -
3046 -
3047 \sa autoDetectUnicode(), setCodec() -
3048*/ -
3049void QTextStream::setAutoDetectUnicode(bool enabled) -
3050{ -
3051 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
3052 d->autoDetectUnicode = enabled;
executed (the execution status of this line is deduced): d->autoDetectUnicode = enabled;
-
3053}
executed: }
Execution Count:54
54
3054 -
3055/*! -
3056 Returns true if automatic Unicode detection is enabled, otherwise -
3057 returns false. Automatic Unicode detection is enabled by default. -
3058 -
3059 \sa setAutoDetectUnicode(), setCodec() -
3060*/ -
3061bool QTextStream::autoDetectUnicode() const -
3062{ -
3063 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
3064 return d->autoDetectUnicode;
executed: return d->autoDetectUnicode;
Execution Count:2
2
3065} -
3066 -
3067/*! -
3068 If \a generate is true and a UTF codec is used, QTextStream will insert -
3069 the BOM (Byte Order Mark) before any data has been written to the -
3070 device. If \a generate is false, no BOM will be inserted. This function -
3071 must be called before any data is written. Otherwise, it does nothing. -
3072 -
3073 \sa generateByteOrderMark(), bom() -
3074*/ -
3075void QTextStream::setGenerateByteOrderMark(bool generate) -
3076{ -
3077 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
3078 if (d->writeBuffer.isEmpty()) {
partially evaluated: d->writeBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
3079 if (generate)
evaluated: generate
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
3080 d->writeConverterState.flags &= ~QTextCodec::IgnoreHeader;
executed: d->writeConverterState.flags &= ~QTextCodec::IgnoreHeader;
Execution Count:2
2
3081 else -
3082 d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
executed: d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
Execution Count:1
1
3083 } -
3084}
executed: }
Execution Count:3
3
3085 -
3086/*! -
3087 Returns true if QTextStream is set to generate the UTF BOM (Byte Order -
3088 Mark) when using a UTF codec; otherwise returns false. UTF BOM generation is -
3089 set to false by default. -
3090 -
3091 \sa setGenerateByteOrderMark() -
3092*/ -
3093bool QTextStream::generateByteOrderMark() const -
3094{ -
3095 Q_D(const QTextStream);
executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
3096 return (d->writeConverterState.flags & QTextCodec::IgnoreHeader) == 0;
executed: return (d->writeConverterState.flags & QTextCodec::IgnoreHeader) == 0;
Execution Count:2
2
3097} -
3098 -
3099#endif -
3100 -
3101/*! -
3102 \since 4.5 -
3103 -
3104 Sets the locale for this stream to \a locale. The specified locale is -
3105 used for conversions between numbers and their string representations. -
3106 -
3107 The default locale is C and it is a special case - the thousands -
3108 group separator is not used for backward compatibility reasons. -
3109 -
3110 \sa locale() -
3111*/ -
3112void QTextStream::setLocale(const QLocale &locale) -
3113{ -
3114 Q_D(QTextStream);
executed (the execution status of this line is deduced): QTextStreamPrivate * const d = d_func();
-
3115 d->locale = locale;
executed (the execution status of this line is deduced): d->locale = locale;
-
3116}
executed: }
Execution Count:16
16
3117 -
3118/*! -
3119 \since 4.5 -
3120 -
3121 Returns the locale for this stream. The default locale is C. -
3122 -
3123 \sa setLocale() -
3124*/ -
3125QLocale QTextStream::locale() const -
3126{ -
3127 Q_D(const QTextStream);
never executed (the execution status of this line is deduced): const QTextStreamPrivate * const d = d_func();
-
3128 return d->locale;
never executed: return d->locale;
0
3129} -
3130 -
3131QT_END_NAMESPACE -
3132 -
3133#ifndef QT_NO_QOBJECT -
3134#include "qtextstream.moc" -
3135#endif -
3136 -
3137 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial