#include <properties.h>
Inheritance diagram for Geddei::Properties:
Public Member Functions | |
const QVariant & | get (const QString &key) const |
const QStringList | keys () const |
Properties & | operator() (const QString &key, const QVariant &value) |
QVariant & | operator[] (const QString &key) |
const QVariant & | operator[] (const QString &key) const |
Properties (const PropertiesInfo &info) | |
Properties () | |
Properties (const QString &key, const QVariant &value) | |
void | set (const Properties &pairs) |
void | set (const QString &key, const QVariant value) |
const uint | size () const |
Friends | |
class | ::NodeServerSession |
class | DRCoupling |
class | rGeddei::RemoteSession |
class | RSCoupling |
Properties is a simple class to store a set of name-value pairs. The values are allowed to be of any valid Qt type.
The only real "magic" is its cool convenience construction method from a string.
Geddei::Properties::Properties | ( | const QString & | key, | |
const QVariant & | value | |||
) | [inline] |
Constructor for initialising a Properties object with one key/value pair in it.
key | The key of the key/value pair that will be in the object. | |
value | The value of the key/value pair that will be in the object. |
Geddei::Properties::Properties | ( | ) | [inline] |
Basic constructor. Creates an empty Properties object.
const QVariant& Geddei::Properties::get | ( | const QString & | key | ) | const [inline] |
Retrieve a value from the mapping.
Example, assuming P is an already populated Properties object:
QString s = P.get("stringKey").toString(); int i = P.get("intKey").toInt();
key | The key whose value is to be retrieved. |
Properties& Geddei::Properties::operator() | ( | const QString & | key, | |
const QVariant & | value | |||
) | [inline] |
Operator to add a key value pair to an existing Properties object.
Typical use would be with a constructor:
Properties p = Properties("a", 1)("b", 2)("c", 3);
It may be used similarly inline when calling methods with Properties arguments:
someObject.someMethod(Properties("a", 1)("b", 2)("c", 3));
key | The key of the pair to be added. | |
value | The value of the pair to be added. |
QVariant& Geddei::Properties::operator[] | ( | const QString & | key | ) | [inline] |
Subscript operator giving full access to the mapping. This can be used for writing to the mapping.
Example; both lines are semanticly equivalent:
P.set("stringKey", "Boo!"); P["stringKey"] = "Boo!";
key | The key of the value to be retrieved. |
const QVariant& Geddei::Properties::operator[] | ( | const QString & | key | ) | const [inline] |
void Geddei::Properties::set | ( | const QString & | key, | |
const QVariant | value | |||
) | [inline] |
Set a value in the mapping.
Example:
Properties P; QString s = P.set("stringKey", "Hello world"); int i = P.get("intKey", 69);
key | The key of the value to be set. | |
value | The value intended for key key . |