|
|
| version 1.151, 2007/02/03 18:08:38 | version 1.154, 2007/08/20 10:02:51 |
|---|---|
| Line 56 static void _int(Request& r, MethodParam | Line 56 static void _int(Request& r, MethodParam |
| int converted; | int converted; |
| try { | try { |
| if(self_string.is_empty()) | if(self_string.is_empty()) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "parameter is empty string, error converting"); | "parameter is empty string, error converting"); |
| converted=self_string.as_int(); | converted=self_string.as_int(); |
| Line 74 static void _double(Request& r, MethodPa | Line 74 static void _double(Request& r, MethodPa |
| double converted; | double converted; |
| try { | try { |
| if(self_string.is_empty()) | if(self_string.is_empty()) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "parameter is empty string, error converting"); | "parameter is empty string, error converting"); |
| converted=self_string.as_double(); | converted=self_string.as_double(); |
| Line 93 static void _bool(Request& r, MethodPara | Line 93 static void _bool(Request& r, MethodPara |
| bool converted; | bool converted; |
| try { | try { |
| if(self_string.is_empty()) | if(self_string.is_empty()) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "parameter is empty string, error converting"); | "parameter is empty string, error converting"); |
| converted=self_string.as_bool(); | converted=self_string.as_bool(); |
| Line 121 static void _bool(Request& r, MethodPara | Line 121 static void _bool(Request& r, MethodPara |
| static void _left(Request& r, MethodParams& params) { | static void _left(Request& r, MethodParams& params) { |
| ssize_t sn=params.as_int(0, "n must be int", r); | ssize_t sn=params.as_int(0, "n must be int", r); |
| if(sn<0) | if(sn<0) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "n(%d) must be >=0", sn); | "n(%d) must be >=0", sn); |
| size_t n=(size_t)sn; | size_t n=(size_t)sn; |
| Line 133 static void _left(Request& r, MethodPara | Line 133 static void _left(Request& r, MethodPara |
| static void _right(Request& r, MethodParams& params) { | static void _right(Request& r, MethodParams& params) { |
| ssize_t sn=(size_t)params.as_int(0, "n must be int", r); | ssize_t sn=(size_t)params.as_int(0, "n must be int", r); |
| if(sn<0) | if(sn<0) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "n(%d) must be >=0", sn); | "n(%d) must be >=0", sn); |
| size_t n=(size_t)sn; | size_t n=(size_t)sn; |
| Line 149 static void _mid(Request& r, MethodParam | Line 149 static void _mid(Request& r, MethodParam |
| ssize_t sbegin=params.as_int(0, "p must be int", r); | ssize_t sbegin=params.as_int(0, "p must be int", r); |
| if(sbegin<0) | if(sbegin<0) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "p(%d) must be >=0", sbegin); | "p(%d) must be >=0", sbegin); |
| size_t begin=(size_t)sbegin; | size_t begin=(size_t)sbegin; |
| Line 158 static void _mid(Request& r, MethodParam | Line 158 static void _mid(Request& r, MethodParam |
| if(params.count()>1) { | if(params.count()>1) { |
| ssize_t sn=params.as_int(1, "n must be int", r); | ssize_t sn=params.as_int(1, "n must be int", r); |
| if(sn<0) | if(sn<0) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "n(%d) must be >=0", sn); | "n(%d) must be >=0", sn); |
| end=begin+(size_t)sn; | end=begin+(size_t)sn; |
| Line 209 static int split_options(const String* o | Line 209 static int split_options(const String* o |
| if(options->pos(o->keyL)!=STRING_NOT_FOUND | if(options->pos(o->keyL)!=STRING_NOT_FOUND |
| || (o->keyU && options->pos(o->keyU)!=STRING_NOT_FOUND)) { | || (o->keyU && options->pos(o->keyU)!=STRING_NOT_FOUND)) { |
| if(result & o->checkBit) | if(result & o->checkBit) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| options, | options, |
| "conflicting split options"); | "conflicting split options"); |
| result |= o->setBit; | result |= o->setBit; |
| Line 336 static void _match(Request& r, MethodPar | Line 336 static void _match(Request& r, MethodPar |
| Temp_lang temp_lang(r, String::L_PASS_APPENDED); | Temp_lang temp_lang(r, String::L_PASS_APPENDED); |
| const String& src=GET_SELF(r, VString).string(); | const String& src=GET_SELF(r, VString).string(); |
| bool just_matched; | int matches_count=0; |
| if(params.count()<3) { // search | if(params.count()<3) { // search |
| Table* table=src.match(r.charsets.source(), | Table* table=src.match(r.charsets.source(), |
| regexp.as_string(), options, | regexp.as_string(), options, |
| search_action, 0, | search_action, 0, |
| just_matched); | matches_count); |
| // Value* result; | // r.write_assign_lang(*new VTable(table)); |
| // if(table) | if(table){ |
| // result=new VTable(table); // table of pre/match/post+substrings | |
| // else | |
| // result=new VBool(just_matched); | |
| // r.write_assign_lang(*result); | |
| r.write_assign_lang(*new VTable(table)); | r.write_assign_lang(*new VTable(table)); |
| } else { | |
| r.write_assign_lang(*new VInt(matches_count)); | |
| } | |
| } else { // replace | } else { // replace |
| Value& replacement_code=params.as_junction(2, "replacement param must be code"); | Value& replacement_code=params.as_junction(2, "replacement param must be code"); |
| Line 367 static void _match(Request& r, MethodPar | Line 367 static void _match(Request& r, MethodPar |
| src.match(r.charsets.source(), | src.match(r.charsets.source(), |
| r.process_to_string(regexp), options, | r.process_to_string(regexp), options, |
| replace_action, &info, | replace_action, &info, |
| just_matched); | matches_count); |
| r.write_assign_lang(result); | r.write_assign_lang(result); |
| } | } |
| } | } |
| Line 402 public: | Line 402 public: |
| bool add_column(SQL_Error& error, const char* /*str*/, size_t /*length*/) { | bool add_column(SQL_Error& error, const char* /*str*/, size_t /*length*/) { |
| if(got_column) { | if(got_column) { |
| error=SQL_Error("parser.runtime", | error=SQL_Error(PARSER_RUNTIME, |
| //statement_string, | //statement_string, |
| "result must contain exactly one column"); | "result must contain exactly one column"); |
| return true; | return true; |
| Line 414 public: | Line 414 public: |
| bool add_row(SQL_Error& /*error*/) { /* ignore */ return false; } | bool add_row(SQL_Error& /*error*/) { /* ignore */ return false; } |
| bool add_row_cell(SQL_Error& error, const char* str, size_t length) { | bool add_row_cell(SQL_Error& error, const char* str, size_t length) { |
| if(got_cell) { | if(got_cell) { |
| error=SQL_Error("parser.runtime", | error=SQL_Error(PARSER_RUNTIME, |
| //statement_string, | //statement_string, |
| "result must not contain more then one row"); | "result must not contain more then one row"); |
| return true; | return true; |
| Line 468 const String* sql_result_string(Request& | Line 468 const String* sql_result_string(Request& |
| valid_options++; | valid_options++; |
| } | } |
| if(valid_options!=options->count()) | if(valid_options!=options->count()) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "called with invalid option"); | "called with invalid option"); |
| } else | } else |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "options must be hash"); | "options must be hash"); |
| } else | } else |
| Line 513 static void _sql(Request& r, MethodParam | Line 513 static void _sql(Request& r, MethodParam |
| if(default_code) { | if(default_code) { |
| string=&r.process_to_string(*default_code); | string=&r.process_to_string(*default_code); |
| } else | } else |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "produced no result, but no default option specified"); | "produced no result, but no default option specified"); |
| } | } |
| Line 526 static void _replace(Request& r, MethodP | Line 526 static void _replace(Request& r, MethodP |
| Table* table=params.as_no_junction(0, "parameter must not be code").get_table(); | Table* table=params.as_no_junction(0, "parameter must not be code").get_table(); |
| if(!table) | if(!table) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "parameter must be table"); | "parameter must be table"); |
| Line 535 static void _replace(Request& r, MethodP | Line 535 static void _replace(Request& r, MethodP |
| } | } |
| static void _save(Request& r, MethodParams& params) { | static void _save(Request& r, MethodParams& params) { |
| const String& file_name=params.as_string(params.count()-1, | const String& file_name=params.as_string(params.count()-1, FILE_NAME_MUST_BE_STRING); |
| "file name must be string"); | |
| const String& src=GET_SELF(r, VString).string(); | const String& src=GET_SELF(r, VString).string(); |
| Line 546 static void _save(Request& r, MethodPara | Line 545 static void _save(Request& r, MethodPara |
| if(mode=="append") | if(mode=="append") |
| do_append=true; | do_append=true; |
| else | else |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &mode, | &mode, |
| "unknown mode, must be 'append'"); | "unknown mode, must be 'append'"); |
| } | } |
| Line 579 static void _trim(Request& r, MethodPara | Line 578 static void _trim(Request& r, MethodPara |
| else if(skind==TRIM_BOTH_OPTION) | else if(skind==TRIM_BOTH_OPTION) |
| kind=String::TRIM_BOTH; | kind=String::TRIM_BOTH; |
| else | else |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &skind, | &skind, |
| "'kind' must be one of "TRIM_START_OPTION", "TRIM_BOTH_OPTION", "TRIM_END_OPTION); | "'kind' must be one of "TRIM_START_OPTION", "TRIM_BOTH_OPTION", "TRIM_END_OPTION); |