37 QObject(parent), m_d(nullptr)
39 qDebug(
"ZTextStream creating input stream");
41 m_t =
new QTextStream(stdin, QFile::ReadOnly);
45 "ZTextStream::ZTextStream - error creating QTextStream object");
53 QObject(parent),
m_d(device)
55 m_t =
new QTextStream();
59 "ZTextStream::ZTextStream - error creating QTextStream object");
61 m_t->setDevice(
m_d.data());
69 QObject(parent),
m_d(nullptr),
m_s(string)
71 m_t =
new QTextStream();
75 "ZTextStream::ZTextStream - error creating QTextStream object");
77 m_t->setString(
m_s.data());
107 map.insert(
"Ok",
Ok);
118 m_tags = QVariant::fromValue(map);
125 connect(
m_zd, SIGNAL(getCurrentDevice(QIODevice**)),
126 SLOT(
getQDevice(QIODevice**)), Qt::DirectConnection);
132 throw ZblException(
"No device or string object available to stream.");
135 throw ZblException(
"Text stream object not initialized.");
140 if(
m_d && !
m_d->isReadable())
142 "Error, device is not readable.");
149 if(
m_d && !
m_d->isWritable())
151 "Error, device is not writable.");
156 qmlRegisterType<ZTextStream>(
"org.zuble.qml", 1, 0,
"ZTextStream");
163 m_t->setLocale(QLocale(locale));
182 *device =
m_t->device();
198 m_t->setAutoDetectUnicode(autoDetectOn);
239 m_t->setNumberFlags(QTextStream::NumberFlags(flags));
256 m_t->setRealNumberNotation(QTextStream::RealNumberNotation(notation));
273 m_t->setFieldAlignment(QTextStream::FieldAlignment(alignment));
290 m_t->setFieldWidth(width);
307 m_t->setRealNumberPrecision(precision);
324 m_t->setPadChar(static_cast<char>(ch));
341 m_t->setIntegerBase(base);
351 retString = *
m_t->string();
408 m_t->skipWhiteSpace();
415 qDebug(
"ZTextStream::readLine maxsize = %d", maxSize);
424 qDebug(
"ZTextStream::read");
433 qDebug(
"ZTextStream::readAll");
441 dataType className::methodName() \
443 qDebug(
"%s::%s", #className, #methodName); \
446 validateReadable(); \
448 ZBL_SLOT_END_RETURN(data, 0, \
449 Z_FAC_JS, className::methodName, methodName failed) \
465 qDebug(
"ZTextStream::readChar");
476 qDebug(
"ZTextStream::readString");
487 qDebug(
"ZTextStream::readBytes");
498 #define writeNumericDataType(dataType, className, methodName) \ 499 bool className::methodName(dataType data) \ 501 qDebug("%s::%s", #className, #methodName); \ 503 validateWritable(); \ 505 ZBL_SLOT_END_RETURN(true, false, \ 506 Z_FAC_JS, className::methodName, methodName failed) \ 523 qDebug(
"ZTextStream::writeChar");
526 *m_t << static_cast<char>(data);
533 qDebug(
"ZTextStream::writeBytes");
538 throw ZblException(
"Error: ZByteArray object expected. " 539 "Object passed was not a ZByteArray.");
548 qDebug(
"ZTextStream::writeString");
558 qDebug(
"ZTextStream::writeLine");
561 *
m_t << text << endl;
static void registerType()
Registers ZTextStream as a QML type.
void setRealNumberNotation(uint notation)
This class supports streaming of text and binary data.
QString getString() const
static QVariant m_tags
QVariantMap of QTextStream enumerations for use by Javascript programs.
ZioDevice * m_zd
Pointer to contained ZioDevice object.
Q_INVOKABLE bool writeShort(signed short data)
Q_INVOKABLE QString readLine(qint64 maxSize)
Q_INVOKABLE bool writeLine(const QString &text)
Q_INVOKABLE bool writeChar(uint data)
void validateReadable() const
ZTextStream(QObject *parent=nullptr)
Q_INVOKABLE void skipWhiteSpace()
Q_INVOKABLE bool writeFloat(float data)
void setFieldWidth(int width)
bool getAutoDetectUnicode() const
int getFieldWidth() const
Q_INVOKABLE bool writeLong(signed long data)
uint getRealNumberNotation() const
void setAutoDetectUnicode(bool autoDetectOn)
Q_INVOKABLE signed long readLong()
Q_INVOKABLE bool writeUShort(unsigned short data)
Q_INVOKABLE double readDouble()
Q_INVOKABLE bool writeBytes(QObject *data)
void setNumberFlags(uint flags)
Q_INVOKABLE bool writeUInt(unsigned int data)
Q_INVOKABLE bool writeULongLong(qulonglong data)
Q_INVOKABLE qulonglong readULongLong()
QSharedPointer< QString > ZqStringPtr
void validateWritable() const
Q_INVOKABLE signed short readShort()
A javascript wrapper for QIODevice.
void getQDevice(QIODevice **device)
Q_INVOKABLE void release()
#define ZBL_SLOT_BEGIN_TRY
Q_INVOKABLE signed int readInt()
Q_INVOKABLE uint readChar()
Q_INVOKABLE QString readString()
void setRealNumberPrecision(int precision)
uint getFieldAlignment() const
Q_INVOKABLE bool writeDouble(double data)
Q_INVOKABLE void setLocale(const QString &locale)
#define ZBL_SLOT_END_VOID(facility, code, error_message)
Q_INVOKABLE unsigned long readULong()
Q_INVOKABLE QString read(qint64 maxSize)
Q_INVOKABLE bool seek(QVariant pos)
Q_INVOKABLE float readFloat()
readNumericDataType(qint16, ZDataStream, readInt16) readNumericDataType(quint16
Q_INVOKABLE bool writeInt(signed int data)
uint getNumberFlags() const
Zuble's Qt Exception Object.
QObject device
A ZioDevice object presents this object's QIODevice interface to Javascript programs.
void setIntegerBase(int base)
Q_INVOKABLE bool writeULong(unsigned long data)
int getRealNumberPrecision() const
int getIntegerBase() const
Q_INVOKABLE void resetStatus()
Q_INVOKABLE QObject * readBytes()
Q_INVOKABLE unsigned short readUShort()
Q_INVOKABLE bool writeLongLong(qlonglong data)
Q_INVOKABLE qlonglong readLongLong()
void setFieldAlignment(uint alignment)
void validateData() const
QSharedPointer< QIODevice > ZqIODevicePtr
writeNumericDataType(qint16, ZDataStream, writeInt16) writeNumericDataType(quint16
Q_INVOKABLE bool writeString(const QString &text)
Q_INVOKABLE unsigned int readUInt()
#define ZBL_SLOT_END_RETURN(return_success, return_failed, facility, code, error_message)
Reads and writes UTF-8 text to an i/o stream.
Q_INVOKABLE QString readAll()