Meta: Support generating case-insensitive value-from-string methods

This also extracts the default parameters for generate_value_from_string
to a structure. This is just to make it cleaner to add new options.
This commit is contained in:
Timothy Flynn 2022-01-10 12:19:58 -05:00 committed by Linus Groh
parent 3dccaa39d8
commit 6da1bfeeea
Notes: sideshowbarker 2024-07-17 21:13:51 +09:00
2 changed files with 27 additions and 5 deletions

View file

@ -1077,7 +1077,11 @@ Optional<StringView> get_locale_@enum_snake@_mapping(StringView locale, StringVi
for (auto const& alias : aliases)
hashes.set(alias.key.hash(), alias.value);
generate_value_from_string(generator, "resolve_{}_alias"sv, s_string_index_type, enum_snake, move(hashes), "StringView"sv, "s_string_list[{}]"sv);
ValueFromStringOptions options {};
options.return_type = "StringView"sv;
options.return_format = "s_string_list[{}]"sv;
generate_value_from_string(generator, "resolve_{}_alias"sv, s_string_index_type, enum_snake, move(hashes), options);
};
append_from_string("Locale"sv, "locale"sv, locale_data.locales.keys(), locale_data.locale_aliases);