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

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.5     ! paf         6:        $Id: pa_vdouble.h,v 1.4 2001/03/11 21:23:59 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: 
                     16: #define MAX_DOUBLE_AS_STRING 20
                     17: 
1.4       paf        18: class VDouble : public VStateless_object {
1.1       paf        19: public: // Value
                     20: 
                     21:        // all: for error reporting after fail(), etc
                     22:        const char *type() const { return "double"; }
                     23:        // double: this
                     24:        Value *get_expr_result() { return this; }
                     25: 
                     26:        // double: fdouble
                     27:        const String *get_string() {
                     28:                char *buf=static_cast<char *>(pool().malloc(MAX_DOUBLE_AS_STRING));
                     29:                snprintf(buf, MAX_DOUBLE_AS_STRING, "%g", fdouble);
                     30:                String *result=NEW String(pool());
                     31:                result->APPEND_CONST(buf);
                     32:                return result;
                     33:        }
                     34:        // double: fdouble
                     35:        double get_double() { return fdouble; }
                     36:        // double: 0 or !0
                     37:        bool get_bool() { return fdouble!=0; }
                     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; }
                     46: 
                     47: private:
                     48: 
                     49:        double fdouble;
                     50: 
                     51: };
                     52: 
                     53: #endif

E-mail: