Annotation of parser3/src/types/pa_wcontext.h, revision 1.28

1.12      paf         1: /**    @file
                      2:        Parser: write context class decl.
                      3: 
1.26      paf         4:        Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
1.27      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       paf         6: 
1.28    ! paf         7:        $Id: pa_wcontext.h,v 1.27 2002/02/08 08:30:21 paf Exp $
1.1       paf         8: */
                      9: 
                     10: #ifndef PA_WCONTEXT_H
                     11: #define PA_WCONTEXT_H
                     12: 
                     13: #include "pa_value.h"
                     14: #include "pa_vstring.h"
                     15: #include "pa_vhash.h"
                     16: 
                     17: class Request;
                     18: 
1.12      paf        19: /** Write context
                     20:        they do different write()s here, later picking up the result
                     21:        @see Request::wcontext
                     22: */
1.1       paf        23: class WContext : public Value {
1.18      paf        24:        friend class Request;
1.19      paf        25: 
1.1       paf        26: public: // Value
                     27: 
                     28:        const char *type() const { return "wcontext"; }
1.12      paf        29:        /// WContext: accumulated fstring
1.1       paf        30:        const String *get_string() { return &fstring; };
                     31: 
1.12      paf        32:        /// WContext: none yet | transparent
1.5       paf        33:        VStateless_class *get_class() { return fvalue?fvalue->get_class():0; }
1.12      paf        34:        /// WContext: transparent
1.1       paf        35:        VAliased *get_aliased() { return fvalue?fvalue->get_aliased():0; }
                     36: 
                     37: public: // WContext
                     38: 
1.12      paf        39:        /// appends a fstring to result
1.22      paf        40:        virtual void write(const String& astring, uchar lang);
1.6       paf        41: 
1.12      paf        42:        /// writes Value; raises an error if already
1.6       paf        43:        virtual void write(Value& avalue);
1.1       paf        44: 
1.12      paf        45:        /**
                     46:                if value is VString writes fstring,
                     47:                else writes Value; raises an error if already
                     48:        */
1.22      paf        49:        virtual void write(Value& avalue, uchar lang);
1.1       paf        50: 
1.12      paf        51:        /**
                     52:                retrives the resulting value
                     53:                that can be VString if value==0 or the Value object
                     54:                wmethod_frame first checks for $result and if there is one, returns it instead
                     55:        */
1.23      paf        56:        virtual Value& result() {
                     57:                return *(fvalue?fvalue:NEW VString(fstring));
1.7       paf        58:        }
                     59: 
1.1       paf        60: public: // usage
                     61: 
1.16      parser     62:        WContext(Pool& apool, Value *avalue) : Value(apool), 
1.7       paf        63:                fstring(*new(apool) String(apool)),
1.20      paf        64:                fvalue(avalue) {
                     65:                flags.constructing=
                     66:                        flags.entered_class=
                     67:                        flags.entered_object=0;
1.1       paf        68:        }
                     69: 
1.20      paf        70:        void set_constructing(bool aconstructing) { flags.constructing=aconstructing?1:0; }
                     71:        bool get_constructing() { return flags.constructing!=0; }
1.19      paf        72: 
1.28    ! paf        73:        void set_in_expression(bool ain_expression) { flags.in_expression=ain_expression?1:0; }
        !            74:        bool get_in_expression() { return flags.in_expression!=0; }
        !            75: 
1.25      paf        76:        void set_somebody_entered_some_class() { flags.entered_class=1; }
1.20      paf        77:        bool get_somebody_entered_some_class() { return flags.entered_class!=0; }
1.19      paf        78: 
                     79:        void set_somebody_entered_some_object(bool aentered_object) {   
1.24      paf        80:                flags.entered_object=aentered_object?1:0; 
                     81:        }
1.20      paf        82:        bool get_somebody_entered_some_object() { return flags.entered_object!=0; }
1.14      paf        83: 
1.1       paf        84: protected:
1.7       paf        85:        String& fstring;
1.19      paf        86:        Value *fvalue;
1.1       paf        87: private:
1.19      paf        88:        struct {
1.20      paf        89:                int constructing:1;
1.28    ! paf        90:                int in_expression:1;
1.20      paf        91:                int entered_object:1;
                     92:                int entered_class:1;
                     93:        } flags;
1.1       paf        94: };
                     95: 
                     96: #endif

E-mail: