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

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.16    ! parser      8:        $Id: pa_wcontext.h,v 1.15 2001/05/07 14:00:55 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: 
                     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.1       paf        40:        virtual void write(const String& astring, String::Untaint_lang 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.1       paf        49:        virtual void write(Value& avalue, String::Untaint_lang lang);
                     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.9       paf        56:        virtual Value *result() {
1.7       paf        57:                return fvalue?fvalue:NEW VString(fstring);
                     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.16    ! parser     64:                fconstructing(false), fvalue(avalue),
1.14      paf        65:                fsomebody_entered_some_class(false),
                     66:                fsomebody_entered_some_object(0){
1.1       paf        67:        }
                     68: 
                     69:        bool constructing() { return fconstructing; }
1.10      paf        70:        void constructing(bool aconstructing) { fconstructing=aconstructing; }
1.4       paf        71:        void set_somebody_entered_some_class() { fsomebody_entered_some_class=true; }
                     72:        bool somebody_entered_some_class() { return fsomebody_entered_some_class; }
1.1       paf        73: 
1.14      paf        74:        void inc_somebody_entered_some_object() { fsomebody_entered_some_object++; }
                     75:        int somebody_entered_some_object() { return fsomebody_entered_some_object; }
                     76:        void clear_somebody_entered_some_object() { fsomebody_entered_some_object=0; }
                     77: 
1.1       paf        78: protected:
1.7       paf        79:        String& fstring;
                     80:        bool fconstructing;  Value *fvalue;
1.1       paf        81: private:
1.4       paf        82:        bool fsomebody_entered_some_class;
1.14      paf        83:        int fsomebody_entered_some_object;
1.1       paf        84: };
                     85: 
                     86: #endif

E-mail: