Annotation of parser3/src/types/pa_vint.h, revision 1.4
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.4 ! paf 6: $Id: pa_vint.h,v 1.3 2001/03/11 12:22:00 paf Exp $
1.1 paf 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:
1.4 ! paf 18: class VInt : public VStateless_object {
1.1 paf 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:
1.4 ! paf 41: VInt(Pool& apool, int ainteger) : VStateless_object(apool, *int_class),
1.1 paf 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: