39 qDebug(
"ZioDevice::ZioDevice");
41 QQmlEngine::setObjectOwnership(
this, QQmlEngine::CppOwnership);
50 qmlRegisterUncreatableType<ZioDevice>
51 (
"org.zuble.qml", 1, 0,
"ZioDevice",
52 QString(
"ZioDevice is obtained from \"device\" property " 53 "of the I/O object you are reading or writing."));
63 map.insert(
"NotOpen", QIODevice::NotOpen);
64 map.insert(
"ReadOnly", QIODevice::ReadOnly);
65 map.insert(
"WriteOnly", QIODevice::WriteOnly);
66 map.insert(
"ReadWrite", QIODevice::ReadWrite);
67 map.insert(
"Append", QIODevice::Append);
68 map.insert(
"Truncate", QIODevice::Truncate);
69 map.insert(
"Text", QIODevice::Text);
70 map.insert(
"Unbuffered", QIODevice::Unbuffered);
72 m_tags = QVariant::fromValue(map);
78 qDebug(
"ZioDevice::isOpen");
79 bool openFlag =
false;
82 openFlag = device->isOpen();
89 qDebug(
"ZioDevice::openMode");
98 qDebug(
"ZioDevice::getTextMode");
107 qDebug(
"ZioDevice::setTextMode");
110 device->setTextModeEnabled(textModeEnabled);
117 qDebug(
"ZioDevice::size");
126 qDebug(
"ZioDevice::pos");
135 qDebug(
"ZioDevice::bytesAvailable");
144 qDebug(
"ZioDevice::bytesToWrite");
155 qDebug(
"ZioDevice::isSequential");
165 qDebug(
"ZioDevice::isWritable");
175 qDebug(
"ZioDevice::isSequential");
194 QIODevice* dev =
nullptr;
205 QIODevice* device =
nullptr;
209 if(device ==
nullptr)
210 return QString(
"Can't get error string: No connected Device.");
212 return device->errorString();
217 QIODevice* device =
nullptr;
221 if(device ==
nullptr)
222 qDebug(
"Error: No connected Device.");
229 QIODevice* device =
nullptr;
233 if(device ==
nullptr)
234 qDebug(
"Error: No connected Device.");
269 qint64 sizeWritten = device->write(text.toUtf8().constData());
271 if(sizeWritten == -1)
273 QString msg(
"File error attempting to write data: %1");
288 throw ZblException(
"Programming error: ZioDevice::writeData() argument must be a ZByteArray");
292 qint64 sizeWritten = device->write(*ba->qByteArray());
294 if((sizeWritten == -1)
295 || (sizeWritten < ba->getSize()))
297 QString msg(
"ZProcess error attempting to write data: %1");
This class supports streaming of text and binary data.
static void registerType()
Registers ZioDevice as a QML type.
qint64 bytesAvailable() const
ZioDevice(QObject *parent=0)
Q_INVOKABLE qint64 writeString(const QString &text)
Write a string to the device.
QIODevice * connectedDevice() const
Emits the getCurrentDevice signal and returns the resulting device, or else throws an exception if a ...
Q_INVOKABLE bool seek(qint64 pos)
static QVariant m_tags
A QVariant containing a QVariantMap of QIODevice enumerations for use by background Javascript thread...
Q_INVOKABLE qint64 writeBytes(const QObject *data)
Write the contents of a ZByteArray to the device.
Q_INVOKABLE bool waitForReadyRead(int msecs)
#define ZBL_SLOT_BEGIN_TRY
#define ZBL_SLOT_END_VOID(facility, code, error_message)
Q_INVOKABLE bool waitForBytesWritten(int msecs)
void getCurrentDevice(QIODevice **device) const
Connected devices should listen to this signal and respond by returning a pointer to the QIODevice ob...
Zuble's Qt Exception Object.
void createTags()
Initializes QIODevice enumeration tags.
#define ZBL_SLOT_END_RETURN(return_success, return_failed, facility, code, error_message)
void setTextMode(bool textModeEnabled)
qint64 bytesToWrite() const