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

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.6     ! paf         6:        $Id: pa_vdouble.h,v 1.5 2001/03/12 12:00:07 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.1       paf        28:                String *result=NEW String(pool());
                     29:                result->APPEND_CONST(buf);
                     30:                return result;
                     31:        }
                     32:        // double: fdouble
                     33:        double get_double() { return fdouble; }
                     34:        // double: 0 or !0
                     35:        bool get_bool() { return fdouble!=0; }
                     36: 
                     37: public: // usage
                     38: 
1.4       paf        39:        VDouble(Pool& apool, double adouble) : VStateless_object(apool, *double_class), 
1.1       paf        40:                fdouble(adouble) {
                     41:        }
                     42: 
                     43:        void inc(double increment) { fdouble+=increment; }
                     44: 
                     45: private:
                     46: 
                     47:        double fdouble;
                     48: 
                     49: };
                     50: 
                     51: #endif

E-mail: