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

1.12    ! paf         1: /**    @file
        !             2:        Parser: write context class decl.
        !             3: 
1.1       paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.12    ! paf         5: 
1.2       paf         6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1       paf         7: 
1.12    ! paf         8:        $Id: pa_wcontext.h,v 1.11 2001/04/12 13:15:25 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_WCONTEXT_H
                     12: #define PA_WCONTEXT_H
                     13: 
                     14: #include "pa_value.h"
                     15: #include "pa_vstring.h"
                     16: #include "pa_vhash.h"
                     17: 
                     18: class Request;
                     19: 
1.12    ! paf        20: /** Write context
        !            21:        they do different write()s here, later picking up the result
        !            22:        @see Request::wcontext
        !            23: */
1.1       paf        24: class WContext : public Value {
                     25:        friend Request;
                     26: public: // Value
                     27: 
1.12    ! paf        28:        /// all: for error reporting after fail(), etc
1.1       paf        29:        const char *type() const { return "wcontext"; }
1.12    ! paf        30:        /// WContext: accumulated fstring
1.1       paf        31:        const String *get_string() { return &fstring; };
                     32: 
1.12    ! paf        33:        /// WContext: none yet | transparent
1.5       paf        34:        VStateless_class *get_class() { return fvalue?fvalue->get_class():0; }
1.12    ! paf        35:        /// WContext: transparent
1.1       paf        36:        VAliased *get_aliased() { return fvalue?fvalue->get_aliased():0; }
                     37: 
                     38: public: // WContext
                     39: 
1.12    ! paf        40:        /// appends a fstring to result
1.1       paf        41:        virtual void write(const String& astring, String::Untaint_lang lang);
1.6       paf        42: 
1.12    ! paf        43:        /// writes Value; raises an error if already
1.6       paf        44:        virtual void write(Value& avalue);
1.1       paf        45: 
1.12    ! paf        46:        /**
        !            47:                if value is VString writes fstring,
        !            48:                else writes Value; raises an error if already
        !            49:        */
1.1       paf        50:        virtual void write(Value& avalue, String::Untaint_lang lang);
                     51: 
1.12    ! paf        52:        /**
        !            53:                retrives the resulting value
        !            54:                that can be VString if value==0 or the Value object
        !            55:                wmethod_frame first checks for $result and if there is one, returns it instead
        !            56:        */
1.9       paf        57:        virtual Value *result() {
                     58:                // not constructing anymore [if were constructing]
                     59:                // so to allow method calls after real constructor-method call
                     60:                // sample:
                     61:                //      $complex[
                     62:                //              $class:constructor[$i]
                     63:                //              ^i.inc[]  ^rem{allow such calls}
                     64:                //              $field[$1]
                     65:                fconstructing=false;
1.7       paf        66:                return fvalue?fvalue:NEW VString(fstring);
                     67:        }
                     68: 
1.1       paf        69: public: // usage
                     70: 
                     71:        WContext(Pool& apool, Value *avalue, bool aconstructing) : Value(apool), 
1.7       paf        72:                fstring(*new(apool) String(apool)),
                     73:                fconstructing(aconstructing), fvalue(avalue),
1.8       paf        74:                fsomebody_entered_some_class(false),
                     75:                fsomebody_entered_some_object(0){
1.1       paf        76:        }
                     77: 
                     78:        bool constructing() { return fconstructing; }
1.10      paf        79:        void constructing(bool aconstructing) { fconstructing=aconstructing; }
1.4       paf        80:        void set_somebody_entered_some_class() { fsomebody_entered_some_class=true; }
                     81:        bool somebody_entered_some_class() { return fsomebody_entered_some_class; }
1.1       paf        82: 
1.8       paf        83:        void inc_somebody_entered_some_object() { fsomebody_entered_some_object++; }
                     84:        int somebody_entered_some_object() { return fsomebody_entered_some_object; }
1.11      paf        85:        void clear_somebody_entered_some_object() { fsomebody_entered_some_object=0; }
1.8       paf        86: 
1.1       paf        87: protected:
1.7       paf        88:        String& fstring;
                     89:        bool fconstructing;  Value *fvalue;
1.1       paf        90: private:
1.4       paf        91:        bool fsomebody_entered_some_class;
1.8       paf        92:        int fsomebody_entered_some_object;
1.1       paf        93: };
                     94: 
                     95: #endif

E-mail: