|
|
| version 1.9, 2001/03/06 17:03:17 | version 1.17, 2001/03/10 16:34:37 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| $Id$ | Parser |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | |
| Author: Alexander Petrosyan <paf@design.ru> | |
| $Id$ | |
| */ | */ |
| #ifndef PA_VSTRING_H | #ifndef PA_VSTRING_H |
| Line 8 | Line 12 |
| #include <stdlib.h> | #include <stdlib.h> |
| #include "pa_value.h" | #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 | public: // Value |
| // all: for error reporting after fail(), etc | // all: for error reporting after fail(), etc |
| const char *type() const { return "string"; } | const char *type() const { return "string"; } |
| // value: value | // string: fvalue as VDouble |
| String *get_string() { return &value; }; | Value *get_expr_result() { return NEW VDouble(pool(), get_double()); } |
| // value: value | // string: fvalue |
| double get_double() { return atof(value.cstr()); } | const String *get_string() { return &fvalue; }; |
| // value: empty or not | // string: fvalue |
| bool get_bool() { return value.size()!=0; }; | double get_double() { return atof(fvalue.cstr()); } |
| // string: empty or not | |
| bool get_bool() { return fvalue.size()!=0; }; | |
| public: // usage | public: // usage |
| VString(Pool& apool) : Value(apool), | VString(Pool& apool) : VObject(apool, *string_class), |
| value(*new(apool) String(apool)) { | fvalue(*new(string_class->pool()) String(string_class->pool())) { |
| } | } |
| VString(String& avalue) : Value(avalue.pool()), | VString(const String& avalue) : VObject(avalue.pool(), *string_class), |
| value(avalue) { | fvalue(avalue) { |
| } | } |
| const String& value() { return fvalue; } | |
| private: | private: |
| String& value; | const String& fvalue; |
| }; | }; |