Use ConvertCase instead of Make{Upper,Lower,Snake} implementations (#7127)

* Unified name case conversion to single method

* Convert bfbs_gen to use ConvertCase

* convert rust to use ConvertCase

* Convert idl_parser to use ConvertCase

* Convert MakeScreamingCamel to ConvertCase

* Replaced MakeCamel with ConvertCase

* minor fixes
This commit is contained in:
Derek Bailey
2022-02-23 16:08:11 -08:00
committed by GitHub
parent 0471fa807c
commit 3694b830a2
20 changed files with 617 additions and 396 deletions

View File

@@ -93,20 +93,6 @@ static bool IsVector(const reflection::BaseType base_type) {
return base_type == reflection::Vector;
}
static std::string MakeCamelCase(const std::string &in,
bool uppercase_first = true) {
std::string s;
for (size_t i = 0; i < in.length(); i++) {
if (!i && uppercase_first)
s += static_cast<char>(::toupper(static_cast<unsigned char>(in[0])));
else if (in[i] == '_' && i + 1 < in.length())
s += static_cast<char>(::toupper(static_cast<unsigned char>(in[++i])));
else
s += in[i];
}
return s;
}
static std::string Denamespace(const flatbuffers::String *name,
std::string &ns) {
const size_t pos = name->str().find_last_of('.');