|
|
| version 1.85, 2001/10/23 14:43:44 | version 1.89, 2001/11/09 11:59:13 |
|---|---|
| Line 2 | Line 2 |
| Parser: @b string parser class. | Parser: @b string parser class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) |
| $Id$ | $Id$ |
| */ | */ |
| Line 83 static void _double(Request& r, const St | Line 83 static void _double(Request& r, const St |
| Value& fmt=params->as_junction(0, "fmt must be code"); | Value& fmt=params->as_junction(0, "fmt must be code"); |
| Temp_lang temp_lang(r, String::UL_PASS_APPENDED); | Temp_lang temp_lang(r, String::UL_PASS_APPENDED); |
| char *buf=format(pool, r.self->as_double(), r.process(fmt).as_string().cstr()); | char *buf=format(pool, r.self->as_double(), |
| r.process(fmt).as_string().cstr(String::UL_UNSPECIFIED)); | |
| String result(pool); | String result(pool); |
| result.APPEND_CLEAN(buf, 0, | result.APPEND_CLEAN(buf, 0, |
| Line 426 static void _replace(Request& r, const S | Line 427 static void _replace(Request& r, const S |
| static void _save(Request& r, const String& method_name, MethodParams *params) { | static void _save(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| Value& vfile_name=params->as_no_junction(0, | const String& file_name=params->as_string(params->size()-1, |
| "file name must not be code"); | "file name must be string"); |
| const String& src=*static_cast<VString *>(r.self)->get_string(); | const String& src=*static_cast<VString *>(r.self)->get_string(); |
| bool do_append=false; | |
| if(params->size()>1) { | |
| const String& mode=params->as_string(0, "mode must be string"); | |
| if(mode=="append") | |
| do_append=true; | |
| else | |
| throw Exception(0, 0, | |
| &mode, | |
| "unknown mode, must be 'append'"); | |
| } | |
| // write | // write |
| file_write(pool, r.absolute(vfile_name.as_string()), | const char *buf=src.cstr(String::UL_UNSPECIFIED); |
| src.cstr(String::UL_AS_IS), src.size(), true); | file_write(pool, r.absolute(file_name), |
| buf, strlen(buf), true, do_append); | |
| } | } |
| // constructor | // constructor |
| Line 487 MString::MString(Pool& apool) : Methoded | Line 500 MString::MString(Pool& apool) : Methoded |
| add_native_method("replace", Method::CT_DYNAMIC, _replace, 1, 1); | add_native_method("replace", Method::CT_DYNAMIC, _replace, 1, 1); |
| // ^string.save[file] | // ^string.save[file] |
| add_native_method("save", Method::CT_DYNAMIC, _save, 1, 1); | add_native_method("save", Method::CT_DYNAMIC, _save, 1, 2); |
| } | } |
| // global variable | // global variable |