From 70643a9e4821bd11c3f363f1708fe420965467d1 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Fri, 28 Aug 2026 22:17:10 +0200 Subject: Format again --- server/src/locale.cppm | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'server/src/locale.cppm') diff --git a/server/src/locale.cppm b/server/src/locale.cppm index 8fd867b..06607f0 100644 --- a/server/src/locale.cppm +++ b/server/src/locale.cppm @@ -50,11 +50,11 @@ struct icu_locale_hash }; using icu_locale_priority_map = - std::unordered_map; + std::unordered_map; using icu_priority_locale = std::pair; auto operator<(icu_priority_locale const& lhs, icu_priority_locale const& rhs) - -> bool + -> bool { return lhs.second < rhs.second; } @@ -66,7 +66,7 @@ class icu_priority_locale_vec_iterator : public icu::Locale::Iterator public: explicit icu_priority_locale_vec_iterator( - std::vector&& ls) + std::vector&& ls) : ls_(std::move(ls)) { } @@ -80,9 +80,8 @@ public: export template concept locale_input_range = - std::ranges::input_range - && std::same_as< - std::locale const&, std::ranges::range_const_reference_t>; + std::ranges::input_range + && std::same_as>; // Helps select a locale based on the Accept-Language header in an // HTTP request. @@ -93,23 +92,23 @@ export class selector std::shared_ptr lgen_; auto make_matcher( - locale_input_range auto supported_locales, std::locale default_locale) + locale_input_range auto supported_locales, std::locale default_locale) { auto builder = icu::LocaleMatcher::Builder{}; for (auto const& supported_locale : supported_locales) { auto const& supported_locale_info = - std::use_facet(supported_locale); + std::use_facet(supported_locale); auto supported_icu_locale = - icu::Locale{supported_locale_info.name().c_str()}; + icu::Locale{supported_locale_info.name().c_str()}; if (supported_icu_locale.isBogus()) throw std::runtime_error{ - "supported locale gives rise to bogus ICU locale" + "supported locale gives rise to bogus ICU locale" }; builder.addSupportedLocale(supported_icu_locale); } auto const& default_locale_info = - std::use_facet(default_locale); + std::use_facet(default_locale); auto default_icu_locale = icu::Locale{default_locale_info.name().c_str()}; if (default_icu_locale.isBogus()) throw std::runtime_error{"default locale gives rise to bogus ICU locale"}; @@ -171,7 +170,7 @@ export class selector while (kw = keywords->next(&kw_len, ec), !U_FAILURE(ec) && kw) { auto value = - l.getKeywordValue(icu::StringPiece(kw, kw_len), ec); + l.getKeywordValue(icu::StringPiece(kw, kw_len), ec); if (!added_at) { posix_name += "@"; @@ -196,8 +195,8 @@ public: // Note: lgen must live at least as long as the selector constructed here! // It is unfortunately not possible to copy/move a blocale::generator. explicit selector( - locale_input_range auto locales, std::locale default_, - std::shared_ptr lgen) + locale_input_range auto locales, std::locale default_, + std::shared_ptr lgen) : default_{default_}, matcher_{make_matcher(locales, default_)}, lgen_{lgen} { } @@ -212,7 +211,7 @@ public: accept_language | std::views::split(","sv) | std::views::enumerate) { auto [lang_range_ut, mweight_ut] = - util::split_on(std::string_view{lang_prio}, ';'); + util::split_on(std::string_view{lang_prio}, ';'); auto lang_range_str = trim_ows(lang_range_ut); auto mweight_str = mweight_ut.transform(trim_ows); if (lang_range_str == "*") @@ -228,7 +227,7 @@ public: { auto weight_str = mweight_str->substr(2, 4); if (auto mweight = - util::parse_float(weight_str, std::chars_format::fixed); + util::parse_float(weight_str, std::chars_format::fixed); mweight && 0.0f < *mweight && *mweight < 1.0f) { weight = *mweight; @@ -238,8 +237,8 @@ public: if (weight > 0.0f) { dlpm[icu_locale] = { - .weight = weight, - .original_index = static_cast(i), + .weight = weight, + .original_index = static_cast(i), }; } else @@ -249,7 +248,7 @@ public: } auto desired_locales = - std::vector{dlpm.begin(), dlpm.end()}; + std::vector{dlpm.begin(), dlpm.end()}; std::sort(desired_locales.begin(), desired_locales.end()); auto it = icu_priority_locale_vec_iterator{std::move(desired_locales)}; auto ec = UErrorCode::U_ZERO_ERROR; @@ -268,7 +267,7 @@ export auto to_bcp47_lang_tag(std::locale locale) -> std::optional auto const& locale_info = std::use_facet(locale); auto ec = UErrorCode::U_ZERO_ERROR; auto bcp47_lang_tag = - icu::Locale{locale_info.name().c_str()}.toLanguageTag(ec); + icu::Locale{locale_info.name().c_str()}.toLanguageTag(ec); if (U_FAILURE(ec)) return std::nullopt; return bcp47_lang_tag; -- cgit v1.3