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

1.1       paf         1: /*
1.8     ! paf         2:   $Id: pa_wwrapper.h,v 1.7 2001/02/25 14:23:31 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: 
                     25: public: // usage
                     26: 
1.7       paf        27:        WWrapper(Pool& apool, Value *avalue, bool aconstructed) : 
                     28:                WContext(apool, avalue, aconstructed) {
1.1       paf        29:        }
                     30:        
                     31: private:
                     32:        // raises an exception on 0 value
                     33:        Value *check_value() const {
                     34:                if(!fvalue)
                     35:                        THROW(0,0,
                     36:                                0,
1.3       paf        37:                                "accessing wrapper without value");
1.1       paf        38: 
                     39:                return fvalue;
                     40:        }
                     41: };
                     42: 
                     43: #endif

E-mail: