--- parser3/src/classes/hash.C 2003/03/18 15:14:14 1.54.2.13.2.1 +++ parser3/src/classes/hash.C 2003/03/21 16:16:42 1.54.2.13.2.7 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_HASH_C="$Date: 2003/03/18 15:14:14 $"; +static const char* IDENT_HASH_C="$Date: 2003/03/21 16:16:42 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -22,7 +22,7 @@ static const char* IDENT_HASH_C="$Date: class MHash: public Methoded { public: // VStateless_class - ValuePtr create_new_value() { return ValuePtr(new VHash()); } + Value* create_new_value() { return Value*(new VHash()); } public: MHash(); @@ -55,7 +55,7 @@ public: statement_string(astatement_string), statement_cstr(astatement_cstr), distinct(adistinct), rows_hash(arows_hash), - row_hash(0), + row_hash(), column_index(0), row_index(0){ } @@ -95,7 +95,7 @@ public: (const char* )ptr, size, statement_cstr, row_index++); if(column_index==0) { - VHashPtr row_vhash(new VHash); + VHash* row_vhash(new VHash); row_hash=&row_vhash->hash(); if(rows_hash.put_dont_replace(cell, row_vhash)) // put. existed? if(!distinct) { @@ -105,7 +105,7 @@ public: return true; } } else - row_hash->put(columns[column_index], ValuePtr(new VString(cell))); + row_hash->put(columns[column_index], Value*(new VString(cell))); column_index++; return false; @@ -126,7 +126,7 @@ static void copy_all_overwrite_to( } static void _create_or_add(Request& r, const String& method_name, MethodParams* params) { if(params->count()) { - ValuePtr vb=params->as_no_junction(0, "param must be hash"); + Value* vb=params->as_no_junction(0, "param must be hash"); if(HashStringValue* b=vb->get_hash(method_name)) b->for_each(copy_all_overwrite_to, &(GET_SELF(r, VHash).hash())); } @@ -139,7 +139,7 @@ static void remove_key_from( dest->remove(key); } static void _sub(Request& r, const String& method_name, MethodParams* params) { - ValuePtr vb=params->as_no_junction(0, "param must be hash"); + Value* vb=params->as_no_junction(0, "param must be hash"); if(HashStringValue* b=vb->get_hash(method_name)) b->for_each(remove_key_from, &GET_SELF(r, VHash).hash()); } @@ -152,11 +152,11 @@ static void copy_all_dontoverwrite_to( } static void _union(Request& r, const String& method_name, MethodParams* params) { // dest = copy of self - ValuePtr result(new VHash(GET_SELF(r, VHash).hash())); + Value* result(new VHash(GET_SELF(r, VHash).hash())); // dest += b - ValuePtr vb=params->as_no_junction(0, "param must be hash"); + Value* vb=params->as_no_junction(0, "param must be hash"); if(HashStringValue* b=vb->get_hash(method_name)) - b->for_each(copy_all_dontoverwrite_to, result->get_hash(Exception::undefined_source)); + b->for_each(copy_all_dontoverwrite_to, result->get_hash()); // return result r.write_no_lang(result); @@ -176,11 +176,11 @@ static void copy_intersection_to( info->dest->put_dont_replace(key, value); } static void _intersection(Request& r, const String& method_name, MethodParams* params) { - ValuePtr result(new VHash); + Value* result(new VHash); // dest += b - ValuePtr vb=params->as_no_junction(0, "param must be hash"); + Value* vb=params->as_no_junction(0, "param must be hash"); if(HashStringValue* b=vb->get_hash(method_name)) { - Copy_intersection_to_info info={b, result->get_hash(Exception::undefined_source)}; + Copy_intersection_to_info info={b, result->get_hash()}; GET_SELF(r, VHash).hash().for_each(copy_intersection_to, &info); } @@ -198,12 +198,12 @@ static bool intersects( static void _intersects(Request& r, const String& method_name, MethodParams* params) { bool result=false; - ValuePtr vb=params->as_no_junction(0, "param must be hash"); + Value* vb=params->as_no_junction(0, "param must be hash"); if(HashStringValue* b=vb->get_hash(method_name)) result=GET_SELF(r, VHash).hash().first_that(intersects, b); // return result - r.write_no_lang(ValuePtr(new VBool(result))); + r.write_no_lang(Value*(new VBool(result))); } @@ -212,25 +212,25 @@ extern const String& sql_offset_name; extern const String& sql_default_name; extern const String& sql_distinct_name; static void _sql(Request& r, const String& method_name, MethodParams* params) { - ValuePtr statement=params->as_junction(0, "statement must be code"); + Value* statement=params->as_junction(0, "statement must be code"); ulong limit=0; ulong offset=0; bool distinct=false; if(params->count()>1) { - ValuePtr 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(HashStringValue* options=voptions->get_hash(method_name)) { int valid_options=0; - if(ValuePtr vlimit=options->get(sql_limit_name)) { + if(Value* vlimit=options->get(sql_limit_name)) { valid_options++; limit=(ulong)r.process_to_value(vlimit)->as_double(); } - if(ValuePtr voffset=options->get(sql_offset_name)) { + if(Value* voffset=options->get(sql_offset_name)) { valid_options++; offset=(ulong)r.process_to_value(voffset)->as_double(); } - if(ValuePtr vdistinct=options->get(sql_distinct_name)) { + if(Value* vdistinct=options->get(sql_distinct_name)) { valid_options++; distinct=r.process_to_value(vdistinct)->as_bool(); } @@ -244,10 +244,10 @@ static void _sql(Request& r, const Strin "options must be hash"); } - Temp_lang temp_lang(r, String::UL_SQL); + Temp_lang temp_lang(r, String::L_SQL); const String& statement_string=r.process_to_string(statement); const char* statement_cstr= - statement_string->cstr(r.pool(), String::UL_UNSPECIFIED, r.connection(method_name)); + statement_string->cstr(r.String::L_UNSPECIFIED, r.connection(method_name)); HashStringValue& hash=GET_SELF(r, VHash).hash(method_name); hash.clear(); Hash_sql_event_handlers handlers(method_name, @@ -275,15 +275,14 @@ static void _keys(Request& r, const Stri GET_SELF(r, VHash).hash(method_name).for_each(keys_collector, table.get()); - r.write_no_lang(ValuePtr(new VTable(table))); + r.write_no_lang(Value*(new VTable(table))); } static void _count(Request& r, const String& method_name, MethodParams* ) { - r.write_no_lang(ValuePtr(new VInt(GET_SELF(r, VHash).hash(method_name).count()))); + r.write_no_lang(Value*(new VInt(GET_SELF(r, VHash).hash(method_name).count()))); } static void _delete(Request& r, const String& method_name, MethodParams* params) { - =r.pool(); GET_SELF(r, VHash).hash(method_name).remove(params->as_string(0, "key must be string")); } @@ -293,10 +292,10 @@ struct Foreach_info { Request *r; const String& key_var_name; const String& value_var_name; - ValuePtr body_code; - ValuePtr delim_maybe_code; + Value* body_code; + Value* delim_maybe_code; - Vconst String& vkey; + const VString& vkey; bool need_delim; }; #endif @@ -311,7 +310,7 @@ static void one_foreach_cycle( StringOrValue sv_processed=info->r->process(info->body_code); const String& s_processed=sv_processed.get_string(); - if(info->delim_maybe_code && s_processed && s_processed->size()) { // delimiter set and we have body + if(info->delim_maybe_code && s_processed && s_processed->length()) { // delimiter set and we have body if(info->need_delim) // need delim & iteration produced string? info->r->write_pass_lang(info->r->process(info->delim_maybe_code)); info->need_delim=true; @@ -324,7 +323,7 @@ static void _foreach(Request& r, const S info.key_var_name=params->as_string(0, "key-var name must be string"); info.value_var_name=params->as_string(1, "value-var name must be string"); info.body_code=params->as_junction(2, "body must be code"); - info.delim_maybe_code=params->count()>3?params->get(3):ValuePtr(0); + info.delim_maybe_code=params->count()>3?params->get(3):0; info.vkey=VString* (new VString); VHash& self=GET_SELF(r, VHash);