--- parser3/src/include/Attic/pa_wcontext.h 2001/02/22 15:39:22 1.8 +++ parser3/src/include/Attic/pa_wcontext.h 2001/02/23 17:12:57 1.13 @@ -1,9 +1,5 @@ /* - $Id: pa_wcontext.h,v 1.8 2001/02/22 15:39:22 paf Exp $ -*/ - -/* - data core + $Id: pa_wcontext.h,v 1.13 2001/02/23 17:12:57 paf Exp $ */ #ifndef PA_WCONTEXT_H @@ -11,24 +7,15 @@ #include "pa_value.h" #include "pa_vstring.h" +#include "pa_vhash.h" class WContext : public Value { public: // Value // all: for error reporting after fail(), etc const char *type() const { return "WContext"; } - // wcontext: accumulated string + // WContext: accumulated string String *get_string() { return string; }; - // wcontext: transparent - Value *get_element(const String& name) { return check_value()->get_element(name); } - // wcontext: transparent - void put_element(const String& name, Value *avalue){ check_value()->put_element(name, avalue); } - // wcontext: transparent - Method *get_method(const String& name) const { return check_value()->get_method(name); } - // wcontext: none yet | transparent - VClass *get_class() const { return fvalue?fvalue->get_class():0; } - // wcontext: none yet | transparent - bool is_or_derived_from(VClass& ancestor) { return fvalue?fvalue->is_or_derived_from(ancestor):false; } public: // usage @@ -56,7 +43,7 @@ public: // usage else if(fvalue) // already have value? THROW(0,0, // don't need to construct twice - 0, + fvalue->name(), "value already assigned, use constructor to reassign it"); else fvalue=avalue; @@ -67,21 +54,11 @@ public: // usage Value *value() const { return fvalue?fvalue:NEW VString(string); } - -private: - String *string; - Value *fvalue; +protected: + Value *fvalue; private: - // raises an exception on 0 value - Value *check_value() const { - if(!fvalue) - THROW(0,0, - 0, - "accessing wcontext without value"); - - return fvalue; - } + String *string; }; #endif