Soprano  2.9.2
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 
73  LiteralValue();
74 
78  ~LiteralValue();
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 
154  LiteralValue( const QDate& date );
155 
160  LiteralValue( const QTime& time );
161 
166  LiteralValue( const QDateTime& datetime );
167 
172  LiteralValue( const QByteArray& data );
174 
176 
179  LiteralValue& operator=( const LiteralValue& other );
180 
193  LiteralValue& operator=( int i );
194 
199  LiteralValue& operator=( qlonglong i );
200 
212  LiteralValue& operator=( uint i );
213 
218  LiteralValue& operator=( qulonglong i );
219 
224  LiteralValue& operator=( bool b );
225 
230  LiteralValue& operator=( double d );
231 
236  LiteralValue& operator=( const QString& s );
237 
242  LiteralValue& operator=( const QLatin1String& s );
243 
248  LiteralValue& operator=( const QDate& date );
249 
254  LiteralValue& operator=( const QTime& time );
255 
260  LiteralValue& operator=( const QDateTime& datetime );
261 
266  LiteralValue& operator=( const QByteArray& data );
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;
329  QDateTime toDateTime() const;
330  QByteArray toByteArray() const;
332 
334 
341  QUrl dataTypeUri() const;
342 
349  LanguageTag language() const;
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 
438  static LiteralValue createPlainLiteral( const QString& value, const LanguageTag& lang = LanguageTag() );
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
SOPRANO_EXPORT QUrl time()
SOPRANO_EXPORT QDebug operator<<(QDebug s, const Soprano::Node &)
SOPRANO_EXPORT QUrl value()
SOPRANO_EXPORT QUrl language()
A LanguageTag represents a language according to RFC 3066 and RFC 4646.
Definition: languagetag.h:44
SOPRANO_EXPORT uint qHash(const LanguageTag &node)
#define SOPRANO_EXPORT
SOPRANO_EXPORT QUrl date()
Represents a literal value of an RDF Node.
Definition: literalvalue.h:66
SOPRANO_EXPORT QUrl type()