MCPcopy Create free account
hub / github.com/apache/fory / to_snake_case

Function to_snake_case

cpp/fory/util/string_util.h:244–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242
243template <size_t MaxLength>
244constexpr std::pair<std::array<char, MaxLength + 1>, size_t>
245to_snake_case(std::string_view name) {
246 std::array<char, MaxLength + 1> buffer{};
247 size_t pos = 0;
248 for (size_t i = 0; i < name.size(); ++i) {
249 char c = name[i];
250 if (c == '_' || c == '-') {
251 buffer[pos++] = '_';
252 continue;
253 }
254 if (needs_snake_separator(name, i)) {
255 buffer[pos++] = '_';
256 }
257 buffer[pos++] = is_upper_ascii(c) ? to_lower_ascii(c) : c;
258 }
259 buffer[pos] = '\0';
260 return {buffer, pos};
261}
262
263} // namespace detail
264

Callers

nothing calls this directly

Calls 4

needs_snake_separatorFunction · 0.85
is_upper_asciiFunction · 0.85
to_lower_asciiFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected