mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 04:33:23 +00:00
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:
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user