--- parser3/src/classes/table.C 2002/10/23 09:32:17 1.166 +++ parser3/src/classes/table.C 2002/12/09 11:07:40 1.169 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_TABLE_C="$Date: 2002/10/23 09:32:17 $"; +static const char* IDENT_TABLE_C="$Date: 2002/12/09 11:07:40 $"; #include "classes.h" #include "pa_common.h" @@ -125,12 +125,19 @@ static void _create(Request& r, const St static void _load(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - // filename is last parameter - Value& vfile_name=params->as_no_junction(params->size()-1, - "file name must not be code"); - + const String& first_param=params->as_string(0, "file name must be string"); + int filename_param_index=0; + bool nameless=first_param=="nameless"; + if(nameless) + filename_param_index++; + int options_param_index=filename_param_index+1; + // loading text - char *data=file_read_text(pool, r.absolute(vfile_name.as_string())); + char *data=file_read_text(pool, + r.absolute(params->as_string(filename_param_index, "file name must be string")), + true, + options_param_indexsize()?params->as_no_junction(options_param_index, "additional params must be hash").get_hash(&method_name):0 + ); // parse columns Array *columns; @@ -139,7 +146,7 @@ static void _load(Request& r, const Stri const char *file=origin.file; uint line=origin.line; #endif - if(params->size()==2) { + if(nameless) { columns=0; // nameless } else { columns=new(pool) Array(pool); @@ -311,7 +318,7 @@ struct Row_info { Array *value_fields; Hash *hash; bool distinct; - int index; + int row; }; #endif static void table_row_to_hash(Array::Item *value, void *info) { @@ -321,7 +328,7 @@ static void table_row_to_hash(Array::Ite const String *key; if(ri.key_code) { - ri.table->set_current(ri.index++); // change context row + ri.table->set_current(ri.row++); // change context row StringOrValue sv_processed=ri.r->process(*ri.key_code); key=&sv_processed.as_string(); } else @@ -594,7 +601,7 @@ static void _join(Request& r, const Stri } #ifndef DOXYGEN -class Table_sql_event_handlers : public SQL_Driver_query_event_handlers { +class Table_sql_event_handlers: public SQL_Driver_query_event_handlers { public: Table_sql_event_handlers(Pool& apool, const String& amethod_name, const String& astatement_string, const char *astatement_cstr) : @@ -765,7 +772,7 @@ MTable::MTable(Pool& apool) : Methoded(a // ^table::load[file] // ^table::load[nameless;file] - add_native_method("load", Method::CT_DYNAMIC, _load, 1, 2); + add_native_method("load", Method::CT_DYNAMIC, _load, 1, 3); // ^table.save[file] // ^table.save[nameless;file]