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

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

E-mail: