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

1.1     ! paf         1: /*
        !             2:   $Id: pa_table.h,v 1.7 2001/01/30 13:43:43 paf Exp $
        !             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: 
        !            40:        virtual Value *get_THIS() const { return check(value)->get_THIS(); }
        !            41:        virtual String *get_code(const String& name) const { return check(value)->get_code(name); }
        !            42:        virtual String *get_code() const { return check(value)->get_code(); }
        !            43: 
        !            44: private:
        !            45:        String& string;
        !            46:        Value *value;
        !            47: 
        !            48: private:
        !            49:        // raises an exception on 0 value
        !            50:        Value *check(const Value *value);
        !            51: };
        !            52: 
        !            53: #endif

E-mail: