PpsObject
#include <bb/PpsObject>
To link against this class, add the following line to your .pro file: LIBS += -lbb
Encapsulates an object in the PPS file system.
See the PPS documentation for more details.
BlackBerry 10.0.0
Public Functions Index
| PpsObject (const QString &path, QObject *parent=0) | |
| virtual | ~PpsObject () |
| int | error () const |
| QString | errorString () const |
| bool | isReadyReadEnabled () const |
| bool | isBlocking () const |
| bool | setBlocking (bool enable) |
| bool | isOpen () const |
| bool | open (PpsOpenMode::Types mode=PpsOpenMode::PublishSubscribe) |
| bool | close () |
| QByteArray | read (bool *ok=0) |
| bool | write (const QByteArray &byteArray) |
| bool | remove () |
Static Public Functions Index
| QVariantMap | decode (const QByteArray &rawData, bool *ok=0) |
| QMap< QString, PpsAttribute > | decodeWithFlags (const QByteArray &rawData, bool *ok=0) |
| QByteArray | encode (const QVariantMap &ppsData, bool *ok=0) |
Public Slots Index
| void | setReadyReadEnabled (bool enable) |
Signals Index
| void | readyRead () |
Public Functions
Creates a new PpsObject that manages the specified object in the PPS file systems.
Open options may be specified as a suffix to the path, following a question mark ("?"). See the PPS documentation for more details.
Note the PPS object must be opened via a separate call to open() before data can be read or written.
| Parameters | |
|---|---|
| path |
File system path of the PPS object to encapsulate. |
| parent |
If not 0, the supplied parent will be responsible for deleting this instance. |
BlackBerry 10.0.0
virtual
Destructor.
BlackBerry 10.0.0
int
Returns the POSIX error code for the last API called on this object.
EOK if the last API call succeeded or the POSIX error code (from errno.h) if the last API call failed.
BlackBerry 10.0.0
QString
Returns a human-readable description of the POSIX error code for the last API called on this object.
The value returned by strerror() (from string.h) for error().
BlackBerry 10.0.0
bool
Determine if the readyRead() signal will fire when data is available.
Checks if the readyRead() signal will fire when the PPS object has data available for reading. The readyRead() signal is enabled by default.
A flag indicating if the readyRead() signal is active.
BlackBerry 10.0.0
bool
Checks if the PPS object is in blocking or non-blocking mode.
In blocking mode, calling read() and write() will block until data can be read or written. In non-blocking, read() and write() will fail (error() returns EAGAIN) if data cannot be read or written immediately.
PPS objects are by default opened in non-blocking mode. Appending "?wait" to the file system path defaults to blocking mode.
Note the PPS object must be open to use this method. Otherwise, this method returns false and error() returns EBADF.
A flag indicating if the PPS object uses blocking or non-blocking I/O.
BlackBerry 10.0.0
bool
Toggles blocking or non-blocking I/O for the PPS object.
In blocking mode, calling read() and write() will block until data can be read or written. In non-blocking, read() and write() will fail (error() returns EAGAIN) if data cannot be read or written immediately.
PPS objects are by default opened in non-blocking mode. Appending "?wait" to the file system path defaults to blocking mode.
| Parameters | |
|---|---|
| enable |
A flag indicating if the PPS object should use blocking or non-blocking I/O. |
A flag indicating the success of the operation. On failure, call error() to identify the cause.
The PPS object must be open to use this method. Otherwise, this method returns false and error() returns EBADF.
BlackBerry 10.0.0
bool
Checks if the PPS object is currently open.
A flag indicating if the PPS object is open or not.
BlackBerry 10.0.0
bool
Opens the PPS object in the specified mode.
See PpsOpenMode for more details.
| Parameters | |
|---|---|
| mode |
A bitfield of PpsOpenMode flag values. |
A flag indicating the success of the operation. On failure, call error() to identify the cause.
The PPS object must be closed to used this method. Otherwise, this method returns false and error() returns EBUSY.
BlackBerry 10.0.0
bool
Closes the previously opened PPS object.
QByteArray
Reads the current content of PPS object.
If no data is available to read and the PPS object is in blocking mode, then this method will block until data is available for reading. If no data is available to read and the PPS object is in non-blocking mode, then this method will fail and error() returns EAGAIN. Use the readyRead() signal to know when data is available for reading.
| Parameters | |
|---|---|
| ok |
If not 0: *ok is set to true if the read succeeded; otherwise *ok is set to false. On failure, call error() to identify the cause. |
A buffer containing the data read from the PPS object.
BlackBerry 10.0.0
bool
Writes all the data in the provided buffer to the PPS object.
The size of the buffer is determined by calling QByteArray::size().
If no data can be written and the PPS object is in blocking mode, then this method will block until the PPS object becomes writable. If no data can be written and the PPS object is in non-blocking mode, then this method will fail and error() returns EAGAIN.
| Parameters | |
|---|---|
| byteArray |
The buffer the contains the data to write to the PPS object. |
true if the write succeeded, false otherwise. On failure, call error() to identify the cause.
BlackBerry 10.0.0
Static Public Functions
QVariantMap
Read PPS data into a QVariantMap.
number - Decoded to a double. 'doubleVal:n:10.5' is accessed as 'double val = ppsData.value("doubleVal").toDouble();'
boolean - Decoded to a bool. 'boolVal:b:true' is accessed as 'bool val = ppsData.value("boolVal").toBool();'
string - Decoded as UTF8 data to a QString. 'strVal::test' is accessed as 'QString val = ppsData.value("strVal").toString();'
json array - Decoded to a QVariantList. 'arrayVal:json:[10,20]' is accessed as 'QVariantList val = ppsData.value("arrayVal").toList();'
json object - Decoded to a QVariantMap. 'objectVal:json:{"val1":10, "val2":20}' is accessed as 'QVariantMap val = ppsData.value("objectVal").toMap();'
json null - Decoded as an invalid QVariant.
| Parameters | |
|---|---|
| rawData |
The raw PPS data. |
| ok |
If not 0: *ok is set to true if the data could be decoded; otherwise *ok is set to false. |
A QVariantMap containing the data in a hierarchical format.
BlackBerry 10.0.0
QMap< QString, PpsAttribute >
Read PPS data into a PpsAttribute map.
| Parameters | |
|---|---|
| rawData |
The raw PPS data. |
| ok |
If not 0: *ok is set to true if the data could be decoded; otherwise *ok is set to false. |
A QMap<QString,PpsAttribute> containing the data in a hierarchical format.
BlackBerry 10.0.0
QByteArray
Write PPS data from a QVariantMap.
double - Encoded as a number. 'ppsData["doubleVal"] = 10.5;' encodes as 'doubleVal:n:10.5'
int - Encoded as a number. 'ppsData["intVal"] = 10;' encodes as 'intVal:n:10'
unsigned int - Encoded as a number. 'ppsData["uintVal"] = 10u;' encodes as 'intVal:n:10'
bool - Encoded as a boolean. 'ppsData["boolVal"] = true;' encodes as 'boolVal:b:true'
QString - Encoded with as a UTF8 string, with default type. 'ppsData["strVal"] = QString("test");' encodes as 'strVal::test'
QVariantList - Encoded as a json array. 'ppsData["arrayVal"] = ( QVariantList() << 10 << 20 );' encodes as 'arrayVal:json:[10,20]'
QVariantMap - Encoded as a json object. 'QVariantMap map; map["val1"] = 10; map["val2"] = 20; ppsData["objectVal"] = map;' encodes as 'objectVal:json:{"val1":10, "val2":20}'
Invalid QVariant - Encoded as a json null. 'ppsData["nullVal"] = QVariant();' encodes as 'nullVal:json:null'
| Parameters | |
|---|---|
| ppsData |
A QVariantMap containing the data in a hierarchical format. |
| ok |
If not 0: *ok is set to true if the data could be encoded; otherwise *ok is set to false. |
A data buffer containing raw PPS data.
BlackBerry 10.0.0
Public Slots
void
Toggles whether the readyRead() signal will fire when the PPS object has data available for reading.
The readyRead() signal is enabled by default.
| Parameters | |
|---|---|
| enable |
A flag indicating if the readyRead() signal is active. |
BlackBerry 10.0.0
Signals
void
Indicates the PPS object has data available for reading.
BlackBerry 10.0.0