Annotation of parser3/src/types/pa_vdouble.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_vdouble.h,v 1.12 2001/03/10 16:34:36 paf Exp $
! 7: */
! 8:
! 9: #ifndef PA_VDOUBLE_H
! 10: #define PA_VDOUBLE_H
! 11:
! 12: #include "pa_value.h"
! 13: #include "pa_common.h"
! 14: #include "_double.h"
! 15:
! 16: #define MAX_DOUBLE_AS_STRING 20
! 17:
! 18: class VDouble : public VObject {
! 19: public: // Value
! 20:
! 21: // all: for error reporting after fail(), etc
! 22: const char *type() const { return "double"; }
! 23: // double: this
! 24: Value *get_expr_result() { return this; }
! 25:
! 26: // double: fdouble
! 27: const String *get_string() {
! 28: char *buf=static_cast<char *>(pool().malloc(MAX_DOUBLE_AS_STRING));
! 29: snprintf(buf, MAX_DOUBLE_AS_STRING, "%g", fdouble);
! 30: String *result=NEW String(pool());
! 31: result->APPEND_CONST(buf);
! 32: return result;
! 33: }
! 34: // double: fdouble
! 35: double get_double() { return fdouble; }
! 36: // double: 0 or !0
! 37: bool get_bool() { return fdouble!=0; }
! 38:
! 39: public: // usage
! 40:
! 41: VDouble(Pool& apool, double adouble) : VObject(apool, *double_class),
! 42: fdouble(adouble) {
! 43: }
! 44:
! 45: void inc(double increment) { fdouble+=increment; }
! 46:
! 47: private:
! 48:
! 49: double fdouble;
! 50:
! 51: };
! 52:
! 53: #endif
E-mail: