--- parser3/src/classes/table.C 2001/08/28 10:33:32 1.107 +++ parser3/src/classes/table.C 2001/09/26 10:32:25 1.115 @@ -2,10 +2,10 @@ Parser: @b table parser class. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: table.C,v 1.115 2001/09/26 10:32:25 parser Exp $ */ -static const char *RCSId="$Id: table.C,v 1.107 2001/08/28 10:33:32 parser Exp $"; #include "classes.h" #include "pa_config_includes.h" @@ -342,20 +342,14 @@ static void _menu(Request& r, const Stri table.set_current(saved_current); } -static void _empty(Request& r, const String& method_name, MethodParams *params) { - Pool& pool=r.pool(); - Table& table=static_cast(r.self)->table(); - - r.write_no_lang(*new(pool) VBool(pool, table.size()==0)); -} - -/// used by table: _hash / table_row_to_hash +#ifndef DOXYGEN struct Row_info { Table *table; int key_field; Array *value_fields; Hash *hash; }; +#endif static void table_row_to_hash(Array::Item *value, void *info) { Array& row=*static_cast(value); Row_info& ri=*static_cast(info); @@ -410,7 +404,7 @@ static void _hash(Request& r, const Stri r.write_no_lang(result); } -/// used by table: _sort / sort_cmp_string|sort_cmp_double +#ifndef DOXYGEN struct Table_seq_item { Array *row; union { @@ -418,6 +412,7 @@ struct Table_seq_item { double d; } value; }; +#endif static int sort_cmp_string(const void *a, const void *b) { return strcmp( static_cast(a)->value.c_str, @@ -617,16 +612,17 @@ static void _sql(Request& r, const Strin ulong limit=0; ulong offset=0; if(params->size()>1) { - Value& options_param=params->as_no_junction(1, "options must be hash, not code"); - if(Hash *options=options_param.get_hash()) { - if(Value *vlimit=(Value *)options->get(*sql_limit_name)) - limit=(ulong)r.process(*vlimit).as_double(); - if(Value *voffset=(Value *)options->get(*sql_offset_name)) - offset=(ulong)r.process(*voffset).as_double(); - } else - PTHROW(0, 0, - &method_name, - "options must be hash"); + Value& voptions=params->as_no_junction(1, "options must be hash, not code"); + if(voptions.is_defined()) + if(Hash *options=voptions.get_hash()) { + if(Value *vlimit=(Value *)options->get(*sql_limit_name)) + limit=(ulong)r.process(*vlimit).as_double(); + if(Value *voffset=(Value *)options->get(*sql_offset_name)) + offset=(ulong)r.process(*voffset).as_double(); + } else + PTHROW(0, 0, + &method_name, + "options must be hash"); } Temp_lang temp_lang(r, String::UL_SQL); @@ -636,7 +632,7 @@ static void _sql(Request& r, const Strin Table_sql_event_handlers handlers(pool, method_name, statement_string, statement_cstr); bool need_rethrow=false; Exception rethrow_me; - PTRY { + PTRY { r.connection->query( statement_cstr, offset, limit, handlers); @@ -715,9 +711,6 @@ MTable::MTable(Pool& apool) : Methoded(a // ^table.menu{code}[delim] add_native_method("menu", Method::CT_DYNAMIC, _menu, 1, 2); - // ^table.empty[] - add_native_method("empty", Method::CT_DYNAMIC, _empty, 0, 0); - // ^table:hash[key field name] // ^table:hash[key field name][value field name;...] add_native_method("hash", Method::CT_DYNAMIC, _hash, 1, 1000);