Annotation of parser3/src/include/pa_wwrapper.h, revision 1.1

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

E-mail: