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

@@ -1057,10 +1057,6 @@ class Parser : public ParserState {
// Utility functions for multiple generators:
extern std::string MakeCamel(const std::string &in, bool first = true);
extern std::string MakeScreamingCamel(const std::string &in);
// Generate text (JSON) from a given FlatBuffer, and a given Parser
// object that has been populated with the corresponding schema.
// If ident_step is 0, no indentation will be generated. Additionally,

View File

@@ -685,6 +685,26 @@ bool ReadEnvironmentVariable(const char *var_name,
// MSVC specific: Send all assert reports to STDOUT to prevent CI hangs.
void SetupDefaultCRTReportMode();
enum class Case {
kUnknown = 0,
// TheQuickBrownFox
kUpperCamel = 1,
// theQuickBrownFox
kLowerCamel = 2,
// the_quick_brown_fox
kSnake = 3,
// THE_QUICK_BROWN_FOX
kScreamingSnake = 4,
// THEQUICKBROWNFOX
kAllUpper = 5,
// thequickbrownfox
kAllLower = 6,
};
// Convert the `input` string of case `input_case` to the specified `output_case`.
std::string ConvertCase(const std::string &input, Case output_case,
Case input_case = Case::kSnake);
} // namespace flatbuffers
#endif // FLATBUFFERS_UTIL_H_