--- parser3/src/classes/string.C 2001/06/28 07:23:59 1.56 +++ parser3/src/classes/string.C 2001/07/09 16:13:17 1.60 @@ -4,9 +4,8 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: string.C,v 1.56 2001/06/28 07:23:59 parser Exp $ */ +static const char *RCSId="$Id: string.C,v 1.60 2001/07/09 16:13:17 parser Exp $"; #include "classes.h" #include "pa_request.h" @@ -56,7 +55,7 @@ static void _double(Request& r, const St /*not static*/void _string_format(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - Value& fmt=params->get_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); char *buf=format(pool, r.self->as_double(), r.process(fmt).as_string().cstr()); @@ -95,7 +94,7 @@ static void _mid(Request& r, const Strin static void _pos(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - Value& substr=params->get_no_junction(0, "substr must not be code"); + Value& substr=params->as_no_junction(0, "substr must not be code"); const String& string=*static_cast(r.self)->get_string(); r.write_assign_lang(*new(pool) VInt(pool, string.pos(substr.as_string()))); @@ -104,7 +103,7 @@ static void _pos(Request& r, const Strin static void split_list(Request& r, const String& method_name, MethodParams *params, const String& string, Array& result) { - Value& delim_value=params->get_no_junction(0, "delimiter must not be code"); + Value& delim_value=params->as_no_junction(0, "delimiter must not be code"); string.split(result, 0, delim_value.as_string()); } @@ -191,31 +190,29 @@ static void _match(Request& r, const Str Pool& pool=r.pool(); const String& src=*static_cast(r.self)->get_string(); - Value& regexp=params->get_no_junction(0, "regexp must not be code"); + Value& regexp=params->as_no_junction(0, "regexp must not be code"); const String *options= params->size()>1? - ¶ms->get_no_junction(1, "options must not be code").as_string():0; + ¶ms->as_no_junction(1, "options must not be code").as_string():0; Value *result; Temp_lang temp_lang(r, String::UL_PASS_APPENDED); Table *table; if(params->size()<3) { // search - if(src.match(r.pcre_tables, + bool matched=src.match(r.pcre_tables, &method_name, regexp.as_string(), options, &table, - search_action, 0)) { - // matched - if(table->columns()->size()==3 && // just matched[3=pre/match/post], no substrings - table->size()==1) // just one row, not /g_lobal search - result=new(pool) VBool(pool, true); - else // table of pre/match/post+substrings - result=new(pool) VTable(pool, table); - } else // not matched [not global] - result=new(pool) VBool(pool, false); + search_action, 0); + // matched + if(table->columns()->size()==3 && // just matched[3=pre/match/post], no substrings + table->size()<=1) // just one row, not /g_lobal search + result=new(pool) VBool(pool, matched); + else // table of pre/match/post+substrings + result=new(pool) VTable(pool, table); } else { // replace - Value& replacement_code=params->get_junction(2, "replacement code must be code"); + Value& replacement_code=params->as_junction(2, "replacement code must be code"); String& dest=*new(pool) String(pool); Replace_action_info replace_action_info={ @@ -258,11 +255,11 @@ String& sql_result_string(Request& r, co &method_name, "without connect"); - Value& statement=params->get_junction(0, "statement must be code"); + Value& statement=params->as_junction(0, "statement must be code"); ulong offset=0; if(params->size()>1) { - Value& offset_code=params->get_junction(1, "offset must be expression"); + Value& offset_code=params->as_junction(1, "offset must be expression"); offset=(ulong)r.process(offset_code).as_double(); }