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 00031 namespace Soprano 00032 { 00068 class SOPRANO_EXPORT LiteralValue 00069 { 00070 public: 00072 00075 LiteralValue(); 00076 00080 ~LiteralValue(); 00081 00085 LiteralValue( const LiteralValue& other ); 00086 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 00278 bool isInt() const; 00279 bool isInt64() const; 00280 bool isUnsignedInt() const; 00281 bool isUnsignedInt64() const; 00282 bool isBool() const; 00283 bool isDouble() const; 00284 00291 bool isString() const; 00292 bool isDate() const; 00293 bool isTime() const; 00294 bool isDateTime() const; 00295 bool isByteArray() const; 00297 00299 int toInt() const; 00300 qlonglong toInt64() const; 00301 uint toUnsignedInt() const; 00302 qulonglong toUnsignedInt64() const; 00303 bool toBool() const; 00304 double toDouble() const; 00305 00314 QString toString() const; 00315 QDate toDate() const; 00316 QTime toTime() const; 00317 QDateTime toDateTime() const; 00318 QByteArray toByteArray() const; 00320 00322 00328 QUrl dataTypeUri() const; 00329 00336 QVariant::Type type() const; 00337 00343 QVariant variant() const; 00345 00353 static LiteralValue fromString( const QString& value, QVariant::Type type ); 00354 00376 static LiteralValue fromString( const QString& value, const QUrl& dataTypeUri ); 00377 00383 static QVariant::Type typeFromDataTypeUri( const QUrl& dataTypeUri ); 00384 00390 static QUrl dataTypeUriFromType( QVariant::Type type ); 00391 00392 private: 00393 class Private; 00394 QSharedDataPointer<Private> d; 00395 }; 00396 } 00397 00398 SOPRANO_EXPORT QDebug operator<<( QDebug dbg, const Soprano::LiteralValue& ); 00399 00400 #endif