Annotation of parser3/src/types/pa_vstring.h, revision 1.5

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.5     ! paf         6:        $Id: pa_vstring.h,v 1.4 2001/03/11 21:23:59 paf Exp $
1.1       paf         7: */
                      8: 
                      9: #ifndef PA_VSTRING_H
                     10: #define PA_VSTRING_H
                     11: 
                     12: #include <stdlib.h>
                     13: 
1.4       paf        14: #include "pa_vstateless_object.h"
1.1       paf        15: #include "pa_vdouble.h"
                     16: #include "_string.h"
                     17: 
1.4       paf        18: class VString : public VStateless_object {
1.1       paf        19: public: // Value
                     20: 
                     21:        // all: for error reporting after fail(), etc
                     22:        const char *type() const { return "string"; }
                     23:        // string: fvalue as VDouble
                     24:        Value *get_expr_result() { return NEW VDouble(pool(), get_double()); }
                     25:        // string: fvalue
                     26:        const String *get_string() { return &fvalue; };
                     27:        // string: fvalue
                     28:        double get_double() { return atof(fvalue.cstr()); }
                     29:        // string: empty or not
                     30:        bool get_bool() { return fvalue.size()!=0; };
                     31: 
                     32: public: // usage
                     33: 
1.4       paf        34:        VString(Pool& apool) : VStateless_object(apool, *string_class), 
1.5     ! paf        35:                fvalue(*new(apool) String(apool)) {
1.1       paf        36:        }
                     37: 
1.4       paf        38:        VString(const String& avalue) : VStateless_object(avalue.pool(), *string_class),
1.1       paf        39:                fvalue(avalue) {
                     40:        }
                     41: 
                     42:        const String& value() { return fvalue; }
                     43: 
                     44: private:
                     45:        const String& fvalue;
                     46: 
                     47: };
                     48: 
                     49: #endif

E-mail: