|
|
| version 1.60, 2007/02/03 18:08:38 | version 1.65, 2012/04/19 19:41:29 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b double parser class. | Parser: @b double parser class. |
| Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2012 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) |
| */ | */ |
| static const char * const IDENT_DOUBLE_C="$Date$"; | |
| #include "classes.h" | #include "classes.h" |
| #include "pa_vmethod_frame.h" | #include "pa_vmethod_frame.h" |
| Line 15 static const char * const IDENT_DOUBLE_C | Line 13 static const char * const IDENT_DOUBLE_C |
| #include "pa_vint.h" | #include "pa_vint.h" |
| #include "pa_vbool.h" | #include "pa_vbool.h" |
| volatile const char * IDENT_DOUBLE_C="$Id$" IDENT_PA_VDOUBLE_H; | |
| // externs | // externs |
| void _string_format(Request& r, MethodParams&); | void _string_format(Request& r, MethodParams&); |
| Line 24 void _string_format(Request& r, MethodPa | Line 24 void _string_format(Request& r, MethodPa |
| class MDouble: public Methoded { | class MDouble: public Methoded { |
| public: | public: |
| MDouble(); | MDouble(); |
| public: // Methoded | |
| bool used_directly() { return true; } | |
| }; | }; |
| // global variable | // global variable |
| Line 58 static void _bool(Request& r, MethodPara | Line 56 static void _bool(Request& r, MethodPara |
| params.as_double(0, "default must be bool", r); | params.as_double(0, "default must be bool", r); |
| VDouble& vdouble=GET_SELF(r, VDouble); | VDouble& vdouble=GET_SELF(r, VDouble); |
| r.write_no_lang(*new VBool(vdouble.as_bool())); | r.write_no_lang(VBool::get(vdouble.as_bool())); |
| } | } |
| typedef void (*vdouble_op_func_ptr)(VDouble& vdouble, double param); | typedef void (*vdouble_op_func_ptr)(VDouble& vdouble, double param); |
| Line 84 static void _div(Request& r, MethodParam | Line 82 static void _div(Request& r, MethodParam |
| static void _mod(Request& r, MethodParams& params) { vdouble_op(r, params, &__mod); } | static void _mod(Request& r, MethodParams& params) { vdouble_op(r, params, &__mod); } |
| // from string.C | // from string.C |
| extern | extern const String* sql_result_string(Request& r, MethodParams& params, Value*& default_code); |
| const String* sql_result_string(Request& r, MethodParams& params, | |
| HashStringValue*& options, Value*& default_code); | |
| static void _sql(Request& r, MethodParams& params) { | static void _sql(Request& r, MethodParams& params) { |
| double val; | double val; |
| HashStringValue* options; | |
| Value* default_code; | Value* default_code; |
| if(const String* string=sql_result_string(r, params, options, default_code)) | if(const String* string=sql_result_string(r, params, default_code)) |
| val=string->as_double(); | val=string->as_double(); |
| else | else |
| if(default_code) | if(default_code) |
| val=r.process_to_value(*default_code).as_double(); | val=r.process_to_value(*default_code).as_double(); |
| else { | else { |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "produced no result, but no default option specified"); | "produced no result, but no default option specified"); |
| } | } |