--- parser3/src/include/Attic/pa_vstring.h 2001/02/22 13:52:25 1.2 +++ parser3/src/include/Attic/pa_vstring.h 2001/03/10 16:34:37 1.17 @@ -1,36 +1,49 @@ /* - $Id: pa_vstring.h,v 1.2 2001/02/22 13:52:25 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 #define PA_VSTRING_H +#include + #include "pa_value.h" +#include "pa_vobject.h" +#include "pa_vdouble.h" +#include "classes/_string.h" -class VString : public Value { +class VString : public VObject { public: // Value // all: for error reporting after fail(), etc - const char *type() const { return "VString"; } - // string: value - String *get_string() { return string; }; - // string: value - void put_string(String *astring) { string=astring; } + const char *type() const { return "string"; } + // 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()); } + // string: empty or not + bool get_bool() { return fvalue.size()!=0; }; public: // usage - VString(Pool& apool) : Value(apool), - string(new(apool) String(apool)) { + VString(Pool& apool) : VObject(apool, *string_class), + fvalue(*new(string_class->pool()) String(string_class->pool())) { } - VString(String *astring) : Value(astring->pool()), - string(astring) { + VString(const String& avalue) : VObject(avalue.pool(), *string_class), + fvalue(avalue) { } - operator String() { return *string; } + const String& value() { return fvalue; } private: - String *string; + const String& fvalue; };