dtl/test/comparators.hpp
2024-06-03 10:05:35 -05:00

26 lines
598 B
C++

#ifndef DTL_COMPARATORS
#define DTL_COMPARATORS
#include "dtl/functors.hpp"
class CaseInsensitive : public dtl::Compare<char> {
public:
virtual bool impl(const char &a, const char &b) const {
return std::tolower(a) == std::tolower(b);
}
};
class StringCaseInsensitive : public dtl::Compare<std::string> {
public:
virtual bool impl(const std::string &a, const std::string &b) const {
if (a.length() == b.length()) {
bool equal = (strncasecmp(a.c_str(), b.c_str(), a.length()) == 0);
return equal;
} else {
return false;
}
}
};
#endif // DTL_COMPARATORS