Annotation of parser3/src/types/pa_vstring.h, revision 1.3
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1 paf 5:
1.3 ! paf 6: $Id: pa_vstring.h,v 1.2 2001/03/11 08:16:38 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_VSTRING_H
10: #define PA_VSTRING_H
11:
12: #include <stdlib.h>
13:
14: #include "pa_value.h"
1.3 ! paf 15: #include "pa_vobject_base.h"
1.1 paf 16: #include "pa_vdouble.h"
17: #include "_string.h"
18:
1.3 ! paf 19: class VString : public VObject_base {
1.1 paf 20: public: // Value
21:
22: // all: for error reporting after fail(), etc
23: const char *type() const { return "string"; }
24: // string: fvalue as VDouble
25: Value *get_expr_result() { return NEW VDouble(pool(), get_double()); }
26: // string: fvalue
27: const String *get_string() { return &fvalue; };
28: // string: fvalue
29: double get_double() { return atof(fvalue.cstr()); }
30: // string: empty or not
31: bool get_bool() { return fvalue.size()!=0; };
32:
33: public: // usage
34:
1.3 ! paf 35: VString(Pool& apool) : VObject_base(apool, *string_class),
1.1 paf 36: fvalue(*new(string_class->pool()) String(string_class->pool())) {
37: }
38:
1.3 ! paf 39: VString(const String& avalue) : VObject_base(avalue.pool(), *string_class),
1.1 paf 40: fvalue(avalue) {
41: }
42:
43: const String& value() { return fvalue; }
44:
45: private:
46: const String& fvalue;
47:
48: };
49:
50: #endif
E-mail: