Annotation of parser3/src/include/pa_vstring.h, revision 1.17

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

E-mail: