Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qsvalues.h 1.1.5 edited 2006-02-23T15:39:57$ 00003 ** 00004 ** Copyright (C) 2001-2006 Trolltech AS. All rights reserved. 00005 ** 00006 ** This file is part of the Qt Script for Applications framework (QSA). 00007 ** 00008 ** This file may be distributed and/or modified under the terms of the 00009 ** GNU General Public License version 2 as published by the Free Software 00010 ** Foundation and appearing in the file LICENSE.GPL included in the 00011 ** packaging of this file. 00012 ** 00013 ** Licensees holding a valid Qt Script for Applications license may use 00014 ** this file in accordance with the Qt Script for Applications License 00015 ** Agreement provided with the Software. 00016 ** 00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00019 ** 00020 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00021 ** information about QSA Commercial License Agreements. 00022 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00023 ** 00024 ** Contact info@trolltech.com if any conditions of this licensing are 00025 ** not clear to you. 00026 ** 00027 *****************************************************************************/ 00028 00029 #ifndef QSVALUES_H 00030 #define QSVALUES_H 00031 00032 #include "qsglobal.h" 00033 #include "qsobject.h" 00034 00035 class QUICKCORE_EXPORT QSUndefined : public QSObject 00036 { 00037 public: 00038 QSUndefined(const QSEnv *env); 00039 }; 00040 00041 00042 class QUICKCORE_EXPORT QSNull : public QSObject 00043 { 00044 public: 00045 QSNull(const QSEnv *env); 00046 }; 00047 00048 00049 class QUICKCORE_EXPORT QSBoolean : public QSObject 00050 { 00051 public: 00052 QSBoolean(const QSEnv *env, bool b = FALSE); 00053 bool value() const; 00054 }; 00055 00056 //### AbanQ 00057 inline bool QSBoolean::value() const 00058 { 00059 return bVal(); 00060 } 00061 //### AbanQ 00062 00063 class QUICKCORE_EXPORT QSNumber : public QSObject 00064 { 00065 public: 00066 QSNumber(const QSEnv *, double value); 00067 00068 double value() const; 00069 int intValue() const; 00070 bool isNaN() const; 00071 bool isInf() const; 00072 }; 00073 00074 //### AbanQ 00075 inline double QSNumber::value() const 00076 { 00077 return dVal(); 00078 } 00079 inline int QSNumber::intValue() const 00080 { 00081 return (int)dVal(); 00082 } 00083 //### AbanQ 00084 00085 #include "qsoperations.h" 00086 00087 class QUICKCORE_EXPORT QSString : public QSObject 00088 { 00089 public: 00090 QSString(const QSEnv *env, const QString &s); 00091 QString value() const; 00092 00093 //### AbanQ 00094 // ## strictly speaking not related to QSString 00095 static QString from(double d) { 00096 // ### -0 00097 if (QS::isNaN(d)) 00098 return QString::fromLatin1("NaN"); 00099 else if (QS::isInf(d)) 00100 return d > 0 ? QString::fromLatin1("+Infinity") : QString::fromLatin1("-Infinity"); 00101 00102 return QString::number(d, 'G', 16); 00103 } 00104 static double toDouble(const QString &s) { 00105 // ### hex, Infinity 00106 bool ok; 00107 double d = s.toDouble(&ok); 00108 if (!ok) { 00109 if (s.stripWhiteSpace().isEmpty()) { 00110 return 0; 00111 } 00112 return NaN; 00113 } 00114 return d; 00115 } 00116 static ulong toULong(const QString &s, bool *ok = 0) { 00117 double d = QSString::toDouble(s); 00118 bool b = TRUE; 00119 00120 if (QS::isNaN(d) || d != ulong(d)) { 00121 b = FALSE; 00122 d = 0; 00123 } 00124 00125 if (ok) 00126 *ok = b; 00127 00128 return ulong(d); 00129 } 00130 //### AbanQ 00131 }; 00132 00133 class QUICKCORE_EXPORT QSArray : public QSObject 00134 { 00135 public: 00136 QSArray(const QSEnv *env); 00137 }; 00138 00139 #endif