|
|
| version 1.131, 2001/11/20 17:58:47 | version 1.136, 2001/12/15 21:28:18 |
|---|---|
| Line 8 | Line 8 |
| */ | */ |
| #include "classes.h" | #include "classes.h" |
| #include "pa_config_includes.h" | |
| #include "pa_common.h" | #include "pa_common.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| #include "pa_vtable.h" | #include "pa_vtable.h" |
| Line 38 public: // Methoded | Line 37 public: // Methoded |
| static void _set(Request& r, const String& method_name, MethodParams *params) { | static void _set(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| // data is last parameter | // data is last parameter |
| Value& vdata=params->as_junction(params->size()-1, "body must be code"); | |
| Temp_lang temp_lang(r, String::UL_PASS_APPENDED); | Temp_lang temp_lang(r, String::UL_PASS_APPENDED); |
| const String& data=r.process(vdata).as_string(); | const String& data= |
| r.process(params->as_junction(params->size()-1, "body must be code")).as_string(); | |
| size_t pos_after=0; | size_t pos_after=0; |
| // parse columns | // parse columns |
| Line 208 static void _offset(Request& r, const St | Line 206 static void _offset(Request& r, const St |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| Table& table=static_cast<VTable *>(r.self)->table(); | Table& table=static_cast<VTable *>(r.self)->table(); |
| if(params->size()) { | if(params->size()) { |
| Value& offset_expr=params->as_junction(0, "offset must be expression"); | bool absolute=false; |
| table.shift(r.process(offset_expr).as_int()); | if(params->size()>1) { |
| const String& whence=params->as_string(0, "whence must be string"); | |
| if(whence=="cur") | |
| absolute=false; | |
| else if(whence=="set") | |
| absolute=true; | |
| else | |
| throw Exception(0, 0, | |
| &whence, | |
| "is invalid whence, valid are 'cur' or 'set'"); | |
| } | |
| Value& offset_expr=params->as_junction(params->size()-1, "offset must be expression"); | |
| table.offset(absolute, r.process(offset_expr).as_int()); | |
| } else { | } else { |
| Value& value=*new(pool) VInt(pool, table.current()); | Value& value=*new(pool) VInt(pool, table.current()); |
| value.set_name(method_name); | value.set_name(method_name); |
| Line 413 static void _flip(Request& r, const Stri | Line 424 static void _flip(Request& r, const Stri |
| static void _append(Request& r, const String& method_name, MethodParams *params) { | static void _append(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| // data is last parameter | // data |
| Temp_lang temp_lang(r, String::UL_PASS_APPENDED); | |
| const String& string= | const String& string= |
| r.process(params->as_junction(0, "body must be code")).as_string(); | r.process(params->as_junction(0, "body must be code")).as_string(); |
| Line 537 static void _sql(Request& r, const Strin | Line 549 static void _sql(Request& r, const Strin |
| Table_sql_event_handlers handlers(pool, method_name, | Table_sql_event_handlers handlers(pool, method_name, |
| statement_string, statement_cstr); | statement_string, statement_cstr); |
| try { | try { |
| #ifdef RESOURCES_DEBUG | |
| struct timeval mt[2]; | |
| //measure:before | |
| gettimeofday(&mt[0],NULL); | |
| #endif | |
| r.connection->query( | r.connection->query( |
| statement_cstr, offset, limit, | statement_cstr, offset, limit, |
| handlers); | handlers); |
| #ifdef RESOURCES_DEBUG | |
| //measure:after connect | |
| gettimeofday(&mt[1],NULL); | |
| double t[2]; | |
| for(int i=0;i<2;i++) | |
| t[i]=mt[i].tv_sec+mt[i].tv_usec/1000000.0; | |
| r.sql_request_time+=t[1]-t[0]; | |
| #endif | |
| } catch(const Exception& e) { // query problem | } catch(const Exception& e) { // query problem |
| // more specific source [were url] | // more specific source [were url] |
| throw Exception(e.type(), e.code(), | throw Exception(e.type(), e.code(), |
| Line 601 MTable::MTable(Pool& apool) : Methoded(a | Line 629 MTable::MTable(Pool& apool) : Methoded(a |
| add_native_method("line", Method::CT_DYNAMIC, _line, 0, 0); | add_native_method("line", Method::CT_DYNAMIC, _line, 0, 0); |
| // ^table.offset[] | // ^table.offset[] |
| // ^table.offset[offset] | // ^table.offset(offset) |
| add_native_method("offset", Method::CT_DYNAMIC, _offset, 0, 1); | // ^table.offset[cur|set](offset) |
| add_native_method("offset", Method::CT_DYNAMIC, _offset, 0, 2); | |
| // ^table.menu{code} | // ^table.menu{code} |
| // ^table.menu{code}[delim] | // ^table.menu{code}[delim] |