Represents a literal value of an RDF Node.
More...
#include <Soprano/LiteralValue>
Represents a literal value of an RDF Node.
LiteralValue is based on QVariant to support a subset of the XML Schema types that are compatible with QT types.
The following types are supported natively including automatic type conversion. Other types are represented as strings.
Literal values can be converted from strings via fromString().
- See also
- Vocabulary::XMLSchema
- Author
- Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org
Definition at line 66 of file literalvalue.h.
◆ LiteralValue() [1/16]
Soprano::LiteralValue::LiteralValue |
( |
| ) |
|
Create an empty literal value
◆ ~LiteralValue()
Soprano::LiteralValue::~LiteralValue |
( |
| ) |
|
◆ LiteralValue() [2/16]
Soprano::LiteralValue::LiteralValue |
( |
const LiteralValue & |
other | ) |
|
◆ LiteralValue() [3/16]
Soprano::LiteralValue::LiteralValue |
( |
const QVariant & |
v | ) |
|
◆ LiteralValue() [4/16]
Soprano::LiteralValue::LiteralValue |
( |
int |
i | ) |
|
◆ LiteralValue() [5/16]
Soprano::LiteralValue::LiteralValue |
( |
qlonglong |
i | ) |
|
◆ LiteralValue() [6/16]
Soprano::LiteralValue::LiteralValue |
( |
uint |
i | ) |
|
◆ LiteralValue() [7/16]
Soprano::LiteralValue::LiteralValue |
( |
qulonglong |
i | ) |
|
◆ LiteralValue() [8/16]
Soprano::LiteralValue::LiteralValue |
( |
bool |
b | ) |
|
◆ LiteralValue() [9/16]
Soprano::LiteralValue::LiteralValue |
( |
double |
d | ) |
|
◆ LiteralValue() [10/16]
Soprano::LiteralValue::LiteralValue |
( |
const char * |
string | ) |
|
◆ LiteralValue() [11/16]
Soprano::LiteralValue::LiteralValue |
( |
const QLatin1String & |
string | ) |
|
◆ LiteralValue() [12/16]
Soprano::LiteralValue::LiteralValue |
( |
const QString & |
string | ) |
|
◆ LiteralValue() [13/16]
Soprano::LiteralValue::LiteralValue |
( |
const QDate & |
date | ) |
|
◆ LiteralValue() [14/16]
Soprano::LiteralValue::LiteralValue |
( |
const QTime & |
time | ) |
|
◆ LiteralValue() [15/16]
Soprano::LiteralValue::LiteralValue |
( |
const QDateTime & |
datetime | ) |
|
◆ LiteralValue() [16/16]
Soprano::LiteralValue::LiteralValue |
( |
const QByteArray & |
data | ) |
|
◆ operator=() [1/13]
◆ operator=() [2/13]
◆ operator=() [3/13]
LiteralValue & Soprano::LiteralValue::operator= |
( |
qlonglong |
i | ) |
|
◆ operator=() [4/13]
◆ operator=() [5/13]
LiteralValue & Soprano::LiteralValue::operator= |
( |
qulonglong |
i | ) |
|
◆ operator=() [6/13]
◆ operator=() [7/13]
◆ operator=() [8/13]
◆ operator=() [9/13]
◆ operator=() [10/13]
◆ operator=() [11/13]
◆ operator=() [12/13]
◆ operator=() [13/13]
◆ operator==()
bool Soprano::LiteralValue::operator== |
( |
const LiteralValue & |
other | ) |
const |
◆ operator!=()
bool Soprano::LiteralValue::operator!= |
( |
const LiteralValue & |
other | ) |
const |
◆ isValid()
bool Soprano::LiteralValue::isValid |
( |
| ) |
const |
◆ isPlain()
bool Soprano::LiteralValue::isPlain |
( |
| ) |
const |
Determines if this literal value is a plain literal. Plain literals have no data type, but may have an optional language tag.
- Returns
true
if this literal is plain
◆ isInt()
bool Soprano::LiteralValue::isInt |
( |
| ) |
const |
◆ isInt64()
bool Soprano::LiteralValue::isInt64 |
( |
| ) |
const |
◆ isUnsignedInt()
bool Soprano::LiteralValue::isUnsignedInt |
( |
| ) |
const |
◆ isUnsignedInt64()
bool Soprano::LiteralValue::isUnsignedInt64 |
( |
| ) |
const |
◆ isBool()
bool Soprano::LiteralValue::isBool |
( |
| ) |
const |
◆ isDouble()
bool Soprano::LiteralValue::isDouble |
( |
| ) |
const |
◆ isString()
bool Soprano::LiteralValue::isString |
( |
| ) |
const |
Check if the literal contains a string value. Be aware that unknown literal types are also treated as strings. In that case compare dataTypeUrl.
◆ isDate()
bool Soprano::LiteralValue::isDate |
( |
| ) |
const |
◆ isTime()
bool Soprano::LiteralValue::isTime |
( |
| ) |
const |
◆ isDateTime()
bool Soprano::LiteralValue::isDateTime |
( |
| ) |
const |
◆ isByteArray()
bool Soprano::LiteralValue::isByteArray |
( |
| ) |
const |
◆ toInt()
int Soprano::LiteralValue::toInt |
( |
| ) |
const |
◆ toInt64()
qlonglong Soprano::LiteralValue::toInt64 |
( |
| ) |
const |
◆ toUnsignedInt()
uint Soprano::LiteralValue::toUnsignedInt |
( |
| ) |
const |
◆ toUnsignedInt64()
qulonglong Soprano::LiteralValue::toUnsignedInt64 |
( |
| ) |
const |
◆ toBool()
bool Soprano::LiteralValue::toBool |
( |
| ) |
const |
◆ toDouble()
double Soprano::LiteralValue::toDouble |
( |
| ) |
const |
◆ toString()
QString Soprano::LiteralValue::toString |
( |
| ) |
const |
Each type can be converted to a string which means that toString in combination with dataTypeUrl provides all the information necessary to store this literal as RDF.
The string value is cached so calling it multiple times in a row is fast.
- Warning
- For historical reasons this is not a user-readable representation.
- See also
- Node::toString
◆ toDate()
QDate Soprano::LiteralValue::toDate |
( |
| ) |
const |
◆ toTime()
QTime Soprano::LiteralValue::toTime |
( |
| ) |
const |
◆ toDateTime()
QDateTime Soprano::LiteralValue::toDateTime |
( |
| ) |
const |
◆ toByteArray()
QByteArray Soprano::LiteralValue::toByteArray |
( |
| ) |
const |
◆ dataTypeUri()
QUrl Soprano::LiteralValue::dataTypeUri |
( |
| ) |
const |
The XML Schema datatype URI.
- Returns
- The URI of the XML Schema type referring to the stored type or an empty QUrl if the LiteralValue is empty or is a plain literal.
◆ language()
The language tag.
- Returns
- The language tag of the plain literal or an empty LanguageTag if the LiteralValue has no language or it is a typed literal.
◆ type()
QVariant::Type Soprano::LiteralValue::type |
( |
| ) |
const |
The type of the data.
- Returns
- The QVariant type of the stored data or QVariant::Invalid if it is an empty value.
◆ variant()
QVariant Soprano::LiteralValue::variant |
( |
| ) |
const |
The literal value represented in a QVariant. Be aware that the RDF typing information is lost in the converted variant.
◆ fromString() [1/2]
static LiteralValue Soprano::LiteralValue::fromString |
( |
const QString & |
value, |
|
|
QVariant::Type |
type |
|
) |
| |
|
static |
◆ fromString() [2/2]
Create a LiteralValue object by parsing string value based on dataTypeUri.
- Parameters
-
value | The value of the literal. Might be converted based on dataTypeUri. |
dataTypeUri | The data type URI. Soprano can automatically convert all XML schema types. All other (unknown) types will be stored as a string value with the plain dataTypeUri as type. Thus, unknown literal types can still be used without automatic type conversion. (Be aware though, that changing the value of a LiteralValue instance will reset the type, ie. custom data type URIs will be lost.) |
Both an empty value and dataTypeUri will result in an invalid LiteralValue instance but an empty value with a valid dataTypeUri is possible. A valid value with an invalid dataTypeUri will result in a LiteralValue of type Vocabulary::XMLSchema::string.
- Returns
- A newly created LiteralValue instance based on the provided value and dataTypeUri.
- See also
- fromString(const QString&, QVariant::Type), Vocabulary::XMLSchema
◆ fromVariant()
Create a LiteralValue object by converting value
to the given dataType
.
If the type of the variant matches the dataType
this method has the same effect as the constructor which takes a QVariant as parameter. However, this method supports automatic conversion for a set of types including:
- Conversion of different decimal types
- Conversion of everything to xsd:string
- Conversion of decimal types to xsd:dateTime (using QDateTime::fromTime_t())
- Parameters
-
value | The value the created LiteralValue should have. If invalid an invalid LiteralValue will be created. |
dataType | The RDF literal data type the created LiteralValue should have. If empty the result will be the same as providing value to the constructor of LiteralValue. No conversion will take place. |
- Returns
- A newly created Literalvalue instance based on the given
value
and dataType
.
- Since
- 2.7
◆ createPlainLiteral()
Create a plain LiteralValue object with an optional language tag.
- Parameters
-
value | The value of the literal. |
lang | The language tag. |
Both an empty value and lang will result in an invalid LiteralValue instance but an empty value with a valid lang is possible. A valid value with an empty lang will result in a plain, untyped literal with no language tag.
- Returns
- A newly created LiteralValue instance based on the provided value and lang.
◆ typeFromDataTypeUri()
static QVariant::Type Soprano::LiteralValue::typeFromDataTypeUri |
( |
const QUrl & |
dataTypeUri | ) |
|
|
static |
Convert an XML Schema URI into a QVariant::Type.
- Returns
- The QVariant::Type corresponding to dataTypeUri or QVariant::Invalid if dataTypeUri is unknown.
◆ dataTypeUriFromType()
static QUrl Soprano::LiteralValue::dataTypeUriFromType |
( |
QVariant::Type |
type | ) |
|
|
static |
Convert a QVariant::Type into an XML Schema URI.
- Returns
- The XML Schema URI that corresponds to
type
or an empty QUrl if the type os unknown, i.e. can not be mapped to an XML Schema type.
The documentation for this class was generated from the following file: