Soprano 2.6.0
|
00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2007 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 00090 LiteralValue( const QVariant& v ); 00091 00096 LiteralValue( int i ); 00097 00102 LiteralValue( qlonglong i ); 00103 00108 LiteralValue( uint i ); 00109 00114 LiteralValue( qulonglong i ); 00115 00120 LiteralValue( bool b ); 00121 00126 LiteralValue( double d ); 00127 00134 LiteralValue( const char* string ); 00135 00140 LiteralValue( const QLatin1String& string ); 00141 00146 LiteralValue( const QString& string ); 00147 00152 LiteralValue( const QDate& date ); 00153 00158 LiteralValue( const QTime& time ); 00159 00164 LiteralValue( const QDateTime& datetime ); 00165 00170 LiteralValue( const QByteArray& data ); 00172 00174 00177 LiteralValue& operator=( const LiteralValue& other ); 00178 00191 LiteralValue& operator=( int i ); 00192 00197 LiteralValue& operator=( qlonglong i ); 00198 00210 LiteralValue& operator=( uint i ); 00211 00216 LiteralValue& operator=( qulonglong i ); 00217 00222 LiteralValue& operator=( bool b ); 00223 00228 LiteralValue& operator=( double d ); 00229 00234 LiteralValue& operator=( const QString& s ); 00235 00240 LiteralValue& operator=( const QLatin1String& s ); 00241 00246 LiteralValue& operator=( const QDate& date ); 00247 00252 LiteralValue& operator=( const QTime& time ); 00253 00258 LiteralValue& operator=( const QDateTime& datetime ); 00259 00264 LiteralValue& operator=( const QByteArray& data ); 00266 00268 bool operator==( const LiteralValue& other ) const; 00269 00270 bool operator!=( const LiteralValue& other ) const; 00272 00274 bool isValid() const; 00275 00282 bool isPlain() const; 00283 00284 bool isInt() const; 00285 bool isInt64() const; 00286 bool isUnsignedInt() const; 00287 bool isUnsignedInt64() const; 00288 bool isBool() const; 00289 bool isDouble() const; 00290 00297 bool isString() const; 00298 bool isDate() const; 00299 bool isTime() const; 00300 bool isDateTime() const; 00301 bool isByteArray() const; 00303 00305 int toInt() const; 00306 qlonglong toInt64() const; 00307 uint toUnsignedInt() const; 00308 qulonglong toUnsignedInt64() const; 00309 bool toBool() const; 00310 double toDouble() const; 00311 00324 QString toString() const; 00325 QDate toDate() const; 00326 QTime toTime() const; 00327 QDateTime toDateTime() const; 00328 QByteArray toByteArray() const; 00330 00332 00339 QUrl dataTypeUri() const; 00340 00347 LanguageTag language() const; 00348 00355 QVariant::Type type() const; 00356 00362 QVariant variant() const; 00364 00372 static LiteralValue fromString( const QString& value, QVariant::Type type ); 00373 00395 static LiteralValue fromString( const QString& value, const QUrl& dataTypeUri ); 00396 00412 static LiteralValue createPlainLiteral( const QString& value, const LanguageTag& lang = LanguageTag() ); 00413 00419 static QVariant::Type typeFromDataTypeUri( const QUrl& dataTypeUri ); 00420 00426 static QUrl dataTypeUriFromType( QVariant::Type type ); 00427 00428 private: 00429 class LiteralValueData; 00430 class PlainData; 00431 class TypedData; 00432 QSharedDataPointer<LiteralValueData> d; 00433 }; 00434 00435 SOPRANO_EXPORT uint qHash( const LiteralValue& lit ); 00436 } 00437 00438 SOPRANO_EXPORT QDebug operator<<( QDebug dbg, const Soprano::LiteralValue& ); 00439 00440 #endif