mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
Replaced ToDasherCase with ConvertCase (#7131)
This commit is contained in:
@@ -91,7 +91,8 @@ std::string BaseGenerator::NamespaceDir(const Parser &parser,
|
||||
std::string namespace_dir = path; // Either empty or ends in separator.
|
||||
auto &namespaces = ns.components;
|
||||
for (auto it = namespaces.begin(); it != namespaces.end(); ++it) {
|
||||
namespace_dir += !dasherize ? *it : ToDasherizedCase(*it);
|
||||
namespace_dir +=
|
||||
!dasherize ? *it : ConvertCase(*it, Case::kDasher, Case::kUpperCamel);
|
||||
namespace_dir += kPathSeparator;
|
||||
EnsureDirExists(namespace_dir);
|
||||
}
|
||||
@@ -103,22 +104,6 @@ std::string BaseGenerator::NamespaceDir(const Namespace &ns,
|
||||
return BaseGenerator::NamespaceDir(parser_, path_, ns, dasherize);
|
||||
}
|
||||
|
||||
std::string BaseGenerator::ToDasherizedCase(const std::string pascal_case) {
|
||||
std::string dasherized_case;
|
||||
char p = 0;
|
||||
for (size_t i = 0; i < pascal_case.length(); i++) {
|
||||
char const &c = pascal_case[i];
|
||||
if (is_alpha_upper(c)) {
|
||||
if (i > 0 && p != kPathSeparator) dasherized_case += "-";
|
||||
dasherized_case += CharToLower(c);
|
||||
} else {
|
||||
dasherized_case += c;
|
||||
}
|
||||
p = c;
|
||||
}
|
||||
return dasherized_case;
|
||||
}
|
||||
|
||||
std::string BaseGenerator::FullNamespace(const char *separator,
|
||||
const Namespace &ns) {
|
||||
std::string namespace_name;
|
||||
|
||||
Reference in New Issue
Block a user