--- parser3/src/include/Attic/pa_wcontext.h 2001/02/23 17:12:57 1.13 +++ parser3/src/include/Attic/pa_wcontext.h 2001/03/10 12:12:50 1.27 @@ -1,5 +1,5 @@ /* - $Id: pa_wcontext.h,v 1.13 2001/02/23 17:12:57 paf Exp $ + $Id: pa_wcontext.h,v 1.27 2001/03/10 12:12:50 paf Exp $ */ #ifndef PA_WCONTEXT_H @@ -9,56 +9,52 @@ #include "pa_vstring.h" #include "pa_vhash.h" +class Request; + class WContext : public Value { + friend Request; public: // Value // all: for error reporting after fail(), etc - const char *type() const { return "WContext"; } - // WContext: accumulated string - String *get_string() { return string; }; + const char *type() const { return "wcontext"; } + // WContext: accumulated fstring + const String *get_string() { return &fstring; }; -public: // usage + // WContext: none yet | transparent + VClass *get_class() { return fvalue?fvalue->get_class():0; } + // wcontext: transparent + VAliased *get_aliased() { return fvalue?fvalue->get_aliased():0; } - WContext(Pool& apool, Value *avalue) : Value(apool), - fvalue(avalue), - string(new(apool) String(apool)) { - } +public: // WContext - // appends a string to result - void write(String *astring) { - if(!astring) - return; + // appends a fstring to result + virtual void write(const String& astring, String::Untaint_lang lang); - *string+=*astring; - } - // if value is VString writes string, + // if value is VString writes fstring, // else writes Value; raises an error if already - void write(Value *avalue) { - if(!avalue) - return; - - String *string=avalue->get_string(); - if(string) - write(string); - else - if(fvalue) // already have value? - THROW(0,0, // don't need to construct twice - fvalue->name(), - "value already assigned, use constructor to reassign it"); - else - fvalue=avalue; + virtual void write(Value& avalue, String::Untaint_lang lang); + +public: // usage + + WContext(Pool& apool, Value *avalue, bool aconstructing) : Value(apool), + fvalue(avalue), + fconstructing(aconstructing), + fstring(*new(apool) String(apool)) { } + bool constructing() { return fconstructing; } + // retrives the resulting value // that can be VString if value==0 or the Value object - Value *value() const { - return fvalue?fvalue:NEW VString(string); + Value *result() const { + return fvalue?fvalue:NEW VString(fstring); } protected: Value *fvalue; private: - String *string; + bool fconstructing; + String& fstring; }; #endif