Soprano
2.7.4
|
00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2007-2011 Sebastian Trueg <trueg@kde.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef LITERAL_VALUE_H 00023 #define LITERAL_VALUE_H 00024 00025 #include "soprano_export.h" 00026 00027 #include <QtCore/QVariant> 00028 #include <QtCore/QSharedDataPointer> 00029 00030 #include "languagetag.h" 00031 00032 00033 namespace Soprano 00034 { 00066 class SOPRANO_EXPORT LiteralValue 00067 { 00068 public: 00070 00073 LiteralValue(); 00074 00078 ~LiteralValue(); 00079 00083 LiteralValue( const LiteralValue& other ); 00084 00092 LiteralValue( const QVariant& v ); 00093 00098 LiteralValue( int i ); 00099 00104 LiteralValue( qlonglong i ); 00105 00110 LiteralValue( uint i ); 00111 00116 LiteralValue( qulonglong i ); 00117 00122 LiteralValue( bool b ); 00123 00128 LiteralValue( double d ); 00129 00136 LiteralValue( const char* string ); 00137 00142 LiteralValue( const QLatin1String& string ); 00143 00148 LiteralValue( const QString& string ); 00149 00154 LiteralValue( const QDate& date ); 00155 00160 LiteralValue( const QTime& time ); 00161 00166 LiteralValue( const QDateTime& datetime ); 00167 00172 LiteralValue( const QByteArray& data ); 00174 00176 00179 LiteralValue& operator=( const LiteralValue& other ); 00180 00193 LiteralValue& operator=( int i ); 00194 00199 LiteralValue& operator=( qlonglong i ); 00200 00212 LiteralValue& operator=( uint i ); 00213 00218 LiteralValue& operator=( qulonglong i ); 00219 00224 LiteralValue& operator=( bool b ); 00225 00230 LiteralValue& operator=( double d ); 00231 00236 LiteralValue& operator=( const QString& s ); 00237 00242 LiteralValue& operator=( const QLatin1String& s ); 00243 00248 LiteralValue& operator=( const QDate& date ); 00249 00254 LiteralValue& operator=( const QTime& time ); 00255 00260 LiteralValue& operator=( const QDateTime& datetime ); 00261 00266 LiteralValue& operator=( const QByteArray& data ); 00268 00270 bool operator==( const LiteralValue& other ) const; 00271 00272 bool operator!=( const LiteralValue& other ) const; 00274 00276 bool isValid() const; 00277 00284 bool isPlain() const; 00285 00286 bool isInt() const; 00287 bool isInt64() const; 00288 bool isUnsignedInt() const; 00289 bool isUnsignedInt64() const; 00290 bool isBool() const; 00291 bool isDouble() const; 00292 00299 bool isString() const; 00300 bool isDate() const; 00301 bool isTime() const; 00302 bool isDateTime() const; 00303 bool isByteArray() const; 00305 00307 int toInt() const; 00308 qlonglong toInt64() const; 00309 uint toUnsignedInt() const; 00310 qulonglong toUnsignedInt64() const; 00311 bool toBool() const; 00312 double toDouble() const; 00313 00326 QString toString() const; 00327 QDate toDate() const; 00328 QTime toTime() const; 00329 QDateTime toDateTime() const; 00330 QByteArray toByteArray() const; 00332 00334 00341 QUrl dataTypeUri() const; 00342 00349 LanguageTag language() const; 00350 00357 QVariant::Type type() const; 00358 00364 QVariant variant() const; 00366 00374 static LiteralValue fromString( const QString& value, QVariant::Type type ); 00375 00397 static LiteralValue fromString( const QString& value, const QUrl& dataTypeUri ); 00398 00421 static LiteralValue fromVariant( const QVariant& value, const QUrl& dataType ); 00422 00438 static LiteralValue createPlainLiteral( const QString& value, const LanguageTag& lang = LanguageTag() ); 00439 00445 static QVariant::Type typeFromDataTypeUri( const QUrl& dataTypeUri ); 00446 00452 static QUrl dataTypeUriFromType( QVariant::Type type ); 00453 00454 private: 00455 class LiteralValueData; 00456 class PlainData; 00457 class TypedData; 00458 QSharedDataPointer<LiteralValueData> d; 00459 }; 00460 00461 SOPRANO_EXPORT uint qHash( const LiteralValue& lit ); 00462 } 00463 00464 SOPRANO_EXPORT QDebug operator<<( QDebug dbg, const Soprano::LiteralValue& ); 00465 00466 #endif