Annotation of parser3/src/include/pa_vint.h, revision 1.1

1.1     ! paf         1: /*
        !             2:   $Id: pa_vinteger.h,v 1.9 2001/03/08 17:14:51 paf Exp $
        !             3: */
        !             4: 
        !             5: #ifndef PA_VINT_H
        !             6: #define PA_VINT_H
        !             7: 
        !             8: #include "pa_value.h"
        !             9: #include "pa_common.h"
        !            10: #include "classes/_int.h"
        !            11: 
        !            12: #define MAX_INT_AS_STRING 20
        !            13: 
        !            14: class VInt : public VObject {
        !            15: public: // Value
        !            16: 
        !            17:        // all: for error reporting after fail(), etc
        !            18:        const char *type() const { return "integer"; }
        !            19:        // int: this
        !            20:        Value *get_expr_result() { return this; }
        !            21: 
        !            22:        // integer: finteger
        !            23:        String *get_string() {
        !            24:                char *buf=static_cast<char *>(pool().malloc(MAX_INT_AS_STRING));
        !            25:                snprintf(buf, MAX_INT_AS_STRING, "%d", finteger);
        !            26:                String *result=NEW String(pool());
        !            27:                result->APPEND_CONST(buf);
        !            28:                return result;
        !            29:        }
        !            30:        // integer: finteger
        !            31:        double get_double() { return finteger; }
        !            32:        // integer: 0 or !0
        !            33:        bool get_bool() { return finteger!=0; }
        !            34: 
        !            35: public: // usage
        !            36: 
        !            37:        VInt(Pool& apool, int ainteger) : VObject(apool, *int_class), 
        !            38:                finteger(ainteger) {
        !            39:        }
        !            40: 
        !            41:        int get_int() { return finteger; }
        !            42: 
        !            43:        void inc(int increment) { finteger+=increment; }
        !            44: 
        !            45: private:
        !            46: 
        !            47:        int finteger;
        !            48: 
        !            49: };
        !            50: 
        !            51: #endif

E-mail: