Annotation of parser3/src/include/pa_wcontext.h, revision 1.2
1.1 paf 1: /*
1.2 ! paf 2: $Id: pa_wcontext.h,v 1.1 2001/02/21 16:11:49 paf Exp $
1.1 paf 3: */
4:
5: /*
6: data core
7: */
8:
9: #ifndef PA_WCONTEXT_H
10: #define PA_WCONTEXT_H
11:
12: #include "pa_value.h"
13:
14: class WContext : public Value {
1.2 ! paf 15: public: // Value
! 16:
! 17: // all: for error reporting after fail(), etc
! 18: /*virtual*/ const char *get_type() const { return "WContext"; }
! 19: // wcontext: accumulated string
! 20: /*virtual*/ String *get_string() { return &string; };
! 21: // wcontext: transparent
! 22: /*virtual*/ Value *get_element(const String& name) const { return check_value()->get_element(name); }
! 23: // wcontext: transparent
! 24: /*virtual*/ void put_element(const String& name, Value *avalue){ check_value()->put_element(name, avalue); }
! 25: // wcontext: transparent
! 26: /*virtual*/ Method *get_method(const String& name) const { return check_value()->get_method(name); }
! 27: // wcontext: none yet | transparent
! 28: /*virtual*/ VClass *get_class() const { return fvalue?fvalue->get_class():0; }
! 29: // wcontext: none yet | transparent
! 30: /*virtual*/ bool is_or_derived_from(VClass& ancestor) { return fvalue?fvalue->is_or_derived_from(ancestor):false; }
! 31:
! 32: public: // usage
! 33:
! 34: WContext(Pool& apool, Value *avalue) : Value(apool),
! 35: fvalue(avalue),
! 36: string(apool) {
! 37: }
1.1 paf 38:
39: // appends a string to result
40: // until Value written, ignores afterwards
41: void write(String& astring);
42: // if value.string!=0 writes string altogether[for showing class names, etc]
43: // writes Value; raises an error if already
44: void write(Value& avalue);
45: //void write(String_iterator& from, String_iterator& to);
46:
47: // retrives the resulting value
48: // that can be Text if value==0 or the Value object
49: Value *value() const {
1.2 ! paf 50: return fvalue?fvalue:0;//TODO: new Text(string);
1.1 paf 51: }
52:
53: private:
54: String string;
1.2 ! paf 55: Value *fvalue;
1.1 paf 56:
57: private:
58: // raises an exception on 0 value
1.2 ! paf 59: Value *check_value() const {
! 60: if(!fvalue)
! 61: pool().exception().raise(0,0,
! 62: 0,
! 63: "accessing wcontext without value");
! 64:
! 65: return fvalue;
! 66: }
1.1 paf 67: };
68:
69: #endif
E-mail: