Annotation of parser3/src/types/pa_vdouble.h, revision 1.18
1.11 paf 1: /** @file
1.16 paf 2: Parser: @b double parser class decl.
1.11 paf 3:
1.1 paf 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.11 paf 5:
1.2 paf 6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1 paf 7:
1.18 ! paf 8: $Id: pa_vdouble.h,v 1.17 2001/04/28 08:44:15 paf Exp $
1.1 paf 9: */
10:
11: #ifndef PA_VDOUBLE_H
12: #define PA_VDOUBLE_H
13:
1.18 ! paf 14: #include "pa_methoded.h"
1.9 paf 15: #include "pa_common.h"
1.5 paf 16: #include "pa_vstateless_object.h"
1.17 paf 17:
18: extern Methoded *double_class;
1.1 paf 19:
1.11 paf 20: /// value of type 'double'. implemented with @c double
1.4 paf 21: class VDouble : public VStateless_object {
1.1 paf 22: public: // Value
23:
1.11 paf 24: /// all: for error reporting after fail(), etc
1.1 paf 25: const char *type() const { return "double"; }
1.11 paf 26: /// VDouble: this
1.14 paf 27: Value *as_expr_result(bool return_string_as_is=false) { return this; }
1.1 paf 28:
1.11 paf 29: /// VDouble: fdouble
1.1 paf 30: const String *get_string() {
1.6 paf 31: char *buf=(char *)pool().malloc(MAX_NUMBER);
32: snprintf(buf, MAX_NUMBER, "%g", fdouble);
1.8 paf 33: return NEW String(pool(), buf);
1.1 paf 34: }
1.11 paf 35: /// VDouble: fdouble
1.14 paf 36: double as_double() { return fdouble; }
1.11 paf 37: /// VDouble: 0 or !0
1.14 paf 38: bool as_bool() { return fdouble!=0; }
1.10 paf 39:
40: protected: // VAliased
41:
1.13 paf 42: /// disable .CLASS element. @see VAliased::get_element
1.15 paf 43: bool hide_class() { return true; }
1.1 paf 44:
45: public: // usage
46:
1.4 paf 47: VDouble(Pool& apool, double adouble) : VStateless_object(apool, *double_class),
1.1 paf 48: fdouble(adouble) {
49: }
50:
51: void inc(double increment) { fdouble+=increment; }
1.7 paf 52: void mul(double k) { fdouble*=k; }
53: void div(double d) { fdouble/=d; }
54: void mod(int d) { fdouble=((int)fdouble)%d; }
1.1 paf 55:
56: private:
57:
58: double fdouble;
59:
60: };
61:
62: #endif
E-mail: