# class Variant

###

Module | nepomuk
Namespace | Nepomuk
Class | Variant
Inherits |

\class Variant variant.h Nepomuk/Variant

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>

### methods

- Variant ( )

  returns ctor

- Variant (other)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  other | Nepomuk.Variant |

- Variant (other)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  other | QVariant |

  Will create an invalid Variant if other has an unsupported type.

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | int |

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | qlonglong |

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | uint |

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | qulonglong |

- Variant (b)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  b | bool |

- Variant (d)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  d | double |

- Variant (string)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  string | char |

- Variant (string)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  string | QString |

- Variant (date)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  date | QDate |

- Variant (time)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  time | QTime |

- Variant (datetime)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  datetime | QDateTime |

- Variant (url)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  url | QUrl |

- Variant (r)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  r | Nepomuk.Resource |

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | QList<int> |

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | QList<qlonglong> |

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | QList<uint> |

- Variant (i)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  i | QList<qulonglong> |

- Variant (b)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  b | QList<bool> |

- Variant (d)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  d | QList<double> |

- Variant (stringlist)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  stringlist | QStringList |

- Variant (date)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  date | QList<QDate> |

- Variant (time)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  time | QList<QTime> |

- Variant (datetime)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  datetime | QList<QDateTime> |

- Variant (url)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  url | QList<QUrl> |

- Variant (r)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  r | QList<Nepomuk::Resource> |

- append (i)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  i | int |

  Append i to this variant. If the variant already contains an int it will be converted to a list of int.

- append (i)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  i | qlonglong |

- append (i)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  i | uint |

- append (i)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  i | qulonglong |

- append (b)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  b | bool |

- append (d)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  d | double |

- append (string)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  string | QString |

- append (date)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  date | QDate |

- append (time)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  time | QTime |

- append (datetime)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  datetime | QDateTime |

- append (url)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | QUrl |

- append (r)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  r | Nepomuk.Resource |

- append (v)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  v | Nepomuk.Variant |

  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()

- fromString (value, type)

  returns Nepomuk.Variant
  static

  Argument | Type | Default
  --- | --- | ---
  value | QString |
  type | int |

  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.

- isBool ( )

  returns bool

- isBoolList ( )

  returns bool

- isDate ( )

  returns bool

- isDateList ( )

  returns bool

- isDateTime ( )

  returns bool

- isDateTimeList ( )

  returns bool

- isDouble ( )

  returns bool

- isDoubleList ( )

  returns bool

- isInt ( )

  returns bool

- isInt64 ( )

  returns bool

- isInt64List ( )

  returns bool

- isIntList ( )

  returns bool

- isList ( )

  returns bool

  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)

- isResource ( )

  returns bool

- isResourceList ( )

  returns bool

- isString ( )

  returns bool

- isStringList ( )

  returns bool

- isTime ( )

  returns bool

- isTimeList ( )

  returns bool

- isUnsignedInt ( )

  returns bool

- isUnsignedInt64 ( )

  returns bool

- isUnsignedInt64List ( )

  returns bool

- isUnsignedIntList ( )

  returns bool

- isUrl ( )

  returns bool

- isUrlList ( )

  returns bool

- isValid ( )

  returns bool

- operator != (other)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  other | Nepomuk.Variant |

  Inverse of operator==

- operator == (other)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  other | Nepomuk.Variant |

  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".

- simpleType ( )

  returns int

  Returns the type of the simple value, i.e. with the list stripped.

- toBool ( )

  returns bool

- toBoolList ( )

  returns QList<bool>

- toDate ( )

  returns QDate

- toDateList ( )

  returns QList<QDate>

- toDateTime ( )

  returns QDateTime

- toDateTimeList ( )

  returns QList<QDateTime>

- toDouble ( )

  returns double

- toDoubleList ( )

  returns QList<double>

- toInt ( )

  returns int

- toInt64 ( )

  returns qlonglong

- toInt64List ( )

  returns QList<qlonglong>

- toIntList ( )

  returns QList<int>

- toResource ( )

  returns Nepomuk.Resource

- toResourceList ( )

  returns QList<Nepomuk::Resource>

- toString ( )

  returns QString

  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.

- toStringList ( )

  returns QStringList

  Just like the toString method toStringList is able to convert all supported types into a list of strings.

- toTime ( )

  returns QTime

- toTimeList ( )

  returns QList<QTime>

- toUnsignedInt ( )

  returns uint

- toUnsignedInt64 ( )

  returns qulonglong

- toUnsignedInt64List ( )

  returns QList<qulonglong>

- toUnsignedIntList ( )

  returns QList<uint>

- toUrl ( )

  returns QUrl

- toUrlList ( )

  returns QList<QUrl>

- type ( )

  returns int

  Returns the QT Meta type id of the type

- variant ( )

  returns QVariant