Annotation of parser3/src/types/pa_vdouble.h, revision 1.10

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.10    ! paf         6:        $Id: pa_vdouble.h,v 1.9 2001/03/19 16:06:16 paf Exp $
1.1       paf         7: */
                      8: 
                      9: #ifndef PA_VDOUBLE_H
                     10: #define PA_VDOUBLE_H
                     11: 
1.9       paf        12: #include "pa_common.h"
1.5       paf        13: #include "pa_vstateless_object.h"
1.1       paf        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; }
1.10    ! paf        34: 
        !            35: protected: // VAliased
        !            36: 
        !            37:        VStateless_class *get_class_alias() { return 0; }
1.1       paf        38: 
                     39: public: // usage
                     40: 
1.4       paf        41:        VDouble(Pool& apool, double adouble) : VStateless_object(apool, *double_class), 
1.1       paf        42:                fdouble(adouble) {
                     43:        }
                     44: 
                     45:        void inc(double increment) { fdouble+=increment; }
1.7       paf        46:        void mul(double k) { fdouble*=k; }
                     47:        void div(double d) { fdouble/=d; }
                     48:        void mod(int d) { fdouble=((int)fdouble)%d; }
1.1       paf        49: 
                     50: private:
                     51: 
                     52:        double fdouble;
                     53: 
                     54: };
                     55: 
                     56: #endif

E-mail: