• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

soprano

Soprano::LiteralValue

Soprano::LiteralValue Class Reference

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

#include <Soprano/LiteralValue>

List of all members.

Public Member Functions



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

Static Public Member Functions

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

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.

  • int (Vocabulary::XMLSchema::xsdInt)
  • qlonglong (Vocabulary::XMLSchema::xsdLong)
  • unsigned int (Vocabulary::XMLSchema::unsignedInt)
  • qulonglong (Vocabulary::XMLSchema::unsignedLong)
  • bool (Vocabulary::XMLSchema::boolean)
  • double and float (Vocabulary::XMLSchema::xsdDouble) (float values are always converted to double)
  • QString (Vocabulary::XMLSchema::string or Vocabulary::RDF::XMLLiteral)
  • QDate (Vocabulary::XMLSchema::date)
  • QTime (Vocabulary::XMLSchema::time)
  • QDateTime (Vocabulary::XMLSchema::dateTime)
  • QByteArray (Vocabulary::XMLSchema::base64Binary)

Literal values can be converted from strings via fromString().

See also:
Vocabulary::XMLSchema
Author:
Sebastian Trueg <trueg@kde.org>

Definition at line 66 of file literalvalue.h.


Constructor & Destructor Documentation

Soprano::LiteralValue::LiteralValue (  ) 

Create an empty literal value.

Soprano::LiteralValue::~LiteralValue (  ) 

Destructor.

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

Default copy constructor.

Soprano::LiteralValue::LiteralValue ( const QVariant &  v  ) 

Creates a new LiteralValue from a QVariant.

User types are not supported. If v contains an unsupported type an invalid LiteralValue is created.

Soprano::LiteralValue::LiteralValue ( int  i  ) 

Creates a literal value of type int (i.e.

http://www.w3.org/2001/XMLSchema#int)

Soprano::LiteralValue::LiteralValue ( qlonglong  i  ) 

Creates a literal value of type long long (i.e.

http://www.w3.org/2001/XMLSchema#long)

Soprano::LiteralValue::LiteralValue ( uint  i  ) 

Creates a literal value of type unsigned int (i.e.

http://www.w3.org/2001/XMLSchema#unsignedInt)

Soprano::LiteralValue::LiteralValue ( qulonglong  i  ) 

Creates a literal value of type unsigned long long (i.e.

http://www.w3.org/2001/XMLSchema#unsignedLong)

Soprano::LiteralValue::LiteralValue ( bool  b  ) 

Creates a literal value of type bool (i.e.

http://www.w3.org/2001/XMLSchema#boolean)

Soprano::LiteralValue::LiteralValue ( double  d  ) 

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:
string The value of the new literal interpreted as UTF-8 encoded string.
Soprano::LiteralValue::LiteralValue ( const QLatin1String &  string  ) 

Creates a literal value of type QString (i.e.

http://www.w3.org/2001/XMLSchema#string)

Soprano::LiteralValue::LiteralValue ( const QString &  string  ) 

Creates a literal value of type QString (i.e.

http://www.w3.org/2001/XMLSchema#string)

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

Creates a literal value of type QDate (i.e.

http://www.w3.org/2001/XMLSchema#date)

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

Creates a literal value of type QTime (i.e.

http://www.w3.org/2001/XMLSchema#time)

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

Creates a literal value of type QDateTime (i.e.

http://www.w3.org/2001/XMLSchema#dateTime)

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

Creates a literal value of type QByteArray (i.e.

http://www.w3.org/2001/XMLSchema#base64Binary)


Member Function Documentation

static LiteralValue Soprano::LiteralValue::createPlainLiteral ( const QString &  value,
const LanguageTag &  lang = LanguageTag() 
) [static]

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.
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.
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.
static LiteralValue Soprano::LiteralValue::fromString ( const QString &  value,
const QUrl &  dataTypeUri 
) [static]

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
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&)
bool Soprano::LiteralValue::isBool (  )  const
bool Soprano::LiteralValue::isByteArray (  )  const
bool Soprano::LiteralValue::isDate (  )  const
bool Soprano::LiteralValue::isDateTime (  )  const
bool Soprano::LiteralValue::isDouble (  )  const
bool Soprano::LiteralValue::isInt (  )  const
bool Soprano::LiteralValue::isInt64 (  )  const
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
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.

bool Soprano::LiteralValue::isTime (  )  const
bool Soprano::LiteralValue::isUnsignedInt (  )  const
bool Soprano::LiteralValue::isUnsignedInt64 (  )  const
bool Soprano::LiteralValue::isValid (  )  const
LanguageTag Soprano::LiteralValue::language (  )  const

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

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 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 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 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 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= ( 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= ( 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= ( 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= ( 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= ( 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= ( 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= ( const LiteralValue &  other  ) 

Creates a copy of other.

bool Soprano::LiteralValue::operator== ( const LiteralValue &  other  )  const
bool Soprano::LiteralValue::toBool (  )  const
QByteArray Soprano::LiteralValue::toByteArray (  )  const
QDate Soprano::LiteralValue::toDate (  )  const
QDateTime Soprano::LiteralValue::toDateTime (  )  const
double Soprano::LiteralValue::toDouble (  )  const
int Soprano::LiteralValue::toInt (  )  const
qlonglong Soprano::LiteralValue::toInt64 (  )  const
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
QTime Soprano::LiteralValue::toTime (  )  const
uint Soprano::LiteralValue::toUnsignedInt (  )  const
qulonglong Soprano::LiteralValue::toUnsignedInt64 (  )  const
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.
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.
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.


The documentation for this class was generated from the following file:
  • literalvalue.h

soprano

Skip menu "soprano"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal