--- parser3/src/classes/table.C 2003/03/24 13:05:15 1.172.2.14.2.14 +++ parser3/src/classes/table.C 2003/03/26 18:52:48 1.172.2.14.2.18 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_TABLE_C="$Date: 2003/03/24 13:05:15 $"; +static const char* IDENT_TABLE_C="$Date: 2003/03/26 18:52:48 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -50,7 +50,7 @@ String sql_distinct_name(SQL_DISTINCT_NA // methods -static void get_copy_options(Request& r, MethodParams* params, int param_index, +static void get_copy_options(Request& r, MethodParams* params, size_t param_index, const Table& source, int& offset, int& limit) { @@ -110,6 +110,7 @@ static void _create(Request& r, MethodPa r.process_to_string(params->as_junction(params->count()-1, "body must be code")); // parse columns + size_t raw_pos_after=0; Table::columns_type columns; if(params->count()==2) { columns=Table::columns_type(0); // nameless @@ -117,11 +118,10 @@ static void _create(Request& r, MethodPa columns=Table::columns_type(new ArrayString); ArrayString head; - size_t pos_after=0; - data.split(head, pos_after, "\n", String::L_AS_IS, 1); + data.split(head, raw_pos_after, "\n", String::L_AS_IS, 1); if(head.count()) { - size_t pos_after=0; - head[0]->split(*columns, pos_after, "\t", String::L_AS_IS); + size_t col_pos_after=0; + head[0]->split(*columns, col_pos_after, "\t", String::L_AS_IS); } } @@ -129,8 +129,7 @@ static void _create(Request& r, MethodPa // parse cells ArrayString rows; - size_t pos_after=0; - data.split(rows, pos_after, "\n", String::L_AS_IS); + data.split(rows, raw_pos_after, "\n", String::L_AS_IS); Array_iterator i(rows); while(i.has_next()) { Table::element_type row(new ArrayString); @@ -139,8 +138,8 @@ static void _create(Request& r, MethodPa if(!string.length()) continue; - size_t pos_after=0; - string.split(*row, pos_after, "\t", String::L_AS_IS); + size_t col_pos_after=0; + string.split(*row, col_pos_after, "\t", String::L_AS_IS); table+=row; } @@ -154,7 +153,7 @@ static void _load(Request& r, MethodPara bool nameless=first_param=="nameless"; if(nameless) filename_param_index++; - int options_param_index=filename_param_index+1; + size_t options_param_index=filename_param_index+1; // loading text char *data=file_read_text(r.charsets.source(), @@ -220,7 +219,7 @@ static void _save(Request& r, MethodPara } else { // nameless table if(int lsize=table.count()?table[0]->count():0) for(int column=0; column* value_fields; HashStringValue* hash; bool distinct; - int row; + size_t row; }; #endif static void table_row_to_hash(Table::element_type row, Row_info *info) { @@ -341,8 +340,8 @@ static void table_row_to_hash(Table::ele VHash* vhash=new VHash; HashStringValue& hash=vhash->hash(); - for(int i=0; ivalue_fields->count(); i++) { - int value_field=info->value_fields->get(i); + for(size_t i=0; ivalue_fields->count(); i++) { + size_t value_field=info->value_fields->get(i); if(value_fieldcount()) hash.put( *info->table->columns()->get(value_field), @@ -389,7 +388,7 @@ static void _hash(Request& r, MethodPara value_fields+=self_table.column_name2index( *value_fields_param.get_string(), true); } else if(Table* value_fields_table=value_fields_param.get_table()) { - for(int i=0; icount(); i++) { + for(size_t i=0; icount(); i++) { const String& value_field_name= *value_fields_table->get(i)->get(0); value_fields+=self_table.column_name2index(value_field_name, true); @@ -400,7 +399,7 @@ static void _hash(Request& r, MethodPara "value field(s) must be string or self_table" ); } else { // by all columns, including key - for(int i=0; icount(); i++) + for(size_t i=0; icount(); i++) value_fields+=i; } @@ -461,12 +460,13 @@ static void _sort(Request& r, MethodPara Table& old_table=GET_SELF(r, VTable).table(); Table& new_table=*new Table(old_table.columns()); - Table_seq_item* seq=new Table_seq_item[old_table.count()]; + Table_seq_item* seq=new(PointerFreeGC) Table_seq_item[old_table.count()]; int i; // calculate key values bool key_values_are_strings=true; - for(i=0; ias_double(); } // sort keys - _qsort(seq, old_table.count(), sizeof(Table_seq_item), + _qsort(seq, old_count, sizeof(Table_seq_item), key_values_are_strings?sort_cmp_string:sort_cmp_double); // reorder table as they require in 'seq' - for(i=0; icount()) - for(int column=0; columncount()) + for(size_t column=0; columncount()?old_row->get(column):new String; } @@ -587,7 +589,7 @@ static void _join(Request& r, MethodPara for(int src_row=offset; src_rowcount(); dest_column++) { + for(size_t dest_column=0; dest_columncount(); dest_column++) { const String* src_item=src.item(*dest_columns->get(dest_column)); *dest_row+=src_item?src_item:new String; } @@ -595,7 +597,8 @@ static void _join(Request& r, MethodPara } src.set_current(saved_src_current); } else { // dest is nameless - for(int src_row=0; src_row