mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 01:07:29 +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:
@@ -121,16 +121,16 @@ class DartGenerator : public BaseGenerator {
|
||||
|
||||
auto ret = sstream.str() + ns.components.back();
|
||||
for (size_t i = 0; i < ret.size(); i++) {
|
||||
auto lower = tolower(ret[i]);
|
||||
auto lower = CharToLower(ret[i]);
|
||||
if (lower != ret[i]) {
|
||||
ret[i] = static_cast<char>(lower);
|
||||
ret[i] = lower;
|
||||
if (i != 0 && ret[i - 1] != '.') {
|
||||
ret.insert(i, "_");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// std::transform(ret.begin(), ret.end(), ret.begin(), ::tolower);
|
||||
// std::transform(ret.begin(), ret.end(), ret.begin(), CharToLower);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -487,11 +487,11 @@ class DartGenerator : public BaseGenerator {
|
||||
|
||||
for (size_t i = 0; i < part.length(); i++) {
|
||||
if (i && !isdigit(part[i]) &&
|
||||
part[i] == static_cast<char>(toupper(part[i]))) {
|
||||
part[i] == CharToUpper(part[i])) {
|
||||
ns += "_";
|
||||
ns += static_cast<char>(tolower(part[i]));
|
||||
ns += CharToLower(part[i]);
|
||||
} else {
|
||||
ns += static_cast<char>(tolower(part[i]));
|
||||
ns += CharToLower(part[i]);
|
||||
}
|
||||
}
|
||||
if (it != qualified_name_parts.end() - 1) { ns += "_"; }
|
||||
|
||||
Reference in New Issue
Block a user