Soprano  2.8.0
Static Public Member Functions
Soprano::LiteralValue Class Reference

Represents a literal value of an RDF Node. More...

#include <Soprano/LiteralValue>

List of all members.

Public Member Functions

 LiteralValue ()
 ~LiteralValue ()
 LiteralValue (const LiteralValue &other)
 LiteralValue (const QVariant &v)
 LiteralValue (int i)
 LiteralValue (qlonglong i)
 LiteralValue (uint i)
 LiteralValue (qulonglong i)
 LiteralValue (bool b)
 LiteralValue (double d)
 LiteralValue (const char *string)
 LiteralValue (const QLatin1String &string)
 LiteralValue (const QString &string)
 LiteralValue (const QDate &date)
 LiteralValue (const QTime &time)
 LiteralValue (const QDateTime &datetime)
 LiteralValue (const QByteArray &data)
LiteralValueoperator= (const LiteralValue &other)
LiteralValueoperator= (int i)
LiteralValueoperator= (qlonglong i)
LiteralValueoperator= (uint i)
LiteralValueoperator= (qulonglong i)
LiteralValueoperator= (bool b)
LiteralValueoperator= (double d)
LiteralValueoperator= (const QString &s)
LiteralValueoperator= (const QLatin1String &s)
LiteralValueoperator= (const QDate &date)
LiteralValueoperator= (const QTime &time)
LiteralValueoperator= (const QDateTime &datetime)
LiteralValueoperator= (const QByteArray &data)
bool operator== (const LiteralValue &other) const
bool operator!= (const LiteralValue &other) const
bool isValid () const
bool isPlain () const
bool isInt () const
bool isInt64 () const
bool isUnsignedInt () const
bool isUnsignedInt64 () const
bool isBool () const
bool isDouble () const
bool isString () const
bool isDate () const
bool isTime () const
bool isDateTime () const
bool isByteArray () const
int toInt () const
qlonglong toInt64 () const
uint toUnsignedInt () const
qulonglong toUnsignedInt64 () const
bool toBool () const
double toDouble () const
QString toString () const
QDate toDate () const
QTime toTime () const
QDateTime toDateTime () const
QByteArray toByteArray () const
QUrl dataTypeUri () const
LanguageTag language () const
QVariant::Type type () const
QVariant variant () const

Static Public Member Functions

static LiteralValue fromString (const QString &value, QVariant::Type type)
static LiteralValue fromString (const QString &value, const QUrl &dataTypeUri)
static LiteralValue fromVariant (const QVariant &value, const QUrl &dataType)
static LiteralValue createPlainLiteral (const QString &value, const LanguageTag &lang=LanguageTag())
static QVariant::Type typeFromDataTypeUri (const QUrl &dataTypeUri)
static QUrl dataTypeUriFromType (QVariant::Type type)

Detailed Description

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.


Constructor & Destructor Documentation

Create an empty literal value

Destructor

Default copy constructor

Creates a new LiteralValue from a QVariant. User types are not supported. If v contains an unsupported type an invalid LiteralValue is created.

See also:
fromVariant()

Creates a literal value of type int (i.e. http://www.w3.org/2001/XMLSchema#int)

Creates a literal value of type long long (i.e. http://www.w3.org/2001/XMLSchema#long)

Creates a literal value of type unsigned int (i.e. http://www.w3.org/2001/XMLSchema#unsignedInt)

Creates a literal value of type unsigned long long (i.e. http://www.w3.org/2001/XMLSchema#unsignedLong)

Creates a literal value of type bool (i.e. http://www.w3.org/2001/XMLSchema#boolean)

Creates a literal value of type double (i.e. http://www.w3.org/2001/XMLSchema#double)

Soprano::LiteralValue::LiteralValue ( const char *  string)

Creates a literal value of type QString (i.e. http://www.w3.org/2001/XMLSchema#string)

Parameters:
stringThe value of the new literal interpreted as UTF-8 encoded string.

Creates a literal value of type QString (i.e. http://www.w3.org/2001/XMLSchema#string)

Creates a literal value of type QString (i.e. http://www.w3.org/2001/XMLSchema#string)

Creates a literal value of type QDate (i.e. http://www.w3.org/2001/XMLSchema#date)

Creates a literal value of type QTime (i.e. http://www.w3.org/2001/XMLSchema#time)

Creates a literal value of type QDateTime (i.e. http://www.w3.org/2001/XMLSchema#dateTime)

Creates a literal value of type QByteArray (i.e. http://www.w3.org/2001/XMLSchema#base64Binary)


Member Function Documentation

LiteralValue& Soprano::LiteralValue::operator= ( const LiteralValue other)

Creates a copy of other

LiteralValue& Soprano::LiteralValue::operator= ( int  i)

Assigns i to this literal value. The type will be set to int (http://www.w3.org/2001/XMLSchema#int) unless it is already set to a compatible type.

Thus, a type http://www.w3.org/2001/XMLSchema#integer or http://www.w3.org/2001/XMLSchema#decimal will not be changed.

Be aware that Soprano does not check the ranges of the integer value yet.

LiteralValue& Soprano::LiteralValue::operator= ( qlonglong  i)

Assigns i to this literal value. The type will be set to long (http://www.w3.org/2001/XMLSchema#long).

LiteralValue& Soprano::LiteralValue::operator= ( uint  i)

Assigns i to this literal value. The type will be set to uint (http://www.w3.org/2001/XMLSchema#unsignedInt) unless it is already set to a compatible type.

Thus, a type http://www.w3.org/2001/XMLSchema#unsignedShort will not be changed.

Be aware that Soprano does not check the ranges of the unsigned value yet.

LiteralValue& Soprano::LiteralValue::operator= ( qulonglong  i)

Assigns i to this literal value. The type will be set to unsigned long (http://www.w3.org/2001/XMLSchema#unsignedLong).

LiteralValue& Soprano::LiteralValue::operator= ( bool  b)

Assigns b to this literal value. The type will be set to bool (http://www.w3.org/2001/XMLSchema#boolean).

LiteralValue& Soprano::LiteralValue::operator= ( double  d)

Assigns d to this literal value. The type will be set to double (http://www.w3.org/2001/XMLSchema#double).

LiteralValue& Soprano::LiteralValue::operator= ( const QString s)

Assigns s to this literal value. The type will be set to string (http://www.w3.org/2001/XMLSchema#string).

LiteralValue& Soprano::LiteralValue::operator= ( const QLatin1String s)

Assigns s to this literal value. The type will be set to string (http://www.w3.org/2001/XMLSchema#string).

LiteralValue& Soprano::LiteralValue::operator= ( const QDate date)

Assigns date to this literal value. The type will be set to data (http://www.w3.org/2001/XMLSchema#date).

LiteralValue& Soprano::LiteralValue::operator= ( const QTime time)

Assigns time to this literal value. The type will be set to time (http://www.w3.org/2001/XMLSchema#time).

LiteralValue& Soprano::LiteralValue::operator= ( const QDateTime datetime)

Assigns datetime to this literal value. The type will be set to dateTime (http://www.w3.org/2001/XMLSchema#dateTime).

LiteralValue& Soprano::LiteralValue::operator= ( const QByteArray data)

Assigns datetime to this literal value. The type will be set to ByteArray (http://www.w3.org/2001/XMLSchema#base64Binary).

bool Soprano::LiteralValue::operator== ( const LiteralValue other) const
bool Soprano::LiteralValue::operator!= ( const LiteralValue other) 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

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

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

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

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

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

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

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

Check if the literal contains a string value. Be aware that unknown literal types are also treated as strings. In that case compare dataTypeUrl.

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

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

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

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

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
qlonglong Soprano::LiteralValue::toInt64 ( ) 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

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

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

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

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

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

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

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

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

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

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.

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

The literal value represented in a QVariant. Be aware that the RDF typing information is lost in the converted variant.

static LiteralValue Soprano::LiteralValue::fromString ( const QString value,
QVariant::Type  type 
) [static]

Create a LiteralValue object by parsing string value based on type. If type is unknown a simple string LiteralValue object is returned containing the plain string value.

See also:
fromString(const QString&, const QUrl&)
static LiteralValue Soprano::LiteralValue::fromString ( const QString value,
const QUrl dataTypeUri 
) [static]

Create a LiteralValue object by parsing string value based on dataTypeUri.

Parameters:
valueThe value of the literal. Might be converted based on dataTypeUri.
dataTypeUriThe 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
static LiteralValue Soprano::LiteralValue::fromVariant ( const QVariant value,
const QUrl dataType 
) [static]

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:
valueThe value the created LiteralValue should have. If invalid an invalid LiteralValue will be created.
dataTypeThe 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
static LiteralValue Soprano::LiteralValue::createPlainLiteral ( const QString value,
const LanguageTag lang = LanguageTag() 
) [static]

Create a plain LiteralValue object with an optional language tag.

Parameters:
valueThe value of the literal.
langThe 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.
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.
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: