Annotation of parser3/src/include/pa_wcontext.h, revision 1.13
1.1 paf 1: /*
1.13 ! paf 2: $Id: pa_WContext.h,v 1.11 2001/02/23 12:47:08 paf Exp $
1.1 paf 3: */
4:
5: #ifndef PA_WCONTEXT_H
6: #define PA_WCONTEXT_H
7:
1.13 ! paf 8: #include "pa_value.h"
! 9: #include "pa_vstring.h"
! 10: #include "pa_vhash.h"
1.1 paf 11:
1.13 ! paf 12: class WContext : public Value {
1.2 paf 13: public: // Value
14:
15: // all: for error reporting after fail(), etc
1.5 paf 16: const char *type() const { return "WContext"; }
1.13 ! paf 17: // WContext: accumulated string
! 18: String *get_string() { return string; };
! 19:
! 20: public: // usage
! 21:
! 22: WContext(Pool& apool, Value *avalue) : Value(apool),
! 23: fvalue(avalue),
! 24: string(new(apool) String(apool)) {
1.10 paf 25: }
26:
1.13 ! paf 27: // appends a string to result
! 28: void write(String *astring) {
! 29: if(!astring)
! 30: return;
1.2 paf 31:
1.13 ! paf 32: *string+=*astring;
! 33: }
! 34: // if value is VString writes string,
! 35: // else writes Value; raises an error if already
! 36: void write(Value *avalue) {
! 37: if(!avalue)
! 38: return;
! 39:
! 40: String *string=avalue->get_string();
! 41: if(string)
! 42: write(string);
! 43: else
! 44: if(fvalue) // already have value?
! 45: THROW(0,0, // don't need to construct twice
! 46: fvalue->name(),
! 47: "value already assigned, use constructor to reassign it");
! 48: else
! 49: fvalue=avalue;
! 50: }
1.2 paf 51:
1.13 ! paf 52: // retrives the resulting value
! 53: // that can be VString if value==0 or the Value object
! 54: Value *value() const {
! 55: return fvalue?fvalue:NEW VString(string);
1.1 paf 56: }
1.13 ! paf 57:
! 58: protected:
! 59: Value *fvalue;
1.1 paf 60: private:
1.13 ! paf 61: String *string;
1.1 paf 62: };
63:
64: #endif
E-mail: