kspread
kspread_value.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KSPREAD_VALUE_H
00021 #define KSPREAD_VALUE_H
00022
00023 #include <qdatetime.h>
00024 #include <qstring.h>
00025 #include <qtextstream.h>
00026
00027 #include <koffice_export.h>
00028
00029 namespace KSpread
00030 {
00031 class ValueData;
00032
00041 class KSPREAD_EXPORT Value
00042 {
00043
00044 public:
00045
00046 typedef enum {
00047 Empty,
00048 Boolean,
00049 Integer,
00050 Float,
00051 String,
00052 Array,
00053 CellRange,
00054 Error
00055 } Type;
00056
00057 typedef enum {
00058 fmt_None,
00059 fmt_Boolean,
00060 fmt_Number,
00061 fmt_Percent,
00062 fmt_Money,
00063 fmt_DateTime,
00064 fmt_Date,
00065 fmt_Time,
00066 fmt_String
00067 } Format;
00071 Value();
00072
00076 Value( Type _type );
00077
00081 virtual ~Value();
00082
00086 Value( const Value& _value );
00087
00094 Value& operator= ( const Value& _value );
00095
00099 Value& assign( const Value& _value );
00100
00104 Value( bool b );
00105
00109 Value( long i );
00110
00114 Value( int i );
00115
00119 Value( double f );
00120
00124 Value( const QString& s );
00125
00126 Value (const char *s);
00133 Value( const QDateTime& dt );
00134
00139 Value( const QTime& time );
00140
00145 Value( const QDate& date );
00146
00150 Value( unsigned columns, unsigned rows );
00151
00155 Type type() const;
00156
00158 Format format() const;
00159
00163 bool isEmpty() const { return type() == Empty; }
00164
00168 bool isBoolean() const { return type() == Boolean; }
00169
00173 bool isInteger() const { return type() == Integer; }
00174
00178 bool isFloat() const { return type() == Float; }
00179
00184 bool isNumber() const { return (type() == Integer) || (type() == Float); }
00185
00189 bool isString() const { return type() == String; }
00190
00194 bool isArray() const { return type() == Array; }
00195
00199 bool isError() const { return type() == Error; }
00200
00204 void setValue( const Value& v );
00205
00209 void setValue( bool b );
00210
00214 void setValue( long i );
00215
00219 void setValue( int i );
00220
00224 void setValue( double f );
00225
00229 void setValue( const QString& s );
00230
00234 void setError( const QString& msg );
00235
00239 void setValue( const QDateTime& dt );
00240
00244 void setValue( const QTime& dt );
00245
00249 void setValue( const QDate& dt );
00250
00252 void setFormat (Format fmt);
00253
00259 bool asBoolean() const;
00260
00266 long asInteger() const;
00267
00273 double asFloat() const;
00274
00280 QString asString() const;
00281
00285 QDateTime asDateTime() const;
00286
00290 QDate asDate() const;
00291
00295 QTime asTime() const;
00296
00300 Value element( unsigned column, unsigned row ) const;
00301
00305 void setElement( unsigned column, unsigned row, const Value& value );
00306
00311 unsigned columns() const;
00312
00317 unsigned rows() const;
00318
00324 QString errorMessage() const;
00325
00331 void detach();
00332
00336 static const Value& empty();
00337
00343 static const Value& errorDIV0();
00344
00350 static const Value& errorNA();
00351
00359 static const Value& errorNAME();
00360
00366 static const Value& errorNUM();
00367
00373 static const Value& errorNULL();
00374
00380 static const Value& errorREF();
00381
00388 static const Value& errorVALUE();
00389
00394 bool allowComparison( const Value& v ) const;
00395
00400 int compare( const Value& v ) const;
00401
00405 bool equal( const Value& v ) const;
00406
00410 bool less( const Value& v ) const;
00411
00415 bool greater( const Value& v ) const;
00416
00417
00418 bool operator==( const Value& v ) const;
00419
00420 static int compare( double v1, double v2 );
00421
00422 bool isZero() const;
00423
00424 static bool isZero( double v );
00425
00426 protected:
00427
00428 ValueData* d;
00429 };
00430
00431 }
00432
00433 QTextStream& operator<<( QTextStream& ts, KSpread::Value::Type type );
00434 QTextStream& operator<<( QTextStream& ts, KSpread::Value value );
00435
00436 #endif // KSPREAD_VALUE_H
|