Annotation of parser3/src/include/pa_vdouble.h, revision 1.10
1.1 paf 1: /*
1.10 ! paf 2: $Id: pa_vdouble.h,v 1.9 2001/03/08 17:14:51 paf Exp $
1.1 paf 3: */
4:
5: #ifndef PA_VDOUBLE_H
6: #define PA_VDOUBLE_H
7:
8: #include "pa_value.h"
1.2 paf 9: #include "pa_common.h"
1.10 ! paf 10: #include "classes/_double.h"
1.2 paf 11:
1.3 paf 12: #define MAX_DOUBLE_AS_STRING 20
1.1 paf 13:
1.10 ! paf 14: class VDouble : public VObject {
1.1 paf 15: public: // Value
16:
17: // all: for error reporting after fail(), etc
1.4 paf 18: const char *type() const { return "double"; }
1.10 ! paf 19: // double: this
! 20: Value *get_expr_result() { return this; }
1.7 paf 21:
22: // double: fdouble
1.2 paf 23: String *get_string() {
1.3 paf 24: char *buf=static_cast<char *>(pool().malloc(MAX_DOUBLE_AS_STRING));
1.9 paf 25: snprintf(buf, MAX_DOUBLE_AS_STRING, "%g", fdouble);
1.2 paf 26: String *result=NEW String(pool());
27: result->APPEND_CONST(buf);
28: return result;
1.7 paf 29: }
30: // double: fdouble
1.9 paf 31: double get_double() { return fdouble; }
1.5 paf 32: // double: 0 or !0
1.9 paf 33: bool get_bool() { return fdouble!=0; }
1.1 paf 34:
35: public: // usage
36:
1.10 ! paf 37: VDouble(Pool& apool, double adouble) : VObject(apool, *double_class),
1.7 paf 38: fdouble(adouble) {
1.1 paf 39: }
1.10 ! paf 40:
! 41: void inc(double increment) { fdouble+=increment; }
1.1 paf 42:
43: private:
1.2 paf 44:
1.9 paf 45: double fdouble;
1.1 paf 46:
47: };
48:
49: #endif
E-mail: