filters
value.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SWINDER_VALUE_H
00021 #define SWINDER_VALUE_H
00022
00023 #include <iostream>
00024 #include "ustring.h"
00025
00026 namespace Swinder
00027 {
00028
00029 class ValueData;
00030
00031
00032
00042 class Value
00043 {
00044
00045 public:
00046
00047 typedef enum {
00048 Empty,
00049 Boolean,
00050 Integer,
00051 Float,
00052 String,
00053 CellRange,
00054 Array,
00055 Error
00056 } Type;
00057
00061 Value();
00062
00066 Value( Type _type );
00067
00071 virtual ~Value();
00072
00076 Value( const Value& _value );
00077
00084 Value& operator= ( const Value& _value );
00085
00089 Value& assign( const Value& _value );
00090
00094 Value( bool b );
00095
00099 Value( int i );
00100
00104 Value( double f );
00105
00109 Value( const UString& s );
00110
00114 Type type() const;
00115
00119 bool isEmpty() const { return type() == Empty; }
00120
00124 bool isBoolean() const { return type() == Boolean; }
00125
00129 bool isInteger() const { return type() == Integer; }
00130
00134 bool isFloat() const { return type() == Float; }
00135
00140 bool isNumber() const { return (type() == Integer) || (type() == Float); }
00141
00145 bool isString() const { return type() == String; }
00146
00150 bool isError() const { return type() == Error; }
00151
00152 void setValue( const Value& v );
00153
00157 void setValue( bool b );
00158
00162 void setValue( int i );
00163
00167 void setValue( double f );
00168
00172 void setValue( const UString& s );
00173
00177 void setError( const UString& msg );
00178
00184 bool asBoolean() const;
00185
00191 int asInteger() const;
00192
00198 double asFloat() const;
00199
00205 UString asString() const;
00206
00212 UString errorMessage() const;
00213
00219 void detach();
00220
00224 static const Value& empty();
00225
00231 static const Value& errorDIV0();
00232
00238 static const Value& errorNA();
00239
00247 static const Value& errorNAME();
00248
00254 static const Value& errorNUM();
00255
00261 static const Value& errorNULL();
00262
00268 static const Value& errorREF();
00269
00276 static const Value& errorVALUE();
00277
00278 protected:
00279
00280 ValueData* d;
00281 };
00282
00286 std::ostream& operator<<( std::ostream& s, Value value );
00287
00288 }
00289
00290 #endif // SWINDER_VALUE_H
|