forked from snowie2000/mactype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash_list.cpp
37 lines (33 loc) · 824 Bytes
/
hash_list.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "hash_list.h"
#include <cwctype>
#include <algorithm>
void CHashedStringList::Add(TCHAR * String, TCHAR * Value)
{
std::wstring buff = String;
if (!m_bCaseSense)
std::transform(buff.begin(), buff.end(), buff.begin(), ::towlower);
strmap::iterator it = stringmap.find(buff);
if (it == stringmap.end()) {
stringmap[buff] = _wcsdup(Value);
}
}
void CHashedStringList::Delete(TCHAR * String)
{
std::wstring buff = String;
if (!m_bCaseSense)
std::transform(buff.begin(), buff.end(), buff.begin(), ::towlower);
stringmap.erase(buff);
}
TCHAR * CHashedStringList::Find(TCHAR * String)
{
TCHAR* b = _wcsdup(String);
if (!m_bCaseSense)
b = _wcslwr(b);
std::wstring buff = b;
free(b);
strmap::iterator it = stringmap.find(buff);
if (it != stringmap.end())
return it->second;
else
return NULL;
}