--- parser3/src/classes/table.C 2002/12/09 11:07:40 1.169 +++ parser3/src/classes/table.C 2003/01/31 12:34:27 1.172.2.2 @@ -1,11 +1,11 @@ /** @file Parser: @b table parser class. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_TABLE_C="$Date: 2002/12/09 11:07:40 $"; +static const char* IDENT_TABLE_C="$Date: 2003/01/31 12:34:27 $"; #include "classes.h" #include "pa_common.h" @@ -19,7 +19,7 @@ static const char* IDENT_TABLE_C="$Date: class MTable : public Methoded { public: // VStateless_class - Value *create_new_value(Pool& pool) { return new(pool) VTable(pool); } + ValuePtr create_new_value() { return ValuePtr(new VTable()); } public: MTable(Pool& pool); @@ -143,7 +143,7 @@ static void _load(Request& r, const Stri Array *columns; #ifndef NO_STRING_ORIGIN const Origin& origin=method_name.origin(); - const char *file=origin.file; + const char* file=origin.file; uint line=origin.line; #endif if(nameless) { @@ -457,8 +457,6 @@ static void _sort(Request& r, const Stri // calculate key values bool key_values_are_strings=true; - // save 'current' - int saved_current=old_table.current(); for(i=0; iAPPEND_TAINTED( - (const char *)ptr, size, - statement_cstr, 0); - columns+=column; - } - void before_rows() { - table=new(pool) Table(pool, &method_name, &columns); - } - void add_row() { - (*table)+=(row=new(pool) Array(pool)); - } - void add_row_cell(void *ptr, size_t size) { - String *cell=new(pool) String(pool); - if(size) - cell->APPEND_TAINTED( - (const char *)ptr, size, - statement_cstr, table->size()-1); - (*row)+=cell; + bool add_column(SQL_Error& error, void *ptr, size_t size) { + try { + String *column=new(pool) String(pool); + column->APPEND_TAINTED( + (const char* )ptr, size, + statement_cstr, 0); + columns+=column; + return false; + } catch(...) { + error=SQL_Error("exception occured in Table_sql_event_handlers::add_column"); + return true; + } + } + bool before_rows(SQL_Error& error) { + try { + table=new(pool) Table(pool, &method_name, &columns); + return false; + } catch(...) { + error=SQL_Error("exception occured in Table_sql_event_handlers::before_rows"); + return true; + } + } + bool add_row(SQL_Error& error) { + try { + (*table)+=(row=new(pool) Array(pool)); + return false; + } catch(...) { + error=SQL_Error("exception occured in Table_sql_event_handlers::add_row"); + return true; + } + } + bool add_row_cell(SQL_Error& error, void *ptr, size_t size) { + try { + String *cell=new(pool) String(pool); + if(size) + cell->APPEND_TAINTED( + (const char* )ptr, size, + statement_cstr, table->size()-1); + (*row)+=cell; + return false; + } catch(...) { + error=SQL_Error("exception occured in Table_sql_event_handlers::add_row_cell"); + return true; + } } private: Pool& pool; const String& method_name; - const String& statement_string; const char *statement_cstr; + const String& statement_string; const char* statement_cstr; Array& columns; Array *row; public: @@ -679,7 +699,7 @@ static void _sql(Request& r, const Strin Temp_lang temp_lang(r, String::UL_SQL); 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(&method_name)); Table_sql_event_handlers handlers(pool, method_name, statement_string, statement_cstr);