WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes | Properties | List of all members
Zbl::ZioDevice Class Reference

A javascript wrapper for QIODevice. More...

#include <ZioDevice.h>

Inheritance diagram for Zbl::ZioDevice:
Inheritance graph
[legend]
Collaboration diagram for Zbl::ZioDevice:
Collaboration graph
[legend]

Public Types

enum  OpenMode {
  NotOpen = QIODevice::NotOpen, ReadOnly = QIODevice::ReadOnly, WriteOnly = QIODevice::WriteOnly, ReadWrite = QIODevice::ReadWrite,
  Append = QIODevice::Append, Truncate = QIODevice::Truncate, Text = QIODevice::Text, Unbuffered = QIODevice::Unbuffered
}
 

Signals

void getCurrentDevice (QIODevice **device) const
 Connected devices should listen to this signal and respond by returning a pointer to the QIODevice object for which this ZioDevice object is currently providing a Javascript interface. More...
 

Public Member Functions

 ZioDevice (QObject *parent=0)
 
bool isOpen () const
 
int openMode () const
 
bool getTextMode () const
 
void setTextMode (bool textModeEnabled)
 
bool isSequential ()
 
bool isWritable () const
 
bool isReadable () const
 
bool atEnd () const
 
qint64 size () const
 
qint64 pos () const
 
qint64 bytesAvailable () const
 
qint64 bytesToWrite () const
 
QVariant getTags ()
 
QString getErrorString ()
 
Q_INVOKABLE bool seek (qint64 pos)
 
Q_INVOKABLE qint64 writeString (const QString &text)
 Write a string to the device. More...
 
Q_INVOKABLE qint64 writeBytes (const QObject *data)
 Write the contents of a ZByteArray to the device. More...
 
Q_INVOKABLE bool waitForBytesWritten (int msecs)
 
Q_INVOKABLE bool waitForReadyRead (int msecs)
 
Q_INVOKABLE void reset ()
 
Q_INVOKABLE void close ()
 

Static Public Member Functions

static void registerType ()
 Registers ZioDevice as a QML type. More...
 

Protected Member Functions

QIODevice * connectedDevice () const
 Emits the getCurrentDevice signal and returns the resulting device, or else throws an exception if a device is not returned in response to the signal. More...
 
void createTags ()
 Initializes QIODevice enumeration tags. More...
 

Static Protected Attributes

static QVariant m_tags
 A QVariant containing a QVariantMap of QIODevice enumerations for use by background Javascript threads. More...
 

Properties

bool isOpen
 Returns true if the device is open; otherwise returns false. More...
 
int openMode
 Returns the mode in which the device has been opened; i.e. ReadOnly or WriteOnly. More...
 
bool textMode
 Sets and gets the text mode flag. When set
sequences are converted to/from
when reading/writing the device on Windows. More...
 
bool isSequential
 
bool writable
 Returns true if the device is writable, false otherwise. More...
 
bool readable
 Returns true if the device is readable, false otherwise. More...
 
bool atEnd
 Returns true if the current read and write position is at the end of the device. More...
 
qint64 size
 For open random-access devices, this function returns the size of the device. For open sequential devices, bytesAvailable() is returned. More...
 
qint64 pos
 
qint64 bytesAvailable
 
qint64 bytesToWrite
 
QString errorString
 
QVariant tags
 

Detailed Description

A javascript wrapper for QIODevice.

See also
Zbl::ZFile

Definition at line 40 of file ZioDevice.h.

Member Enumeration Documentation

◆ OpenMode

Enumerator
NotOpen 
ReadOnly 
WriteOnly 
ReadWrite 
Append 
Truncate 
Text 
Unbuffered 

Definition at line 46 of file ZioDevice.h.

Constructor & Destructor Documentation

◆ ZioDevice()

Zbl::ZioDevice::ZioDevice ( QObject *  parent = 0)
explicit

Definition at line 36 of file ZioDevice.cpp.

Member Function Documentation

◆ atEnd()

bool Zbl::ZioDevice::atEnd ( ) const

Referenced by isReadable().

◆ bytesAvailable()

qint64 Zbl::ZioDevice::bytesAvailable ( ) const

Referenced by setTextMode().

◆ bytesToWrite()

qint64 Zbl::ZioDevice::bytesToWrite ( ) const

Referenced by setTextMode().

◆ close()

void Zbl::ZioDevice::close ( )

Definition at line 227 of file ZioDevice.cpp.

◆ connectedDevice()

QIODevice * Zbl::ZioDevice::connectedDevice ( ) const
protected

Emits the getCurrentDevice signal and returns the resulting device, or else throws an exception if a device is not returned in response to the signal.

Returns
A pointer to the currently connected QIODevice object.

Definition at line 192 of file ZioDevice.cpp.

Referenced by createTags(), getTextMode(), isReadable(), isWritable(), seek(), setTextMode(), waitForBytesWritten(), waitForReadyRead(), writeBytes(), and writeString().

◆ createTags()

void Zbl::ZioDevice::createTags ( )
protected

Initializes QIODevice enumeration tags.

Definition at line 56 of file ZioDevice.cpp.

Referenced by ZioDevice().

◆ getCurrentDevice

void Zbl::ZioDevice::getCurrentDevice ( QIODevice **  device) const
signal

Connected devices should listen to this signal and respond by returning a pointer to the QIODevice object for which this ZioDevice object is currently providing a Javascript interface.

for example:

QFile f = new QFile(); device = qobject_cast<QIODevice>(f);

ZioDevice can't cache the pointer to QIODevice because some classes, such as QTextStream, allow the QIODevice object to be reset (i.e. via the QTextStream::setDevice method).

Parameters
deviceA pointer to a pointer to a QIODevice object. The connected slot should write the pointer to its class's QIODevice object to this location.
See also
ZFile::getQDevice

Referenced by close(), connectedDevice(), getErrorString(), and reset().

◆ getErrorString()

QString Zbl::ZioDevice::getErrorString ( )

Definition at line 203 of file ZioDevice.cpp.

Referenced by writeBytes(), and writeString().

◆ getTags()

QVariant Zbl::ZioDevice::getTags ( )

Definition at line 305 of file ZioDevice.cpp.

◆ getTextMode()

bool Zbl::ZioDevice::getTextMode ( ) const

Definition at line 96 of file ZioDevice.cpp.

◆ isOpen()

bool Zbl::ZioDevice::isOpen ( ) const

Referenced by createTags().

◆ isReadable()

bool Zbl::ZioDevice::isReadable ( ) const

Definition at line 173 of file ZioDevice.cpp.

◆ isSequential()

bool Zbl::ZioDevice::isSequential ( )

Referenced by setTextMode().

◆ isWritable()

bool Zbl::ZioDevice::isWritable ( ) const

Definition at line 163 of file ZioDevice.cpp.

◆ openMode()

int Zbl::ZioDevice::openMode ( ) const

Referenced by createTags().

◆ pos()

qint64 Zbl::ZioDevice::pos ( ) const

Referenced by setTextMode().

◆ registerType()

void Zbl::ZioDevice::registerType ( )
static

Registers ZioDevice as a QML type.

Definition at line 48 of file ZioDevice.cpp.

Referenced by Zbl::Zblcore::registerTypes().

◆ reset()

void Zbl::ZioDevice::reset ( )

Definition at line 215 of file ZioDevice.cpp.

◆ seek()

bool Zbl::ZioDevice::seek ( qint64  pos)

Definition at line 239 of file ZioDevice.cpp.

◆ setTextMode()

void Zbl::ZioDevice::setTextMode ( bool  textModeEnabled)

Definition at line 105 of file ZioDevice.cpp.

◆ size()

qint64 Zbl::ZioDevice::size ( ) const

Referenced by setTextMode().

◆ waitForBytesWritten()

bool Zbl::ZioDevice::waitForBytesWritten ( int  msecs)

Definition at line 247 of file ZioDevice.cpp.

◆ waitForReadyRead()

bool Zbl::ZioDevice::waitForReadyRead ( int  msecs)

Definition at line 255 of file ZioDevice.cpp.

◆ writeBytes()

qint64 Zbl::ZioDevice::writeBytes ( const QObject *  data)

Write the contents of a ZByteArray to the device.

Returns
The number of bytes written, or -1 if error

Definition at line 280 of file ZioDevice.cpp.

◆ writeString()

qint64 Zbl::ZioDevice::writeString ( const QString &  text)

Write a string to the device.

Returns
The number of bytes written, or -1 if error

Definition at line 263 of file ZioDevice.cpp.

Member Data Documentation

◆ m_tags

QVariant Zbl::ZioDevice::m_tags
staticprotected

A QVariant containing a QVariantMap of QIODevice enumerations for use by background Javascript threads.

This is needed because background Javascript threads can't use QQmlEngine's type system.

Definition at line 233 of file ZioDevice.h.

Referenced by createTags(), and getTags().

Property Documentation

◆ atEnd

bool Zbl::ZioDevice::atEnd
read

Returns true if the current read and write position is at the end of the device.

Definition at line 103 of file ZioDevice.h.

◆ bytesAvailable

qint64 Zbl::ZioDevice::bytesAvailable
read

Definition at line 125 of file ZioDevice.h.

◆ bytesToWrite

qint64 Zbl::ZioDevice::bytesToWrite
read

Definition at line 130 of file ZioDevice.h.

◆ errorString

QString Zbl::ZioDevice::errorString
read

Definition at line 133 of file ZioDevice.h.

◆ isOpen

bool Zbl::ZioDevice::isOpen
read

Returns true if the device is open; otherwise returns false.

Definition at line 71 of file ZioDevice.h.

◆ isSequential

bool Zbl::ZioDevice::isSequential
read

Definition at line 87 of file ZioDevice.h.

◆ openMode

int Zbl::ZioDevice::openMode
read

Returns the mode in which the device has been opened; i.e. ReadOnly or WriteOnly.

Definition at line 77 of file ZioDevice.h.

◆ pos

qint64 Zbl::ZioDevice::pos
read

Definition at line 120 of file ZioDevice.h.

◆ readable

bool Zbl::ZioDevice::readable
read

Returns true if the device is readable, false otherwise.

Definition at line 97 of file ZioDevice.h.

◆ size

qint64 Zbl::ZioDevice::size
read

For open random-access devices, this function returns the size of the device. For open sequential devices, bytesAvailable() is returned.

If the device is closed, the size returned will not reflect the actual size of the device.

Definition at line 115 of file ZioDevice.h.

◆ tags

QVariant Zbl::ZioDevice::tags
read

Definition at line 134 of file ZioDevice.h.

◆ textMode

bool Zbl::ZioDevice::textMode
readwrite

Sets and gets the text mode flag. When set
sequences are converted to/from
when reading/writing the device on Windows.

Definition at line 84 of file ZioDevice.h.

◆ writable

bool Zbl::ZioDevice::writable
read

Returns true if the device is writable, false otherwise.

Definition at line 92 of file ZioDevice.h.


The documentation for this class was generated from the following files: