|
|
| version 1.29, 2024/10/27 13:53:08 | version 1.30, 2024/10/27 17:50:59 |
|---|---|
| Line 897 static void _at(Request& r, MethodParams | Line 897 static void _at(Request& r, MethodParams |
| ArrayValue& array=GET_SELF(r, VArray).array(); | ArrayValue& array=GET_SELF(r, VArray).array(); |
| size_t count=array.used(); // not array.count() | size_t count=array.used(); // not array.count() |
| int pos=0; | |
| AtResultType result_type=AtResultTypeValue; | AtResultType result_type=AtResultTypeValue; |
| if(params.count() > 1) { | if(params.count() > 1) { |
| const String& stype=params.as_string(1, "type must be string"); | const String& stype=params.as_string(1, "type must be string"); |
| Line 910 static void _at(Request& r, MethodParams | Line 908 static void _at(Request& r, MethodParams |
| throw Exception(PARSER_RUNTIME, &stype, "type must be 'key', 'value' or 'hash'"); | throw Exception(PARSER_RUNTIME, &stype, "type must be 'key', 'value' or 'hash'"); |
| } | } |
| Value& vwhence=params[0]; | int pos=params.as_index(0, count, r); |
| if(vwhence.is_string()) { | |
| const String& swhence=*vwhence.get_string(); | |
| if(swhence == "last") | |
| pos=count-1; | |
| else if(swhence != "first") | |
| throw Exception(PARSER_RUNTIME, &swhence, "whence must be 'first', 'last' or expression"); | |
| } else { | |
| pos=r.process(vwhence).as_int(); | |
| if(pos < 0) | |
| pos+=count; | |
| } | |
| if(count && pos >= 0 && (size_t)pos < count){ | if(count && pos >= 0 && (size_t)pos < count){ |
| if(count == array.count()){ | if(count == array.count()){ |