Annotation of parser3/src/types/pa_wcontext.h, revision 1.11
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1 paf 5:
1.11 ! paf 6: $Id: pa_wcontext.h,v 1.10 2001/04/05 19:35:18 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_WCONTEXT_H
10: #define PA_WCONTEXT_H
11:
12: #include "pa_value.h"
13: #include "pa_vstring.h"
14: #include "pa_vhash.h"
15:
16: class Request;
17:
18: class WContext : public Value {
19: friend Request;
20: public: // Value
21:
22: // all: for error reporting after fail(), etc
23: const char *type() const { return "wcontext"; }
24: // WContext: accumulated fstring
25: const String *get_string() { return &fstring; };
26:
27: // WContext: none yet | transparent
1.5 paf 28: VStateless_class *get_class() { return fvalue?fvalue->get_class():0; }
1.1 paf 29: // wcontext: transparent
30: VAliased *get_aliased() { return fvalue?fvalue->get_aliased():0; }
31:
32: public: // WContext
33:
34: // appends a fstring to result
35: virtual void write(const String& astring, String::Untaint_lang lang);
1.6 paf 36:
37: // writes Value; raises an error if already
38: virtual void write(Value& avalue);
1.1 paf 39:
40: // if value is VString writes fstring,
41: // else writes Value; raises an error if already
42: virtual void write(Value& avalue, String::Untaint_lang lang);
43:
1.7 paf 44: // retrives the resulting value
45: // that can be VString if value==0 or the Value object
46: // wmethod_frame first checks for $result and if there is one, returns it instead
1.9 paf 47: virtual Value *result() {
48: // not constructing anymore [if were constructing]
49: // so to allow method calls after real constructor-method call
50: // sample:
51: // $complex[
52: // $class:constructor[$i]
53: // ^i.inc[] ^rem{allow such calls}
54: // $field[$1]
55: fconstructing=false;
1.7 paf 56: return fvalue?fvalue:NEW VString(fstring);
57: }
58:
1.1 paf 59: public: // usage
60:
61: WContext(Pool& apool, Value *avalue, bool aconstructing) : Value(apool),
1.7 paf 62: fstring(*new(apool) String(apool)),
63: fconstructing(aconstructing), fvalue(avalue),
1.8 paf 64: fsomebody_entered_some_class(false),
65: fsomebody_entered_some_object(0){
1.1 paf 66: }
67:
68: bool constructing() { return fconstructing; }
1.10 paf 69: void constructing(bool aconstructing) { fconstructing=aconstructing; }
1.4 paf 70: void set_somebody_entered_some_class() { fsomebody_entered_some_class=true; }
71: bool somebody_entered_some_class() { return fsomebody_entered_some_class; }
1.1 paf 72:
1.8 paf 73: void inc_somebody_entered_some_object() { fsomebody_entered_some_object++; }
74: int somebody_entered_some_object() { return fsomebody_entered_some_object; }
1.11 ! paf 75: void clear_somebody_entered_some_object() { fsomebody_entered_some_object=0; }
1.8 paf 76:
1.1 paf 77: protected:
1.7 paf 78: String& fstring;
79: bool fconstructing; Value *fvalue;
1.1 paf 80: private:
1.4 paf 81: bool fsomebody_entered_some_class;
1.8 paf 82: int fsomebody_entered_some_object;
1.1 paf 83: };
84:
85: #endif
E-mail: