|
|
| version 1.52, 2002/08/01 11:41:19 | version 1.52.4.1, 2002/10/25 08:02:09 |
|---|---|
| Line 208 void Hash::clear() { | Line 208 void Hash::clear() { |
| memset(refs, 0, sizeof(*refs)*allocated); | memset(refs, 0, sizeof(*refs)*allocated); |
| count=used=0; | count=used=0; |
| } | } |
| #ifndef DOXYGEN | |
| struct Stringtolower_eq_string_info { | |
| Pool *pool; | |
| const String *looking_lower; | |
| }; | |
| #endif | |
| void *stringtolower_eq_string(const Hash::Key& key, Hash::Val *value, void *info) { | |
| Stringtolower_eq_string_info& i=*static_cast<Stringtolower_eq_string_info *>(info); | |
| return key.change_case(*i.pool, String::CC_LOWER) == *i.looking_lower?value:0; | |
| } | |
| Hash::Val *Hash::get_case_insensitive_internal(const Key& key_lower) const { | |
| Stringtolower_eq_string_info info={&pool(), &key_lower}; | |
| return first_that(stringtolower_eq_string, &info); | |
| } | |
| Hash::Val *Hash::get_case_insensitive(const Key& key) const { | |
| return get_case_insensitive_internal(key.change_case(pool(), String::CC_LOWER)); | |
| } | |
| bool put_case_insensitive(const Key& key, Val *value) { | |
| const Key& key_lower=key.change_case(pool(), String::CC_LOWER); | |
| if(get_case_insensitive_internal(key_lower)) | |
| return true; | |
| } | |
| // not as quick as it can be, but that's not needed [now] | |
| bool Hash::put_dont_replace_case_insensitive(const Key& key, Val *value) { | |
| const Key& key_lower=key.change_case(pool(), String::CC_LOWER); | |
| if(get_case_insensitive_internal(key_lower)) | |
| return true; | |
| put(key_lower, value); | |
| return false; | |
| } |