Go to the documentation of this file.
7 #ifndef __LOCALEMATCHER_H__
8 #define __LOCALEMATCHER_H__
12 #if U_SHOW_CPLUSPLUS_API
23 #ifndef U_HIDE_DRAFT_API
102 class LocaleDistance;
103 class LocaleLsrIterator;
105 class XLikelySubtags;
242 int32_t desIndex, int32_t suppIndex,
UBool owned) :
243 desiredLocale(desired), supportedLocale(supported),
244 desiredIndex(desIndex), supportedIndex(suppIndex),
245 desiredIsOwned(owned) {}
247 Result(
const Result &other) =
delete;
248 Result &operator=(
const Result &other) =
delete;
250 const Locale *desiredLocale;
251 const Locale *supportedLocale;
252 int32_t desiredIndex;
253 int32_t supportedIndex;
254 UBool desiredIsOwned;
338 template<
typename Iter>
340 if (
U_FAILURE(errorCode_)) {
return *
this; }
341 clearSupportedLocales();
342 while (begin != end) {
343 addSupportedLocale(*begin++);
363 template<
typename Iter,
typename Conv>
365 if (
U_FAILURE(errorCode_)) {
return *
this; }
366 clearSupportedLocales();
367 while (begin != end) {
368 addSupportedLocale(converter(*begin++));
445 void clearSupportedLocales();
446 bool ensureSupportedLocaleVector();
449 UVector *supportedLocales_ =
nullptr;
450 int32_t thresholdDistance_ = -1;
452 Locale *defaultLocale_ =
nullptr;
534 Result getBestMatchResult(
const Locale &desiredLocale,
UErrorCode &errorCode)
const;
550 #ifndef U_HIDE_INTERNAL_API
570 #endif // U_HIDE_INTERNAL_API
577 int32_t getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remainingIter,
UErrorCode &errorCode)
const;
579 const XLikelySubtags &likelySubtags;
580 const LocaleDistance &localeDistance;
581 int32_t thresholdDistance;
582 int32_t demotionPerDesiredLocale;
586 const Locale ** supportedLocales;
588 int32_t supportedLocalesLength;
593 const LSR **supportedLSRs;
594 int32_t *supportedIndexes;
595 int32_t supportedLSRsLength;
596 Locale *ownedDefaultLocale;
597 const Locale *defaultLocale;
598 int32_t defaultLocaleIndex;
603 #endif // U_HIDE_DRAFT_API
604 #endif // U_SHOW_CPLUSPLUS_API
605 #endif // __LOCALEMATCHER_H__
struct UHashtable UHashtable
Data for the best-matching pair of a desired and a supported locale.
Basic definitions for ICU, for both C and C++ APIs.
ULocMatchDemotion
Builder option for whether all desired locales are treated equally or earlier ones are preferred.
int8_t UBool
The ICU boolean type.
int32_t getSupportedIndex() const
Returns the index of the best-matching supported locale in the constructor’s or builder’s input order...
C++ API: StringPiece: Read-only byte string wrapper class.
const Locale * getDesiredLocale() const
Returns the best-matching desired locale.
Builder()
Constructs a builder used in chaining parameters for building a LocaleMatcher.
#define U_FAILURE(x)
Does the error code indicate a failure?
A Locale iterator interface similar to a Java Iterator<Locale>.
ULocMatchFavorSubtag
Builder option for whether the language subtag or the script subtag is most important.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
All desired locales are treated equally.
UMemory is the common ICU base class.
const Locale * getSupportedLocale() const
Returns the best-matching supported locale.
Builder & setSupportedLocales(Iter begin, Iter end)
Copies the supported locales from the begin/end range, preserving iteration order.
Builder & setSupportedLocalesViaConverter(Iter begin, Iter end, Conv converter)
Copies the supported locales from the begin/end range, preserving iteration order.
Language differences are most important, then script differences, then region differences.
Immutable class that picks the best match between a user's desired locales and an application's suppo...
int32_t getDesiredIndex() const
Returns the index of the best-matching desired locale in the input Iterable order.
Makes script differences matter relatively more than language differences.
C++ API: Locale ID object.
C++ API: Common ICU base class UObject.
A string-like object that points to a sized piece of memory.
A Locale object represents a specific geographical, political, or cultural region.
Earlier desired locales are preferred.