42 static const int QTEXTSTREAM_BUFFERSIZE = 16384;
228 #include "private/qtextstream_p.h"
233 #include <private/qdebug_p.h>
236 #include "private/qlocale_p.h"
237 #include "private/qstringconverter_p.h"
245 #define CHECK_VALID_STREAM(x) do { \
246 if (!d->string && !d->device) { \
247 qWarning("QTextStream: No device"); \
252 #define IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(type) do { \
254 CHECK_VALID_STREAM(*this); \
256 switch (d->getNumber(&tmp)) { \
257 case QTextStreamPrivate::npsOk: \
260 case QTextStreamPrivate::npsMissingDigit: \
261 case QTextStreamPrivate::npsInvalidPrefix: \
263 setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); \
266 return *this; } while (0)
268 #define IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR(type) do { \
270 CHECK_VALID_STREAM(*this); \
272 if (d->getReal(&tmp)) { \
276 setStatus(atEnd() ? QTextStream::ReadPastEnd : QTextStream::ReadCorruptData); \
278 return *this; } while (0)
288 : readConverterSavedStateOffset(0),
301 #ifndef QT_NO_QOBJECT
360 char buf[QTEXTSTREAM_BUFFERSIZE];
362 #if defined(Q_OS_WIN)
369 #
if !defined(QT_NO_QOBJECT)
404 #if defined (QTEXTSTREAM_DEBUG)
408 #if defined (QTEXTSTREAM_DEBUG)
409 qDebug(
"QTextStreamPrivate::fillReadBuffer(), device->read(\"%s\", %d) == %d",
417 if (
readBuffer.size() > oldReadBufferSize && textModeEnabled) {
423 int n = oldReadBufferSize;
428 if (++writePtr == endPtr)
446 #if defined (QTEXTSTREAM_DEBUG)
447 qDebug(
"QTextStreamPrivate::fillReadBuffer() read %d bytes from device. readBuffer = [%s]",
int(bytesRead),
481 #if defined (Q_OS_WIN)
484 if (textModeEnabled) {
496 #if defined (QTEXTSTREAM_DEBUG)
497 qDebug(
"QTextStreamPrivate::flushWriteBuffer(), device->write(\"%s\") == %d",
501 #if defined (Q_OS_WIN)
513 #ifndef QT_NO_QOBJECT
520 #if defined (QTEXTSTREAM_DEBUG)
521 qDebug(
"QTextStreamPrivate::flushWriteBuffer() wrote %d bytes",
541 #if defined (QTEXTSTREAM_DEBUG)
542 qDebug(
"QTextStreamPrivate::read() maxlen = %d, token length = %d", maxlen,
ret.length());
558 bool consumeDelimiter =
false;
559 bool foundToken =
false;
570 chPtr =
string->constData();
571 endOffset =
string->size();
573 chPtr += startOffset;
575 for (; !foundToken && startOffset < endOffset && (!maxlen || totalSize < maxlen); ++startOffset) {
595 delimSize = (lastChar ==
QLatin1Char(
'\r')) ? 2 : 1;
596 consumeDelimiter =
true;
603 && (!maxlen || totalSize < maxlen)
606 if (totalSize == 0) {
607 #if defined (QTEXTSTREAM_DEBUG)
608 qDebug(
"QTextStreamPrivate::scan() reached the end of input.");
615 if (delimiter ==
EndOfLine && totalSize > 0 && !foundToken) {
618 consumeDelimiter =
true;
625 *
length = totalSize - delimSize;
632 if (!consumeDelimiter)
635 #if defined (QTEXTSTREAM_DEBUG)
636 qDebug(
"QTextStreamPrivate::scan(%p, %p, %d, %x) token length = %d, delimiter = %d",
637 ptr,
length, maxlen, (
int)delimiter, totalSize - delimSize, delimSize);
668 #if defined (QTEXTSTREAM_DEBUG)
669 qDebug(
"QTextStreamPrivate::consume(%d)",
size);
749 string->append(
data);
815 if (
params.fieldWidth > 0)
831 const int padSize =
params.fieldWidth -
len;
833 switch (
params.fieldAlignment) {
843 right = padSize - padSize/2;
920 #if defined (QTEXTSTREAM_DEBUG)
921 qDebug(
"QTextStream::QTextStream()");
933 #if defined (QTEXTSTREAM_DEBUG)
934 qDebug(
"QTextStream::QTextStream(QIODevice *device == *%p)",
939 #ifndef QT_NO_QOBJECT
940 d->deviceClosedNotifier.setupDevice(
this,
d->device);
952 #if defined (QTEXTSTREAM_DEBUG)
953 qDebug(
"QTextStream::QTextStream(QString *string == *%p, openMode = %d)",
954 string,
int(openMode));
958 d->stringOpenMode = openMode;
970 #if defined (QTEXTSTREAM_DEBUG)
971 qDebug(
"QTextStream::QTextStream(QByteArray *array == *%p, openMode = %d)",
972 array,
int(openMode));
976 d->device->open(openMode);
977 d->deleteDevice =
true;
978 #ifndef QT_NO_QOBJECT
979 d->deviceClosedNotifier.setupDevice(
this,
d->device);
997 #if defined (QTEXTSTREAM_DEBUG)
998 qDebug(
"QTextStream::QTextStream(const QByteArray &array == *(%p), openMode = %d)",
999 &
array,
int(openMode));
1007 d->deleteDevice =
true;
1008 #ifndef QT_NO_QOBJECT
1009 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1028 #if defined (QTEXTSTREAM_DEBUG)
1029 qDebug(
"QTextStream::QTextStream(FILE *fileHandle = %p, openMode = %d)",
1030 fileHandle,
int(openMode));
1037 d->deleteDevice =
true;
1038 #ifndef QT_NO_QOBJECT
1039 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1053 #if defined (QTEXTSTREAM_DEBUG)
1054 qDebug(
"QTextStream::~QTextStream()");
1056 if (!
d->writeBuffer.isEmpty())
1057 d->flushWriteBuffer();
1080 d->flushWriteBuffer();
1090 d->lastTokenSize = 0;
1094 d->flushWriteBuffer();
1095 if (!
d->device->seek(
pos))
1097 d->resetReadBuffer();
1099 d->toUtf16.resetState();
1100 d->fromUtf16.resetState();
1105 if (
d->string && pos <= d->
string->size()) {
1106 d->stringOffset = int(
pos);
1131 if (
d->readBuffer.isEmpty())
1132 return d->device->pos();
1133 if (
d->device->isSequential())
1137 if (!
d->device->seek(
d->readBufferStartDevicePos))
1145 if (
d->readBufferStartDevicePos == 0)
1150 int oldReadBufferOffset =
d->readBufferOffset +
d->readConverterSavedStateOffset;
1151 while (
d->readBuffer.size() < oldReadBufferOffset) {
1159 return d->device->pos();
1163 return d->stringOffset;
1165 qWarning(
"QTextStream::pos: no device");
1185 d->consumeLastToken();
1202 if (
d->deleteDevice) {
1203 #ifndef QT_NO_QOBJECT
1204 d->deviceClosedNotifier.disconnect();
1207 d->deleteDevice =
false;
1213 d->resetReadBuffer();
1214 #ifndef QT_NO_QOBJECT
1215 d->deviceClosedNotifier.setupDevice(
this,
d->device);
1242 if (
d->deleteDevice) {
1243 #ifndef QT_NO_QOBJECT
1244 d->deviceClosedNotifier.disconnect();
1245 d->device->blockSignals(
true);
1248 d->deleteDevice =
false;
1254 d->stringOpenMode = openMode;
1280 d->params.fieldAlignment =
mode;
1291 return d->params.fieldAlignment;
1312 d->params.padChar =
ch;
1323 return d->params.padChar;
1341 d->params.fieldWidth =
width;
1352 return d->params.fieldWidth;
1366 d->params.numberFlags =
flags;
1377 return d->params.numberFlags;
1393 d->params.integerBase =
base;
1405 return d->params.integerBase;
1419 d->params.realNumberNotation = notation;
1430 return d->params.realNumberNotation;
1446 qWarning(
"QTextStream::setRealNumberPrecision: Invalid precision (%d)",
precision);
1447 d->params.realNumberPrecision = 6;
1462 return d->params.realNumberPrecision;
1503 if (
d->status ==
Ok)
1519 return d->string->size() ==
d->stringOffset;
1520 return d->readBuffer.isEmpty() &&
d->device->atEnd();
1538 return d->read(INT_MAX);
1595 if (!
d->string && !
d->device) {
1596 qWarning(
"QTextStream: No device");
1602 const QChar *readPtr;
1612 d->consumeLastToken();
1632 return d->read(
int(maxlen));
1683 QChar pf1, pf2, dig;
1693 if (
n ==
'0' ||
n ==
'1') {
1719 if (
n >=
'0' &&
n <=
'7') {
1754 val +=
ch.digitValue();
1774 QChar pf1, pf2, dig;
1784 if (
n >=
'0' &&
n <=
'9') {
1787 }
else if (
n >=
'a' &&
n <=
'f') {
1789 val += 10 + (
n -
'a');
1851 { 0, Sign, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 },
1852 { 0, 0, Mantissa, Dot, 0, Inf1, Nan1, 0, 0, 0 },
1853 { Done, Done, Mantissa, Dot, ExpMark, 0, 0, 0, 0, 0 },
1854 { 0, 0, Abscissa, 0, 0, 0, 0, 0, 0, 0 },
1855 { Done, Done, Abscissa, Done, ExpMark, 0, 0, 0, 0, 0 },
1856 { 0, ExpSign, Exponent, 0, 0, 0, 0, 0, 0, 0 },
1857 { 0, 0, Exponent, 0, 0, 0, 0, 0, 0, 0 },
1858 { Done, Done, Exponent, Done, Done, 0, 0, 0, 0, 0 },
1859 { 0, 0, 0, 0, 0, 0, 0, 0, Nan2, 0 },
1860 { 0, 0, 0, 0, 0, 0, NanInf, 0, 0, 0 },
1861 { 0, 0, 0, 0, 0, 0, Inf2, 0, 0, 0 },
1862 { 0, 0, 0, 0, 0, 0, 0, NanInf, 0, 0 },
1863 { Done, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1866 ParserState
state = Init;
1878 switch (
c.unicode()) {
1879 case '0':
case '1':
case '2':
case '3':
case '4':
1880 case '5':
case '6':
case '7':
case '8':
case '9':
1931 buf[
i++] =
c.toLatin1();
1974 if (!
d->getChar(&
c))
2135 d->consumeLastToken();
2145 d->consumeLastToken();
2162 d->consumeLastToken();
2174 d->consumeLastToken();
2198 d->consumeLastToken();
2210 d->consumeLastToken();
2222 const QTextStream::NumberFlags numberFlags =
params.numberFlags;
2239 if (negative &&
base == 10) {
2242 }
else if (negative) {
2400 d->putNumber(
i,
false);
2417 return *
this << double(
f);
2468 d->putString(
num,
true);
2483 d->putString(
string);
2498 d->putString(
string.
cbegin(),
int(
string.
size()));
2512 d->putString(
string);
2561 const int oldBase =
d->params.integerBase;
2562 const NumberFlags oldFlags =
d->params.numberFlags;
2563 d->params.integerBase = 16;
2565 d->putNumber(
reinterpret_cast<quintptr>(ptr),
false);
2566 d->params.integerBase = oldBase;
2567 d->params.numberFlags = oldFlags;
2962 if (!
d->readBuffer.isEmpty()) {
2963 if (!
d->device->isSequential()) {
2970 bool generateBOM =
d->hasWrittenData &&
d->generateBOM;
2974 if (seekPos >=0 && !
d->readBuffer.isEmpty())
3015 return d->autoDetectUnicode;
3029 if (
d->hasWrittenData ||
d->generateBOM ==
generate)
3046 return d->generateBOM;
3081 #ifndef QT_NO_QOBJECT
3082 #include "moc_qtextstream_p.cpp"
small capitals from c petite p scientific i
[1]
The QBuffer class provides a QIODevice interface for a QByteArray.
void setData(const QByteArray &data)
The QByteArray class provides an array of bytes.
const char * constData() const noexcept
The QChar class provides a 16-bit Unicode character.
constexpr bool isDigit() const noexcept
QChar toLower() const noexcept
int digitValue() const noexcept
constexpr char16_t unicode() const noexcept
static constexpr QChar fromLatin1(char c) noexcept
The QFileDevice class provides an interface for reading from and writing to open files.
The QFile class provides an interface for reading from and writing to files.
bool open(OpenMode flags) override
The QIODevice class is the base interface class of all I/O devices in Qt.
virtual qint64 pos() const
virtual bool isSequential() const
qint64 readLine(char *data, qint64 maxlen)
void setTextModeEnabled(bool enabled)
qint64 write(const char *data, qint64 len)
virtual bool atEnd() const
bool isTextModeEnabled() const
qint64 read(char *data, qint64 maxlen)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
QString decimalPoint() const
double toDouble(const QString &s, bool *ok=nullptr) const
QString negativeSign() const
QString groupSeparator() const
QString exponential() const
QString positiveSign() const
NumberOptions numberOptions() const
@ IncludeTrailingZeroesAfterDot
@ OmitLeadingZeroInExponent
const QLocaleData *const m_data
bool blockSignals(bool b) noexcept
static Q_CORE_EXPORT const char * nameForEncoding(Encoding e)
static Q_CORE_EXPORT std::optional< Encoding > encodingForData(QByteArrayView data, char16_t expectedFirstCharacter=0)
The QStringDecoder class provides a state-based decoder for text. \reentrant.
The QStringEncoder class provides a state-based encoder for text. \reentrant.
char * appendToBuffer(char *out, QStringView in)
The QString class provides a Unicode character string.
QString & prepend(QChar c)
static QString fromLatin1(QByteArrayView ba)
QString & setUnicode(const QChar *unicode, qsizetype size)
static QString fromUtf8(QByteArrayView utf8)
QString toLower() const &
void resize(qsizetype size)
The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QStrin...
QByteArray toUtf8() const
The QTextStream class provides a convenient interface for reading and writing text.
void setStatus(Status status)
QTextStream & operator>>(QChar &ch)
bool autoDetectUnicode() const
void setRealNumberPrecision(int precision)
QString read(qint64 maxlen)
void setRealNumberNotation(RealNumberNotation notation)
int realNumberPrecision() const
void setEncoding(QStringConverter::Encoding encoding)
void setPadChar(QChar ch)
QIODevice * device() const
void setGenerateByteOrderMark(bool generate)
FieldAlignment fieldAlignment() const
NumberFlags numberFlags() const
QString readLine(qint64 maxlen=0)
void setString(QString *string, OpenMode openMode=ReadWrite)
bool readLineInto(QString *line, qint64 maxlen=0)
void setIntegerBase(int base)
RealNumberNotation realNumberNotation() const
void setFieldAlignment(FieldAlignment alignment)
bool generateByteOrderMark() const
void setAutoDetectUnicode(bool enabled)
void setFieldWidth(int width)
QStringConverter::Encoding encoding() const
QTextStream & operator<<(QChar ch)
void setNumberFlags(NumberFlags flags)
void setLocale(const QLocale &locale)
void setDevice(QIODevice *device)
QTextStream::FieldAlignment fieldAlignment
QTextStream::RealNumberNotation realNumberNotation
QTextStream::NumberFlags numberFlags
void saveConverterState(qint64 newPos)
void write(const QString &data)
void restoreToSavedConverterState()
int readConverterSavedStateOffset
QStringDecoder savedToUtf16
const QChar * readPtr() const
PaddingResult padding(int len) const
bool scan(const QChar **ptr, int *tokenLength, int maxlen, TokenDelimiter delimiter)
QTextStreamPrivate(QTextStream *q_ptr)
qint64 readBufferStartDevicePos
bool fillReadBuffer(qint64 maxBytes=-1)
void putNumber(qulonglong number, bool negative)
QTextStream::Status status
void writePadding(int len)
QStringConverter::Encoding encoding
NumberParsingStatus getNumber(qulonglong *l)
QIODevice::OpenMode stringOpenMode
void putString(const QString &ch, bool number=false)
auto generate(StringRef generatorName, SourceLineInfo const &lineInfo, L const &generatorExpression) -> decltype(std::declval< decltype(generatorExpression())>().get())
Q_CORE_EXPORT QByteArray toPrintable(const char *data, int len, int maxSize)
QTextStream & flush(QTextStream &stream)
QTextStream & hex(QTextStream &stream)
QTextStream & uppercasebase(QTextStream &stream)
QTextStream & bin(QTextStream &stream)
QTextStream & showbase(QTextStream &stream)
QTextStream & lowercasebase(QTextStream &stream)
QTextStream & noforcesign(QTextStream &stream)
QTextStream & uppercasedigits(QTextStream &stream)
QTextStream & bom(QTextStream &stream)
QTextStream & reset(QTextStream &stream)
QTextStream & oct(QTextStream &stream)
QTextStream & lowercasedigits(QTextStream &stream)
QTextStream & noshowbase(QTextStream &stream)
QTextStream & right(QTextStream &stream)
QTextStream & dec(QTextStream &stream)
QTextStream & noforcepoint(QTextStream &stream)
QTextStream & ws(QTextStream &stream)
QTextStream & fixed(QTextStream &stream)
QTextStream & forcesign(QTextStream &stream)
QTextStream & left(QTextStream &stream)
QTextStream & center(QTextStream &stream)
QTextStream & forcepoint(QTextStream &stream)
QTextStream & endl(QTextStream &stream)
QTextStream & scientific(QTextStream &stream)
decltype(auto) cbegin(const T &t)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if
Q_CORE_EXPORT int qstricmp(const char *, const char *)
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qInf()
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qQNaN()
GLenum GLuint GLenum GLsizei length
GLenum GLsizei GLuint GLint * bytesWritten
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLenum input
GLenum GLenum GLsizei void * table
GLenum GLint GLint * precision
GLsizei const GLchar *const * string
[0]
GLbitfield GLuint readBuffer
#define IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR(type)
#define IMPLEMENT_STREAM_RIGHT_INT_OPERATOR(type)
#define CHECK_VALID_STREAM(x)
QBasicUtf8StringView< false > QUtf8StringView
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QString doubleToString(double d, int precision=-1, DoubleForm form=DFSignificantDigits, int width=-1, unsigned flags=NoFlags) const
QString longLongToString(qint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
QString unsLongLongToString(quint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const