Diff for /parser3/src/classes/table.C between versions 1.241 and 1.246

version 1.241, 2008/04/08 12:34:01 version 1.246, 2008/09/03 14:29:17
Line 451  static void _save(Request& r, MethodPara Line 451  static void _save(Request& r, MethodPara
                 --param_index;                  --param_index;
   
         const String& file_name=params.as_string(param_index++, FILE_NAME_MUST_NOT_BE_CODE);          const String& file_name=params.as_string(param_index++, FILE_NAME_MUST_NOT_BE_CODE);
           String file_spec=r.absolute(file_name);
   
           if(do_append && file_exist(file_spec))
                   output_column_names=false;
   
         TableSeparators separators;          TableSeparators separators;
         if(param_index<params.count()) {          if(param_index<params.count()) {
Line 515  static void _save(Request& r, MethodPara Line 519  static void _save(Request& r, MethodPara
         // write          // write
         {          {
                 const char* data_cstr=sdata.cstr();                  const char* data_cstr=sdata.cstr();
                 file_write(r.absolute(file_name),                   file_write(file_spec, 
                         data_cstr, sdata.length(), true, do_append);                          data_cstr, sdata.length(), true, do_append);
                 if(*data_cstr) // not empty (when empty it's not heap memory)                  if(*data_cstr) // not empty (when empty it's not heap memory)
                         pa_free((void*)data_cstr); // not needed anymore                          pa_free((void*)data_cstr); // not needed anymore
Line 566  static void _save(Request& r, MethodPara Line 570  static void _save(Request& r, MethodPara
         // write          // write
         {          {
                 string data=ost.str();                  string data=ost.str();
                 const char* data_cstr = data.c_str();                  const char* data_cstr=data.c_str();
   
                 file_write(r.absolute(file_name), data_cstr, data.length(), true /* as text */, do_append);                  file_write(file_spec, data_cstr, data.length(), true /* as text */, do_append);
         }          }
   
 #endif  #endif
Line 623  static void _menu(Request& r, MethodPara Line 627  static void _menu(Request& r, MethodPara
   
                 StringOrValue sv_processed=r.process(body_code);                  StringOrValue sv_processed=r.process(body_code);
                 Request::Skip lskip=r.get_skip(); r.set_skip(Request::SKIP_NOTHING);                  Request::Skip lskip=r.get_skip(); r.set_skip(Request::SKIP_NOTHING);
   
                 const String* s_processed=sv_processed.get_string();                  const String* s_processed=sv_processed.get_string();
                 if(delim_maybe_code && s_processed && s_processed->length()) { // delimiter set and we have body                  if(delim_maybe_code && s_processed && s_processed->length()) { // delimiter set and we have body
                         if(need_delim) // need delim & iteration produced string?                          if(need_delim) // need delim & iteration produced string?
                                 r.write_pass_lang(r.process(*delim_maybe_code));                                  r.write_pass_lang(r.process(*delim_maybe_code));
                         need_delim=true;                          else
                                   need_delim=true;
                 }                  }
   
                 r.write_pass_lang(sv_processed);                  r.write_pass_lang(sv_processed);
   
                 if(lskip==Request::SKIP_BREAK)                  if(lskip==Request::SKIP_BREAK)
Line 663  static void table_row_to_hash(Table::ele Line 670  static void table_row_to_hash(Table::ele
         if(!key)          if(!key)
                 return; // ignore rows without key [too-short-record_array if-indexed]                  return; // ignore rows without key [too-short-record_array if-indexed]
                                   
         bool exist = false;          bool exist=false;
         switch (info->value_type) {          switch(info->value_type) {
         case C_STRING:                  case C_STRING: {
                 {  
                         exist=info->hash->put_dont_replace(*key, new VString(*row->get(info->value_fields->get(0))));                          exist=info->hash->put_dont_replace(*key, new VString(*row->get(info->value_fields->get(0))));
                           break;
                 }                  }
                 break;                  case C_HASH: {
         case C_HASH:  
                 {  
                         VHash* vhash=new VHash;                          VHash* vhash=new VHash;
                         HashStringValue& hash=vhash->hash();                          HashStringValue& hash=vhash->hash();
                         for(Array_iterator<int> i(*info->value_fields); i.has_next(); ) {                          for(Array_iterator<int> i(*info->value_fields); i.has_next(); ) {
Line 683  static void table_row_to_hash(Table::ele Line 688  static void table_row_to_hash(Table::ele
                         }                          }
   
                         exist=info->hash->put_dont_replace(*key, vhash);                          exist=info->hash->put_dont_replace(*key, vhash);
                           break;
                 }                  }
                 break;                  case C_TABLE: {
         case C_TABLE:                          VTable* vtable=(VTable*)info->hash->get(*key); // table exist?
                 {  
                         VTable* vtable=(VTable*)info->hash->get(*key); // put. table existed?  
                         if( info->distinct==D_ILLEGAL ){  
                                 exist=true;  
                                 break;  
                         }  
   
                         Table* table;                          Table* table;
                         if(vtable) {                          if(vtable) {
                                   if(info->distinct==D_ILLEGAL) {
                                           exist=true;
                                           break;
                                   }
                                 table=vtable->get_table();                                  table=vtable->get_table();
                         } else {                          } else {
                                 // no? creating table of same structure as source                                  // no? creating table of same structure as source
Line 703  static void table_row_to_hash(Table::ele Line 706  static void table_row_to_hash(Table::ele
                                 info->hash->put(*key, new VTable(table));                                  info->hash->put(*key, new VTable(table));
                         }                          }
                         *table+=row;                          *table+=row;
                           break;
                 }                  }
                 break;  
         }          }
         if(exist && info->distinct==D_ILLEGAL)          if(exist && info->distinct==D_ILLEGAL)
                 throw Exception(PARSER_RUNTIME,                  throw Exception(PARSER_RUNTIME,
Line 1118  static void _sql(Request& r, MethodParam Line 1121  static void _sql(Request& r, MethodParam
         Value& statement=params.as_junction(0, "statement must be code");          Value& statement=params.as_junction(0, "statement must be code");
   
         HashStringValue* bind=0;          HashStringValue* bind=0;
         ulong limit=0;          ulong limit=SQL_NO_LIMIT;
         ulong offset=0;          ulong offset=0;
         if(params.count()>1) {          if(params.count()>1) {
                 Value& voptions=params.as_no_junction(1, "options must be hash, not code");                  Value& voptions=params.as_no_junction(1, "options must be hash, not code");

Removed from v.1.241  
changed lines
  Added in v.1.246


E-mail: