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

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

E-mail: