246 #ifndef QT_NO_TEXTCODEC 252 #include "private/qlocale_p.h" 258 #if defined QTEXTSTREAM_DEBUG 265 static QByteArray qt_prettyDebug(
const char *
data,
int len,
int maxSize)
267 if (!data)
return "(null)";
269 for (
int i = 0; i < len; ++i) {
271 if (isprint(
int(
uchar(c)))) {
274 case '\n': out +=
"\\n";
break;
275 case '\r': out +=
"\\r";
break;
276 case '\t': out +=
"\\t";
break;
279 tmp.
sprintf(
"\\x%x", (
unsigned int)(
unsigned char)c);
295 #define CHECK_VALID_STREAM(x) do { \ 296 if (!d->string && !d->device) { \ 297 qWarning("QTextStream: No device"); \ 302 #define IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(type) do { \ 304 CHECK_VALID_STREAM(*this); \ 306 switch (d->getNumber(&tmp)) { \ 307 case QTextStreamPrivate::npsOk: \ 310 case QTextStreamPrivate::npsMissingDigit: \ 311 case QTextStreamPrivate::npsInvalidPrefix: \ 313 setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); \ 316 return *this; } while (0) 318 #define IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR(type) do { \ 320 CHECK_VALID_STREAM(*this); \ 322 if (d->getReal(&tmp)) { \ 326 setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); \ 328 return *this; } while (0) 332 #ifndef QT_NO_QOBJECT 367 #ifndef QT_NO_QOBJECT 377 #ifndef QT_NO_TEXTCODEC 394 bool scan(
const QChar **
ptr,
int *tokenLength,
396 inline const QChar *readPtr()
const;
397 inline void consumeLastToken();
398 inline void consume(
int nchars);
399 void saveConverterState(
qint64 newPos);
400 void restoreToSavedConverterState();
411 inline void ungetChar(
const QChar &ch);
413 bool getReal(
double *f);
416 inline void putString(
const QString &ch,
bool number =
false);
417 void putNumber(
qulonglong number,
bool negative);
420 bool fillReadBuffer(
qint64 maxBytes = -1);
421 void resetReadBuffer();
422 void flushWriteBuffer();
451 readConverterSavedState(0),
453 readConverterSavedStateOffset(0),
465 #ifndef QT_NO_QOBJECT 470 #ifndef QT_NO_TEXTCODEC 475 #ifndef QT_NO_TEXTCODEC 518 #ifndef QT_NO_TEXTCODEC 546 #if defined(Q_OS_WIN) 553 #if !defined(QT_NO_QOBJECT) 558 bytesRead =
device->
readLine(buf, qMin<qint64>(
sizeof(buf), maxBytes));
565 bytesRead =
device->
read(buf, qMin<qint64>(
sizeof(buf), maxBytes));
570 #ifndef QT_NO_TEXTCODEC 582 #if defined (QTEXTSTREAM_DEBUG) 583 qDebug(
"QTextStreamPrivate::fillReadBuffer(), using %s codec",
588 #if defined (QTEXTSTREAM_DEBUG) 589 qDebug(
"QTextStreamPrivate::fillReadBuffer(), device->read(\"%s\", %d) == %d",
590 qt_prettyDebug(buf,
qMin(32,
int(bytesRead)) ,
int(bytesRead)).constData(),
sizeof(buf),
int(bytesRead));
597 #ifndef QT_NO_TEXTCODEC 615 int n = oldReadBufferSize;
616 if (readPtr < endPtr) {
618 while (*readPtr++ != CR) {
620 if (++writePtr == endPtr)
624 while (readPtr < endPtr) {
625 QChar ch = *readPtr++;
638 #if defined (QTEXTSTREAM_DEBUG) 639 qDebug(
"QTextStreamPrivate::fillReadBuffer() read %d bytes from device. readBuffer = [%s]",
int(bytesRead),
671 #if defined (Q_OS_WIN) 674 if (textModeEnabled) {
680 #ifndef QT_NO_TEXTCODEC 683 #if defined (QTEXTSTREAM_DEBUG) 684 qDebug(
"QTextStreamPrivate::flushWriteBuffer(), using %s codec (%s generating BOM)",
697 #if defined (QTEXTSTREAM_DEBUG) 698 qDebug(
"QTextStreamPrivate::flushWriteBuffer(), device->write(\"%s\") == %d",
701 if (bytesWritten <= 0) {
706 #if defined (Q_OS_WIN) 713 #ifndef QT_NO_QOBJECT 715 bool flushed = !file || file->
flush();
720 #if defined (QTEXTSTREAM_DEBUG) 721 qDebug(
"QTextStreamPrivate::flushWriteBuffer() wrote %d bytes",
724 if (!flushed || bytesWritten !=
qint64(data.
size()))
741 #if defined (QTEXTSTREAM_DEBUG) 742 qDebug(
"QTextStreamPrivate::read() maxlen = %d, token length = %d", maxlen, ret.
length());
760 bool consumeDelimiter =
false;
761 bool foundToken =
false;
765 bool canStillReadFromDevice =
true;
773 chPtr =
string->constData();
774 endOffset =
string->size();
776 chPtr += startOffset;
778 for (; !foundToken && startOffset < endOffset && (!maxlen || totalSize < maxlen); ++startOffset) {
779 const QChar ch = *chPtr++;
798 delimSize = (lastChar ==
QLatin1Char(
'\r')) ? 2 : 1;
799 consumeDelimiter =
true;
806 && (!maxlen || totalSize < maxlen)
812 if (!foundToken && (!maxlen || totalSize < maxlen)
814 || (
string &&
stringOffset + totalSize <
string->size())
816 #if defined (QTEXTSTREAM_DEBUG) 817 qDebug(
"QTextStreamPrivate::scan() did not find the token.");
824 if (delimiter ==
EndOfLine && totalSize > 0 && !foundToken) {
827 consumeDelimiter =
true;
834 *length = totalSize - delimSize;
841 if (!consumeDelimiter)
844 #if defined (QTEXTSTREAM_DEBUG) 845 qDebug(
"QTextStreamPrivate::scan(%p, %p, %d, %x) token length = %d, delimiter = %d",
846 ptr, length, maxlen, (
int)delimiter, totalSize - delimSize, delimSize);
874 #if defined (QTEXTSTREAM_DEBUG) 875 qDebug(
"QTextStreamPrivate::consume(%d)", size);
899 #ifndef QT_NO_TEXTCODEC 919 #ifndef QT_NO_TEXTCODEC 938 string->append(data);
1001 data[padSize] = tmp.
at(0);
1011 #if defined (QTEXTSTREAM_DEBUG) 1014 qDebug(
"QTextStreamPrivate::putString(\"%s\") calls write(\"%s\")",
1030 #if defined (QTEXTSTREAM_DEBUG) 1031 qDebug(
"QTextStream::QTextStream()");
1043 #if defined (QTEXTSTREAM_DEBUG) 1044 qDebug(
"QTextStream::QTextStream(QIODevice *device == *%p)",
1049 #ifndef QT_NO_QOBJECT 1050 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1062 #if defined (QTEXTSTREAM_DEBUG) 1063 qDebug(
"QTextStream::QTextStream(QString *string == *%p, openMode = %d)",
1064 string,
int(openMode));
1068 d->stringOpenMode = openMode;
1080 #if defined (QTEXTSTREAM_DEBUG) 1081 qDebug(
"QTextStream::QTextStream(QByteArray *array == *%p, openMode = %d)",
1082 array,
int(openMode));
1086 d->device->open(openMode);
1087 d->deleteDevice =
true;
1088 #ifndef QT_NO_QOBJECT 1089 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1107 #if defined (QTEXTSTREAM_DEBUG) 1108 qDebug(
"QTextStream::QTextStream(const QByteArray &array == *(%p), openMode = %d)",
1109 &array,
int(openMode));
1113 buffer->
open(openMode);
1117 d->deleteDevice =
true;
1118 #ifndef QT_NO_QOBJECT 1119 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1138 #if defined (QTEXTSTREAM_DEBUG) 1139 qDebug(
"QTextStream::QTextStream(FILE *fileHandle = %p, openMode = %d)",
1140 fileHandle,
int(openMode));
1143 file->
open(fileHandle, openMode);
1147 d->deleteDevice =
true;
1148 #ifndef QT_NO_QOBJECT 1149 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1163 #if defined (QTEXTSTREAM_DEBUG) 1164 qDebug(
"QTextStream::~QTextStream()");
1166 if (!
d->writeBuffer.isEmpty())
1167 d->flushWriteBuffer();
1179 d->realNumberPrecision = 6;
1196 d->flushWriteBuffer();
1206 d->lastTokenSize = 0;
1210 d->flushWriteBuffer();
1211 if (!
d->device->seek(pos))
1213 d->resetReadBuffer();
1215 #ifndef QT_NO_TEXTCODEC 1219 delete d->readConverterSavedState;
1220 d->readConverterSavedState = 0;
1228 d->stringOffset = int(pos);
1256 if (
d->readBuffer.isEmpty())
1257 return d->device->pos();
1258 if (
d->device->isSequential())
1262 if (!
d->device->seek(
d->readBufferStartDevicePos))
1269 #ifndef QT_NO_TEXTCODEC 1271 if (
d->readBufferStartDevicePos == 0)
1277 int oldReadBufferOffset =
d->readBufferOffset +
d->readConverterSavedStateOffset;
1278 while (
d->readBuffer.size() < oldReadBufferOffset) {
1286 return d->device->pos();
1290 return d->stringOffset;
1292 qWarning(
"QTextStream::pos: no device");
1312 d->consumeLastToken();
1329 if (
d->deleteDevice) {
1330 #ifndef QT_NO_QOBJECT 1331 d->deviceClosedNotifier.disconnect();
1334 d->deleteDevice =
false;
1340 d->resetReadBuffer();
1341 #ifndef QT_NO_QOBJECT 1342 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1369 if (
d->deleteDevice) {
1370 #ifndef QT_NO_QOBJECT 1371 d->deviceClosedNotifier.disconnect();
1372 d->device->blockSignals(
true);
1375 d->deleteDevice =
false;
1381 d->stringOpenMode = openMode;
1407 d->fieldAlignment = mode;
1418 return d->fieldAlignment;
1468 d->fieldWidth = width;
1479 return d->fieldWidth;
1493 d->numberFlags = flags;
1504 return d->numberFlags;
1520 d->integerBase =
base;
1532 return d->integerBase;
1546 d->realNumberNotation = notation;
1557 return d->realNumberNotation;
1572 if (precision < 0) {
1573 qWarning(
"QTextStream::setRealNumberPrecision: Invalid precision (%d)", precision);
1574 d->realNumberPrecision = 6;
1577 d->realNumberPrecision = precision;
1589 return d->realNumberPrecision;
1636 if (
d->status ==
Ok)
1652 return d->string->size() ==
d->stringOffset;
1653 return d->readBuffer.isEmpty() &&
d->device->atEnd();
1697 const QChar *readPtr;
1703 d->consumeLastToken();
1726 return d->read(
int(maxlen));
1733 scan(0, 0, 0, NotSpace);
1741 return npsInvalidPrefix;
1765 return npsInvalidPrefix;
1776 QChar pf1, pf2, dig;
1779 return npsInvalidPrefix;
1781 return npsInvalidPrefix;
1786 if (n ==
'0' || n ==
'1') {
1799 return npsMissingDigit;
1807 return npsInvalidPrefix;
1812 if (n >=
'0' && n <=
'7') {
1824 return npsMissingDigit;
1833 return npsMissingDigit;
1837 return npsMissingDigit;
1857 return npsMissingDigit;
1867 QChar pf1, pf2, dig;
1870 return npsInvalidPrefix;
1872 return npsInvalidPrefix;
1877 if (n >=
'0' && n <=
'9') {
1880 }
else if (n >=
'a' && n <=
'f') {
1882 val += 10 + (n -
'a');
1890 return npsMissingDigit;
1896 return npsInvalidPrefix;
1941 static const uchar table[13][10] = {
1943 { 0, Sign, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 },
1944 { 0, 0, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 },
1945 { Done, Done, Mantissa, Dot, ExpMark, 0, 0, 0, 0, 0 },
1946 { 0, 0, Abscissa, 0, 0, 0, 0, 0, 0, 0 },
1947 { Done, Done, Abscissa, Done, ExpMark, 0, 0, 0, 0, 0 },
1948 { 0, ExpSign, Exponent, 0, 0, 0, 0, 0, 0, 0 },
1949 { 0, 0, Exponent, 0, 0, 0, 0, 0, 0, 0 },
1950 { Done, Done, Exponent, Done, Done, 0, 0, 0, 0, 0 },
1951 { 0, 0, 0, 0, 0, 0, 0, 0, Nan2, 0 },
1952 { 0, 0, 0, 0, 0, 0, NanInf, 0, 0, 0 },
1953 { 0, 0, 0, 0, 0, 0, Inf2, 0, 0, 0 },
1954 { 0, 0, 0, 0, 0, 0, 0, NanInf, 0, 0 },
1955 { Done, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1958 ParserState state = Init;
1959 InputToken input =
None;
1961 scan(0, 0, 0, NotSpace);
1964 const int BufferSize = 128;
1965 char buf[BufferSize];
1971 case '0':
case '1':
case '2':
case '3':
case '4':
1972 case '5':
case '6':
case '7':
case '8':
case '9':
2008 state = ParserState(table[state][input]);
2010 if (state == Init || state == Done || i > (BufferSize - 5)) {
2012 if (i > (BufferSize - 5)) {
2042 }
else if (!
qstricmp(buf,
"-inf")) {
2066 if (!
d->getChar(&c))
2254 d->consumeLastToken();
2264 d->consumeLastToken();
2285 d->consumeLastToken();
2294 for (
int i = 0; i < length; ++i)
2295 array += ptr[i].toLatin1();
2297 d->consumeLastToken();
2323 d->consumeLastToken();
2332 for (
int i = 0; i < length; ++i)
2333 *c++ = ptr[i].toLatin1();
2335 d->consumeLastToken();
2362 if (negative && base == 10) {
2365 }
else if (negative) {
2376 if (number == 0 && base == 8 &&
numberFlags & QTextStream::ShowBase
2381 putString(result,
true);
2390 return *
this << bool(b);
2547 d->putNumber(i,
false);
2564 return *
this << double(f);
2607 d->putString(num,
true);
2623 d->putString(
string);
2681 int oldBase =
d->integerBase;
2682 NumberFlags oldFlags =
d->numberFlags;
2683 d->integerBase = 16;
2685 d->putNumber(reinterpret_cast<quintptr>(ptr),
false);
2686 d->integerBase = oldBase;
2687 d->numberFlags = oldFlags;
3115 #ifndef QT_NO_TEXTCODEC 3152 if (!
d->readBuffer.isEmpty()) {
3153 if (!
d->device->isSequential()) {
3158 if (seekPos >=0 && !
d->readBuffer.isEmpty())
3218 return d->autoDetectUnicode;
3232 if (
d->writeBuffer.isEmpty()) {
3234 d->writeConverterState.flags &= ~
QTextCodec::IgnoreHeader;
3352 int QTextStream::flagsInternal()
const 3357 switch (
d->fieldAlignment) {
3364 switch (
d->integerBase) {
3365 case 2: f |=
bin;
break;
3366 case 8: f |=
oct;
break;
3367 case 10: f |=
dec;
break;
3368 case 16: f |=
hex;
break;
3372 switch (
d->realNumberNotation) {
3391 int QTextStream::flagsInternal(
int newFlags)
3393 int oldFlags = flagsInternal();
3395 if (newFlags &
left)
3397 else if (newFlags &
right)
3399 else if (newFlags &
internal)
3404 else if (newFlags &
oct)
3406 else if (newFlags &
dec)
3408 else if (newFlags &
hex)
3413 if (newFlags & showpos)
3415 if (newFlags & showpoint)
3417 if (newFlags & uppercase)
3420 if (newFlags &
fixed)
3428 #ifndef QT_NO_TEXTCODEC 3432 void QTextStream::setEncoding(Encoding encoding)
3442 d->autoDetectUnicode =
true;
3448 d->autoDetectUnicode =
false;
3452 d->autoDetectUnicode =
false;
3458 d->autoDetectUnicode =
false;
3460 case UnicodeNetworkOrder:
3464 d->autoDetectUnicode =
false;
3466 case UnicodeReverse:
3470 d->autoDetectUnicode =
false;
3475 d->autoDetectUnicode =
true;
3633 #ifndef QT_NO_QOBJECT 3634 #include "qtextstream.moc" QString * string() const
Returns the current string assigned to the QTextStream, or 0 if no string has been assigned...
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
T qobject_cast(QObject *object)
const QChar * readPtr() const
void ungetChar(const QChar &ch)
Status status() const
Returns the status of the text stream.
QChar positiveSign() const
Returns the positive sign character of this locale.
int integerBase() const
Returns the current base of integers.
bool fillReadBuffer(qint64 maxBytes=-1)
QTextStream & lowercasedigits(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::UppercaseDigits) on stre...
#define CHECK_VALID_STREAM(x)
QTextStream & endl(QTextStream &stream)
Writes ' ' to the stream and flushes the stream.
QTextStream()
Constructs a QTextStream.
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
QString & sprintf(const char *format,...)
Safely builds a formatted string from the format string cformat and an arbitrary list of arguments...
void setDevice(QIODevice *device)
Sets the current device to device.
void putString(const QString &ch, bool number=false)
bool seek(qint64 pos)
Seeks to the position pos in the device.
QTextStream & noforcepoint(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ForcePoint) on stream an...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
static void copyConverterStateHelper(QTextCodec::ConverterState *dest, const QTextCodec::ConverterState *src)
QString readLine(qint64 maxlen=0)
Reads one line of text from the stream, and returns it as a QString.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
QLocale locale() const
Returns the locale for this stream.
int digitValue() const
Returns the numeric value of the digit, or -1 if the character is not a digit.
const QChar at(int i) const
Returns the character at the given index position in the string.
QTextStream & forcesign(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ForceSign) on stream and ...
void write(const QString &data)
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void reset()
Resets QTextStream's formatting options, bringing it back to its original constructed state...
void setStatus(Status status)
Sets the status of the text stream to the status given.
void putNumber(qulonglong number, bool negative)
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
bool open(OpenMode openMode)
Reimplemented Function
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
void setString(QString *string, QIODevice::OpenMode openMode=QIODevice::ReadWrite)
Sets the current string to string, using the given openMode.
static const int QTEXTSTREAM_BUFFERSIZE
QString & replace(int i, int len, QChar after)
The QByteArray class provides an array of bytes.
QChar exponential() const
Returns the exponential character of this locale.
QTextCodec::ConverterState writeConverterState
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
int length() const
Returns the number of characters in this string.
void setCodec(QTextCodec *codec)
Sets the codec for this stream to codec.
QString & prepend(QChar c)
QScopedPointer< QTextStreamPrivate > d_ptr
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
bool scan(const QChar **ptr, int *tokenLength, int maxlen, TokenDelimiter delimiter)
Scans no more than maxlen QChars in the current buffer for the first delimiter.
void setRealNumberNotation(RealNumberNotation notation)
Sets the real number notation to notation (SmartNotation, FixedNotation, ScientificNotation).
QTextStream::RealNumberNotation realNumberNotation
void setAutoDetectUnicode(bool enabled)
If enabled is true, QTextStream will attempt to detect Unicode encoding by peeking into the stream da...
FieldAlignment
This enum specifies how to align text in fields when the field is wider than the text that occupies i...
void setupDevice(QTextStream *stream, QIODevice *device)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setFieldWidth(int width)
Sets the current field width to width.
long ASN1_INTEGER_get ASN1_INTEGER * a
~ConverterState()
Destroys the ConverterState object.
int fieldWidth() const
Returns the current field width.
The QBuffer class provides a QIODevice interface for a QByteArray.
The QString class provides a Unicode character string.
Q_DECL_CONSTEXPR T qAbs(const T &t)
The QObject class is the base class of all Qt objects.
QTextStream & bom(QTextStream &stream)
Toggles insertion of the Byte Order Mark on stream when QTextStream is used with a UTF codec...
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i.e.
The QChar class provides a 16-bit Unicode character.
QChar * data()
Returns a pointer to the data stored in the QString.
void setTextModeEnabled(bool enabled)
If enabled is true, this function sets the Text flag on the device; otherwise the Text flag is remove...
void saveConverterState(qint64 newPos)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
QTextCodec * codec() const
Returns the codec that is current assigned to the stream.
QTextStream::FieldAlignment fieldAlignment
static QString doubleToString(const QChar zero, const QChar plus, const QChar minus, const QChar exponent, const QChar group, const QChar decimal, double d, int precision, DoubleForm form, int width, unsigned flags)
QDeviceClosedNotifier deviceClosedNotifier
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
QTextCodec::ConverterState * readConverterSavedState
Q_CORE_EXPORT void qDebug(const char *,...)
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream...
static QString unsLongLongToString(const QChar zero, const QChar group, const QChar plus, quint64 l, int precision, int base, int width, unsigned flags)
virtual ~QTextStream()
Destroys the QTextStream.
void setLocale(const QLocale &locale)
Sets the locale for this stream to locale.
QTextStream & right(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on stream and returns stream...
static QString longLongToString(const QChar zero, const QChar group, const QChar plus, const QChar minus, qint64 l, int precision, int base, int width, unsigned flags)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
static void resetCodecConverterStateHelper(QTextCodec::ConverterState *state)
QTextStream & reset(QTextStream &stream)
Calls QTextStream::reset() on stream and returns stream.
QTextStream & lowercasebase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::UppercaseBase) on stream...
QTextStream & forcepoint(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ForcePoint) on stream and...
QChar decimalPoint() const
Returns the decimal point character of this locale.
void setIntegerBase(int base)
Sets the base of integers to base, both for reading and for generating numbers.
QChar groupSeparator() const
Returns the group separator character of this locale.
int size() const
Returns the number of characters in this string.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
int readConverterSavedStateOffset
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
QTextStream & fixed(QTextStream &stream)
Calls QTextStream::setRealNumberNotation(QTextStream::FixedNotation) on stream and returns stream...
void resetStatus()
Resets the status of the text stream.
static unsigned int getChar(const QChar *str, int &i, const int len)
static QByteArray fromRawData(const char *, int size)
Constructs a QByteArray that uses the first size bytes of the data array.
bool flush()
Flushes any buffered data to the file.
QTextStreamPrivate(QTextStream *q_ptr)
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
void setRealNumberPrecision(int precision)
Sets the precision of real numbers to precision.
#define IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR(type)
QTextStream::Status status
bool autoDetectUnicode() const
Returns true if automatic Unicode detection is enabled, otherwise returns false.
const T * ptr(const T &t)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
QChar negativeSign() const
Returns the negative sign character of this locale.
int handle() const
Returns the file handle of the file.
QIODevice * device() const
Returns the current device associated with the QTextStream, or 0 if no device has been assigned...
QTextStream & scientific(QTextStream &stream)
Calls QTextStream::setRealNumberNotation(QTextStream::ScientificNotation) on stream and returns strea...
QTextStream & operator>>(QChar &ch)
Reads a character from the stream and stores it in c.
void setGenerateByteOrderMark(bool generate)
If generate is true and a UTF codec is used, QTextStream will insert the BOM (Byte Order Mark) before...
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
QTextStream & ws(QTextStream &stream)
Calls skipWhiteSpace() on stream and returns stream.
RealNumberNotation
This enum specifies which notations to use for expressing float and double as strings.
Q_CORE_EXPORT double qSNaN()
Returns the bit pattern of a signalling NaN as a double.
int length() const
Same as size().
void resize(int size)
Sets the size of the string to size characters.
virtual QByteArray name() const =0
QTextCodec subclasses must reimplement this function.
const char * constData() const
Returns a pointer to the data stored in the byte array.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
#define IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(type)
const QLocalePrivate * d() const
NumberParsingStatus getNumber(qulonglong *l)
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
#define Q_DECLARE_PUBLIC(Class)
QString & append(QChar c)
void setNumberFlags(NumberFlags flags)
Sets the current number flags to flags.
QTextCodec::ConverterState readConverterState
FieldAlignment fieldAlignment() const
Returns the current field alignment.
The QFile class provides an interface for reading from and writing to files.
Status
This enum describes the current status of the text stream.
double toDouble(const QString &s, bool *ok=0) const
Returns the double represented by the localized string s, or 0.0 if the conversion failed...
qint64 readBufferStartDevicePos
QTextStream & bin(QTextStream &stream)
Calls QTextStream::setIntegerBase(2) on stream and returns stream.
The QTextStream class provides a convenient interface for reading and writing text.
QTextStream & oct(QTextStream &stream)
Calls QTextStream::setIntegerBase(8) on stream and returns stream.
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes...
void clear()
Clears the contents of the string and makes it empty.
QString read(qint64 maxlen)
Reads at most maxlen characters from the stream, and returns the data read as a QString.
bool generateByteOrderMark() const
Returns true if QTextStream is set to generate the UTF BOM (Byte Order Mark) when using a UTF codec; ...
Q_CORE_EXPORT double qInf()
Returns the bit pattern for an infinite number as a double.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
QTextStream & uppercasebase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::UppercaseBase) on stream ...
QTextStream & operator<<(QBool b)
QTextStream & noforcesign(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ForceSign) on stream and...
NumberFlags numberFlags() const
Returns the current number flags.
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
void restoreToSavedConverterState()
bool isTextModeEnabled() const
Returns true if the Text flag is enabled; otherwise returns false.
int size() const
Returns the number of bytes in this byte array.
char toLatin1() const
Returns the Latin-1 character equivalent to the QChar, or 0.
QTextStream::NumberFlags numberFlags
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
RealNumberNotation realNumberNotation() const
Returns the current real number notation.
void flush()
Flushes any buffered data waiting to be written to the device.
void setFieldAlignment(FieldAlignment alignment)
Sets the field alignment to mode.
static QTextCodec * codecForUtfText(const QByteArray &ba)
Tries to detect the encoding of the provided snippet ba by using the BOM (Byte Order Mark) and return...
QString readAll()
Reads the entire content of the stream, and returns it as a QString.
QChar padChar() const
Returns the current pad character.
QTextStream & noshowbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) on stream and ...
qint64 pos() const
Returns the device position corresponding to the current position of the stream, or -1 if an error oc...
bool atEnd() const
Returns true if there is no more data to be read from the QTextStream; otherwise returns false...
int realNumberPrecision() const
Returns the current real number precision, or the number of fraction digits QTextStream will write wh...
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Q_CORE_EXPORT int qstricmp(const char *, const char *)
The QTextCodec class provides conversions between text encodings.
The QIODevice class is the base interface class of all I/O devices in Qt.
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
bool isDigit() const
Returns true if the character is a decimal digit (Number_DecimalDigit); otherwise returns false...
void setPadChar(QChar ch)
Sets the pad character to ch.
void clear()
Clears the contents of the byte array and makes it empty.
QTextStream & flush(QTextStream &stream)
Calls QTextStream::flush() on stream and returns stream.
QIODevice::OpenMode stringOpenMode
QTextStream & uppercasedigits(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::UppercaseDigits) on strea...
void skipWhiteSpace()
Reads and discards whitespace from the stream until either a non-space character is detected...
QTextStream & left(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on stream and returns stream...