|
|
| version 1.199, 2011/05/19 06:58:40 | version 1.201, 2012/01/08 05:58:27 |
|---|---|
| Line 554 const String* sql_result_string(Request& | Line 554 const String* sql_result_string(Request& |
| } | } |
| if(valid_options!=options->count()) | if(valid_options!=options->count()) |
| throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); | throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); |
| } else | } |
| throw Exception(PARSER_RUNTIME, 0, OPTIONS_MUST_BE_HASH); | |
| else | else |
| options=0; | options=0; |
| Line 606 static void _sql(Request& r, MethodParam | Line 605 static void _sql(Request& r, MethodParam |
| static void _replace(Request& r, MethodParams& params) { | static void _replace(Request& r, MethodParams& params) { |
| const String& src=GET_SELF(r, VString).string(); | const String& src=GET_SELF(r, VString).string(); |
| Table* table=params.as_no_junction(0, PARAM_MUST_NOT_BE_CODE).get_table(); | if(params.count()==1) { |
| if(!table) | // ^string.replace[table] |
| throw Exception(PARSER_RUNTIME, | Table* table=params.as_no_junction(0, PARAM_MUST_NOT_BE_CODE).get_table(); |
| 0, | if(!table) |
| "parameter must be table"); | throw Exception(PARSER_RUNTIME, |
| 0, | |
| "parameter must be table"); | |
| Dictionary dict(*table); | |
| r.write_assign_lang(src.replace(dict)); | |
| } else { | |
| // ^string.replace[from-string;to-string] | |
| Dictionary dict( | |
| params.as_string(0, "from must be string"), | |
| params.as_string(1, "to must be string") | |
| ); | |
| r.write_assign_lang(src.replace(dict)); | |
| } | |
| Dictionary dict(*table); | |
| r.write_assign_lang(src.replace(dict)); | |
| } | } |
| static void _save(Request& r, MethodParams& params) { | static void _save(Request& r, MethodParams& params) { |
| Line 783 MString::MString(): Methoded("string") { | Line 792 MString::MString(): Methoded("string") { |
| add_native_method("sql", Method::CT_STATIC, _sql, 1, 2); | add_native_method("sql", Method::CT_STATIC, _sql, 1, 2); |
| // ^string.replace[table] | // ^string.replace[table] |
| add_native_method("replace", Method::CT_DYNAMIC, _replace, 1, 1); | add_native_method("replace", Method::CT_DYNAMIC, _replace, 1, 2); |
| // ^string.save[append][file] | // ^string.save[append][file] |
| // ^string.save[file] | // ^string.save[file] |