--- parser3/src/include/Attic/pa_vstring.h 2001/03/08 17:39:08 1.12.2.1 +++ parser3/src/include/Attic/pa_vstring.h 2001/03/10 16:34:37 1.17 @@ -1,5 +1,9 @@ /* - $Id: pa_vstring.h,v 1.12.2.1 2001/03/08 17:39:08 paf Exp $ + Parser + Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan + + $Id: pa_vstring.h,v 1.17 2001/03/10 16:34:37 paf Exp $ */ #ifndef PA_VSTRING_H @@ -9,31 +13,37 @@ #include "pa_value.h" #include "pa_vobject.h" +#include "pa_vdouble.h" +#include "classes/_string.h" class VString : public VObject { public: // Value // all: for error reporting after fail(), etc const char *type() const { return "string"; } - // value: fvalue - String *get_string() { return &fvalue; }; - // value: fvalue + // string: fvalue as VDouble + Value *get_expr_result() { return NEW VDouble(pool(), get_double()); } + // string: fvalue + const String *get_string() { return &fvalue; }; + // string: fvalue double get_double() { return atof(fvalue.cstr()); } - // value: empty or not + // string: empty or not bool get_bool() { return fvalue.size()!=0; }; public: // usage - VString(VClass& aclass) : VObject(aclass), - fvalue(*new(aclass.pool()) String(aclass.pool())) { + VString(Pool& apool) : VObject(apool, *string_class), + fvalue(*new(string_class->pool()) String(string_class->pool())) { } - VString(VClass& aclass, String& avalue) : VObject(aclass), + VString(const String& avalue) : VObject(avalue.pool(), *string_class), fvalue(avalue) { } + const String& value() { return fvalue; } + private: - String& fvalue; + const String& fvalue; };