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

@@ -248,10 +248,10 @@ class CppGenerator : public BaseGenerator {
name.erase(name.length() - union_suffix_len, union_suffix_len);
}
if (opts_.cpp_object_api_field_case_style == IDLOptions::CaseStyle_Upper)
name = MakeCamel(name, true); /* upper */
name = ConvertCase(name, Case::kUpperCamel);
else if (opts_.cpp_object_api_field_case_style ==
IDLOptions::CaseStyle_Lower)
name = MakeCamel(name, false); /* lower */
name = ConvertCase(name, Case::kLowerCamel);
// restore the union field type suffix
if (is_union_type) name.append(UnionTypeFieldSuffix(), union_suffix_len);
return EscapeKeyword(name);