|
|
| version 1.146, 2005/11/22 11:12:39 | version 1.150, 2007/01/18 17:48:15 |
|---|---|
| Line 323 static void _match(Request& r, MethodPar | Line 323 static void _match(Request& r, MethodPar |
| regexp.as_string(), options, | regexp.as_string(), options, |
| search_action, 0, | search_action, 0, |
| just_matched); | just_matched); |
| Value* result; | // Value* result; |
| if(table) | // if(table) |
| result=new VTable(table); // table of pre/match/post+substrings | // result=new VTable(table); // table of pre/match/post+substrings |
| else | // else |
| result=new VBool(just_matched); | // result=new VBool(just_matched); |
| r.write_assign_lang(*result); | // r.write_assign_lang(*result); |
| r.write_assign_lang(*new VTable(table)); | |
| } 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 446 const String* sql_result_string(Request& | Line 447 const String* sql_result_string(Request& |
| } | } |
| if((default_code=options->get(sql_default_name))) { | if((default_code=options->get(sql_default_name))) { |
| valid_options++; | valid_options++; |
| if(!default_code->get_junction()) | |
| throw Exception("parser.runtime", | |
| 0, | |
| "default option must be code"); | |
| } | } |
| if(valid_options!=options->count()) | if(valid_options!=options->count()) |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| Line 589 static void _append(Request& r, MethodPa | Line 586 static void _append(Request& r, MethodPa |
| static void _base64(Request& r, MethodParams& params) { | static void _base64(Request& r, MethodParams& params) { |
| if(params.count()) { | if(params.count()) { |
| // encode | |
| const char* cstr=params.as_string(0, "parameter must be string").cstr(); | |
| const char* encoded=pa_base64_encode(cstr, strlen(cstr)); | |
| r.write_assign_lang(*new String(encoded, 0, true/*once ?param=base64(something) was needed*/)); | |
| } else { | |
| // decode | // decode |
| VString& vself=GET_SELF(r, VString); | const char* cstr=params.as_string(0, "parameter must be string").cstr(); |
| const char* cstr=vself.string().cstr(); | char* decoded_cstr=0; |
| void* decoded_cstr=0; | |
| size_t decoded_size=0; | size_t decoded_size=0; |
| pa_base64_decode(cstr, strlen(cstr), decoded_cstr, decoded_size); | pa_base64_decode(cstr, strlen(cstr), decoded_cstr, decoded_size); |
| if(decoded_cstr && decoded_size) | if(decoded_cstr && decoded_size) |
| r.write_assign_lang(*new String(static_cast<const char*>(decoded_cstr), decoded_size, true)); | r.write_assign_lang(*new String(decoded_cstr, decoded_size, true)); |
| } else { | |
| // encode | |
| VString& self=GET_SELF(r, VString); | |
| const char* cstr=self.string().cstr(); | |
| const char* encoded=pa_base64_encode(cstr, strlen(cstr)); | |
| r.write_assign_lang(*new String(encoded, 0, true/*once ?param=base64(something) was needed*/)); | |
| } | } |
| } | } |
| Line 669 MString::MString(): Methoded("string") { | Line 666 MString::MString(): Methoded("string") { |
| add_native_method("append", Method::CT_DYNAMIC, _append, 1, 1); | add_native_method("append", Method::CT_DYNAMIC, _append, 1, 1); |
| // ^string.base64[] << encode | // ^string.base64[] << encode |
| // ^string:base64[string] << decode | // ^string:base64[encoded string] << decode |
| add_native_method("base64", Method::CT_ANY, _base64, 0, 1); | add_native_method("base64", Method::CT_ANY, _base64, 0, 1); |
| } | } |