2002-06-03 16:34:22 +00:00
|
|
|
#include "CString.h"
|
2002-06-10 22:06:45 +00:00
|
|
|
#include <cctype>
|
2002-06-03 16:34:22 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
//
|
|
|
|
// CStringUtil::CaselessCmp
|
|
|
|
//
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
bool
|
|
|
|
CStringUtil::CaselessCmp::cmpEqual(
|
2002-06-17 13:31:21 +00:00
|
|
|
const CString::value_type& a,
|
|
|
|
const CString::value_type& b)
|
2002-06-03 16:34:22 +00:00
|
|
|
{
|
2002-06-10 22:06:45 +00:00
|
|
|
// FIXME -- use std::tolower but not in all versions of libstdc++
|
2002-06-03 16:34:22 +00:00
|
|
|
return tolower(a) == tolower(b);
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
bool
|
|
|
|
CStringUtil::CaselessCmp::cmpLess(
|
2002-06-17 13:31:21 +00:00
|
|
|
const CString::value_type& a,
|
|
|
|
const CString::value_type& b)
|
2002-06-03 16:34:22 +00:00
|
|
|
{
|
2002-06-10 22:06:45 +00:00
|
|
|
// FIXME -- use std::tolower but not in all versions of libstdc++
|
2002-06-03 16:34:22 +00:00
|
|
|
return tolower(a) < tolower(b);
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
bool
|
2002-06-17 13:31:21 +00:00
|
|
|
CStringUtil::CaselessCmp::less(const CString& a, const CString& b)
|
2002-06-03 16:34:22 +00:00
|
|
|
{
|
|
|
|
return std::lexicographical_compare(
|
|
|
|
a.begin(), a.end(),
|
|
|
|
b.begin(), b.end(),
|
|
|
|
&CStringUtil::CaselessCmp::cmpLess);
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
bool
|
2002-06-17 13:31:21 +00:00
|
|
|
CStringUtil::CaselessCmp::equal(const CString& a, const CString& b)
|
2002-06-03 16:34:22 +00:00
|
|
|
{
|
|
|
|
return !(less(a, b) || less(b, a));
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
bool
|
2002-06-17 13:31:21 +00:00
|
|
|
CStringUtil::CaselessCmp::operator()(const CString& a, const CString& b) const
|
2002-06-03 16:34:22 +00:00
|
|
|
{
|
|
|
|
return less(a, b);
|
|
|
|
}
|