--- parser3/src/classes/hash.C 2006/06/09 19:03:49 1.78 +++ parser3/src/classes/hash.C 2007/05/18 12:44:22 1.80 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_HASH_C="$Date: 2006/06/09 19:03:49 $"; +static const char * const IDENT_HASH_C="$Date: 2007/05/18 12:44:22 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -73,7 +73,7 @@ public: } bool before_rows(SQL_Error& error) { if(columns.count()<1) { - error=SQL_Error("parser.runtime", "no columns"); + error=SQL_Error(PARSER_RUNTIME, "no columns"); return true; } only_one_column=columns.count()==1; @@ -100,7 +100,7 @@ public: row_hash->put(*columns[column_index], new VString(cell)); if(duplicate & !distinct) { - error=SQL_Error("parser.runtime", "duplicate key"); + error=SQL_Error(PARSER_RUNTIME, "duplicate key"); return true; } @@ -265,11 +265,11 @@ static void _sql(Request& r, MethodParam distinct=r.process_to_value(*vdistinct).as_bool(); } if(valid_options!=options->count()) - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, 0, "called with invalid option"); } else - throw Exception("parser.runtime", + throw Exception(PARSER_RUNTIME, 0, "options must be hash"); } @@ -333,6 +333,12 @@ static void _delete(Request& r, MethodPa GET_SELF(r, VHash).hash().remove(params.as_string(0, "key must be string")); } +static void _contain(Request& r, MethodParams& params) { + + bool result = GET_SELF(r, VHash).hash().contain(params.as_string(0, "key must be string")); + r.write_no_lang(*new VBool(result)); +} + #ifndef DOXYGEN struct Foreach_info { Request *r; @@ -406,7 +412,10 @@ MHash::MHash(): Methoded("hash") // ^a.delete[key] add_native_method("delete", Method::CT_DYNAMIC, _delete, 1, 1); - // ^hash:sql[query][options hash] + // ^a.contain[key] + add_native_method("contain", Method::CT_DYNAMIC, _contain, 1, 1); + + // ^hash::sql[query][options hash] add_native_method("sql", Method::CT_DYNAMIC, _sql, 1, 2); // ^hash._keys[[column name]]