|
|
| version 1.115, 2001/09/26 10:32:25 | version 1.121, 2001/10/09 08:13:04 |
|---|---|
| Line 65 static void _set(Request& r, const Strin | Line 65 static void _set(Request& r, const Strin |
| while(i.has_next()) { | while(i.has_next()) { |
| Array& row=*new(pool) Array(pool); | Array& row=*new(pool) Array(pool); |
| const String& string=*i.next_string(); | const String& string=*i.next_string(); |
| // remove empty lines | // remove comment lines |
| if(!string.size()) | if(!string.size()) |
| continue; | continue; |
| Line 110 static void _load(Request& r, const Stri | Line 110 static void _load(Request& r, const Stri |
| Table& table=*new(pool) Table(pool, &method_name, columns); | Table& table=*new(pool) Table(pool, &method_name, columns); |
| char *row_chars; | char *row_chars; |
| while(row_chars=getrow(&data)) { | while(row_chars=getrow(&data)) { |
| if(!*row_chars) // remove empty lines | // remove empty&comment lines |
| if(!*row_chars || *row_chars == '#') | |
| continue; | continue; |
| Array *row=new(pool) Array(pool); | Array *row=new(pool) Array(pool); |
| while(char *cell_chars=lsplit(&row_chars, '\t')) { | while(char *cell_chars=lsplit(&row_chars, '\t')) { |
| Line 133 static Table *fill_month_days(Request& r | Line 134 static Table *fill_month_days(Request& r |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| Table *result=new(pool) Table(pool, &method_name, 0/*&columns*/); | Table *result=new(pool) Table(pool, &method_name, 0/*&columns*/); |
| int year=params->as_int(1, r); | int year=params->as_int(1, "year must be int", r); |
| int month=max(1, min(params->as_int(2, r), 12)) -1; | int month=max(1, min(params->as_int(2, "month must be int", r), 12)) -1; |
| tm tmIn={0, 0, 0, 1, month, year-1900}; | tm tmIn={0, 0, 0, 1, month, year-1900}; |
| time_t t=mktime(&tmIn); | time_t t=mktime(&tmIn); |
| Line 176 static Table *fill_week_days(Request& r, | Line 177 static Table *fill_week_days(Request& r, |
| columns+=new(pool) String(pool, "weekday"); | columns+=new(pool) String(pool, "weekday"); |
| Table *result=new(pool) Table(pool, &method_name, &columns); | Table *result=new(pool) Table(pool, &method_name, &columns); |
| int year=params->as_int(1, r); | int year=params->as_int(1, "year must be int", r); |
| int month=max(1, min(params->as_int(2, r), 12)) -1; | int month=max(1, min(params->as_int(2, "month must be int", r), 12)) -1; |
| int day=params->as_int(3, r); | int day=params->as_int(3, "day must be int", r); |
| tm tmIn={0, 0, 18, day, month, year-1900}; | tm tmIn={0, 0, 18, day, month, year-1900}; |
| time_t t=mktime(&tmIn); | time_t t=mktime(&tmIn); |
| Line 320 static void _offset(Request& r, const St | Line 321 static void _offset(Request& r, const St |
| static void _menu(Request& r, const String& method_name, MethodParams *params) { | static void _menu(Request& r, const String& method_name, MethodParams *params) { |
| Value& body_code=params->as_junction(0, "body must be code"); | Value& body_code=params->as_junction(0, "body must be code"); |
| Value *delim_code=params->size()==2?¶ms->get(1):0; | Value *delim_maybe_code=params->size()==2?¶ms->get(1):0; |
| VTable& vtable=*static_cast<VTable *>(r.self); | VTable& vtable=*static_cast<VTable *>(r.self); |
| Table& table=vtable.table(); | Table& table=vtable.table(); |
| Line 331 static void _menu(Request& r, const Stri | Line 332 static void _menu(Request& r, const Stri |
| table.set_current(row); | table.set_current(row); |
| Value& processed_body=r.process(body_code); | Value& processed_body=r.process(body_code); |
| if(delim_code) { // delimiter set? | if(delim_maybe_code) { // delimiter set? |
| const String *string=processed_body.get_string(); | const String *string=processed_body.get_string(); |
| if(need_delim && string && string->size()) // need delim & iteration produced string? | if(need_delim && string && string->size()) // need delim & iteration produced string? |
| r.write_pass_lang(r.process(*delim_code)); | r.write_pass_lang(r.process(*delim_maybe_code)); |
| need_delim=true; | need_delim=true; |
| } | } |
| r.write_pass_lang(processed_body); | r.write_pass_lang(processed_body); |
| Line 470 static void _sort(Request& r, const Stri | Line 471 static void _sort(Request& r, const Stri |
| for(i=0; i<old_table.size(); i++) | for(i=0; i<old_table.size(); i++) |
| new_table+=seq[reverse?old_table.size()-1-i:i].row; | new_table+=seq[reverse?old_table.size()-1-i:i].row; |
| r.write_no_lang(*new(pool) VTable(pool, &new_table)); | // replace any previous table value |
| static_cast<VTable *>(r.self)->set_table(new_table); | |
| } | } |
| static void _locate(Request& r, const String& method_name, MethodParams *params) { | static void _locate(Request& r, const String& method_name, MethodParams *params) { |
| Line 479 static void _locate(Request& r, const St | Line 481 static void _locate(Request& r, const St |
| VTable& vtable=*static_cast<VTable *>(r.self); | VTable& vtable=*static_cast<VTable *>(r.self); |
| Table& table=vtable.table(); | Table& table=vtable.table(); |
| Value& result=*new(pool) VBool(pool, table.locate( | Value& result=*new(pool) VBool(pool, table.locate( |
| params->get(0).as_string(), | params->as_string(0, "column name must be string"), |
| params->get(1).as_string())); | params->as_string(1, "value must be string") |
| )); | |
| result.set_name(method_name); | result.set_name(method_name); |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } | } |