File indexing completed on 2025-01-19 04:25:16

0001 /*
0002  * Replacement fot QT Bindings that were removed from QT5
0003  * Copyright (C) 2020  Pedro de Carvalho Gomes <pedrogomes81@gmail.com>
0004  *
0005  * This program is free software: you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation, either version 3 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #ifndef CORETEXTSTREAM_H
0020 #define CORETEXTSTREAM_H
0021 
0022 #include "QtBinding.h"
0023 
0024 #include <QObject>
0025 #include <QTextStream>
0026 
0027 namespace QtBindings
0028 {
0029     namespace Core
0030     {
0031         class TextStream : public QObject, public QTextStream, public QtBindings::Base<TextStream>
0032         {
0033         Q_OBJECT
0034         public:
0035             Q_INVOKABLE TextStream();
0036             Q_INVOKABLE TextStream(const TextStream &textStream);
0037             Q_INVOKABLE TextStream(QIODevice *device);
0038             Q_INVOKABLE TextStream(FILE *fileHandle, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
0039             Q_INVOKABLE TextStream(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
0040             Q_INVOKABLE TextStream(QByteArray *array, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
0041             Q_INVOKABLE TextStream(const QByteArray &array, QIODevice::OpenMode openMode = QIODevice::ReadOnly);
0042             TextStream &operator=(const TextStream &other);
0043         public slots:
0044             bool atEnd() const;
0045             bool autoDetectUnicode() const;
0046             QTextCodec *codec() const;
0047             QIODevice *device() const;
0048             FieldAlignment fieldAlignment() const;
0049             int fieldWidth() const;
0050             void flush();
0051             bool generateByteOrderMark() const;
0052             int integerBase() const;
0053             QLocale locale() const;
0054             NumberFlags numberFlags() const;
0055             QChar padChar() const;
0056             qint64 pos() const;
0057             QString readAll();
0058             bool readLineInto(QString *line, qint64 maxlen = 0);
0059             QString readLine(qint64 maxlen = 0);
0060             QString read(qint64 maxlen);
0061             RealNumberNotation realNumberNotation() const;
0062             int realNumberPrecision() const;
0063             void reset();
0064             void resetStatus();
0065             bool seek(qint64 pos);
0066             void setAutoDetectUnicode(bool enabled);
0067             void setCodec(const char *codecName);
0068             void setCodec(QTextCodec *codec);
0069             void setDevice(QIODevice *device);
0070             void setFieldAlignment(FieldAlignment alignment);
0071             void setFieldWidth(int width);
0072             void setGenerateByteOrderMark(bool generate);
0073             void setIntegerBase(int base);
0074             void setLocale(const QLocale &locale);
0075             void setNumberFlags(NumberFlags flags);
0076             void setPadChar(QChar ch);
0077             void setRealNumberNotation(RealNumberNotation notation);
0078             void setRealNumberPrecision(int precision);
0079             void setStatus(Status status);
0080             void setString(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
0081             void skipWhiteSpace();
0082             Status status() const;
0083             QString *string() const;
0084         };
0085     }
0086 }
0087 Q_DECLARE_METATYPE(QtBindings::Core::TextStream)
0088 #endif //CORETEXTSTREAM_H