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

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.2       paf         5:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1       paf         6: 
1.18    ! paf         7:        $Id: pa_wcontext.h,v 1.17 2001/09/26 10:32:26 parser 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.1       paf        25: public: // Value
                     26: 
                     27:        const char *type() const { return "wcontext"; }
1.12      paf        28:        /// WContext: accumulated fstring
1.1       paf        29:        const String *get_string() { return &fstring; };
                     30: 
1.12      paf        31:        /// WContext: none yet | transparent
1.5       paf        32:        VStateless_class *get_class() { return fvalue?fvalue->get_class():0; }
1.12      paf        33:        /// WContext: transparent
1.1       paf        34:        VAliased *get_aliased() { return fvalue?fvalue->get_aliased():0; }
                     35: 
                     36: public: // WContext
                     37: 
1.12      paf        38:        /// appends a fstring to result
1.1       paf        39:        virtual void write(const String& astring, String::Untaint_lang lang);
1.6       paf        40: 
1.12      paf        41:        /// writes Value; raises an error if already
1.6       paf        42:        virtual void write(Value& avalue);
1.1       paf        43: 
1.12      paf        44:        /**
                     45:                if value is VString writes fstring,
                     46:                else writes Value; raises an error if already
                     47:        */
1.1       paf        48:        virtual void write(Value& avalue, String::Untaint_lang lang);
                     49: 
1.12      paf        50:        /**
                     51:                retrives the resulting value
                     52:                that can be VString if value==0 or the Value object
                     53:                wmethod_frame first checks for $result and if there is one, returns it instead
                     54:        */
1.9       paf        55:        virtual Value *result() {
1.7       paf        56:                return fvalue?fvalue:NEW VString(fstring);
                     57:        }
                     58: 
1.1       paf        59: public: // usage
                     60: 
1.16      parser     61:        WContext(Pool& apool, Value *avalue) : Value(apool), 
1.7       paf        62:                fstring(*new(apool) String(apool)),
1.16      parser     63:                fconstructing(false), fvalue(avalue),
1.14      paf        64:                fsomebody_entered_some_class(false),
                     65:                fsomebody_entered_some_object(0){
1.1       paf        66:        }
                     67: 
                     68:        bool constructing() { return fconstructing; }
1.10      paf        69:        void constructing(bool aconstructing) { fconstructing=aconstructing; }
1.4       paf        70:        void set_somebody_entered_some_class() { fsomebody_entered_some_class=true; }
                     71:        bool somebody_entered_some_class() { return fsomebody_entered_some_class; }
1.1       paf        72: 
1.14      paf        73:        void inc_somebody_entered_some_object() { fsomebody_entered_some_object++; }
                     74:        int somebody_entered_some_object() { return fsomebody_entered_some_object; }
                     75:        void clear_somebody_entered_some_object() { fsomebody_entered_some_object=0; }
                     76: 
1.1       paf        77: protected:
1.7       paf        78:        String& fstring;
                     79:        bool fconstructing;  Value *fvalue;
1.1       paf        80: private:
1.4       paf        81:        bool fsomebody_entered_some_class;
1.14      paf        82:        int fsomebody_entered_some_object;
1.1       paf        83: };
                     84: 
                     85: #endif

E-mail: