|
|
| version 1.222, 2015/10/26 01:21:54 | version 1.224, 2016/03/31 21:46:20 |
|---|---|
| Line 31 public: | Line 31 public: |
| // global variable | // global variable |
| DECLARE_CLASS_VAR(string, new MString, 0); | DECLARE_CLASS_VAR(string, new MString); |
| // void class, inherited from string and thus should be inited afterwards | // void class, inherited from string and thus should be inited afterwards |
| Line 42 public: | Line 42 public: |
| // void global variable should be after string global variable | // void global variable should be after string global variable |
| DECLARE_CLASS_VAR(void, new MVoid, 0); | DECLARE_CLASS_VAR(void, new MVoid); |
| // defines for statics | // defines for statics |
| 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) { |