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

1.1       paf         1: /*
1.3     ! paf         2:   $Id: pa_vdouble.h,v 1.2 2001/03/06 14:09:35 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #ifndef PA_VDOUBLE_H
                      6: #define PA_VDOUBLE_H
                      7: 
                      8: #include "pa_value.h"
1.2       paf         9: #include "pa_common.h"
                     10: 
1.3     ! paf        11: #define MAX_DOUBLE_AS_STRING 20
1.1       paf        12: 
                     13: class VDouble : public Value {
                     14: public: // Value
                     15: 
                     16:        // all: for error reporting after fail(), etc
                     17:        const char *type() const { return "Double"; }
                     18:        // double: value
1.2       paf        19:        String *get_string() {
1.3     ! paf        20:                char *buf=static_cast<char *>(pool().malloc(MAX_DOUBLE_AS_STRING));
        !            21:                snprintf(buf, MAX_DOUBLE_AS_STRING, "%g", value);
1.2       paf        22:                String *result=NEW String(pool());
                     23:                result->APPEND_CONST(buf);
                     24:                return result;
                     25:        };
                     26:        // double: value
1.1       paf        27:        double get_double() { return value; };
                     28: 
                     29: public: // usage
                     30: 
                     31:        VDouble(Pool& apool, double avalue=0) : Value(apool), 
                     32:                value(avalue) {
                     33:        }
                     34: 
                     35: private:
1.2       paf        36: 
1.1       paf        37:        double value;
                     38: 
                     39: };
                     40: 
                     41: #endif

E-mail: