--- parser3/src/classes/table.C 2005/11/25 09:52:07 1.217 +++ parser3/src/classes/table.C 2006/04/09 13:38:47 1.221 @@ -4,7 +4,8 @@ Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_TABLE_C="$Date: 2005/11/25 09:52:07 $"; + +static const char * const IDENT_TABLE_C="$Date: 2006/04/09 13:38:47 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -33,6 +34,10 @@ public: // Methoded DECLARE_CLASS_VAR(table, new MTable, 0); +// externs + +extern String cycle_data_name; + // defines for globals #define SQL_BIND_NAME "bind" @@ -331,9 +336,10 @@ static void _load(Request& r, MethodPara } Table& table=*new Table(columns); + int columns_count=columns? columns->count(): 0; // parse cells - Table::element_type row(new ArrayString); + Table::element_type row(new ArrayString(columns_count)); skip_empty_and_comment_lines(&data); while( lsplit_result sr=lsplit(&data, separators.column, '\n', separators.encloser) ) { if(!*sr.piece && !sr.delim && !row->count()) // append last empty column [if without \n] @@ -341,7 +347,7 @@ static void _load(Request& r, MethodPara *row+=new String(sr.piece, 0, true); if(sr.delim=='\n') { table+=row; - row=new ArrayString; + row=new ArrayString(columns_count); skip_empty_and_comment_lines(&data); } } @@ -358,9 +364,10 @@ static void maybe_enclose( String& to, c to<<*sencloser; // while we have 'encloser'... size_t pos_after=0; - for( size_t pos_before; (pos_before=from.pos( encloser, pos_after ))!=STRING_NOT_FOUND; pos_after=pos_before+1) { - to< + cycle_data_setter(r.classes_conf, cycle_data_name, /*any not null flag*/&r); + Value& body_code=params.as_junction(0, "body must be code"); Value* delim_maybe_code=params.count()>1?¶ms[1]:0; @@ -500,6 +510,7 @@ static void _menu(Request& r, MethodPara table.set_current(row); StringOrValue sv_processed=r.process(body_code); + Request::Skip lskip=r.get_skip(); r.set_skip(Request::SKIP_NOTHING); const String* s_processed=sv_processed.get_string(); if(delim_maybe_code && s_processed && s_processed->length()) { // delimiter set and we have body if(need_delim) // need delim & iteration produced string? @@ -507,6 +518,9 @@ static void _menu(Request& r, MethodPara need_delim=true; } r.write_pass_lang(sv_processed); + + if(lskip==Request::SKIP_BREAK) + break; } table.set_current(saved_current); } @@ -845,6 +859,7 @@ static void _join(Request& r, MethodPara #ifndef DOXYGEN class Table_sql_event_handlers: public SQL_Driver_query_event_handlers { ArrayString& columns; + int columns_count; ArrayString* row; public: Table* table; @@ -865,6 +880,7 @@ public: bool before_rows(SQL_Error& error) { try { table=new Table(&columns); + columns_count=columns.count(); return false; } catch(...) { error=SQL_Error("exception occured in Table_sql_event_handlers::before_rows"); @@ -873,7 +889,7 @@ public: } bool add_row(SQL_Error& error) { try { - *table+=row=new ArrayString; + *table+=row=new ArrayString(columns_count); return false; } catch(...) { error=SQL_Error("exception occured in Table_sql_event_handlers::add_row"); @@ -914,7 +930,7 @@ int marshal_binds(HashStringValue& hash, int hash_count=hash.count(); placeholders=new(UseGC) SQL_Driver::Placeholder[hash_count]; SQL_Driver::Placeholder* ptr=placeholders; - hash.for_each(marshal_bind, &ptr); + hash.for_each(marshal_bind, &ptr); return hash_count; }