|
|
| version 1.2, 2001/06/28 07:41:59 | version 1.6, 2001/08/09 06:44:04 |
|---|---|
| Line 4 | Line 4 |
| 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://design.ru/paf) | Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) |
| $Id$ | |
| */ | */ |
| static char *RCSId="$Id$"; | static const char *RCSId="$Id$"; |
| #include "classes.h" | #include "classes.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| Line 33 public: // Methoded | Line 31 public: // Methoded |
| static void _int(Request& r, const String&, MethodParams *) { | static void _int(Request& r, const String&, MethodParams *) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VInt *vunknown=static_cast<VInt *>(r.self); | VVoid *vvoid=static_cast<VVoid *>(r.self); |
| Value& value=*new(pool) VInt(pool, vunknown->as_int()); | Value& value=*new(pool) VVoid(pool, vvoid->as_int()); |
| r.write_no_lang(value); | r.write_no_lang(value); |
| } | } |
| static void _double(Request& r, const String&, MethodParams *) { | static void _double(Request& r, const String&, MethodParams *) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VInt *vunknown=static_cast<VInt *>(r.self); | VVoid *vvoid=static_cast<VVoid *>(r.self); |
| Value& value=*new(pool) VDouble(pool, vunknown->as_double()); | Value& value=*new(pool) VDouble(pool, vvoid->as_double()); |
| r.write_no_lang(value); | r.write_no_lang(value); |
| } | } |
| #ifndef DOXYGEN | |
| class Void_sql_event_handlers : public SQL_Driver_query_event_handlers { | |
| public: | |
| Void_sql_event_handlers(Pool& apool, const String& astatement_string) : | |
| pool(apool), statement_string(astatement_string) { | |
| } | |
| void add_column(void *ptr, size_t size) { /* ignore */ } | |
| void before_rows() { | |
| // there are some result rows, which is wrong | |
| PTHROW(0, 0, | |
| &statement_string, | |
| "must return nothing"); | |
| } | |
| void add_row() { /* never */ } | |
| void add_row_cell(void *ptr, size_t size) { /* never */ } | |
| private: | |
| Pool& pool; | |
| const String& statement_string; | |
| }; | |
| #endif | |
| static void _sql(Request& r, const String& method_name, MethodParams *params) { | static void _sql(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| Line 53 static void _sql(Request& r, const Strin | Line 72 static void _sql(Request& r, const Strin |
| &method_name, | &method_name, |
| "without connect"); | "without connect"); |
| Value& statement=params->get_junction(0, "statement must be code"); | Value& statement=params->as_junction(0, "statement must be code"); |
| Temp_lang temp_lang(r, String::UL_SQL); | Temp_lang temp_lang(r, String::UL_SQL); |
| const String& statement_string=r.process(statement).as_string(); | const String& statement_string=r.process(statement).as_string(); |
| const char *statement_cstr= | const char *statement_cstr= |
| statement_string.cstr(String::UL_UNSPECIFIED, r.connection); | statement_string.cstr(String::UL_UNSPECIFIED, r.connection); |
| unsigned int sql_column_count; SQL_Driver::Cell *sql_columns; | Void_sql_event_handlers handlers(pool, statement_string); |
| unsigned long sql_row_count; SQL_Driver::Cell **sql_rows; | |
| bool need_rethrow=false; Exception rethrow_me; | bool need_rethrow=false; Exception rethrow_me; |
| PTRY { | PTRY { |
| r.connection->query( | r.connection->query( |
| statement_cstr, 0, 0, | statement_cstr, 0, 0, |
| &sql_column_count, &sql_columns, | handlers); |
| &sql_row_count, &sql_rows); | |
| } | } |
| PCATCH(e) { // connect/process problem | PCATCH(e) { |
| rethrow_me=e; need_rethrow=true; | rethrow_me=e; need_rethrow=true; |
| } | } |
| PEND_CATCH | PEND_CATCH |
| Line 76 static void _sql(Request& r, const Strin | Line 93 static void _sql(Request& r, const Strin |
| PTHROW(rethrow_me.type(), rethrow_me.code(), | PTHROW(rethrow_me.type(), rethrow_me.code(), |
| &statement_string, // setting more specific source [were url] | &statement_string, // setting more specific source [were url] |
| rethrow_me.comment()); | rethrow_me.comment()); |
| // there are some result rows, which is wrong | |
| if(sql_row_count) | |
| PTHROW(0, 0, | |
| &statement_string, | |
| "must not return result"); | |
| } | } |
| // constructor | // constructor |