--- parser3/src/classes/table.C 2001/03/30 09:58:57 1.41 +++ parser3/src/classes/table.C 2001/04/02 15:59:06 1.43 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: table.C,v 1.41 2001/03/30 09:58:57 paf Exp $ + $Id: table.C,v 1.43 2001/04/02 15:59:06 paf Exp $ */ #include "pa_config_includes.h" @@ -20,7 +20,7 @@ VStateless_class *table_class; // methods -/// @todo now remove CONFIG untaint, make pos() searches in String +/// @test remove CONFIG untaint, make pos() searches in String static void set_or_load( Request& r, const String& method_name, Array *params, @@ -353,7 +353,7 @@ static void _flip(Request& r, const Stri vtable.set_table(new_table); } -/// @todo now require \t to be clean [UL_NO] +/// @test require \t to be clean [UL_NO] static void _append(Request& r, const String& method_name, Array *params) { Pool& pool=r.pool(); // data is last parameter @@ -378,6 +378,42 @@ static void _append(Request& r, const St static_cast(r.self)->table()+=&row; } +static void _join(Request& r, const String& method_name, Array *params) { + Pool& pool=r.pool(); + + Value *value=static_cast(params->get(0)); + // forcing [this table ref type] + r.fail_if_junction_(true, *value, method_name, "table ref must not be junction"); + + Table *maybe_src=value->get_table(); + if(!maybe_src) + RTHROW(0, 0, + &method_name, + "source is not a table"); + + Table& src=*maybe_src; + Table& dest=static_cast(r.self)->table(); + if(&src == &dest) + RTHROW(0, 0, + &method_name, + "source and destination are same table"); + + if(const Array *dest_columns=dest.columns()) { // dest is named + int saved_src_current=src.current(); + for(int src_row=0; src_rowsize(); dest_column++) + dest_row+=src.item(*dest_columns->get_string(dest_column)); + dest+=&dest_row; + } + src.set_current(saved_src_current); + } else { // dest is nameless + for(int src_row=0; src_row