Annotation of parser3/src/types/pa_vdouble.h, revision 1.8
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1 paf 5:
1.8 ! paf 6: $Id: pa_vdouble.h,v 1.7 2001/03/13 11:52:45 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_VDOUBLE_H
10: #define PA_VDOUBLE_H
11:
1.5 paf 12: #include "pa_vstateless_object.h"
1.1 paf 13: #include "pa_common.h"
14: #include "_double.h"
15:
1.4 paf 16: class VDouble : public VStateless_object {
1.1 paf 17: public: // Value
18:
19: // all: for error reporting after fail(), etc
20: const char *type() const { return "double"; }
21: // double: this
22: Value *get_expr_result() { return this; }
23:
24: // double: fdouble
25: const String *get_string() {
1.6 paf 26: char *buf=(char *)pool().malloc(MAX_NUMBER);
27: snprintf(buf, MAX_NUMBER, "%g", fdouble);
1.8 ! paf 28: return NEW String(pool(), buf);
1.1 paf 29: }
30: // double: fdouble
31: double get_double() { return fdouble; }
32: // double: 0 or !0
33: bool get_bool() { return fdouble!=0; }
34:
35: public: // usage
36:
1.4 paf 37: VDouble(Pool& apool, double adouble) : VStateless_object(apool, *double_class),
1.1 paf 38: fdouble(adouble) {
39: }
40:
41: void inc(double increment) { fdouble+=increment; }
1.7 paf 42: void mul(double k) { fdouble*=k; }
43: void div(double d) { fdouble/=d; }
44: void mod(int d) { fdouble=((int)fdouble)%d; }
1.1 paf 45:
46: private:
47:
48: double fdouble;
49:
50: };
51:
52: #endif
E-mail: