Annotation of parser3/src/include/pa_vdouble.h, revision 1.5
1.1 paf 1: /*
1.5 ! paf 2: $Id: pa_vdouble.h,v 1.4 2001/03/06 15:02:46 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"
10:
1.3 paf 11: #define MAX_DOUBLE_AS_STRING 20
1.1 paf 12:
13: class VDouble : public Value {
14: public: // Value
15:
16: // all: for error reporting after fail(), etc
1.4 paf 17: const char *type() const { return "double"; }
1.1 paf 18: // double: value
1.2 paf 19: String *get_string() {
1.3 paf 20: char *buf=static_cast<char *>(pool().malloc(MAX_DOUBLE_AS_STRING));
21: snprintf(buf, MAX_DOUBLE_AS_STRING, "%g", value);
1.2 paf 22: String *result=NEW String(pool());
23: result->APPEND_CONST(buf);
24: return result;
25: };
26: // double: value
1.1 paf 27: double get_double() { return value; };
1.5 ! paf 28: // double: 0 or !0
! 29: bool get_bool() { return value!=0; };
1.1 paf 30:
31: public: // usage
32:
33: VDouble(Pool& apool, double avalue=0) : Value(apool),
34: value(avalue) {
35: }
36:
37: private:
1.2 paf 38:
1.1 paf 39: double value;
40:
41: };
42:
43: #endif
E-mail: