Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtextstream_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QTEXTSTREAM_P_H
6#define QTEXTSTREAM_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/private/qglobal_p.h>
20#include <QtCore/qstringconverter.h>
21#include <QtCore/qiodevice.h>
22#include <QtCore/qlocale.h>
23#include "qtextstream.h"
24
26
27#ifndef QT_NO_QOBJECT
29{
31public:
33 { }
35
36 inline void setupDevice(QTextStream *stream, QIODevice *device)
37 {
38 disconnect();
39 if (device) {
40 // Force direct connection here so that QTextStream can be used
41 // from multiple threads when the application code is handling
42 // synchronization (see also QTBUG-12055).
43 connect(device, SIGNAL(aboutToClose()), this, SLOT(flushStream()),
44 Qt::DirectConnection);
45 }
46 m_stream = stream;
47 }
48
49public Q_SLOTS:
50 void flushStream() { m_stream->flush(); }
51
52private:
54};
55#endif
56
58{
59 Q_DECLARE_PUBLIC(QTextStream)
60public:
61 // streaming parameters
75
76 QTextStreamPrivate(QTextStream *q_ptr);
78 void reset();
79
80 // device
81 QIODevice *device;
82#ifndef QT_NO_QOBJECT
84#endif
85
86 // string
87 QString *string;
90
95
96 QString writeBuffer;
97 QString readBuffer;
99 int readConverterSavedStateOffset; //the offset between readBufferStartDevicePos and that start of the buffer
101
103
104 // status
106 QLocale locale;
108
112 bool hasWrittenData = false;
113 bool generateBOM = false;
114
115 // i/o
121
122 QString read(int maxlen);
123 bool scan(const QChar **ptr, int *tokenLength,
124 int maxlen, TokenDelimiter delimiter);
125 inline const QChar *readPtr() const;
126 inline void consumeLastToken();
127 inline void consume(int nchars);
128 void saveConverterState(qint64 newPos);
130
131 // Return value type for getNumber()
137
138 inline bool getChar(QChar *ch);
139 inline void ungetChar(QChar ch);
140 NumberParsingStatus getNumber(qulonglong *l);
141 bool getReal(double *f);
142
143 inline void write(QStringView data) { write(data.begin(), data.size()); }
144 inline void write(QChar ch);
145 void write(const QChar *data, qsizetype len);
146 void write(QLatin1StringView data);
147 void writePadding(qsizetype len);
148 inline void putString(QStringView string, bool number = false)
149 {
150 putString(string.constData(), string.size(), number);
151 }
152 void putString(const QChar *data, qsizetype len, bool number = false);
153 void putString(QLatin1StringView data, bool number = false);
154 void putString(QUtf8StringView data, bool number = false);
155 inline void putChar(QChar ch);
156 void putNumber(qulonglong number, bool negative);
157
160 };
161 PaddingResult padding(qsizetype len) const;
162
163 // buffers
164 bool fillReadBuffer(qint64 maxBytes = -1);
165 void resetReadBuffer();
166 void flushWriteBuffer();
167};
168
169QT_END_NAMESPACE
170
171#endif // QTEXTSTREAM_P_H
void setupDevice(QTextStream *stream, QIODevice *device)
void saveConverterState(qint64 newPos)
QTextStreamPrivate(QTextStream *q_ptr)
PaddingResult padding(qsizetype len) const
bool getChar(QChar *ch)
void putChar(QChar ch)
void ungetChar(QChar ch)
void restoreToSavedConverterState()
void write(QStringView data)
void writePadding(qsizetype len)
QString read(int maxlen)
QStringDecoder savedToUtf16
const QChar * readPtr() const
void putString(QStringView string, bool number=false)
bool scan(const QChar **ptr, int *tokenLength, int maxlen, TokenDelimiter delimiter)
void write(const QChar *data, qsizetype len)
qint64 readBufferStartDevicePos
bool fillReadBuffer(qint64 maxBytes=-1)
QTextStream * q_ptr
void consume(int nchars)
void putNumber(qulonglong number, bool negative)
QStringConverter::Encoding encoding
QDeviceClosedNotifier deviceClosedNotifier
QStringDecoder toUtf16
QStringEncoder fromUtf16
void putString(const QChar *data, qsizetype len, bool number=false)
NumberParsingStatus getNumber(qulonglong *l)
QIODevice::OpenMode stringOpenMode
bool getReal(double *f)
Combined button and popup list for selecting options.