mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-14 08:26:59 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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_
|
||||
|
||||
Reference in New Issue
Block a user