--- parser3/src/classes/void.C 2001/11/05 11:46:21 1.13 +++ parser3/src/classes/void.C 2002/08/01 11:26:44 1.20 @@ -1,12 +1,12 @@ /** @file Parser: @b VOID parser class. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) - - $Id: void.C,v 1.13 2001/11/05 11:46:21 paf Exp $ + Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) */ +static const char* IDENT_VOID_C="$Id: void.C,v 1.20 2002/08/01 11:26:44 paf Exp $"; + #include "classes.h" #include "pa_request.h" #include "pa_vint.h" @@ -14,10 +14,6 @@ #include "pa_vvoid.h" #include "pa_sql_connection.h" -// defines - -#define VOID_CLASS_NAME "void" - // class class MVoid : public Methoded { @@ -52,7 +48,7 @@ public: void add_column(void *ptr, size_t size) { /* ignore */ } void before_rows() { // there are some result rows, which is wrong - throw Exception(0, 0, + throw Exception("parser.runtime", &statement_string, "must return nothing"); } @@ -67,25 +63,20 @@ private: static void _sql(Request& r, const String& method_name, MethodParams *params) { 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"); 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= - 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); try { - r.connection->query( + r.connection(&method_name)->query( statement_cstr, 0, 0, handlers); } catch(const Exception& e) { // more specific source [were url] - throw Exception(e.type(), e.code(), + throw Exception("sql.execute", &statement_string, "%s", e.comment()); } @@ -93,10 +84,7 @@ static void _sql(Request& r, const Strin // constructor -MVoid::MVoid(Pool& apool) : Methoded(apool) { - set_name(*NEW String(pool(), VOID_CLASS_NAME)); - - +MVoid::MVoid(Pool& apool) : Methoded(apool, "void") { // ^void.int[] // ^void.int(default) add_native_method("int", Method::CT_DYNAMIC, _int, 0, 1);