|
|
| version 1.70, 2001/08/07 13:54:13 | version 1.71, 2001/08/28 09:27:42 |
|---|---|
| Line 15 static const char *RCSId="$Id$"; | Line 15 static const char *RCSId="$Id$"; |
| #include "pa_vbool.h" | #include "pa_vbool.h" |
| #include "pa_string.h" | #include "pa_string.h" |
| #include "pa_sql_connection.h" | #include "pa_sql_connection.h" |
| #include "pa_dictionary.h" | |
| // defines | // defines |
| Line 386 static void _sql(Request& r, const Strin | Line 387 static void _sql(Request& r, const Strin |
| r.write_assign_lang(result); | r.write_assign_lang(result); |
| } | } |
| static void _replace(Request& r, const String& method_name, MethodParams *params) { | |
| Pool& pool=r.pool(); | |
| const String& src=*static_cast<VString *>(r.self)->get_string(); | |
| Table *table=params->as_no_junction(0, "parameter must not be code").get_table(); | |
| if(!table) | |
| PTHROW(0, 0, | |
| &method_name, | |
| "parameter must be table"); | |
| Dictionary dict(*table); | |
| r.write_assign_lang(*new(pool) VString(src.replace(pool, dict))); | |
| } | |
| // constructor | // constructor |
| MString::MString(Pool& apool) : Methoded(apool) { | MString::MString(Pool& apool) : Methoded(apool) { |
| Line 431 MString::MString(Pool& apool) : Methoded | Line 445 MString::MString(Pool& apool) : Methoded |
| // ^sql[query] | // ^sql[query] |
| // ^sql[query][$.limit(1) $.offset(2) $.default[n/a]] | // ^sql[query][$.limit(1) $.offset(2) $.default[n/a]] |
| add_native_method("sql", Method::CT_STATIC, _sql, 1, 2); | add_native_method("sql", Method::CT_STATIC, _sql, 1, 2); |
| // ^string.replace[table] | |
| add_native_method("replace", Method::CT_DYNAMIC, _replace, 1, 1); | |
| } | } |
| // global variable | // global variable |