|
|
| version 1.144, 2005/08/26 11:12:45 | version 1.147, 2005/11/22 11:21:35 |
|---|---|
| Line 429 const String* sql_result_string(Request& | Line 429 const String* sql_result_string(Request& |
| default_code=0; | default_code=0; |
| if(params.count()>1) { | if(params.count()>1) { |
| Value& voptions=params.as_no_junction(1, "options must be hash, not code"); | Value& voptions=params.as_no_junction(1, "options must be hash, not code"); |
| if(!voptions.is_string()) | if(voptions.is_defined() && !voptions.is_string()) |
| if((options=voptions.get_hash())) { | if((options=voptions.get_hash())) { |
| int valid_options=0; | int valid_options=0; |
| if(Value* vbind=options->get(sql_bind_name)) { | if(Value* vbind=options->get(sql_bind_name)) { |
| Line 587 static void _append(Request& r, MethodPa | Line 587 static void _append(Request& r, MethodPa |
| va.set_string(c); | va.set_string(c); |
| } | } |
| static void _base64(Request& r, MethodParams& params) { | |
| if(params.count()) { | |
| // decode | |
| const char* cstr=params.as_string(0, "parameter must be string").cstr(); | |
| void* decoded_cstr=0; | |
| size_t decoded_size=0; | |
| pa_base64_decode(cstr, strlen(cstr), decoded_cstr, decoded_size); | |
| if(decoded_cstr && decoded_size) | |
| r.write_assign_lang(*new String(static_cast<const char*>(decoded_cstr), decoded_size, true)); | |
| } else { | |
| // encode | |
| VString& vself=GET_SELF(r, VString); | |
| const char* cstr=vself.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*/)); | |
| } | |
| } | |
| // constructor | // constructor |
| MString::MString(): Methoded("string") { | MString::MString(): Methoded("string") { |
| Line 649 MString::MString(): Methoded("string") { | Line 667 MString::MString(): Methoded("string") { |
| // ^string.append[string] | // ^string.append[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[encoded string] << decode | |
| add_native_method("base64", Method::CT_ANY, _base64, 0, 1); | |
| } | } |