|
|
| version 1.220, 2015/10/07 22:25:40 | version 1.223, 2015/11/16 18:27:15 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b string parser class. | Parser: @b string parser class. |
| Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 92 static void _int(Request& r, MethodParam | Line 92 static void _int(Request& r, MethodParam |
| static void _double(Request& r, MethodParams& params) { | static void _double(Request& r, MethodParams& params) { |
| const String& self_string=GET_SELF(r, VString).string(); | const String& self_string=GET_SELF(r, VString).string(); |
| double converted; | |
| if(self_string.is_empty()) { | if(self_string.is_empty()) { |
| if(params.count()>0) | if(params.count()>0) |
| converted=params.as_double(0, "default must be double", r); // (default) | r.write_no_lang(*new VDouble(params.as_double(0, "default must be double", r))); // (default) |
| else | else |
| throw Exception(PARSER_RUNTIME, 0, "unable to convert empty string without default specified"); | throw Exception(PARSER_RUNTIME, 0, "unable to convert empty string without default specified"); |
| } else { | } else { |
| try { | try { |
| converted=self_string.as_double(); | r.write_no_lang(*new VDouble(self_string.as_double())); |
| } catch(...) { // convert problem | } catch(...) { // convert problem |
| if(params.count()>0) | if(params.count()>0) |
| converted=params.as_double(0, "default must be double", r); // (default) | r.write_no_lang(*new VDouble(params.as_double(0, "default must be double", r))); // (default) |
| else | else |
| rethrow; // we have a problem when no default | rethrow; // we have a problem when no default |
| } | } |
| } | } |
| r.write_no_lang(*new VDouble(converted)); | |
| } | } |
| static void _bool(Request& r, MethodParams& params) { | static void _bool(Request& r, MethodParams& params) { |
| Line 790 static void _unescape(Request& r, Method | Line 787 static void _unescape(Request& r, Method |
| const char* unescaped=unescape_chars(src.cstr(), src.length(), from_charset, mode_js); | const char* unescaped=unescape_chars(src.cstr(), src.length(), from_charset, mode_js); |
| if(*unescaped){ | if(*unescaped){ |
| const String* result=new String(Charset::transcode(String::Body(unescaped), *from_charset, r.charsets.source()), String::L_TAINTED); | const String* result=new String(Charset::transcode(unescaped, *from_charset, r.charsets.source()), String::L_TAINTED); |
| r.write_assign_lang(*result); | r.write_assign_lang(*result); |
| } | } |
| } | } |