2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 23:07:42 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

View File

@@ -3,35 +3,29 @@
#include <string>
#include <cstring>
namespace urde
{
namespace urde {
class CStringExtras
{
class CStringExtras {
public:
static int CompareCaseInsensitive(const char* a, const char* b)
{
static int CompareCaseInsensitive(const char* a, const char* b) {
#if _WIN32
return _stricmp(a, b);
return _stricmp(a, b);
#else
return strcasecmp(a, b);
return strcasecmp(a, b);
#endif
}
static int CompareCaseInsensitive(std::string_view a, std::string_view b)
{
return CompareCaseInsensitive(a.data(), b.data());
}
}
static int CompareCaseInsensitive(std::string_view a, std::string_view b) {
return CompareCaseInsensitive(a.data(), b.data());
}
static int IndexOfSubstring(std::string_view haystack, std::string_view needle)
{
std::string str(haystack);
std::transform(str.begin(), str.end(), str.begin(), tolower);
std::string::size_type s = str.find(needle);
if (s == std::string::npos)
return -1;
return s;
}
static int IndexOfSubstring(std::string_view haystack, std::string_view needle) {
std::string str(haystack);
std::transform(str.begin(), str.end(), str.begin(), tolower);
std::string::size_type s = str.find(needle);
if (s == std::string::npos)
return -1;
return s;
}
};
}
} // namespace urde