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

1.1       paf         1: /*
1.12    ! paf         2:   $Id: pa_wcontext.h,v 1.11 2001/02/23 12:47:08 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #ifndef PA_WCONTEXT_H
                      6: #define PA_WCONTEXT_H
                      7: 
1.12    ! paf         8: #include "pa_wvalue.h"
1.1       paf         9: 
1.12    ! paf        10: class WContext : public WValue {
1.2       paf        11: public: // Value
                     12: 
                     13:        // all: for error reporting after fail(), etc
1.5       paf        14:        const char *type() const { return "WContext"; }
1.2       paf        15:        // wcontext: transparent
1.8       paf        16:        Value *get_element(const String& name) { return check_value()->get_element(name); }
1.2       paf        17:        // wcontext: transparent
1.10      paf        18:        void put_element(const String& name, Value *avalue){ 
                     19:                if(!fvalue)
                     20:                        fvalue=NEW VHash(pool());
                     21:                fvalue->put_element(name, avalue); 
                     22:        }
                     23: 
1.2       paf        24:        // wcontext: transparent
1.5       paf        25:        Method *get_method(const String& name) const { return check_value()->get_method(name); }
1.2       paf        26:        // wcontext: none yet | transparent
1.5       paf        27:        VClass *get_class() const { return fvalue?fvalue->get_class():0; }
1.2       paf        28:        // wcontext: none yet | transparent
1.5       paf        29:        bool is_or_derived_from(VClass& ancestor) { return fvalue?fvalue->is_or_derived_from(ancestor):false; }
1.2       paf        30: 
                     31: public: // usage
                     32: 
1.12    ! paf        33:        WContext(Pool& apool, Value *avalue) : WValue(apool, avalue) {
1.1       paf        34:        }
                     35:        
                     36: private:
                     37:        // raises an exception on 0 value
1.2       paf        38:        Value *check_value() const {
                     39:                if(!fvalue)
1.6       paf        40:                        THROW(0,0,
1.2       paf        41:                                0,
                     42:                                "accessing wcontext without value");
                     43: 
                     44:                return fvalue;
                     45:        }
1.1       paf        46: };
                     47: 
                     48: #endif

E-mail: