|
|
| version 1.13, 2001/11/05 11:46:21 | version 1.22, 2002/08/15 10:38:18 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b VOID parser class. | Parser: @b VOID parser class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | |
| */ | */ |
| static const char* IDENT_VOID_C="$Date$"; | |
| #include "classes.h" | #include "classes.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| #include "pa_vint.h" | #include "pa_vint.h" |
| Line 14 | Line 14 |
| #include "pa_vvoid.h" | #include "pa_vvoid.h" |
| #include "pa_sql_connection.h" | #include "pa_sql_connection.h" |
| // defines | |
| #define VOID_CLASS_NAME "void" | |
| // class | // class |
| class MVoid : public Methoded { | class MVoid : public Methoded { |
| Line 52 public: | Line 48 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 |
| throw Exception(0, 0, | throw Exception("parser.runtime", |
| &statement_string, | &statement_string, |
| "must return nothing"); | "must return nothing"); |
| } | } |
| Line 67 private: | Line 63 private: |
| 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(); |
| if(!r.connection) | |
| throw Exception(0, 0, | |
| &method_name, | |
| "without connect"); | |
| Value& statement=params->as_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_to_string(statement); |
| const char *statement_cstr= | const char *statement_cstr= |
| statement_string.cstr(String::UL_UNSPECIFIED, r.connection); | statement_string.cstr(String::UL_UNSPECIFIED, r.connection(&method_name)); |
| Void_sql_event_handlers handlers(pool, statement_string); | Void_sql_event_handlers handlers(pool, statement_string); |
| try { | r.connection(&method_name)->query( |
| r.connection->query( | statement_cstr, 0, 0, |
| statement_cstr, 0, 0, | handlers, |
| handlers); | statement_string); |
| } catch(const Exception& e) { | |
| // more specific source [were url] | |
| throw Exception(e.type(), e.code(), | |
| &statement_string, | |
| "%s", e.comment()); | |
| } | |
| } | } |
| // constructor | // constructor |
| MVoid::MVoid(Pool& apool) : Methoded(apool) { | MVoid::MVoid(Pool& apool) : Methoded(apool, "void") { |
| set_name(*NEW String(pool(), VOID_CLASS_NAME)); | |
| // ^void.int[] | // ^void.int[] |
| // ^void.int(default) | // ^void.int(default) |
| add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1); | add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1); |