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

1.1     ! paf         1: /*
        !             2:   $Id: pa_context.h,v 1.7 2001/02/21 11:10:02 paf Exp $
        !             3: */
        !             4: 
        !             5: /*
        !             6:        data core
        !             7: */
        !             8: 
        !             9: #ifndef PA_WCONTEXT_H
        !            10: #define PA_WCONTEXT_H
        !            11: 
        !            12: #include "pa_value.h"
        !            13: 
        !            14: class WContext : public Value {
        !            15: public:
        !            16:        WContext(Pool& apool) : Pooled(apool), string(apool) {}
        !            17: 
        !            18:        // appends a string to result
        !            19:        // until Value written, ignores afterwards
        !            20:        void write(String& astring);
        !            21:        // if value.string!=0 writes string altogether[for showing class names, etc]
        !            22:        // writes Value; raises an error if already
        !            23:        void write(Value& avalue);
        !            24:        //void write(String_iterator& from, String_iterator& to);
        !            25: 
        !            26:        // retrives the resulting value
        !            27:        // that can be Text if value==0 or the Value object
        !            28:        Value *value() const {
        !            29:                return value?value:new Text(string);
        !            30:        }
        !            31:        
        !            32: public: //implement by replicating to value->calls
        !            33: 
        !            34:        const char *get_type() const { return "WContext"; }
        !            35: 
        !            36:        String *get_string() const { return &string };
        !            37:        void put_string(const String *astring) { check(value)->put_string(astring); };
        !            38: 
        !            39:        Method_ref *get_method_ref() const { return check(value)->get_method_ref(); }
        !            40: 
        !            41:        Value *get_element(const String& name) const { return check(value)->get_element(name); }
        !            42:        void put_element(const String& name, const Value *avalue){ check(value)->put_element(name, avalue); }
        !            43: 
        !            44:        Method *get_method(const String& name) const { return check(value)->get_method(name); }
        !            45: 
        !            46:        Class *get_class() const { return value?value->get_class():0; }
        !            47:        bool has_parent(Class *aparent) { return value?value->has_parent(aparent):false; }
        !            48: 
        !            49: private:
        !            50:        String string;
        !            51:        Value *value;
        !            52: 
        !            53: private:
        !            54:        // raises an exception on 0 value
        !            55:        Value *check(const Value *value);
        !            56: };
        !            57: 
        !            58: #endif

E-mail: