Annotation of parser3/src/include/pa_vdouble.h, revision 1.12

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

E-mail: