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// Qt-Security score:significant reason:header-decls-only
5
6#ifndef QTEXTSTREAM_P_H
7#define QTEXTSTREAM_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtCore/private/qglobal_p.h>
21#include <QtCore/qstringconverter.h>
22#include <QtCore/qiodevice.h>
23#include <QtCore/qlocale.h>
24#include "qtextstream.h"
25
27
29{
30 Q_DECLARE_PUBLIC(QTextStream)
31public:
32 // streaming parameters
33 class Params
34 {
35 public:
36 void reset();
37
38 // As for QString, QLocale functions taking these: the values of
39 // precision, base and width can't sensibly need even eight bits, so
40 // there's no sense expanding beyond int.
48 };
49
50 QTextStreamPrivate(QTextStream *q_ptr);
52 void reset();
53
54 inline void setupDevice(QIODevice *device);
55 inline void disconnectFromDevice();
56
57 // device
58 QIODevice *device;
59#ifndef QT_NO_QOBJECT
61#endif
62
63 // string
64 QString *string;
67
72
73 QString writeBuffer;
74 QString readBuffer;
76 qsizetype readConverterSavedStateOffset; //the offset between readBufferStartDevicePos and that start of the buffer
78
80
81 // status
83 QLocale locale;
85
89 bool hasWrittenData = false;
90 bool generateBOM = false;
91
92 // i/o
98
99 QString read(qsizetype maxlen);
100 bool scan(const QChar **ptr, qsizetype *tokenLength,
101 qsizetype maxlen, TokenDelimiter delimiter);
102 inline const QChar *readPtr() const;
103 inline void consumeLastToken();
104 inline void consume(qsizetype nchars);
105 void saveConverterState(qint64 newPos);
107
108 // Return value type for getNumber()
114
115 inline bool getChar(QChar *ch);
116 inline void ungetChar(QChar ch);
117 NumberParsingStatus getNumber(qulonglong *l);
118 bool getReal(double *f);
119
120 void write(QStringView data);
121 void write(QChar ch);
122 void write(QLatin1StringView data);
123 void writePadding(qsizetype len);
124
125 enum class PutStringMode : bool { String, Number };
126 void putString(QStringView string, PutStringMode = PutStringMode::String);
127 void putString(QLatin1StringView data, PutStringMode = PutStringMode::String);
128 void putString(QUtf8StringView data, PutStringMode = PutStringMode::String);
129
130 inline void putChar(QChar ch);
131 void putNumber(qulonglong number, bool negative);
132
136 PaddingResult padding(qsizetype len) const;
137
138 // buffers
139 bool fillReadBuffer(qint64 maxBytes = -1);
140 void resetReadBuffer();
141 void flushWriteBuffer();
142
143private:
144 template <typename Appendable>
145 void writeImpl(Appendable data);
146 template <typename StringView>
147 void putStringImpl(StringView view, PutStringMode mode);
148};
149
150QT_END_NAMESPACE
151
152#endif // QTEXTSTREAM_P_H
void saveConverterState(qint64 newPos)
QTextStreamPrivate(QTextStream *q_ptr)
PaddingResult padding(qsizetype len) const
qsizetype readConverterSavedStateOffset
bool getChar(QChar *ch)
void putChar(QChar ch)
void ungetChar(QChar ch)
void restoreToSavedConverterState()
void write(QStringView data)
void writePadding(qsizetype len)
QStringDecoder savedToUtf16
const QChar * readPtr() const
QMetaObject::Connection aboutToCloseConnection
qsizetype lastTokenSize
qint64 readBufferStartDevicePos
bool fillReadBuffer(qint64 maxBytes=-1)
QTextStream * q_ptr
qsizetype readBufferOffset
void putNumber(qulonglong number, bool negative)
void setupDevice(QIODevice *device)
bool scan(const QChar **ptr, qsizetype *tokenLength, qsizetype maxlen, TokenDelimiter delimiter)
void consume(qsizetype nchars)
QStringConverter::Encoding encoding
QStringDecoder toUtf16
QStringEncoder fromUtf16
NumberParsingStatus getNumber(qulonglong *l)
QIODevice::OpenMode stringOpenMode
void putString(QStringView string, PutStringMode=PutStringMode::String)
bool getReal(double *f)
QString read(qsizetype maxlen)