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

1.1       paf         1: /*
1.4     ! paf         2:   $Id: pa_wwrapper.h,v 1.3 2001/02/24 11:20:32 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"; }
1.4     ! paf        16:        // wwrapper: transparent
1.1       paf        17:        Value *get_element(const String& name) { return check_value()->get_element(name); }
1.4     ! paf        18:        // wwrapper: transparent
1.1       paf        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: 
1.4     ! paf        25:        // wwrapper: none yet | transparent
1.1       paf        26:        VClass *get_class() const { return fvalue?fvalue->get_class():0; }
1.4     ! paf        27:        // wwrapper: none yet | transparent
1.1       paf        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: