--- parser3/src/classes/string.C 2005/11/18 12:51:18 1.142.6.4 +++ parser3/src/classes/string.C 2005/08/09 08:14:48 1.143 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_STRING_C="$Date: 2005/11/18 12:51:18 $"; +static const char * const IDENT_STRING_C="$Date: 2005/08/09 08:14:48 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -54,6 +54,8 @@ static void _length(Request& r, MethodPa static void _int(Request& r, MethodParams& params) { const String& self_string=GET_SELF(r, VString).string(); int converted; + Value* default_code=params.count()>0?¶ms.as_junction(0, "default must be int") + :0; // (default) try { if(self_string.is_empty()) throw Exception("parser.runtime", @@ -61,8 +63,8 @@ static void _int(Request& r, MethodParam "parameter is empty string, error converting"); converted=self_string.as_int(); } catch(...) { // convert problem - if(params.count()>0) - converted=params.as_int(0, "default must be int", r); // (default) + if(default_code) + converted=r.process_to_value(*default_code).as_int(); else rethrow; // we have a problem when no default } @@ -72,6 +74,8 @@ static void _int(Request& r, MethodParam static void _double(Request& r, MethodParams& params) { const String& self_string=GET_SELF(r, VString).string(); double converted; + Value* default_code=params.count()>0?¶ms.as_junction(0, "default must be double") + :0; // (default) try { if(self_string.is_empty()) throw Exception("parser.runtime", @@ -79,8 +83,8 @@ static void _double(Request& r, MethodPa "parameter is empty string, error converting"); converted=self_string.as_double(); } catch(...) { // convert problem - if(params.count()>0) - converted=params.as_double(0, "default must be double", r); // (default) + if(default_code) + converted=r.process_to_value(*default_code).as_double(); else rethrow; // we have a problem when no default } @@ -429,7 +433,7 @@ const String* sql_result_string(Request& default_code=0; if(params.count()>1) { Value& voptions=params.as_no_junction(1, "options must be hash, not code"); - if(voptions.is_defined() && !voptions.is_string()) + if(!voptions.is_string()) if((options=voptions.get_hash())) { int valid_options=0; if(Value* vbind=options->get(sql_bind_name)) { @@ -489,6 +493,7 @@ const String* sql_result_string(Request& } static void _sql(Request& r, MethodParams& params) { + HashStringValue* options; Value* default_code; const String* string=sql_result_string(r, params, options, default_code);