Diff for /parser3/src/include/Attic/pa_wcontext.h between versions 1.7 and 1.23.4.1

version 1.7, 2001/02/22 13:33:25 version 1.23.4.1, 2001/03/08 17:59:28
Line 2 Line 2
   $Id$    $Id$
 */  */
   
 /*  
         data core  
 */  
   
 #ifndef PA_WCONTEXT_H  #ifndef PA_WCONTEXT_H
 #define PA_WCONTEXT_H  #define PA_WCONTEXT_H
   
 #include "pa_value.h"  #include "pa_value.h"
 #include "pa_vstring.h"  #include "pa_vstring.h"
   #include "pa_vhash.h"
   
 class WContext : public Value {  class WContext : public Value {
 public: // Value  public: // Value
   
         // all: for error reporting after fail(), etc          // all: for error reporting after fail(), etc
         const char *type() const { return "WContext"; }          const char *type() const { return "wcontext"; }
         // wcontext: accumulated string          // WContext: accumulated fstring
         String *get_string() { return string; };          String *get_string() { return &fstring; };
         // wcontext: transparent  
         Value *get_element(const String& name) const { return check_value()->get_element(name); }          // WContext: none yet | transparent
         // wcontext: transparent          VClass *get_class() { return fvalue?fvalue->get_class():0; }
         void put_element(const String& name, Value *avalue){ check_value()->put_element(name, avalue); }  
         // wcontext: transparent          // wcontext: transparent
         Method *get_method(const String& name) const { return check_value()->get_method(name); }          VAliased *get_aliased() { return fvalue?fvalue->get_aliased():0; }
         // wcontext: none yet | transparent  
         VClass *get_class() const { return fvalue?fvalue->get_class():0; }  public: // WContext
         // wcontext: none yet | transparent  
         bool is_or_derived_from(VClass& ancestor) { return fvalue?fvalue->is_or_derived_from(ancestor):false; }          // appends a fstring to result
           virtual void write(String& astring);
   
           // if value is VString writes fstring,
           // else writes Value; raises an error if already
           virtual void write(Value& avalue);
   
 public: // usage  public: // usage
   
         WContext(Pool& apool, Value *avalue) : Value(apool),           WContext(Pool& apool, Value *avalue, bool aconstructing) : Value(apool), 
                 fvalue(avalue),                  fvalue(avalue),
                 string(new(apool) String(apool)) {                  fconstructing(aconstructing),
                   fstring(*new(apool) String(apool)) {
         }          }
   
         // appends a string to result          bool constructing() { return fconstructing; }
         void write(String *astring) {  
                 if(!astring)  
                         return;  
   
                 *string+=*astring;  
         }  
         // if value is VString writes string,  
         // 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  
                                         0,  
                                         "value already assigned, use constructor to reassign it");  
                         else  
                                 fvalue=avalue;  
         }  
   
         // retrives the resulting value          // retrives the resulting value
         // that can be VString if value==0 or the Value object          // that can be VString if value==0 or the Value object
         Value *value() const {          Value *result() const {
                 return fvalue?fvalue:NEW VString(string);                  return fvalue?fvalue:NEW VString(fstring);
         }          }
           
 private:  
         String *string;  
         Value *fvalue;  
   
   protected:
           Value *fvalue;
 private:  private:
         // raises an exception on 0 value          bool fconstructing;
         Value *check_value() const {          String& fstring;
                 if(!fvalue)  
                         THROW(0,0,  
                                 0,  
                                 "accessing wcontext without value");  
   
                 return fvalue;  
         }  
 };  };
   
 #endif  #endif

Removed from v.1.7  
changed lines
  Added in v.1.23.4.1


E-mail: