1// qtextstream.sip generated by MetaSIP
2//
3// This file is part of the QtCore Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23%ModuleCode
24#include <qtextstream.h>
25%End
26
27class QTextStream
28{
29%TypeHeaderCode
30#include <qtextstream.h>
31%End
32
33public:
34    enum RealNumberNotation
35    {
36        SmartNotation,
37        FixedNotation,
38        ScientificNotation,
39    };
40
41    enum FieldAlignment
42    {
43        AlignLeft,
44        AlignRight,
45        AlignCenter,
46        AlignAccountingStyle,
47    };
48
49    enum NumberFlag
50    {
51        ShowBase,
52        ForcePoint,
53        ForceSign,
54        UppercaseBase,
55        UppercaseDigits,
56    };
57
58    enum Status
59    {
60        Ok,
61        ReadPastEnd,
62        ReadCorruptData,
63        WriteFailed,
64    };
65
66    typedef QFlags<QTextStream::NumberFlag> NumberFlags;
67    QTextStream();
68    explicit QTextStream(QIODevice *device);
69    QTextStream(QByteArray *array /Constrained/, QIODevice::OpenMode mode = QIODevice::ReadWrite);
70    virtual ~QTextStream();
71    void setCodec(QTextCodec *codec /KeepReference/);
72    void setCodec(const char *codecName);
73    QTextCodec *codec() const;
74    void setAutoDetectUnicode(bool enabled);
75    bool autoDetectUnicode() const;
76    void setGenerateByteOrderMark(bool generate);
77    bool generateByteOrderMark() const;
78    void setDevice(QIODevice *device);
79    QIODevice *device() const;
80    bool atEnd() const;
81    void reset();
82    void flush() /ReleaseGIL/;
83    bool seek(qint64 pos);
84    void skipWhiteSpace();
85    QString read(qint64 maxlen) /ReleaseGIL/;
86    QString readLine(qint64 maxLength = 0) /ReleaseGIL/;
87    QString readAll() /ReleaseGIL/;
88    void setFieldAlignment(QTextStream::FieldAlignment alignment);
89    QTextStream::FieldAlignment fieldAlignment() const;
90    void setPadChar(QChar ch);
91    QChar padChar() const;
92    void setFieldWidth(int width);
93    int fieldWidth() const;
94    void setNumberFlags(QTextStream::NumberFlags flags);
95    QTextStream::NumberFlags numberFlags() const;
96    void setIntegerBase(int base);
97    int integerBase() const;
98    void setRealNumberNotation(QTextStream::RealNumberNotation notation);
99    QTextStream::RealNumberNotation realNumberNotation() const;
100    void setRealNumberPrecision(int precision);
101    int realNumberPrecision() const;
102    QTextStream::Status status() const;
103    void setStatus(QTextStream::Status status);
104    void resetStatus();
105    qint64 pos() const;
106    QTextStream &operator>>(QByteArray &array /Constrained/);
107    QTextStream &operator<<(const QString &s);
108    QTextStream &operator<<(const QByteArray &array);
109    QTextStream &operator<<(double f /Constrained/);
110    QTextStream &operator<<(SIP_PYOBJECT i /TypeHint="int"/);
111%MethodCode
112        #if PY_MAJOR_VERSION < 3
113        if (PyInt_Check(a1))
114        {
115            qlonglong val = PyInt_AsLong(a1);
116
117            sipRes = &(*a0 << val);
118        }
119        else
120        #endif
121        {
122            qlonglong val = sipLong_AsLongLong(a1);
123
124            if (!PyErr_Occurred())
125            {
126                sipRes = &(*a0 << val);
127            }
128            else
129            {
130                // If it is positive then it might fit an unsigned long long.
131
132                qulonglong uval = sipLong_AsUnsignedLongLong(a1);
133
134                if (!PyErr_Occurred())
135                {
136                    sipRes = &(*a0 << uval);
137                }
138                else
139                {
140                    sipError = (PyErr_ExceptionMatches(PyExc_OverflowError)
141                            ? sipErrorFail : sipErrorContinue);
142                }
143            }
144        }
145%End
146
147    void setLocale(const QLocale &locale);
148    QLocale locale() const;
149
150private:
151    QTextStream(const QTextStream &);
152};
153
154QFlags<QTextStream::NumberFlag> operator|(QTextStream::NumberFlag f1, QFlags<QTextStream::NumberFlag> f2);
155class QTextStreamManipulator;
156QTextStream &operator<<(QTextStream &s, QTextStreamManipulator m);
157QTextStream &bin(QTextStream &s) /PyName=bin_/;
158QTextStream &oct(QTextStream &s) /PyName=oct_/;
159QTextStream &dec(QTextStream &s);
160QTextStream &hex(QTextStream &s) /PyName=hex_/;
161QTextStream &showbase(QTextStream &s);
162QTextStream &forcesign(QTextStream &s);
163QTextStream &forcepoint(QTextStream &s);
164QTextStream &noshowbase(QTextStream &s);
165QTextStream &noforcesign(QTextStream &s);
166QTextStream &noforcepoint(QTextStream &s);
167QTextStream &uppercasebase(QTextStream &s);
168QTextStream &uppercasedigits(QTextStream &s);
169QTextStream &lowercasebase(QTextStream &s);
170QTextStream &lowercasedigits(QTextStream &s);
171QTextStream &fixed(QTextStream &s);
172QTextStream &scientific(QTextStream &s);
173QTextStream &left(QTextStream &s);
174QTextStream &right(QTextStream &s);
175QTextStream &center(QTextStream &s);
176QTextStream &endl(QTextStream &s);
177QTextStream &flush(QTextStream &s);
178QTextStream &reset(QTextStream &s);
179QTextStream &bom(QTextStream &s);
180QTextStream &ws(QTextStream &s);
181QTextStreamManipulator qSetFieldWidth(int width);
182QTextStreamManipulator qSetPadChar(QChar ch);
183QTextStreamManipulator qSetRealNumberPrecision(int precision);
184