--- parser3/src/include/pa_hash.h 2005/07/27 14:04:15 1.64.2.3 +++ parser3/src/include/pa_hash.h 2005/07/28 11:23:02 1.65 @@ -17,7 +17,7 @@ #ifndef PA_HASH_H #define PA_HASH_H -static const char * const IDENT_HASH_H="$Date: 2005/07/27 14:04:15 $"; +static const char * const IDENT_HASH_H="$Date: 2005/07/28 11:23:02 $"; #include "pa_memory.h" #include "pa_types.h" @@ -104,9 +104,9 @@ public: } /// put a [value] under the [key] @returns existed or not - template R maybe_put(K key, V value, F prevent) { + template R replace_maybe_append(K key, V value, F prevent, I info) { if(!value) { - // they can come here from somewhere (true with maybe_maybe_append, keeping parallel) + // they can come here from somewhere (true with maybe_replace_maybe_append, keeping parallel) remove(key); // this has nothing to do with properties, doing no special property handling here return 0; @@ -121,16 +121,16 @@ public: for(Pair *pair=*ref; pair; pair=pair->link) if(pair->code==code && pair->key==key) { // found a pair with the same key - - // prevent-function intercepted put? - if(R result=prevent(pair->value)) - return result; - pair->value=value; return reinterpret_cast(1); } - // proper pair not found -- create&link_in new pair + // proper pair not found + // prevent-function intercepted append? + if(R result=prevent(value, info)) + return result; + + //create&link_in new pair if(!*ref) // root cell were fused_refs? fused_refs++; // not, we'll use it and record the fact *ref=new Pair(code, key, value, *ref); @@ -139,9 +139,11 @@ public: } /// put a [value] under the [key] @returns existed or not - template R maybe_append(K key, V value, F prevent, I info) { + template + R maybe_replace_maybe_append(K key, V value, F1 prevent_replace, F2 prevent_append, I info) + { if(!value) { - // they can come here from somewhere (true with maybe_maybe_append, keeping parallel) + // they can come here from Temp_value_element::dctor to restore some empty value remove(key); // this has nothing to do with properties, doing no special property handling here return 0; @@ -156,13 +158,18 @@ public: for(Pair *pair=*ref; pair; pair=pair->link) if(pair->code==code && pair->key==key) { // found a pair with the same key + + // prevent-function intercepted replace? + if(R result=prevent_replace(pair->value, info)) + return result; + pair->value=value; return reinterpret_cast(1); } // proper pair not found - // prevent-function intercepted put? - if(R result=prevent(value, info)) + // prevent-function intercepted append? + if(R result=prevent_append(value, info)) return result; //create&link_in new pair @@ -174,11 +181,11 @@ public: } /// put a [value] under the [key] @returns existed or not - template - R maybe_maybe_append(K key, V value, F1 prevent_replace, F2 prevent_append, I info) + template + R maybe_replace_never_append(K key, V value, F1 prevent_replace, I info) { if(!value) { - // they can come here from Temp_value_element::dctor to restore some empty value + // they can come here from somewhere (true with maybe_replace_maybe_append, keeping parallel) remove(key); // this has nothing to do with properties, doing no special property handling here return 0; @@ -194,7 +201,7 @@ public: if(pair->code==code && pair->key==key) { // found a pair with the same key - // prevent-function intercepted put? + // prevent-function intercepted replace? if(R result=prevent_replace(pair->value, info)) return result; @@ -202,16 +209,6 @@ public: return reinterpret_cast(1); } - // proper pair not found - // prevent-function intercepted put? - if(R result=prevent_append(value, info)) - return result; - - //create&link_in new pair - if(!*ref) // root cell were fused_refs? - fused_refs++; // not, we'll use it and record the fact - *ref=new Pair(code, key, value, *ref); - fpairs_count++; return 0; }