Nepomuk-Core
#include <Nepomuk2/Variant>
Public Member Functions | |
Variant () | |
Variant (const Variant &other) | |
Variant (const QVariant &other) | |
Variant (int i) | |
Variant (qlonglong i) | |
Variant (uint i) | |
Variant (qulonglong i) | |
Variant (bool b) | |
Variant (double d) | |
Variant (const char *string) | |
Variant (const QString &string) | |
Variant (const QDate &date) | |
Variant (const QTime &time) | |
Variant (const QDateTime &datetime) | |
Variant (const QUrl &url) | |
Variant (const Resource &r) | |
Variant (const QList< int > &i) | |
Variant (const QList< qlonglong > &i) | |
Variant (const QList< uint > &i) | |
Variant (const QList< qulonglong > &i) | |
Variant (const QList< bool > &b) | |
Variant (const QList< double > &d) | |
Variant (const QStringList &stringlist) | |
Variant (const QList< QDate > &date) | |
Variant (const QList< QTime > &time) | |
Variant (const QList< QDateTime > &datetime) | |
Variant (const QList< QUrl > &url) | |
Variant (const QList< Resource > &r) | |
Variant (const QList< Variant > &vl) | |
~Variant () | |
void | append (int i) |
void | append (qlonglong i) |
void | append (uint i) |
void | append (qulonglong i) |
void | append (bool b) |
void | append (double d) |
void | append (const QString &string) |
void | append (const QDate &date) |
void | append (const QTime &time) |
void | append (const QDateTime &datetime) |
void | append (const QUrl &url) |
void | append (const Resource &r) |
void | append (const Variant &v) |
bool | isBool () const |
bool | isBoolList () const |
bool | isDate () const |
bool | isDateList () const |
bool | isDateTime () const |
bool | isDateTimeList () const |
bool | isDouble () const |
bool | isDoubleList () const |
bool | isInt () const |
bool | isInt64 () const |
bool | isInt64List () const |
bool | isIntList () const |
bool | isList () const |
bool | isResource () const |
bool | isResourceList () const |
bool | isString () const |
bool | isStringList () const |
bool | isTime () const |
bool | isTimeList () const |
bool | isUnsignedInt () const |
bool | isUnsignedInt64 () const |
bool | isUnsignedInt64List () const |
bool | isUnsignedIntList () const |
bool | isUrl () const |
bool | isUrlList () const |
bool | isValid () const |
bool | operator!= (const Variant &other) const |
Variant & | operator= (const Variant &) |
Variant & | operator= (int i) |
Variant & | operator= (qlonglong i) |
Variant & | operator= (uint i) |
Variant & | operator= (qulonglong i) |
Variant & | operator= (bool b) |
Variant & | operator= (double d) |
Variant & | operator= (const QString &string) |
Variant & | operator= (const QDate &date) |
Variant & | operator= (const QTime &time) |
Variant & | operator= (const QDateTime &datetime) |
Variant & | operator= (const QUrl &url) |
Variant & | operator= (const Resource &r) |
Variant & | operator= (const QList< int > &i) |
Variant & | operator= (const QList< qlonglong > &i) |
Variant & | operator= (const QList< uint > &i) |
Variant & | operator= (const QList< qulonglong > &i) |
Variant & | operator= (const QList< bool > &b) |
Variant & | operator= (const QList< double > &d) |
Variant & | operator= (const QStringList &stringlist) |
Variant & | operator= (const QList< QDate > &date) |
Variant & | operator= (const QList< QTime > &time) |
Variant & | operator= (const QList< QDateTime > &datetime) |
Variant & | operator= (const QList< QUrl > &url) |
Variant & | operator= (const QList< Resource > &r) |
bool | operator== (const Variant &other) const |
int | simpleType () const |
bool | toBool () const |
QList< bool > | toBoolList () const |
QDate | toDate () const |
QList< QDate > | toDateList () const |
QDateTime | toDateTime () const |
QList< QDateTime > | toDateTimeList () const |
double | toDouble () const |
QList< double > | toDoubleList () const |
int | toInt () const |
qlonglong | toInt64 () const |
QList< qlonglong > | toInt64List () const |
QList< int > | toIntList () const |
Soprano::Node | toNode () const |
QList< Soprano::Node > | toNodeList () const |
Resource | toResource () const |
QList< Resource > | toResourceList () const |
QString | toString () const |
QStringList | toStringList () const |
QTime | toTime () const |
QList< QTime > | toTimeList () const |
uint | toUnsignedInt () const |
qulonglong | toUnsignedInt64 () const |
QList< qulonglong > | toUnsignedInt64List () const |
QList< uint > | toUnsignedIntList () const |
QUrl | toUrl () const |
QList< QUrl > | toUrlList () const |
QList< Variant > | toVariantList () const |
int | type () const |
QVariant | variant () const |
Static Public Member Functions | |
static Variant | fromNode (const Soprano::Node &node) |
static Variant | fromNodeList (const QList< Soprano::Node > &node) |
static Variant | fromString (const QString &value, int type) |
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.
- Variant comes with direct support for Resource. There is one special thing about QUrl Variants though: for both isUrl() and isResource() return
true
. However, toUrl() will return different values for Resource and for QUrl Variants: in the former case the actual Resource::resourceUri() is returned which can be different in case of file:/ URLs.
Constructor & Destructor Documentation
Nepomuk2::Variant::Variant | ( | ) |
Definition at line 51 of file variant.cpp.
Nepomuk2::Variant::~Variant | ( | ) |
Definition at line 57 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const Variant & | other | ) |
Definition at line 63 of file variant.cpp.
|
explicit |
Will create an invalid Variant if other has an unsupported type.
Definition at line 70 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | int | i | ) |
Definition at line 102 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | qlonglong | i | ) |
Definition at line 109 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | uint | i | ) |
Definition at line 116 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | qulonglong | i | ) |
Definition at line 123 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | bool | b | ) |
Definition at line 130 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | double | d | ) |
Definition at line 137 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const char * | string | ) |
Definition at line 144 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QString & | string | ) |
Definition at line 151 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QDate & | date | ) |
Definition at line 158 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QTime & | time | ) |
Definition at line 165 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QDateTime & | datetime | ) |
Definition at line 172 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QUrl & | url | ) |
Definition at line 179 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const Resource & | r | ) |
Definition at line 186 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< int > & | i | ) |
Definition at line 193 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< qlonglong > & | i | ) |
Definition at line 200 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< uint > & | i | ) |
Definition at line 207 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< qulonglong > & | i | ) |
Definition at line 214 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< bool > & | b | ) |
Definition at line 221 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< double > & | d | ) |
Definition at line 228 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QStringList & | stringlist | ) |
Definition at line 235 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< QDate > & | date | ) |
Definition at line 242 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< QTime > & | time | ) |
Definition at line 249 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< QDateTime > & | datetime | ) |
Definition at line 256 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< QUrl > & | url | ) |
Definition at line 263 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< Resource > & | r | ) |
Definition at line 271 of file variant.cpp.
Nepomuk2::Variant::Variant | ( | const QList< Variant > & | vl | ) |
Member Function Documentation
void Nepomuk2::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.
Definition at line 462 of file variant.cpp.
void Nepomuk2::Variant::append | ( | qlonglong | i | ) |
Definition at line 470 of file variant.cpp.
void Nepomuk2::Variant::append | ( | uint | i | ) |
Definition at line 478 of file variant.cpp.
void Nepomuk2::Variant::append | ( | qulonglong | i | ) |
Definition at line 486 of file variant.cpp.
void Nepomuk2::Variant::append | ( | bool | b | ) |
Definition at line 494 of file variant.cpp.
void Nepomuk2::Variant::append | ( | double | d | ) |
Definition at line 502 of file variant.cpp.
void Nepomuk2::Variant::append | ( | const QString & | string | ) |
Definition at line 510 of file variant.cpp.
void Nepomuk2::Variant::append | ( | const QDate & | date | ) |
Definition at line 518 of file variant.cpp.
void Nepomuk2::Variant::append | ( | const QTime & | time | ) |
Definition at line 526 of file variant.cpp.
void Nepomuk2::Variant::append | ( | const QDateTime & | datetime | ) |
Definition at line 534 of file variant.cpp.
void Nepomuk2::Variant::append | ( | const QUrl & | url | ) |
Definition at line 542 of file variant.cpp.
void Nepomuk2::Variant::append | ( | const Resource & | r | ) |
Definition at line 550 of file variant.cpp.
void Nepomuk2::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()
Definition at line 560 of file variant.cpp.
|
static |
|
static |
Create a Variant object from a list of Soprano::Node.
- Since
- 4.6
Definition at line 1384 of file variant.cpp.
|
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.
Definition at line 1346 of file variant.cpp.
bool Nepomuk2::Variant::isBool | ( | ) | const |
Definition at line 632 of file variant.cpp.
bool Nepomuk2::Variant::isBoolList | ( | ) | const |
Definition at line 705 of file variant.cpp.
bool Nepomuk2::Variant::isDate | ( | ) | const |
Definition at line 650 of file variant.cpp.
bool Nepomuk2::Variant::isDateList | ( | ) | const |
Definition at line 723 of file variant.cpp.
bool Nepomuk2::Variant::isDateTime | ( | ) | const |
Definition at line 662 of file variant.cpp.
bool Nepomuk2::Variant::isDateTimeList | ( | ) | const |
Definition at line 735 of file variant.cpp.
bool Nepomuk2::Variant::isDouble | ( | ) | const |
Definition at line 638 of file variant.cpp.
bool Nepomuk2::Variant::isDoubleList | ( | ) | const |
Definition at line 711 of file variant.cpp.
bool Nepomuk2::Variant::isInt | ( | ) | const |
Definition at line 608 of file variant.cpp.
bool Nepomuk2::Variant::isInt64 | ( | ) | const |
Definition at line 614 of file variant.cpp.
bool Nepomuk2::Variant::isInt64List | ( | ) | const |
Definition at line 693 of file variant.cpp.
bool Nepomuk2::Variant::isIntList | ( | ) | const |
Definition at line 681 of file variant.cpp.
bool Nepomuk2::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)
Definition at line 1291 of file variant.cpp.
bool Nepomuk2::Variant::isResource | ( | ) | const |
Definition at line 674 of file variant.cpp.
bool Nepomuk2::Variant::isResourceList | ( | ) | const |
Definition at line 747 of file variant.cpp.
bool Nepomuk2::Variant::isString | ( | ) | const |
Definition at line 644 of file variant.cpp.
bool Nepomuk2::Variant::isStringList | ( | ) | const |
Definition at line 717 of file variant.cpp.
bool Nepomuk2::Variant::isTime | ( | ) | const |
Definition at line 656 of file variant.cpp.
bool Nepomuk2::Variant::isTimeList | ( | ) | const |
Definition at line 729 of file variant.cpp.
bool Nepomuk2::Variant::isUnsignedInt | ( | ) | const |
Definition at line 620 of file variant.cpp.
bool Nepomuk2::Variant::isUnsignedInt64 | ( | ) | const |
Definition at line 626 of file variant.cpp.
bool Nepomuk2::Variant::isUnsignedInt64List | ( | ) | const |
Definition at line 699 of file variant.cpp.
bool Nepomuk2::Variant::isUnsignedIntList | ( | ) | const |
Definition at line 687 of file variant.cpp.
bool Nepomuk2::Variant::isUrl | ( | ) | const |
Definition at line 668 of file variant.cpp.
bool Nepomuk2::Variant::isUrlList | ( | ) | const |
Definition at line 741 of file variant.cpp.
bool Nepomuk2::Variant::isValid | ( | ) | const |
Definition at line 1460 of file variant.cpp.
bool Nepomuk2::Variant::operator!= | ( | const Variant & | other | ) | const |
Inverse of operator==.
Definition at line 1448 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const Variant & | v | ) |
Definition at line 287 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | int | i | ) |
Definition at line 294 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | qlonglong | i | ) |
Definition at line 301 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | uint | i | ) |
Definition at line 308 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | qulonglong | i | ) |
Definition at line 315 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | bool | b | ) |
Definition at line 322 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | double | d | ) |
Definition at line 329 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QString & | string | ) |
Definition at line 336 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QDate & | date | ) |
Definition at line 343 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QTime & | time | ) |
Definition at line 350 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QDateTime & | datetime | ) |
Definition at line 357 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QUrl & | url | ) |
Definition at line 364 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const Resource & | r | ) |
Definition at line 371 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< int > & | i | ) |
Definition at line 378 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< qlonglong > & | i | ) |
Definition at line 385 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< uint > & | i | ) |
Definition at line 392 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< qulonglong > & | i | ) |
Definition at line 399 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< bool > & | b | ) |
Definition at line 406 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< double > & | d | ) |
Definition at line 413 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QStringList & | stringlist | ) |
Definition at line 420 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< QDate > & | date | ) |
Definition at line 427 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< QTime > & | time | ) |
Definition at line 434 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< QDateTime > & | datetime | ) |
Definition at line 441 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< QUrl > & | url | ) |
Definition at line 448 of file variant.cpp.
Nepomuk2::Variant & Nepomuk2::Variant::operator= | ( | const QList< Resource > & | r | ) |
Definition at line 455 of file variant.cpp.
bool Nepomuk2::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".
Definition at line 1411 of file variant.cpp.
int Nepomuk2::Variant::simpleType | ( | ) | const |
- Returns
- the type of the simple value, i.e. with the list stripped.
Definition at line 1314 of file variant.cpp.
bool Nepomuk2::Variant::toBool | ( | ) | const |
Convert into a bool value.
Will return the first value of a bool list.
Definition at line 803 of file variant.cpp.
QList< bool > Nepomuk2::Variant::toBoolList | ( | ) | const |
Definition at line 1024 of file variant.cpp.
QDate Nepomuk2::Variant::toDate | ( | ) | const |
Convert into a QDate value.
Will return the first value of a QDate list.
Definition at line 860 of file variant.cpp.
QList< QDate > Nepomuk2::Variant::toDateList | ( | ) | const |
Definition at line 1095 of file variant.cpp.
QDateTime Nepomuk2::Variant::toDateTime | ( | ) | const |
Convert into a QDateTime value.
Will return the first value of a QDateTime list.
Definition at line 882 of file variant.cpp.
QList< QDateTime > Nepomuk2::Variant::toDateTimeList | ( | ) | const |
Definition at line 1119 of file variant.cpp.
double Nepomuk2::Variant::toDouble | ( | ) | const |
Convert into a double value.
Will return the first value of a double list.
Definition at line 815 of file variant.cpp.
QList< double > Nepomuk2::Variant::toDoubleList | ( | ) | const |
Definition at line 1036 of file variant.cpp.
int Nepomuk2::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.
Definition at line 755 of file variant.cpp.
qlonglong Nepomuk2::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.
Definition at line 767 of file variant.cpp.
QList< qlonglong > Nepomuk2::Variant::toInt64List | ( | ) | const |
Definition at line 949 of file variant.cpp.
QList< int > Nepomuk2::Variant::toIntList | ( | ) | const |
Definition at line 924 of file variant.cpp.
Soprano::Node Nepomuk2::Variant::toNode | ( | ) | const |
QList< Soprano::Node > Nepomuk2::Variant::toNodeList | ( | ) | const |
Nepomuk2::Resource Nepomuk2::Variant::toResource | ( | ) | const |
Convert into a Resource value.
Will return the first value of a Resource list. Will also convert QUrl variants.
Definition at line 908 of file variant.cpp.
QList< Nepomuk2::Resource > Nepomuk2::Variant::toResourceList | ( | ) | const |
Definition at line 1152 of file variant.cpp.
QString Nepomuk2::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.
Definition at line 827 of file variant.cpp.
QStringList Nepomuk2::Variant::toStringList | ( | ) | const |
Just like the toString method toStringList is able to convert all supported types into a list of strings.
Definition at line 1059 of file variant.cpp.
QTime Nepomuk2::Variant::toTime | ( | ) | const |
Convert into a QTime value.
Will return the first value of a QTime list.
Definition at line 871 of file variant.cpp.
QList< QTime > Nepomuk2::Variant::toTimeList | ( | ) | const |
Definition at line 1107 of file variant.cpp.
uint Nepomuk2::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.
Definition at line 779 of file variant.cpp.
qulonglong Nepomuk2::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.
Definition at line 791 of file variant.cpp.
QList< qulonglong > Nepomuk2::Variant::toUnsignedInt64List | ( | ) | const |
Definition at line 999 of file variant.cpp.
QList< uint > Nepomuk2::Variant::toUnsignedIntList | ( | ) | const |
Definition at line 974 of file variant.cpp.
QUrl Nepomuk2::Variant::toUrl | ( | ) | const |
Convert into a QUrl value.
Can handle both QUrl and Resource variants. The latter will be converted into its resource URI
Will return the first value of a QUrl list.
- See also
- Resource::resourceUri
Definition at line 893 of file variant.cpp.
QList< QUrl > Nepomuk2::Variant::toUrlList | ( | ) | const |
Definition at line 1131 of file variant.cpp.
QList< Nepomuk2::Variant > Nepomuk2::Variant::toVariantList | ( | ) | const |
int Nepomuk2::Variant::type | ( | ) | const |
- Returns
- the QT Meta type id of the type
Definition at line 1308 of file variant.cpp.
QVariant Nepomuk2::Variant::variant | ( | ) | const |
Definition at line 1454 of file variant.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.