Annotation of parser3/src/include/pa_context.h, revision 1.6
1.1 paf 1: /*
1.6 ! paf 2: $Id: pa_context.h,v 1.5 2001/02/14 12:20:47 paf Exp $
1.1 paf 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);
1.6 ! paf 25: void write(String_iterator& from, String_iterator& to);
1.1 paf 26:
27: // retrives the resulting value
28: // that can be Text if value==0 or the Value object
29: Value *value() const {
30: return value?value:new Text(string);
31: }
32:
33: public: //implement by replicating to value->calls
34:
35: virtual String *get_string() const { return &string };
36: virtual void put_string(const String *astring) { check(value)->put_string(astring); };
37:
1.3 paf 38: virtual Method_ref *get_method_ref() const { return check(value)->get_method_ref(); }
39:
1.1 paf 40: virtual Value *get_element(const String& name) const { return check(value)->get_element(name); }
41: virtual void put_element(const String& name, const Value *avalue){ check(value)->put_element(name, avalue); }
42:
1.2 paf 43: virtual Method *get_method(const String& name) const { return check(value)->get_method(name); }
1.4 paf 44:
1.5 paf 45: virtual Class *get_class() const { return value?value->get_class():0; }
46: virtual bool has_parent(Class *aparent) { return value?value->has_parent(aparent):false; }
1.1 paf 47:
48: private:
49: String& string;
50: Value *value;
51:
52: private:
53: // raises an exception on 0 value
54: Value *check(const Value *value);
55: };
56:
57: #endif
E-mail: