--- parser3/src/classes/table.C 2001/04/28 15:22:39 1.68 +++ parser3/src/classes/table.C 2001/05/08 06:00:34 1.72 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: table.C,v 1.68 2001/04/28 15:22:39 paf Exp $ + $Id: table.C,v 1.72 2001/05/08 06:00:34 paf Exp $ */ #include "pa_config_includes.h" @@ -19,6 +19,7 @@ #include "pa_vint.h" #include "pa_sql_connection.h" #include "pa_dir.h" +#include "pa_vbool.h" // defines @@ -28,13 +29,13 @@ class MTable : public Methoded { public: // VStateless_class - Value *create_new_value(Pool& pool) { return new(pool) VTable(pool); } public: MTable(Pool& pool); - bool used_directly() { return true; } +public: // Methoded + bool used_directly() { return true; } }; // methods @@ -328,18 +329,15 @@ static void _sort(Request& r, const Stri } static void _locate(Request& r, const String& method_name, MethodParams *params) { + Pool& pool=r.pool(); + VTable& vtable=*static_cast(r.self); Table& table=vtable.table(); - vtable.last_locate_was_successful=table.locate( + Value& result=*new(pool) VBool(pool, table.locate( params->get(0).as_string(), - params->get(1).as_string()); -} - -static void _found(Request& r, const String& method_name, MethodParams *params) { - if(static_cast(r.self)->last_locate_was_successful) - r.write_pass_lang(r.process(params->get_junction(0, "found-parameter must be code"))); - else if(params->size()==2) - r.write_pass_lang(r.process(params->get_junction(0, "else-parameter must be code"))); + params->get(1).as_string())); + result.set_name(method_name); + r.write_no_lang(result); } static void _flip(Request& r, const String& method_name, MethodParams *params) { @@ -411,7 +409,6 @@ static void _join(Request& r, const Stri } } -/// ^table:sql{query}[(count[;offset])] static void _sql(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); @@ -487,8 +484,6 @@ static void _sql(Request& r, const Strin static_cast(r.self)->set_table(table); } -/// ^table:dir[path] -/// ^table:dir[path][regexp] static void _dir(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); @@ -548,7 +543,7 @@ static void _dir(Request& r, const Strin char *file_name_cstr=(char *)r.malloc(file_name_size); memcpy(file_name_cstr, ffblk.ff_name, file_name_size); String &file_name=*new(pool) String(pool); - file_name.APPEND_TAINTED(file_name_cstr, file_name_size, + file_name.APPEND(file_name_cstr, file_name_size, String::UL_FILE_NAME, method_name.origin().file, method_name.origin().line); Array& row=*new(pool) Array(pool); @@ -608,9 +603,6 @@ MTable::MTable(Pool& apool) : Methoded(a // ^table.locate[field;value] add_native_method("locate", Method::CT_DYNAMIC, _locate, 2, 2); - // ^table.found{when-found} - // ^table.found{when-found}{when-not-found} - add_native_method("found", Method::CT_DYNAMIC, _found, 1, 2); // ^table.flip[] add_native_method("flip", Method::CT_DYNAMIC, _flip, 0, 0);