Add CharToLower and CharToUpper into util.s (#6126)

This commit adds replacement of `::tolower` and `::toupper`.
Added CharToLower and CharToUpper routines reduce the number of cast operators
that required for correct usage of standard C/C++ `::tolower/toupper` routines.
This commit is contained in:
Vladimir Glavnyy
2020-09-21 23:31:27 +07:00
committed by GitHub
parent 8c67b5b129
commit fb4e1c34f9
7 changed files with 27 additions and 28 deletions

View File

@@ -98,9 +98,9 @@ std::string MakeCamel(const std::string &in, bool first) {
std::string s;
for (size_t i = 0; i < in.length(); i++) {
if (!i && first)
s += static_cast<char>(toupper(in[0]));
s += CharToUpper(in[0]);
else if (in[i] == '_' && i + 1 < in.length())
s += static_cast<char>(toupper(in[++i]));
s += CharToUpper(in[++i]);
else
s += in[i];
}
@@ -112,7 +112,7 @@ std::string MakeScreamingCamel(const std::string &in) {
std::string s;
for (size_t i = 0; i < in.length(); i++) {
if (in[i] != '_')
s += static_cast<char>(toupper(in[i]));
s += CharToUpper(in[i]);
else
s += in[i];
}