Soprano  2.9.4
literalvalue.h
Go to the documentation of this file.
1 /*
2  * This file is part of Soprano Project.
3  *
4  * Copyright (C) 2007-2011 Sebastian Trueg <trueg@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef LITERAL_VALUE_H
23 #define LITERAL_VALUE_H
24 
25 #include "soprano_export.h"
26 
27 #include <QtCore/QVariant>
28 #include <QtCore/QSharedDataPointer>
29 
30 #include "languagetag.h"
31 
32 
33 namespace Soprano
34 {
67  {
68  public:
70 
74 
79 
83  LiteralValue( const LiteralValue& other );
84 
92  LiteralValue( const QVariant& v );
93 
98  LiteralValue( int i );
99 
104  LiteralValue( qlonglong i );
105 
110  LiteralValue( uint i );
111 
116  LiteralValue( qulonglong i );
117 
122  LiteralValue( bool b );
123 
128  LiteralValue( double d );
129 
136  LiteralValue( const char* string );
137 
142  LiteralValue( const QLatin1String& string );
143 
148  LiteralValue( const QString& string );
149 
155 
161 
166  LiteralValue( const QDateTime& datetime );
167 
172  LiteralValue( const QByteArray& data );
174 
176 
180 
194 
199  LiteralValue& operator=( qlonglong i );
200 
213 
218  LiteralValue& operator=( qulonglong i );
219 
225 
230  LiteralValue& operator=( double d );
231 
237 
243 
249 
255 
260  LiteralValue& operator=( const QDateTime& datetime );
261 
268 
270  bool operator==( const LiteralValue& other ) const;
271 
272  bool operator!=( const LiteralValue& other ) const;
274 
276  bool isValid() const;
277 
284  bool isPlain() const;
285 
286  bool isInt() const;
287  bool isInt64() const;
288  bool isUnsignedInt() const;
289  bool isUnsignedInt64() const;
290  bool isBool() const;
291  bool isDouble() const;
292 
299  bool isString() const;
300  bool isDate() const;
301  bool isTime() const;
302  bool isDateTime() const;
303  bool isByteArray() const;
305 
307  int toInt() const;
308  qlonglong toInt64() const;
309  uint toUnsignedInt() const;
310  qulonglong toUnsignedInt64() const;
311  bool toBool() const;
312  double toDouble() const;
313 
326  QString toString() const;
327  QDate toDate() const;
328  QTime toTime() const;
332 
334 
341  QUrl dataTypeUri() const;
342 
350 
357  QVariant::Type type() const;
358 
364  QVariant variant() const;
366 
374  static LiteralValue fromString( const QString& value, QVariant::Type type );
375 
397  static LiteralValue fromString( const QString& value, const QUrl& dataTypeUri );
398 
421  static LiteralValue fromVariant( const QVariant& value, const QUrl& dataType );
422 
439 
445  static QVariant::Type typeFromDataTypeUri( const QUrl& dataTypeUri );
446 
452  static QUrl dataTypeUriFromType( QVariant::Type type );
453 
454  private:
455  class LiteralValueData;
456  class PlainData;
457  class TypedData;
459  };
460 
461  SOPRANO_EXPORT uint qHash( const LiteralValue& lit );
462 }
463 
464 SOPRANO_EXPORT QDebug operator<<( QDebug dbg, const Soprano::LiteralValue& );
465 
466 #endif
A LanguageTag represents a language according to RFC 3066 and RFC 4646.
Definition: languagetag.h:45
Represents a literal value of an RDF Node.
Definition: literalvalue.h:67
LiteralValue(const LiteralValue &other)
QVariant variant() const
LiteralValue(const QVariant &v)
LiteralValue & operator=(const QString &s)
bool isValid() const
static LiteralValue fromString(const QString &value, const QUrl &dataTypeUri)
LiteralValue & operator=(const QDateTime &datetime)
bool isDouble() const
QVariant::Type type() const
static LiteralValue createPlainLiteral(const QString &value, const LanguageTag &lang=LanguageTag())
LiteralValue(qlonglong i)
LiteralValue(qulonglong i)
LiteralValue & operator=(const QTime &time)
bool isDateTime() const
LiteralValue(const QTime &time)
bool isInt64() const
qlonglong toInt64() const
LiteralValue(const QLatin1String &string)
LiteralValue & operator=(const QByteArray &data)
LiteralValue & operator=(bool b)
uint toUnsignedInt() const
bool operator==(const LiteralValue &other) const
bool isByteArray() const
LiteralValue & operator=(qulonglong i)
LiteralValue & operator=(double d)
bool isUnsignedInt() const
LanguageTag language() const
double toDouble() const
QUrl dataTypeUri() const
LiteralValue & operator=(const QLatin1String &s)
bool isString() const
bool isUnsignedInt64() const
QString toString() const
LiteralValue(const QByteArray &data)
static LiteralValue fromString(const QString &value, QVariant::Type type)
LiteralValue(const QDate &date)
QByteArray toByteArray() const
qulonglong toUnsignedInt64() const
LiteralValue & operator=(const QDate &date)
LiteralValue & operator=(const LiteralValue &other)
bool operator!=(const LiteralValue &other) const
LiteralValue & operator=(qlonglong i)
static QUrl dataTypeUriFromType(QVariant::Type type)
LiteralValue(const QDateTime &datetime)
LiteralValue & operator=(uint i)
LiteralValue & operator=(int i)
static LiteralValue fromVariant(const QVariant &value, const QUrl &dataType)
QDateTime toDateTime() const
LiteralValue(const QString &string)
static QVariant::Type typeFromDataTypeUri(const QUrl &dataTypeUri)
QTime toTime() const
QDate toDate() const
bool isPlain() const
LiteralValue(const char *string)
SOPRANO_EXPORT QDebug operator<<(QDebug s, const Soprano::Node &)
SOPRANO_EXPORT QUrl value()
SOPRANO_EXPORT QUrl type()
SOPRANO_EXPORT QUrl date()
SOPRANO_EXPORT QUrl time()
SOPRANO_EXPORT uint qHash(const LanguageTag &node)
#define SOPRANO_EXPORT