Nepomuk::Variant Class Reference
The Nepomuk Variant extends over QVariant by introducing direct support for Resource embedding, automatic list conversion and a restricted set of supported types.
More...
#include <Nepomuk/Variant>
List of all members.
Detailed Description
The Nepomuk Variant extends over QVariant by introducing direct support for Resource embedding, automatic list conversion and a restricted set of supported types.
Important differences are:
- No new types can be added other than the ones that have defined constructors and get-methods
- Variant supports automatic list generation. For example a Variant containing an int also can produce an int-list via the toIntList method.
- toString and toStringList always return a valid list and do automatic conversion from the actual type used in the Variant. Thus, if one only needs to display the value in a Variant toString and toStringList do the job.
- Author:
- Sebastian Trueg <trueg@kde.org>
Definition at line 55 of file variant.h.
Constructor & Destructor Documentation
| Nepomuk::Variant::Variant |
( |
|
) |
|
| Nepomuk::Variant::~Variant |
( |
|
) |
|
| Nepomuk::Variant::Variant |
( |
const Variant & |
other |
) |
|
| Nepomuk::Variant::Variant |
( |
const QVariant & |
other |
) |
[explicit] |
Will create an invalid Variant if other has an unsupported type.
| Nepomuk::Variant::Variant |
( |
int |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
qlonglong |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
uint |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
qulonglong |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
bool |
b |
) |
|
| Nepomuk::Variant::Variant |
( |
double |
d |
) |
|
| Nepomuk::Variant::Variant |
( |
const char * |
string |
) |
|
| Nepomuk::Variant::Variant |
( |
const QString & |
string |
) |
|
| Nepomuk::Variant::Variant |
( |
const QDate & |
date |
) |
|
| Nepomuk::Variant::Variant |
( |
const QTime & |
time |
) |
|
| Nepomuk::Variant::Variant |
( |
const QDateTime & |
datetime |
) |
|
| Nepomuk::Variant::Variant |
( |
const QUrl & |
url |
) |
|
| Nepomuk::Variant::Variant |
( |
const Resource & |
r |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< int > & |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< qlonglong > & |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< uint > & |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< qulonglong > & |
i |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< bool > & |
b |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< double > & |
d |
) |
|
| Nepomuk::Variant::Variant |
( |
const QStringList & |
stringlist |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< QDate > & |
date |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< QTime > & |
time |
) |
|
| Nepomuk::Variant::Variant |
( |
const QList< QUrl > & |
url |
) |
|
Create a new Variant from a list of Variants.
- Since:
- 4.3
Member Function Documentation
| void Nepomuk::Variant::append |
( |
const Variant & |
v |
) |
|
Appends the value stored in v to the list in this Variant.
If this Variant contains a value with the same simple type as v they are merged into a list. Otherwise this Variant will contain one list of simple type v.simpleType()
| void Nepomuk::Variant::append |
( |
const Resource & |
r |
) |
|
| void Nepomuk::Variant::append |
( |
const QUrl & |
url |
) |
|
| void Nepomuk::Variant::append |
( |
const QDateTime & |
datetime |
) |
|
| void Nepomuk::Variant::append |
( |
const QTime & |
time |
) |
|
| void Nepomuk::Variant::append |
( |
const QDate & |
date |
) |
|
| void Nepomuk::Variant::append |
( |
const QString & |
string |
) |
|
| void Nepomuk::Variant::append |
( |
double |
d |
) |
|
| void Nepomuk::Variant::append |
( |
bool |
b |
) |
|
| void Nepomuk::Variant::append |
( |
qulonglong |
i |
) |
|
| void Nepomuk::Variant::append |
( |
uint |
i |
) |
|
| void Nepomuk::Variant::append |
( |
qlonglong |
i |
) |
|
| void Nepomuk::Variant::append |
( |
int |
i |
) |
|
Append i to this variant.
If the variant already contains an int it will be converted to a list of int.
| static Variant Nepomuk::Variant::fromString |
( |
const QString & |
value, |
|
|
int |
type | |
|
) |
| | [static] |
Create a Variant object by parsing string value based on type.
If type is unknown a simple string Variant object is returned containing the plain string value.
| bool Nepomuk::Variant::isBool |
( |
|
) |
const |
| bool Nepomuk::Variant::isBoolList |
( |
|
) |
const |
| bool Nepomuk::Variant::isDate |
( |
|
) |
const |
| bool Nepomuk::Variant::isDateList |
( |
|
) |
const |
| bool Nepomuk::Variant::isDateTime |
( |
|
) |
const |
| bool Nepomuk::Variant::isDateTimeList |
( |
|
) |
const |
| bool Nepomuk::Variant::isDouble |
( |
|
) |
const |
| bool Nepomuk::Variant::isDoubleList |
( |
|
) |
const |
| bool Nepomuk::Variant::isInt |
( |
|
) |
const |
| bool Nepomuk::Variant::isInt64 |
( |
|
) |
const |
| bool Nepomuk::Variant::isInt64List |
( |
|
) |
const |
| bool Nepomuk::Variant::isIntList |
( |
|
) |
const |
| bool Nepomuk::Variant::isList |
( |
|
) |
const |
This methods does not handle all list types.
It checks the following:
- QList<Resource>
- QList<int>
- QList<double>
- QList<bool>
- QList<QDate>
- QList<QTime>
- QList<QDateTime>
- QList<QUrl>
- QList<String> (QStringList)
| bool Nepomuk::Variant::isResource |
( |
|
) |
const |
| bool Nepomuk::Variant::isResourceList |
( |
|
) |
const |
| bool Nepomuk::Variant::isString |
( |
|
) |
const |
| bool Nepomuk::Variant::isStringList |
( |
|
) |
const |
| bool Nepomuk::Variant::isTime |
( |
|
) |
const |
| bool Nepomuk::Variant::isTimeList |
( |
|
) |
const |
| bool Nepomuk::Variant::isUnsignedInt |
( |
|
) |
const |
| bool Nepomuk::Variant::isUnsignedInt64 |
( |
|
) |
const |
| bool Nepomuk::Variant::isUnsignedInt64List |
( |
|
) |
const |
| bool Nepomuk::Variant::isUnsignedIntList |
( |
|
) |
const |
| bool Nepomuk::Variant::isUrl |
( |
|
) |
const |
| bool Nepomuk::Variant::isUrlList |
( |
|
) |
const |
| bool Nepomuk::Variant::isValid |
( |
|
) |
const |
| bool Nepomuk::Variant::operator!= |
( |
const Variant & |
other |
) |
const |
| Variant& Nepomuk::Variant::operator= |
( |
const QList< double > & |
d |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
const QList< bool > & |
b |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
const QList< qulonglong > & |
i |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
const QList< uint > & |
i |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
const QList< qlonglong > & |
i |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
const QList< int > & |
i |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
const QUrl & |
url |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
double |
d |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
bool |
b |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
qulonglong |
i |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
uint |
i |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
qlonglong |
i |
) |
|
| Variant& Nepomuk::Variant::operator= |
( |
int |
i |
) |
|
| bool Nepomuk::Variant::operator== |
( |
const Variant & |
other |
) |
const |
Does compare two Variant objects.
single-valued lists are treated as the single value itself. For example a QStringList variant with one element "x" equals a QString variant with value "x".
| int Nepomuk::Variant::simpleType |
( |
|
) |
const |
- Returns:
- the type of the simple value, i.e. with the list stripped.
| bool Nepomuk::Variant::toBool |
( |
|
) |
const |
Convert into a bool value.
Will return the first value of a bool list.
| QList<bool> Nepomuk::Variant::toBoolList |
( |
|
) |
const |
| QDate Nepomuk::Variant::toDate |
( |
|
) |
const |
Convert into a QDate value.
Will return the first value of a QDate list.
| QList<QDate> Nepomuk::Variant::toDateList |
( |
|
) |
const |
| QDateTime Nepomuk::Variant::toDateTime |
( |
|
) |
const |
| double Nepomuk::Variant::toDouble |
( |
|
) |
const |
Convert into a double value.
Will return the first value of a double list.
| QList<double> Nepomuk::Variant::toDoubleList |
( |
|
) |
const |
| int Nepomuk::Variant::toInt |
( |
|
) |
const |
Convert into an int value.
Returns a valid value for all decimal types.
Will return the first value of an int list.
| qlonglong Nepomuk::Variant::toInt64 |
( |
|
) |
const |
Convert into a qlonglong value.
Returns a valid value for all decimal types.
Will return the first value of a qlonglong list.
| QList<qlonglong> Nepomuk::Variant::toInt64List |
( |
|
) |
const |
| QList<int> Nepomuk::Variant::toIntList |
( |
|
) |
const |
| Resource Nepomuk::Variant::toResource |
( |
|
) |
const |
| QString Nepomuk::Variant::toString |
( |
|
) |
const |
The toString() method is a little more powerful than other toXXX methods since it actually converts all values to string.
Thus, toString should work always (even list variants are converted to a comma-separated list)
Resources are converted to a string representation of their URI.
Just like the toString method toStringList is able to convert all supported types into a list of strings.
| QTime Nepomuk::Variant::toTime |
( |
|
) |
const |
Convert into a QTime value.
Will return the first value of a QTime list.
| QList<QTime> Nepomuk::Variant::toTimeList |
( |
|
) |
const |
| uint Nepomuk::Variant::toUnsignedInt |
( |
|
) |
const |
Convert into a uint value.
Returns a valid value for all decimal types.
Will return the first value of a uint list.
| qulonglong Nepomuk::Variant::toUnsignedInt64 |
( |
|
) |
const |
Convert into a qulonglong value.
Returns a valid value for all decimal types.
Will return the first value of a qulonglong list.
| QList<qulonglong> Nepomuk::Variant::toUnsignedInt64List |
( |
|
) |
const |
| QList<uint> Nepomuk::Variant::toUnsignedIntList |
( |
|
) |
const |
| QUrl Nepomuk::Variant::toUrl |
( |
|
) |
const |
| QList<QUrl> Nepomuk::Variant::toUrlList |
( |
|
) |
const |
Convert a Variant to a list of Variants.
- Since:
- 4.3
| int Nepomuk::Variant::type |
( |
|
) |
const |
- Returns:
- the QT Meta type id of the type
| QVariant Nepomuk::Variant::variant |
( |
|
) |
const |
The documentation for this class was generated from the following file: