Diff for /parser3/src/classes/table.C between versions 1.26 and 1.29

version 1.26, 2001/03/25 08:52:28 version 1.29, 2001/03/26 09:53:42
Line 69  static void set_or_load( Line 69  static void set_or_load(
         }          }
   
         // parse cells          // parse cells
         Table& table=*new(pool) Table(pool, columns);          Table& table=*new(pool) Table(pool, &method_name, columns);
         char *row_chars;          char *row_chars;
         while(row_chars=getrow(&data)) {          while(row_chars=getrow(&data)) {
                   if(!*row_chars) // remove empty lines
                           continue;
                 Array *row=new(pool) Array(pool);                  Array *row=new(pool) Array(pool);
                 while(char *cell_chars=lsplit(&row_chars, '\t')) {                  while(char *cell_chars=lsplit(&row_chars, '\t')) {
                         String *cell=new(pool) String(pool);                          String *cell=new(pool) String(pool);
Line 212  static void _empty(Request& r, const Str Line 214  static void _empty(Request& r, const Str
         }          }
 }  }
   
   struct Record_info {
           Pool *pool;
           Table *table;
           Hash *hash;
   };
   static void store_column_item_to_hash(Array::Item *item, void *info) {
           Record_info& ri=*static_cast<Record_info *>(info);
           String& column_name=*static_cast<String *>(item);
           const String *column_item=ri.table->item(column_name);
           Value *value;
           if(column_item)
                   value=new(*ri.pool) VString(*column_item);
           else
                   value=new(*ri.pool) VUnknown(*ri.pool);
           ri.hash->put(column_name, value);
   }
   static void _record(Request& r, const String&, Array *params) {
           Table& table=static_cast<VTable *>(r.self)->table();
           if(const Array *columns=table.columns()) {
                   Pool& pool=r.pool();
                   Value& value=*new(pool) VHash(pool);
                   Record_info record_info={&pool, &table, value.get_hash()};
                   columns->for_each(store_column_item_to_hash, &record_info);
                   
                   r.write_no_lang(value);
           }
   }
   
 // initialize  // initialize
   
 void initialize_table_class(Pool& pool, VStateless_class& vclass) {  void initialize_table_class(Pool& pool, VStateless_class& vclass) {
Line 245  void initialize_table_class(Pool& pool, Line 275  void initialize_table_class(Pool& pool,
         // ^table.empty{code-when-empty}{code-when-not}          // ^table.empty{code-when-empty}{code-when-not}
         vclass.add_native_method("empty", _empty, 1, 2);          vclass.add_native_method("empty", _empty, 1, 2);
   
           // ^table.record[]
           vclass.add_native_method("record", _record, 0, 0);
   
 }         }       

Removed from v.1.26  
changed lines
  Added in v.1.29


E-mail: