PpsAttribute

Since: BlackBerry 10.0.0

#include <bb/PpsAttribute>

To link against this class, add the following line to your .pro file: LIBS += -lbb

The PpsAttribute class encapsulates a PPS attribute.

Example:
 bb::PpsObject ppsObject("/pps/somepath");
 ppsObject.open(bb::PpsOpenMode::Subscribe);
 QByteArray rawData = ppsObject.read();
 QMap<QString, bb::PpsAttribute> ppsData = bb::PpsObject::decodeWithFlags(rawData);
 bb::PpsAttribute rootObject = ppsData.value("@somepath");
 ...


Overview

Public Types Index

enum Type

None 0, Number 1, Bool 2, String 3, Array 4, Object 5

Public Functions Index

PpsAttribute ()
PpsAttribute (const PpsAttribute &other)
~PpsAttribute ()
PpsAttributeFlag::Typesflags () const
boolisArray () const
boolisBool () const
boolisNumber () const
boolisObject () const
boolisString () const
boolisValid () const
booloperator!= (const PpsAttribute &other) const
PpsAttribute &operator= (const PpsAttribute &other)
booloperator== (const PpsAttribute &other) const
booltoBool () const
doubletoDouble () const
inttoInt () const
QList< PpsAttribute >toList () const
qlonglongtoLongLong () const
QMap< QString, PpsAttribute >toMap () const
QStringtoString () const
QVarianttoVariant () const
Typetype () const

Public Types

Type

Attribute encoding types.

Since:

BlackBerry 10.0.0

None 0

The attribute has no type because the PpsAttribute is invalid.

Number 1

The attribute was encoded as a number (e.g., "attr:n:10").

Since:

BlackBerry 10.0.0

Bool 2

The attribute was encoded as a Boolean (e.g., "attr:b:false").

Since:

BlackBerry 10.0.0

String 3

The attribute was encoded as a string (e.g., "attr::value").

Since:

BlackBerry 10.0.0

Array 4

The attribute was encoded as a JSON array (e.g., "attr:json:[10, 20]").

Since:

BlackBerry 10.0.0

Object 5

The attribute was encoded as a PPS or JSON object (e.g., "attr:json: { "key":10 }").

This type is also used if the flags for this attribute include bb::PpsAttributeFlag::Deleted, since the actual type of a deleted attribute cannot be determined. The map associated with the attribute will be empty.

Since:

BlackBerry 10.0.0

Public Functions

PpsAttribute ()

Creates an invalid PpsAttribute.

Since:

BlackBerry 10.0.0

PpsAttribute (

Copy constructor.

Creates a copy of a PpsAttribute.

Parameters
other

The PpsAttribute to copy.

Since:

BlackBerry 10.0.0

~PpsAttribute ()

Destructor.

Since:

BlackBerry 10.0.0

PpsAttributeFlag::Types flags ()

Gets the PPS attribute's flags.

See also:

PpsAttributeFlag

If the returned flags include bb::PpsAttributeFlag::Deleted, the type for this attribute will always be bb::PpsAttribute::Object with an empty map, since the actual type of the deleted attribute cannot be determined.
Return:

The PPS attribute's flags.

Since:

BlackBerry 10.0.0

bool isArray ()

Checks whether this PPS attribute is type bb::PpsAttribute::Array.

Return:

true if type() is bb::PpsAttribute::Array, false otherwise.

Since:

BlackBerry 10.0.0

bool isBool ()

Checks whether this PPS attribute is type bb::PpsAttribute::Bool.

Return:

true if type() is bb::PpsAttribute::Bool, false otherwise.

Since:

BlackBerry 10.0.0

bool isNumber ()

Checks whether this PPS attribute is type Number.

Return:

true if type() is Number, false otherwise.

Since:

BlackBerry 10.0.0

bool isObject ()

Checks whether this PPS attribute is type bb::PpsAttribute::Object.

Return:

true if type() is bb::PpsAttribute::Object, false otherwise.

Since:

BlackBerry 10.0.0

bool isString ()

Checks whether this PPS attribute is type bb::PpsAttribute::String.

Return:

true if type() is bb::PpsAttribute::String, false otherwise.

Since:

BlackBerry 10.0.0

bool isValid ()

Whether this PpsAttribute object contains valid information about a PPS attribute.

Return:

true if this PpsAttribute object contains valid information about a PPS attribute; false otherwise.

Since:

BlackBerry 10.0.0

bool operator!= (

Inequality operator.

Attributes of different types are not equal. For example, Number/10.0 and String/10.0 are not equal.

Parameters
other

The PpsAttribute to compare to.

Return:

true if other has a different type(), flags(), or value; false otherwise.

Since:

BlackBerry 10.0.0

PpsAttribute & operator= (

Assignment operator.

Assigns a copy of a PpsAttribute.

Parameters
other

The source PpsAttribute.

Return:

The PpsAttribute instance.

Since:

BlackBerry 10.0.0

bool operator== (

Equality operator.

Attributes of different types are not equal. For example, Number/10.0 and String/10.0 are not equal.

Parameters
other

The PpsAttribute to compare to.

Return:

true if the other has the same type(), flags(), and value; false otherwise.

Since:

BlackBerry 10.0.0

bool toBool ()

Gets the value of this attribute as a bool.

If type() is bb::PpsAttribute::Bool, then this will return the Boolean value as a bool.

If type() is bb::PpsAttribute::Number or bb::PpsAttribute::String, this will convert the raw value to a bool using QVariant.toBool().

Return:

The value of the PPS attribute as a bool if the value can be represented as a bool, false otherwise.

Since:

BlackBerry 10.0.0

double toDouble ()

Gets the value of this attribute as a double.

If type() is bb::PpsAttribute::Number, then this will return the number value as a double.

If type() is bb::PpsAttribute::Bool or bb::PpsAttribute::String, this will convert the raw value to a double using QVariant.toDouble().

Return:

The value of the PPS attribute as a double if the value can be represented as a double, 0 otherwise.

Since:

BlackBerry 10.0.0

int toInt ()

Gets the value of this attribute as an int.

If type() is bb::PpsAttribute::Number, then this will return the number value as an int.

If type() is bb::PpsAttribute::Bool or bb::PpsAttribute::String, this will convert the raw value to an int using QVariant.toInt().

Return:

The value of the PPS attribute as an int if the value can be represented as an int, 0 otherwise.

Since:

BlackBerry 10.0.0

QList< PpsAttribute > toList ()

Gets the value of this attribute as a QList.

Return:

The value of the PPS attribute as a QList if type() is bb::PpsAttribute::Array, a default-constructed QList<PpsAttribute> otherwise.

Since:

BlackBerry 10.0.0

qlonglong toLongLong ()

Gets the value of this attribute as a qlonglong.

If type() is bb::PpsAttribute::Number, then this will return the number value as a qlonglong.

If type() is bb::PpsAttribute::Bool or bb::PpsAttribute::String, this will convert the raw value to a qlonglong using QVariant.toLongLong().

Return:

The value of the PPS attribute as a qlongong if the value can be represented as a qlongong, 0 otherwise.

Since:

BlackBerry 10.0.0

QMap< QString, PpsAttribute > toMap ()

Gets the value of this attribute as a QMap.

Return:

The value of the PPS attribute as a QMap if type() is bb::PpsAttribute::Object, a default-constructed QMap<QString, PpsAttribute> otherwise.

Since:

BlackBerry 10.0.0

QString toString ()

Gets the value of this attribute as a QString.

If type() is bb::PpsAttribute::String, then this will return the string value as a QString.

If type() is bb::PpsAttribute::Bool or bb::PpsAttribute::Number, this will convert the raw value to a QString using QVariant.toString().

Return:

The value of the PPS attribute as a QString if the value can be represented as a QString, a default-constructed QString otherwise.

Since:

BlackBerry 10.0.0

QVariant toVariant ()

Gets the value of this attribute as a QVariant.

Return:

The value of the PPS attribute as a QVariant.

Since:

BlackBerry 10.0.0

Type type ()

Gets the type of the PPS attribute.

Return:

The type of the PPS attribute.

Since:

BlackBerry 10.0.0

Last modified: 2014-09-30



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus