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

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

E-mail: