--- parser3/src/classes/table.C 2024/10/05 18:05:23 1.367 +++ parser3/src/classes/table.C 2024/11/16 02:57:05 1.372 @@ -1,7 +1,7 @@ /** @file Parser: @b table parser class. - Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian */ @@ -26,7 +26,7 @@ #include "pa_array.h" #include "pa_varray.h" -volatile const char * IDENT_TABLE_C="$Id: table.C,v 1.367 2024/10/05 18:05:23 moko Exp $"; +volatile const char * IDENT_TABLE_C="$Id: table.C,v 1.372 2024/11/16 02:57:05 moko Exp $"; // class @@ -751,7 +751,7 @@ static void _offset(Request& r, MethodPa else if(whence=="set") absolute=true; else - throw Exception(PARSER_RUNTIME, &whence, "is invalid whence, valid are 'cur' or 'set'"); + throw Exception(PARSER_RUNTIME, &whence, "is an invalid whence, valid are 'cur' or 'set'"); } int offset=params.as_int(params.count()-1, "offset must be expression", r); @@ -768,7 +768,7 @@ static void _menu(Request& r, MethodPara Value* delim_maybe_code=params.count()>1?¶ms[1]:0; Table& table=GET_SELF(r, VTable).table(); - size_t saved_current=table.current(); + Temp_current tc(table); if(delim_maybe_code) { // delimiter set bool need_delim=false; @@ -801,7 +801,6 @@ static void _menu(Request& r, MethodPara break; } } - table.set_current(saved_current); } #ifndef DOXYGEN @@ -1002,9 +1001,7 @@ static void _hash(Request& r, MethodPara }; info.key_field=(info.key_code ? -1 : self_table.column_name2index(key_param->as_string(), true)); - int saved_current=self_table.current(); self_table.for_each(table_row_to_hash, &info); - self_table.set_current(saved_current); result.extract_default(); @@ -1019,7 +1016,7 @@ static void _cells(Request& r, MethodPar int limit=params.as_int(params.count()-1, "offset must be expression", r); if(limit<0) limit=0; - if(limit3?¶ms[3]:0; Table& table=GET_SELF(r, VTable).table(); - size_t saved_current=table.current(); + Temp_current tc(table); rownum_var_name=rownum_var_name->is_empty()? 0 : rownum_var_name; value_var_name=value_var_name->is_empty()? 0 : value_var_name; @@ -1219,7 +1218,6 @@ static void _foreach(Request& r, MethodP break; } } - table.set_current(saved_current); } static void update_cell(HashStringValue::key_type aname, HashStringValue::value_type avalue, VTable *dest) { @@ -1245,11 +1243,10 @@ static void _append(Request& r, MethodPa HashStringValue* hash=params[0].get_hash(); if(hash){ + Temp_current tc(table); table+=new ArrayString(); - size_t saved_current=table.current(); table.set_current(table.count()-1); hash->for_each(update_cell, &vtable); - table.set_current(saved_current); } else { table+=row_from_string(r, params[0]); } @@ -1500,7 +1497,7 @@ static void _select(Request& r, MethodPa if(offset<0) offset+=size; if(size && limit>0 && offset>=0 && (size_t)offsetcount(); i++) { + for(size_t i=0; icount(); i++) { const String *column = columns->get(i); if(Value* vto=names->get(*column)){ if(const String *sto=vto->get_string()) @@ -1560,7 +1556,7 @@ static void _rename(Request& r, MethodPa } } } else if(name_from){ - for(int i=0; icount(); i++) { + for(size_t i=0; icount(); i++) { const String *column = columns->get(i); if(*column == *name_from) columns->put(i, name_to);