Annotation of parser3/src/include/pa_vstring.h, revision 1.16
1.1 paf 1: /*
1.16 ! paf 2: $Id: pa_vstring.h,v 1.15 2001/03/10 11:44:32 paf Exp $
1.1 paf 3: */
4:
5: #ifndef PA_VSTRING_H
6: #define PA_VSTRING_H
7:
1.6 paf 8: #include <stdlib.h>
9:
1.1 paf 10: #include "pa_value.h"
1.13 paf 11: #include "pa_vobject.h"
1.14 paf 12: #include "pa_vdouble.h"
1.13 paf 13: #include "classes/_string.h"
1.1 paf 14:
1.13 paf 15: class VString : public VObject {
1.1 paf 16: public: // Value
17:
18: // all: for error reporting after fail(), etc
1.9 paf 19: const char *type() const { return "string"; }
1.14 paf 20: // string: fvalue as VDouble
21: Value *get_expr_result() { return NEW VDouble(pool(), get_double()); }
22: // string: fvalue
1.15 paf 23: const String *get_string() { return &fvalue; };
1.14 paf 24: // string: fvalue
1.10 paf 25: double get_double() { return atof(fvalue.cstr()); }
1.14 paf 26: // string: empty or not
1.10 paf 27: bool get_bool() { return fvalue.size()!=0; };
1.1 paf 28:
29: public: // usage
30:
1.14 paf 31: VString(Pool& apool) : VObject(apool, *string_class),
1.13 paf 32: fvalue(*new(string_class->pool()) String(string_class->pool())) {
1.2 paf 33: }
34:
1.15 paf 35: VString(const String& avalue) : VObject(avalue.pool(), *string_class),
1.10 paf 36: fvalue(avalue) {
1.1 paf 37: }
1.16 ! paf 38:
! 39: const String& value() { return fvalue; }
1.1 paf 40:
41: private:
1.15 paf 42: const String& fvalue;
1.1 paf 43:
44: };
45:
46: #endif
E-mail: