7 #ifndef __LOCALEMATCHER_H__ 8 #define __LOCALEMATCHER_H__ 12 #if U_SHOW_CPLUSPLUS_API 139 class LocaleDistance;
140 class LocaleLsrIterator;
278 int32_t desIndex, int32_t suppIndex,
UBool owned) :
279 desiredLocale(desired), supportedLocale(supported),
280 desiredIndex(desIndex), supportedIndex(suppIndex),
281 desiredIsOwned(owned) {}
283 Result(
const Result &other) =
delete;
284 Result &operator=(
const Result &other) =
delete;
286 const Locale *desiredLocale;
287 const Locale *supportedLocale;
288 int32_t desiredIndex;
289 int32_t supportedIndex;
290 UBool desiredIsOwned;
373 template<
typename Iter>
375 if (
U_FAILURE(errorCode_)) {
return *
this; }
376 clearSupportedLocales();
377 while (begin != end) {
378 addSupportedLocale(*begin++);
398 template<
typename Iter,
typename Conv>
400 if (
U_FAILURE(errorCode_)) {
return *
this; }
401 clearSupportedLocales();
402 while (begin != end) {
403 addSupportedLocale(converter(*begin++));
472 direction_ = matchDirection;
530 void clearSupportedLocales();
531 bool ensureSupportedLocaleVector();
534 UVector *supportedLocales_ =
nullptr;
535 int32_t thresholdDistance_ = -1;
537 Locale *defaultLocale_ =
nullptr;
538 bool withDefault_ =
true;
541 Locale *maxDistanceDesired_ =
nullptr;
542 Locale *maxDistanceSupported_ =
nullptr;
623 Result getBestMatchResult(
const Locale &desiredLocale,
UErrorCode &errorCode)
const;
654 #ifndef U_HIDE_INTERNAL_API 674 #endif // U_HIDE_INTERNAL_API 681 int32_t putIfAbsent(
const LSR &lsr, int32_t i, int32_t suppLength,
UErrorCode &errorCode);
683 std::optional<int32_t> getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remainingIter,
UErrorCode &errorCode)
const;
685 const LikelySubtags &likelySubtags;
686 const LocaleDistance &localeDistance;
687 int32_t thresholdDistance;
688 int32_t demotionPerDesiredLocale;
693 const Locale ** supportedLocales;
695 int32_t supportedLocalesLength;
700 const LSR **supportedLSRs;
701 int32_t *supportedIndexes;
702 int32_t supportedLSRsLength;
703 Locale *ownedDefaultLocale;
704 const Locale *defaultLocale;
709 #endif // U_SHOW_CPLUSPLUS_API 710 #endif // __LOCALEMATCHER_H__ int32_t getSupportedIndex() const
Returns the index of the best-matching supported locale in the constructor’s or builder’s input ord...
struct UHashtable UHashtable
All desired locales are treated equally.
Builder & setSupportedLocalesViaConverter(Iter begin, Iter end, Conv converter)
Copies the supported locales from the begin/end range, preserving iteration order.
#define U_SUCCESS(x)
Does the error code indicate success?
#define U_FAILURE(x)
Does the error code indicate a failure?
ULocMatchDemotion
Builder option for whether all desired locales are treated equally or earlier ones are preferred...
Makes script differences matter relatively more than language differences.
Locale matching limited to two-way matches including e.g.
Builder & setDirection(ULocMatchDirection matchDirection)
Option for whether to include or ignore one-way (fallback) match data.
Builder & setSupportedLocales(Iter begin, Iter end)
Copies the supported locales from the begin/end range, preserving iteration order.
const Locale * getDesiredLocale() const
Returns the best-matching desired locale.
Earlier desired locales are preferred.
A Locale iterator interface similar to a Java Iterator<Locale>.
C++ API: StringPiece: Read-only byte string wrapper class.
Locale matching includes one-way matches such as Breton→French.
ULocMatchFavorSubtag
Builder option for whether the language subtag or the script subtag is most important.
Immutable class that picks the best match between a user's desired locales and an application's suppo...
Builder()
Constructs a builder used in chaining parameters for building a LocaleMatcher.
ULocMatchDirection
Builder option for whether to include or ignore one-way (fallback) match data.
int32_t getDesiredIndex() const
Returns the index of the best-matching desired locale in the input Iterable order.
const Locale * getSupportedLocale() const
Returns the best-matching supported locale.
Data for the best-matching pair of a desired and a supported locale.
C++ API: Common ICU base class UObject.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
C++ API: Locale ID object.
Language differences are most important, then script differences, then region differences.
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
A string-like object that points to a sized piece of memory.
UMemory is the common ICU base class.
int8_t UBool
The ICU boolean type, a signed-byte integer.
A Locale object represents a specific geographical, political, or cultural region.