|
|
| version 1.164, 2008/07/17 09:11:35 | version 1.166, 2008/07/18 09:12:17 |
|---|---|
| Line 186 static void _pos(Request& r, MethodParam | Line 186 static void _pos(Request& r, MethodParam |
| Value& substr=params.as_no_junction(0, "substr must not be code"); | Value& substr=params.as_no_junction(0, "substr must not be code"); |
| const String& string=GET_SELF(r, VString).string(); | const String& string=GET_SELF(r, VString).string(); |
| r.write_assign_lang(*new VInt((int)string.pos(r.charsets.source(), substr.as_string()))); | ssize_t offset=0; |
| if(params.count()>1){ | |
| offset=params.as_int(1, "n must be int", r); | |
| if(offset<0) | |
| throw Exception(PARSER_RUNTIME, | |
| 0, | |
| "n(%d) must be >=0", offset); | |
| } | |
| r.write_no_lang(*new VInt((int)string.pos(r.charsets.source(), substr.as_string(), (size_t)offset))); | |
| } | } |
| static void split_list(MethodParams& params, int paramIndex, | static void split_list(MethodParams& params, int paramIndex, |
| Line 662 MString::MString(): Methoded("string") { | Line 671 MString::MString(): Methoded("string") { |
| // ^void.bool(default) | // ^void.bool(default) |
| add_native_method("bool", Method::CT_DYNAMIC, _bool, 0, 1); | add_native_method("bool", Method::CT_DYNAMIC, _bool, 0, 1); |
| // ^string.format{format} | // ^string.format[format] |
| add_native_method("format", Method::CT_DYNAMIC, _string_format, 1, 1); | add_native_method("format", Method::CT_DYNAMIC, _string_format, 1, 1); |
| // ^string.left(n) | // ^string.left(n) |
| add_native_method("left", Method::CT_DYNAMIC, _left, 1, 1); | add_native_method("left", Method::CT_DYNAMIC, _left, 1, 1); |
| // ^string.right(n) | // ^string.right(n) |
| add_native_method("right", Method::CT_DYNAMIC, _right, 1, 1); | add_native_method("right", Method::CT_DYNAMIC, _right, 1, 1); |
| // ^string.mid(p) | |
| // ^string.mid(p;n) | // ^string.mid(p;n) |
| add_native_method("mid", Method::CT_DYNAMIC, _mid, 1, 2); | add_native_method("mid", Method::CT_DYNAMIC, _mid, 1, 2); |
| // ^string.pos[substr] | // ^string.pos[substr] |
| add_native_method("pos", Method::CT_DYNAMIC, _pos, 1, 1); | // ^string.pos[substr](n) |
| add_native_method("pos", Method::CT_DYNAMIC, _pos, 1, 2); | |
| // ^string.split[delim] | // ^string.split[delim] |
| // ^string.split[delim][options] | // ^string.split[delim][options] |
| Line 689 MString::MString(): Methoded("string") { | Line 700 MString::MString(): Methoded("string") { |
| // ^string.match[regexp][options]{replacement-code} | // ^string.match[regexp][options]{replacement-code} |
| add_native_method("match", Method::CT_DYNAMIC, _match, 1, 3); | add_native_method("match", Method::CT_DYNAMIC, _match, 1, 3); |
| // ^string.toupper[] | // ^string.upper[] |
| add_native_method("upper", Method::CT_DYNAMIC, _upper, 0, 0); | add_native_method("upper", Method::CT_DYNAMIC, _upper, 0, 0); |
| // ^string.tolower[] | // ^string.lower[] |
| add_native_method("lower", Method::CT_DYNAMIC, _lower, 0, 0); | add_native_method("lower", Method::CT_DYNAMIC, _lower, 0, 0); |
| // ^sql[query] | // ^sql[query] |