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
|
A javascript wrapper for QFile. More...
#include <ZFile.h>
Public Types | |
enum | Permission { ReadOwner = QFileDevice::ReadOwner, WriteOwner = QFileDevice::WriteOwner, ExeOwner = QFileDevice::ExeOwner, ReadUser = QFileDevice::ReadUser, WriteUser = QFileDevice::WriteUser, ExeUser = QFileDevice::ExeUser, ReadGroup = QFileDevice::ReadGroup, WriteGroup = QFileDevice::WriteGroup, ExeGroup = QFileDevice::ExeGroup, ReadOther = QFileDevice::ReadOther, WriteOther = QFileDevice::WriteOther, ExeOther = QFileDevice::ExeOther } |
Public Slots | |
void | getQDevice (QIODevice **device) |
Signals | |
void | tagsChanged () |
Public Member Functions | |
ZFile (QObject *parent=0) | |
virtual | ~ZFile () |
QString | getFileName () const |
void | setFileName (const QString &fileName) |
QObject * | getJsDevice () |
QVariant | getTags () |
Q_INVOKABLE void | release () |
Releases references from this object to wrapped Qt C++ objects. More... | |
Q_INVOKABLE void | close () |
Closes the device and sets its OpenMode to NotOpen. The error string is also reset. More... | |
Q_INVOKABLE bool | open (int openMode) |
Opens the device and sets its open mode to openMode. Returns true if successful; otherwise returns false. More... | |
Q_INVOKABLE bool | copy (const QString &newName) |
Copies this file to newName. More... | |
Q_INVOKABLE bool | rename (const QString &newName) |
Renames this file to newName. More... | |
Q_INVOKABLE bool | remove () |
Removes the file. Returns true if successful; otherwise returns false. More... | |
Q_INVOKABLE bool | exists () |
Determine if the file currently exists. Returns true if file exists; otherwise returns false. More... | |
Q_INVOKABLE bool | exists (const QString &fileName) |
Determine if the specified file currently exists. More... | |
Q_INVOKABLE QString | getAbsoluteFilePath (const QString &filePath) |
Returns the absolute file path for the given file path. More... | |
Q_INVOKABLE QString | getCanonicalFilePath (const QString &filePath) |
Returns the canonical file path for the given file path. More... | |
Q_INVOKABLE QObject * | zReadData (int maxSize) |
Reads up to maxSize bytes or up to end of data, whichever comes first, into a ZByteArray. More... | |
Q_INVOKABLE QObject * | zReadDataLine (int maxSize) |
Reads up to the next new line or up to maxSize bytes or up to end of data, whichever comes first, into a ZByteArray. More... | |
Q_INVOKABLE QObject * | zReadDataAll () |
Reads up to the end of data into a ZByteArray. More... | |
Q_INVOKABLE QList< int > | jReadData (int maxSize) |
Reads up to maxSize bytes or up to end of data, whichever comes first, into a Javascript array. More... | |
Q_INVOKABLE QList< int > | jReadDataLine (int maxSize) |
Reads up to the next new line or up to maxSize bytes or up to end of data, whichever comes first, into a Javascript array. More... | |
Q_INVOKABLE QList< int > | jReadDataAll () |
Reads up to the end of data into a Javascript array. More... | |
Q_INVOKABLE bool | zWriteData (const ZByteArray &data) |
Write the contents of a ZByteArray to the device. More... | |
Q_INVOKABLE bool | jWriteData (const QList< int > data) |
Write the contents of a Javascript array of numbers to the device as bytes. More... | |
Q_INVOKABLE QObject * | zTextStream () |
Returns a Zbl::ZTextStream object that can be used to stream text to or from the device. More... | |
Q_INVOKABLE QObject * | zDataStream () |
Returns a Zbl::ZDataStream object that can be used to stream binary data to or from the device. More... | |
Static Public Member Functions | |
static void | registerType () |
Registers ZFile as a QML type. More... | |
Protected Member Functions | |
ZBL_DECLARE_LOGGED_OBJECT void | initZioDevice () |
Construct and connect a ZioDevice object that presents a Javascript interface to this file's QIODevice object. More... | |
void | createTags () |
Create the m_tag object that presents a Javascript interface to QFile enumeration values. More... | |
QList< int > | jGetData (int maxSize, bool lineModeOn=false) |
A common method for line and no-line mode data fetch operations into a Javascript array. More... | |
void | initFile (const QString &fileName) |
Closes the current file if opened, then creates a new embedded QFile object with the specified file name. More... | |
void | validateFile () const |
Ensures the embedded QFile object has been initialized by throwing an exception if not. More... | |
void | validateReadable () const |
Ensures the embedded QFile object is readable by throwing an exception if not. More... | |
void | validateWritable () const |
Ensures the embedded QFile object is writable by throwing an exception if not. More... | |
void | validateReadDataSuccess (const QByteArray &ba) const |
Throws an exception if both the supplied QByteArray object is empty and an error condition exists on the embedded QFile object, or if the embedded QFile object is not initialized. More... | |
Protected Attributes | |
ZqFilePtr | m_f |
Smart pointer to the embedded QFile object. More... | |
ZioDevice * | m_zd |
Pointer to QioDevice interface object. More... | |
Static Protected Attributes | |
static QVariant | m_tags |
A QVariantMap used to pass QFile enumeration values to Javascript programs. More... | |
Properties | |
QString | fileName |
The name of the file. More... | |
QObject | device |
A ZioDevice object that represents the File's QioDevice interface. More... | |
QVariant | tags |
A Javascript object containing QFile enumeration values. More... | |
A javascript wrapper for QFile.
You must set the fileName property before using this object unless otherwise noted in the method or property description.
void Zbl::ZFile::close | ( | ) |
Closes the device and sets its OpenMode to NotOpen. The error string is also reset.
Definition at line 139 of file ZFile.cpp.
Referenced by initFile(), setFileName(), and ~ZFile().
bool Zbl::ZFile::copy | ( | const QString & | newName | ) |
|
protected |
bool Zbl::ZFile::exists | ( | ) |
bool Zbl::ZFile::exists | ( | const QString & | fileName | ) |
QString Zbl::ZFile::getAbsoluteFilePath | ( | const QString & | filePath | ) |
QString Zbl::ZFile::getCanonicalFilePath | ( | const QString & | filePath | ) |
|
slot |
Definition at line 127 of file ZFile.cpp.
Referenced by initZioDevice().
|
inlineprotected |
Closes the current file if opened, then creates a new embedded QFile object with the specified file name.
fileName | The file name to set for the new embedded QFile object. |
Definition at line 364 of file ZFile.h.
Referenced by setFileName().
|
protected |
|
protected |
A common method for line and no-line mode data fetch operations into a Javascript array.
maxSize | The largest number of bytes to read |
lineModeOn | true stops reading if a new line is encountered before maxBytes number of bytes have been read. false continues reading until maxBytes number of bytes or the end of data is encountered. Default is false. |
Definition at line 334 of file ZFile.cpp.
Referenced by jReadData(), jReadDataAll(), and jReadDataLine().
QList< int > Zbl::ZFile::jReadData | ( | int | maxSize | ) |
QList< int > Zbl::ZFile::jReadDataAll | ( | ) |
QList< int > Zbl::ZFile::jReadDataLine | ( | int | maxSize | ) |
bool Zbl::ZFile::jWriteData | ( | const QList< int > | data | ) |
bool Zbl::ZFile::open | ( | int | openMode | ) |
Opens the device and sets its open mode to openMode. Returns true if successful; otherwise returns false.
Definition at line 173 of file ZFile.cpp.
Referenced by Zbl::ZTableFile::validateWatcher().
|
static |
Registers ZFile as a QML type.
Definition at line 76 of file ZFile.cpp.
Referenced by Zbl::Zblcore::registerTypes().
void Zbl::ZFile::release | ( | ) |
Releases references from this object to wrapped Qt C++ objects.
The C++ objects may be deleted by this function if no other Javascript objects reference them at the time this method is called.
WARNING: The ZFile object can't be used again once this function is called.
bool Zbl::ZFile::remove | ( | ) |
bool Zbl::ZFile::rename | ( | const QString & | newName | ) |
|
signal |
|
inlineprotected |
Ensures the embedded QFile object has been initialized by throwing an exception if not.
Definition at line 373 of file ZFile.h.
Referenced by copy(), exists(), open(), remove(), rename(), validateReadable(), validateReadDataSuccess(), and validateWritable().
|
inlineprotected |
Ensures the embedded QFile object is readable by throwing an exception if not.
Definition at line 383 of file ZFile.h.
Referenced by jGetData(), jReadDataAll(), zReadData(), zReadDataAll(), and zReadDataLine().
|
inlineprotected |
Throws an exception if both the supplied QByteArray object is empty and an error condition exists on the embedded QFile object, or if the embedded QFile object is not initialized.
ba | The byte array to check for empty |
Definition at line 401 of file ZFile.h.
Referenced by zReadData(), zReadDataAll(), and zReadDataLine().
|
inlineprotected |
Ensures the embedded QFile object is writable by throwing an exception if not.
Definition at line 392 of file ZFile.h.
Referenced by jWriteData(), and zWriteData().
QObject * Zbl::ZFile::zDataStream | ( | ) |
Returns a Zbl::ZDataStream object that can be used to stream binary data to or from the device.
QObject * Zbl::ZFile::zReadData | ( | int | maxSize | ) |
Reads up to maxSize bytes or up to end of data, whichever comes first, into a ZByteArray.
QObject * Zbl::ZFile::zReadDataAll | ( | ) |
Reads up to the end of data into a ZByteArray.
QObject * Zbl::ZFile::zReadDataLine | ( | int | maxSize | ) |
Reads up to the next new line or up to maxSize bytes or up to end of data, whichever comes first, into a ZByteArray.
QObject * Zbl::ZFile::zTextStream | ( | ) |
Returns a Zbl::ZTextStream object that can be used to stream text to or from the device.
bool Zbl::ZFile::zWriteData | ( | const ZByteArray & | data | ) |
Write the contents of a ZByteArray to the device.
|
protected |
Smart pointer to the embedded QFile object.
Definition at line 347 of file ZFile.h.
Referenced by close(), copy(), exists(), getFileName(), getQDevice(), jGetData(), jReadDataAll(), jWriteData(), open(), release(), remove(), rename(), validateFile(), validateReadable(), validateReadDataSuccess(), validateWritable(), zDataStream(), zReadData(), zReadDataAll(), zReadDataLine(), zTextStream(), and zWriteData().
|
staticprotected |
A QVariantMap used to pass QFile enumeration values to Javascript programs.
Definition at line 359 of file ZFile.h.
Referenced by createTags(), and getTags().
|
protected |
Pointer to QioDevice interface object.
Definition at line 352 of file ZFile.h.
Referenced by getJsDevice(), and initZioDevice().
|
read |
|
readwrite |
The name of the file.
The name can have no path, a relative path, or an absolute path. Do not assign a file name if the file has already been opened.
If the file name has no path or a relative path, the path used will be the application's current directory path at the time of the open() call.
Definition at line 100 of file ZFile.h.
Referenced by getFileName().
|
read |
Zuble documentation copyright © 2019 Bob Dinitto. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Zuble is a derivative work of Qt version 5. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.