class string_compare
{
public:
string_compare (cmp_mode m = normal) : mode(m) { }
bool operator() (const tstring& s1, const tstring& s2) const
{
if (mode == normal) { return s1<s2; }
else
{
return lexicographical_compare(s1.begin(), s1.end(),
s2.begin(), s2.end(),
nocase_compare);
}
}
// 비교 상수
enum cmp_mode { normal, nocase };
private:
const cmp_mode mode;
static bool nocase_compare (TCHAR c1, TCHAR c2)
{
return toupper(c1) < toupper(c2);
}
};
typedef std::basic_string<TCHAR, std::char_traits<TCHAR>, std::allocator<TCHAR>> tstring;
typedef std::map<tstring, tstring, string_compare> string_map;
string_compare ignorecase(string_compare::nocase);
string_map nocasedic(ignorecase);