Added toLower/UpperUnsafe.

This commit is contained in:
Branimir Karadžić
2017-02-12 21:59:55 -08:00
parent d0443c4255
commit 0ecb9af21f
3 changed files with 23 additions and 9 deletions

View File

@@ -110,12 +110,18 @@ namespace bx
///
char toLower(char _ch);
///
void toLowerUnsafe(char* _inOutStr, size_t _len);
///
void toLower(char* _inOutStr, size_t _max = INT32_MAX);
///
char toUpper(char _ch);
///
void toUpperUnsafe(char* _inOutStr, size_t _len);
///
void toUpper(char* _inOutStr, size_t _max = INT32_MAX);

View File

@@ -288,7 +288,7 @@ namespace bx
if (_param.upper)
{
toUpper(str, len);
toUpperUnsafe(str, len);
}
const char* dot = strnchr(str, '.');

View File

@@ -60,31 +60,39 @@ namespace bx
return _ch + (isUpper(_ch) ? 0x20 : 0);
}
void toLower(char* _inOutStr, size_t _max)
void toLowerUnsafe(char* _inOutStr, size_t _len)
{
size_t len = strnlen(_inOutStr, _max);
for (size_t ii = 0; ii < len; ++ii)
for (size_t ii = 0; ii < _len; ++ii)
{
*_inOutStr = toLower(*_inOutStr);
}
}
void toLower(char* _inOutStr, size_t _max)
{
const size_t len = strnlen(_inOutStr, _max);
toLowerUnsafe(_inOutStr, len);
}
char toUpper(char _ch)
{
return _ch - (isLower(_ch) ? 0x20 : 0);
}
void toUpper(char* _inOutStr, size_t _max)
void toUpperUnsafe(char* _inOutStr, size_t _len)
{
size_t len = strnlen(_inOutStr, _max);
for (size_t ii = 0; ii < len; ++ii)
for (size_t ii = 0; ii < _len; ++ii)
{
*_inOutStr = toUpper(*_inOutStr);
}
}
void toUpper(char* _inOutStr, size_t _max)
{
const size_t len = strnlen(_inOutStr, _max);
toUpperUnsafe(_inOutStr, len);
}
bool toBool(const char* _str)
{
char ch = toLower(_str[0]);