lib
variant.h
00001 /*************************************************************************** 00002 * variant.h 00003 * This file is part of the KDE project 00004 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program 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 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 ***************************************************************************/ 00019 00020 #ifndef KROSS_API_VARIANT_H 00021 #define KROSS_API_VARIANT_H 00022 00023 #include <qstring.h> 00024 #include <qvariant.h> 00025 //#include <kdebug.h> 00026 00027 #include "object.h" 00028 #include "value.h" 00029 #include "exception.h" 00030 00031 namespace Kross { namespace Api { 00032 00037 class Variant : public Value<Variant, QVariant> 00038 { 00039 friend class Value<Variant, QVariant>; 00040 public: 00041 00049 Variant(const QVariant& value, const QString& name = "variant"); 00050 00051 operator bool () { return getValue().toBool(); } 00052 operator int () { return getValue().toInt(); } 00053 operator uint () { return getValue().toUInt(); } 00054 operator double () { return getValue().toDouble(); } 00055 operator const char* () { return getValue().toString().latin1(); } 00056 operator QString () { return getValue().toString(); } 00057 operator const QString () { return getValue().toString(); } 00058 operator const QString& () { return getValue().asString(); } 00059 operator QCString () { return getValue().toCString(); } 00060 operator const QCString () { return getValue().toCString(); } 00061 operator const QCString& () { return getValue().asCString(); } 00062 operator const QVariant& () { return getValue(); } 00063 00067 virtual ~Variant(); 00068 00070 virtual const QString getClassName() const; 00071 00077 virtual const QString toString(); 00078 00091 static const QString getVariantType(Object::Ptr object); 00092 00101 static const QVariant& toVariant(Object::Ptr object); 00102 00111 static const QString toString(Object::Ptr object); 00112 00121 static int toInt(Object::Ptr object); 00122 00131 static uint toUInt(Object::Ptr object); 00132 00141 static double toDouble(Object::Ptr object); 00142 00151 static Q_LLONG toLLONG(Object::Ptr object); 00152 00161 static Q_ULLONG toULLONG(Object::Ptr object); 00162 00171 static bool toBool(Object::Ptr object); 00172 00181 static QValueList<QVariant> toList(Object::Ptr object); 00182 00183 }; 00184 00185 }} 00186 00187 #endif 00188