Diff for /parser3/src/include/Attic/pa_wcontext.h between versions 1.10 and 1.12

version 1.10, 2001/02/23 09:43:14 version 1.12, 2001/02/23 14:18:26
Line 5 Line 5
 #ifndef PA_WCONTEXT_H  #ifndef PA_WCONTEXT_H
 #define PA_WCONTEXT_H  #define PA_WCONTEXT_H
   
 #include "pa_value.h"  #include "pa_wvalue.h"
 #include "pa_vstring.h"  
 #include "pa_vhash.h"  
   
 class WContext : public Value {  class WContext : public WValue {
 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  
         String *get_string() { return string; };  
         // wcontext: transparent          // wcontext: transparent
         Value *get_element(const String& name) { return check_value()->get_element(name); }          Value *get_element(const String& name) { return check_value()->get_element(name); }
         // wcontext: transparent          // wcontext: transparent
 //      void put_element(const String& name, Value *avalue){ check_value()->put_element(name, avalue); }  
         void put_element(const String& name, Value *avalue){           void put_element(const String& name, Value *avalue){ 
                 if(!fvalue)                  if(!fvalue)
                         fvalue=NEW VHash(pool());                          fvalue=NEW VHash(pool());
Line 35  public: // Value Line 30  public: // Value
   
 public: // usage  public: // usage
   
         WContext(Pool& apool, Value *avalue) : Value(apool),           WContext(Pool& apool, Value *avalue) : WValue(apool, avalue) {
                 fvalue(avalue),  
                 string(new(apool) String(apool)) {  
         }  
   
         // appends a string to result  
         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  
         // that can be VString if value==0 or the Value object  
         Value *value() const {  
                 return fvalue?fvalue:NEW VString(string);  
         }          }
                   
 private:  private:
         String *string;  
         Value *fvalue;  
   
 private:  
         // raises an exception on 0 value          // raises an exception on 0 value
         Value *check_value() const {          Value *check_value() const {
                 if(!fvalue)                  if(!fvalue)

Removed from v.1.10  
changed lines
  Added in v.1.12


E-mail: