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.

Since:

BlackBerry 10.0.0

Public Functions Index

PpsObject (const QString &path, QObject *parent=0)
virtual ~PpsObject ()
interror () const
QStringerrorString () const
boolisReadyReadEnabled () const
boolisBlocking () const
boolsetBlocking (bool enable)
boolisOpen () const
boolopen (PpsOpenMode::Types mode=PpsOpenMode::PublishSubscribe)
boolclose ()
QByteArrayread (bool *ok=0)
boolwrite (const QByteArray &byteArray)
boolremove ()

Static Public Functions Index

QVariantMapdecode (const QByteArray &rawData, bool *ok=0)
QMap< QString, PpsAttribute >decodeWithFlags (const QByteArray &rawData, bool *ok=0)
QByteArrayencode (const QVariantMap &ppsData, bool *ok=0)

Public Slots Index

voidsetReadyReadEnabled (bool enable)

Signals Index

voidreadyRead ()

Public Functions

PpsObject (

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.

Since:

BlackBerry 10.0.0

virtual~PpsObject ()

Destructor.

Since:

BlackBerry 10.0.0

int error ()

Returns the POSIX error code for the last API called on this object.

Return:

EOK if the last API call succeeded or the POSIX error code (from errno.h) if the last API call failed.

Since:

BlackBerry 10.0.0

QString errorString ()

Returns a human-readable description of the POSIX error code for the last API called on this object.

Return:

The value returned by strerror() (from string.h) for error().

Since:

BlackBerry 10.0.0

bool isReadyReadEnabled ()

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.

Return:

A flag indicating if the readyRead() signal is active.

Since:

BlackBerry 10.0.0

bool isBlocking ()

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.

Return:

A flag indicating if the PPS object uses blocking or non-blocking I/O.

Since:

BlackBerry 10.0.0

bool setBlocking (
  • boolenable)

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.

Return:

A flag indicating the success of the operation. On failure, call error() to identify the cause.

Note:

The PPS object must be open to use this method. Otherwise, this method returns false and error() returns EBADF.

Since:

BlackBerry 10.0.0

bool isOpen ()

Checks if the PPS object is currently open.

Return:

A flag indicating if the PPS object is open or not.

Since:

BlackBerry 10.0.0

bool open (
  • PpsOpenMode::Typesmode)

Opens the PPS object in the specified mode.

See PpsOpenMode for more details.

Parameters
mode

A bitfield of PpsOpenMode flag values.

Return:

A flag indicating the success of the operation. On failure, call error() to identify the cause.

Note:

The PPS object must be closed to used this method. Otherwise, this method returns false and error() returns EBUSY.

Since:

BlackBerry 10.0.0

bool close ()

Closes the previously opened PPS object.

Return:

A flag indicating the success of the operation. On failure, call error() to identify the cause.

Note:

The PPS object must be open to use this method. Otherwise, this method returns false and error() returns EBADF.

Since:

BlackBerry 10.0.0

QByteArray read (
  • bool *ok)

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.

Return:

A buffer containing the data read from the PPS object.

Since:

BlackBerry 10.0.0

bool write (

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.

Return:

true if the write succeeded, false otherwise. On failure, call error() to identify the cause.

Since:

BlackBerry 10.0.0

bool remove ()

Deletes the object managed by this PpsObject from the PPS file system.

Return:

A flag indicating the success of the operation. On failure, call error() to identify the cause.

Since:

BlackBerry 10.0.0

Static Public Functions

QVariantMap decode (

Read PPS data into a QVariantMap.

Attributes in the PPS file are decoded as follows:
  • 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.

Return:

A QVariantMap containing the data in a hierarchical format.

Since:

BlackBerry 10.0.0

QMap< QString, PpsAttribute > decodeWithFlags (

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.

Return:

A QMap<QString,PpsAttribute> containing the data in a hierarchical format.

Since:

BlackBerry 10.0.0

QByteArray encode (

Write PPS data from a QVariantMap.

Each QVariant value in the map is encoded based on the runtime type:
  • 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.

Return:

A data buffer containing raw PPS data.

Since:

BlackBerry 10.0.0

Public Slots

void setReadyReadEnabled (
  • boolenable)

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.

Since:

BlackBerry 10.0.0

Signals

void readyRead ()

Indicates the PPS object has data available for reading.

Since:

BlackBerry 10.0.0