|
|
| version 1.7, 2001/08/09 06:48:45 | version 1.13, 2001/11/05 11:46:21 |
|---|---|
| Line 2 | Line 2 |
| Parser: @b VOID parser class. | Parser: @b VOID parser class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | $Id$ |
| */ | */ |
| static const char *RCSId="$Id$"; | |
| #include "classes.h" | #include "classes.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| Line 29 public: // Methoded | Line 29 public: // Methoded |
| // methods | // methods |
| static void _int(Request& r, const String&, MethodParams *) { | static void _int(Request& r, const String&, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VVoid *vvoid=static_cast<VVoid *>(r.self); | VVoid *vvoid=static_cast<VVoid *>(r.self); |
| r.write_no_lang(*new(pool) VInt(pool, vvoid->as_int())); | r.write_no_lang(*new(pool) VInt(pool, |
| params->size()==0?vvoid->as_int():params->as_int(0, "default must be int", r))); | |
| } | } |
| static void _double(Request& r, const String&, MethodParams *) { | static void _double(Request& r, const String&, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VVoid *vvoid=static_cast<VVoid *>(r.self); | VVoid *vvoid=static_cast<VVoid *>(r.self); |
| r.write_no_lang(*new(pool) VDouble(pool, vvoid->as_double())); | r.write_no_lang(*new(pool) VDouble(pool, |
| params->size()==0?vvoid->as_double():params->as_double(0, "default must be double", r))); | |
| } | } |
| #ifndef DOXYGEN | #ifndef DOXYGEN |
| Line 50 public: | Line 52 public: |
| void add_column(void *ptr, size_t size) { /* ignore */ } | void add_column(void *ptr, size_t size) { /* ignore */ } |
| void before_rows() { | void before_rows() { |
| // there are some result rows, which is wrong | // there are some result rows, which is wrong |
| PTHROW(0, 0, | throw Exception(0, 0, |
| &statement_string, | &statement_string, |
| "must return nothing"); | "must return nothing"); |
| } | } |
| Line 66 static void _sql(Request& r, const Strin | Line 68 static void _sql(Request& r, const Strin |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| if(!r.connection) | if(!r.connection) |
| PTHROW(0, 0, | throw Exception(0, 0, |
| &method_name, | &method_name, |
| "without connect"); | "without connect"); |
| Line 77 static void _sql(Request& r, const Strin | Line 79 static void _sql(Request& r, const Strin |
| const char *statement_cstr= | const char *statement_cstr= |
| statement_string.cstr(String::UL_UNSPECIFIED, r.connection); | statement_string.cstr(String::UL_UNSPECIFIED, r.connection); |
| Void_sql_event_handlers handlers(pool, statement_string); | Void_sql_event_handlers handlers(pool, statement_string); |
| bool need_rethrow=false; Exception rethrow_me; | try { |
| PTRY { | |
| r.connection->query( | r.connection->query( |
| statement_cstr, 0, 0, | statement_cstr, 0, 0, |
| handlers); | handlers); |
| } catch(const Exception& e) { | |
| // more specific source [were url] | |
| throw Exception(e.type(), e.code(), | |
| &statement_string, | |
| "%s", e.comment()); | |
| } | } |
| PCATCH(e) { | |
| rethrow_me=e; need_rethrow=true; | |
| } | |
| PEND_CATCH | |
| if(need_rethrow) | |
| PTHROW(rethrow_me.type(), rethrow_me.code(), | |
| &statement_string, // setting more specific source [were url] | |
| rethrow_me.comment()); | |
| } | } |
| // constructor | // constructor |
| Line 99 MVoid::MVoid(Pool& apool) : Methoded(apo | Line 97 MVoid::MVoid(Pool& apool) : Methoded(apo |
| set_name(*NEW String(pool(), VOID_CLASS_NAME)); | set_name(*NEW String(pool(), VOID_CLASS_NAME)); |
| // ^VOID.int[] | // ^void.int[] |
| add_native_method("int", Method::CT_DYNAMIC, _int, 0, 0); | // ^void.int(default) |
| add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1); | |
| // ^VOID.double[] | |
| add_native_method("double", Method::CT_DYNAMIC, _double, 0, 0); | // ^void.double[] |
| // ^void.double(default) | |
| add_native_method("double", Method::CT_DYNAMIC, _double, 0, 1); | |
| // ^sql[query] | // ^sql[query] |
| add_native_method("sql", Method::CT_STATIC, _sql, 1, 1); | add_native_method("sql", Method::CT_STATIC, _sql, 1, 1); |