mirror of
https://github.com/BeneficialCode/WinArk
synced 2026-08-09 12:00:31 +00:00
32 lines
1018 B
C++
32 lines
1018 B
C++
#include "stdafx.h"
|
|
#include "SortHelper.h"
|
|
|
|
bool SortHelper::SortStrings(const CString& s1, const CString& s2, bool ascending) {
|
|
return ascending ? s2.CompareNoCase(s1) > 0 : s2.CompareNoCase(s1) < 0;
|
|
}
|
|
|
|
bool SortHelper::SortStrings(const std::string& s1, const std::string& s2, bool ascending) {
|
|
auto compare = ::_stricmp(s2.c_str(), s1.c_str());
|
|
return ascending ? compare > 0 : compare < 0;
|
|
}
|
|
|
|
bool SortHelper::SortStrings(const std::wstring& s1, const std::wstring& s2, bool ascending) {
|
|
auto compare = ::_wcsicmp(s2.c_str(), s1.c_str());
|
|
return ascending ? compare > 0 : compare < 0;
|
|
}
|
|
|
|
bool SortHelper::SortStrings(PCWSTR s1, PCWSTR s2, bool ascending) {
|
|
if ((s1 == nullptr || *s1 == 0) && (s2 == nullptr || *s2 == 0))
|
|
return false;
|
|
if (s1 == nullptr || *s2 == 0)
|
|
return false;
|
|
if (s2 == nullptr || *s2 == 0)
|
|
return false;
|
|
|
|
auto compare = ::_wcsicmp(s2, s1);
|
|
return ascending ? compare > 0 : compare < 0;
|
|
}
|
|
|
|
bool SortHelper::SortBoolean(bool a, bool b, bool asc) {
|
|
return asc ? b > a : a > b;
|
|
} |