Diff for /parser3/src/classes/hash.C between versions 1.90 and 1.102

version 1.90, 2009/05/04 09:26:19 version 1.102, 2009/07/29 05:01:33
Line 22  static const char * const IDENT_HASH_C=" Line 22  static const char * const IDENT_HASH_C="
   
 class MHash: public Methoded {  class MHash: public Methoded {
 public: // VStateless_class  public: // VStateless_class
         Value* create_new_value(Pool&, HashStringValue&) { return new VHash(); }          Value* create_new_value(Pool&, HashStringValue*) { return new VHash(); }
   
 public:  public:
         MHash();          MHash();
Line 34  public: // Methoded Line 34  public: // Methoded
   
 DECLARE_CLASS_VAR(hash, new MHash, 0);  DECLARE_CLASS_VAR(hash, new MHash, 0);
   
 // externs  
   
 extern String cycle_data_name;  
   
 // methods  // methods
   
 #ifndef DOXYGEN  #ifndef DOXYGEN
Line 76  public: Line 72  public:
   
         bool add_column(SQL_Error& error, const char* str, size_t length) {          bool add_column(SQL_Error& error, const char* str, size_t length) {
                 try {                  try {
                         columns+=new String(str, length, true);                          columns+=new String(str, String::L_TAINTED, length);
                         return false;                          return false;
                 } catch(...) {                  } catch(...) {
                         error=SQL_Error("exception occured in Hash_sql_event_handlers::add_column");                          error=SQL_Error("exception occured in Hash_sql_event_handlers::add_column");
Line 115  public: Line 111  public:
   
         bool add_row_cell(SQL_Error& error, const char *ptr, size_t length) {          bool add_row_cell(SQL_Error& error, const char *ptr, size_t length) {
                 try {                  try {
                         String& cell=*new String;                          String& cell=*new String(ptr, String::L_TAINTED, length);
                         if(length)  
                                 cell.append_know_length(ptr, length, String::L_TAINTED);  
   
                         bool duplicate=false;                          bool duplicate=false;
                         if(one_bool_column) {                          if(one_bool_column) {
Line 234  static void _sub(Request& r, MethodParam Line 228  static void _sub(Request& r, MethodParam
 }  }
   
 static void copy_all_dontoverwrite_to(  static void copy_all_dontoverwrite_to(
                                                                   HashStringValue::key_type key,                                           HashStringValue::key_type key, 
                                                                   HashStringValue::value_type value,                                           HashStringValue::value_type value, 
                                                                   HashStringValue* dest) {                                          HashStringValue* dest) {
         dest->put_dont_replace(key, value);          dest->put_dont_replace(key, value);
 }  }
 static void _union(Request& r, MethodParams& params) {  static void _union(Request& r, MethodParams& params) {
Line 258  struct Copy_intersection_to_info { Line 252  struct Copy_intersection_to_info {
 };  };
 #endif  #endif
 static void copy_intersection_to(  static void copy_intersection_to(
                                                                  HashStringValue::key_type key,                                           HashStringValue::key_type key, 
                                                                  HashStringValue::value_type value,                                           HashStringValue::value_type value, 
                                                                  Copy_intersection_to_info *info) {                                          Copy_intersection_to_info *info) {
         if(info->b->get(key))          if(info->b->get(key))
                 info->dest->put_dont_replace(key, value);                  info->dest->put_dont_replace(key, value);
 }  }
Line 278  static void _intersection(Request& r, Me Line 272  static void _intersection(Request& r, Me
 }  }
   
 static bool intersects(  static bool intersects(
                                            HashStringValue::key_type key,                                           HashStringValue::key_type key, 
                                            HashStringValue::value_type /*value*/,                                           HashStringValue::value_type /*value*/, 
                                            HashStringValue* b) {                                          HashStringValue* b) {
         return b->get(key)!=0;          return b->get(key)!=0;
 }  }
   
Line 356  static void _sql(Request& r, MethodParam Line 350  static void _sql(Request& r, MethodParam
   
         Temp_lang temp_lang(r, String::L_SQL);          Temp_lang temp_lang(r, String::L_SQL);
         const String& statement_string=r.process_to_string(statement);          const String& statement_string=r.process_to_string(statement);
         const char* statement_cstr=          const char* statement_cstr=statement_string.untaint_cstr(r.flang, r.connection());
                 statement_string.cstr(String::L_UNSPECIFIED, r.connection());  
         HashStringValue& hash=GET_SELF(r, VHash).hash();          HashStringValue& hash=GET_SELF(r, VHash).hash();
         hash.clear();             hash.clear();   
         Hash_sql_event_handlers handlers(          Hash_sql_event_handlers handlers(
Line 378  static void _sql(Request& r, MethodParam Line 372  static void _sql(Request& r, MethodParam
 }  }
   
 static void keys_collector(  static void keys_collector(
                            HashStringValue::key_type key,                           HashStringValue::key_type key, 
                            HashStringValue::value_type,                           HashStringValue::value_type, 
                            Table *table) {                          Table *table) {
         Table::element_type row(new ArrayString);          Table::element_type row(new ArrayString(1));
         *row+=new String(key, String::L_TAINTED);          *row+=new String(key, String::L_TAINTED);
         *table+=row;          *table+=row;
 }  }
Line 392  static void _keys(Request& r, MethodPara Line 386  static void _keys(Request& r, MethodPara
         else           else 
                 keys_column_name=new String("key");                  keys_column_name=new String("key");
   
         Table::columns_type columns(new ArrayString);          Table::columns_type columns(new ArrayString(1));
         *columns+=keys_column_name;          *columns+=keys_column_name;
         Table* table=new Table(columns);          Table* table=new Table(columns);
   
Line 424  struct Foreach_info { Line 418  struct Foreach_info {
         Value* delim_maybe_code;          Value* delim_maybe_code;
   
         Value* var_context;          Value* var_context;
         VString* vkey;  
         bool need_delim;          bool need_delim;
 };  };
 #endif  #endif
Line 434  static bool one_foreach_cycle( Line 427  static bool one_foreach_cycle(
                                 Foreach_info *info) {                                  Foreach_info *info) {
         Value& var_context=*info->var_context;          Value& var_context=*info->var_context;
         if(info->key_var_name){          if(info->key_var_name){
                 info->vkey->set_string(*new String(akey, String::L_TAINTED));                  VString* vkey=new VString(*new String(akey, String::L_TAINTED));
                 var_context.put_element(var_context, *info->key_var_name, info->vkey, false);                  var_context.put_element(var_context, *info->key_var_name, vkey, false);
         }          }
         if(info->value_var_name)          if(info->value_var_name)
                 var_context.put_element(var_context, *info->value_var_name, avalue, false);                  var_context.put_element(var_context, *info->value_var_name, avalue, false);
   
         if(info->delim_maybe_code){          if(info->delim_maybe_code){ // delimiter set
                 StringOrValue sv_processed=info->r->process(*info->body_code);                  StringOrValue sv_processed=info->r->process(*info->body_code);
                 Request::Skip lskip=info->r->get_skip(); info->r->set_skip(Request::SKIP_NOTHING);                  Request::Skip lskip=info->r->get_skip(); info->r->set_skip(Request::SKIP_NOTHING);
   
                 const String* s_processed=sv_processed.get_string();                  const String* s_processed=sv_processed.get_string();
                 if(s_processed && s_processed->length()) { // delimiter set and we have body                  if(s_processed && !s_processed->is_empty()) { // we have body
                         if(info->need_delim) // need delim & iteration produced string?                          if(info->need_delim) // need delim & iteration produced string?
                                 info->r->write_pass_lang(info->r->process(*info->delim_maybe_code));                                  info->r->write_pass_lang(info->r->process(*info->delim_maybe_code));
                         else                          else
Line 460  static bool one_foreach_cycle( Line 453  static bool one_foreach_cycle(
         }          }
 }  }
 static void _foreach(Request& r, MethodParams& params) {  static void _foreach(Request& r, MethodParams& params) {
         Temp_hash_value<const String::Body, void*>           InCycle temp(r);
                 cycle_data_setter(r.classes_conf, cycle_data_name, /*any not null flag*/&r);  
   
         const String& key_var_name=params.as_string(0, "key-var name must be string");          const String& key_var_name=params.as_string(0, "key-var name must be string");
         const String& value_var_name=params.as_string(1, "value-var name must be string");          const String& value_var_name=params.as_string(1, "value-var name must be string");
Line 473  static void _foreach(Request& r, MethodP Line 465  static void _foreach(Request& r, MethodP
                 &params.as_junction(2, "body must be code"),                  &params.as_junction(2, "body must be code"),
                 /*delimiter*/params.count()>3?params.get(3):0,                  /*delimiter*/params.count()>3?params.get(3):0,
                 /*var_context*/r.get_method_frame()->caller(),                  /*var_context*/r.get_method_frame()->caller(),
                 /*vkey=*/new VString,  
                 false                  false
         };          };
   

Removed from v.1.90  
changed lines
  Added in v.1.102


E-mail: