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(
|
|
|
|
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(
|
|
|
|
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::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
|
|
|
|
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
|
|
|
|
CStringUtil::CaselessCmp::operator()(
|
|
|
|
const CString& a,
|
|
|
|
const CString& b) const
|
2002-06-03 16:34:22 +00:00
|
|
|
{
|
|
|
|
return less(a, b);
|
|
|
|
}
|