|
|
| version 1.9, 2001/03/08 17:14:51 | version 1.11, 2001/03/10 11:44:32 |
|---|---|
| Line 7 | Line 7 |
| #include "pa_value.h" | #include "pa_value.h" |
| #include "pa_common.h" | #include "pa_common.h" |
| #include "classes/_double.h" | |
| #define MAX_DOUBLE_AS_STRING 20 | #define MAX_DOUBLE_AS_STRING 20 |
| class VDouble : public Value { | class VDouble : public VObject { |
| public: // Value | public: // Value |
| // all: for error reporting after fail(), etc | // all: for error reporting after fail(), etc |
| const char *type() const { return "double"; } | const char *type() const { return "double"; } |
| // double: this | |
| Value *get_expr_result() { return this; } | |
| // double: fdouble | // double: fdouble |
| String *get_string() { | const String *get_string() { |
| char *buf=static_cast<char *>(pool().malloc(MAX_DOUBLE_AS_STRING)); | char *buf=static_cast<char *>(pool().malloc(MAX_DOUBLE_AS_STRING)); |
| snprintf(buf, MAX_DOUBLE_AS_STRING, "%g", fdouble); | snprintf(buf, MAX_DOUBLE_AS_STRING, "%g", fdouble); |
| String *result=NEW String(pool()); | String *result=NEW String(pool()); |
| Line 31 public: // Value | Line 34 public: // Value |
| public: // usage | public: // usage |
| VDouble(Pool& apool, double adouble) : Value(apool), | VDouble(Pool& apool, double adouble) : VObject(apool, *double_class), |
| fdouble(adouble) { | fdouble(adouble) { |
| } | } |
| void inc(double increment) { fdouble+=increment; } | |
| private: | private: |
| double fdouble; | double fdouble; |