Annotation of parser3/src/include/pa_context.h, revision 1.2

1.1       paf         1: /*
1.2     ! paf         2:   $Id: pa_context.h,v 1.1 2001/02/11 19:35:38 paf Exp $
1.1       paf         3: */
                      4: 
                      5: /*
                      6:        data core
                      7: */
                      8: 
                      9: #ifndef PA_CONTEXT_H
                     10: #define PA_CONTEXT_H
                     11: 
                     12: #include "pa_value.h"
                     13: 
                     14: typedef Value RContext;
                     15: 
                     16: class WContext : public Value {
                     17: public:
                     18: 
                     19:        // appends a string to result
                     20:        // until Value written, ignores afterwards
                     21:        void write(String& astring);
                     22:        // if value.string!=0 writes just string, not Value
                     23:        // raises an error if already
                     24:        void write(Value& avalue);
                     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:        virtual String *get_string() const { return &string };
                     35:        virtual void put_string(const String *astring) { check(value)->put_string(astring); };
                     36: 
                     37:        virtual Value *get_element(const String& name) const { return check(value)->get_element(name); }
                     38:        virtual void put_element(const String& name, const Value *avalue){ check(value)->put_element(name, avalue); }
                     39: 
1.2     ! paf        40:        virtual Method *get_method(const String& name) const { return check(value)->get_method(name); }
        !            41:        virtual Method_ref *get_method_ref() const { return check(value)->get_method_ref(); }
1.1       paf        42: 
                     43: private:
                     44:        String& string;
                     45:        Value *value;
                     46: 
                     47: private:
                     48:        // raises an exception on 0 value
                     49:        Value *check(const Value *value);
                     50: };
                     51: 
                     52: #endif

E-mail: