7 #ifndef __LOCALEMATCHER_H__
8 #define __LOCALEMATCHER_H__
12 #if U_SHOW_CPLUSPLUS_API
136 class LocaleDistance;
137 class LocaleLsrIterator;
139 class XLikelySubtags;
276 int32_t desIndex, int32_t suppIndex,
UBool owned) :
277 desiredLocale(desired), supportedLocale(supported),
278 desiredIndex(desIndex), supportedIndex(suppIndex),
279 desiredIsOwned(owned) {}
281 Result(
const Result &other) =
delete;
282 Result &operator=(
const Result &other) =
delete;
284 const Locale *desiredLocale;
285 const Locale *supportedLocale;
286 int32_t desiredIndex;
287 int32_t supportedIndex;
288 UBool desiredIsOwned;
371 template<typename Iter>
372 Builder &setSupportedLocales(Iter begin, Iter end) {
373 if (
U_FAILURE(errorCode_)) {
return *
this; }
374 clearSupportedLocales();
375 while (begin != end) {
376 addSupportedLocale(*begin++);
396 template<
typename Iter,
typename Conv>
398 if (
U_FAILURE(errorCode_)) {
return *
this; }
399 clearSupportedLocales();
400 while (begin != end) {
401 addSupportedLocale(converter(*begin++));
470 direction_ = matchDirection;
528 void clearSupportedLocales();
529 bool ensureSupportedLocaleVector();
532 UVector *supportedLocales_ =
nullptr;
533 int32_t thresholdDistance_ = -1;
535 Locale *defaultLocale_ =
nullptr;
536 bool withDefault_ =
true;
539 Locale *maxDistanceDesired_ =
nullptr;
540 Locale *maxDistanceSupported_ =
nullptr;
621 Result getBestMatchResult(const
Locale &desiredLocale,
UErrorCode &errorCode) const;
635 Result getBestMatchResult(
Locale::Iterator &desiredLocales,
UErrorCode &errorCode) const;
652 #ifndef U_HIDE_INTERNAL_API
672 #endif // U_HIDE_INTERNAL_API
679 int32_t putIfAbsent(
const LSR &lsr, int32_t i, int32_t suppLength,
UErrorCode &errorCode);
681 int32_t getBestSuppIndex(LSR desiredLSR, LocaleLsrIterator *remainingIter,
UErrorCode &errorCode)
const;
683 const XLikelySubtags &likelySubtags;
684 const LocaleDistance &localeDistance;
685 int32_t thresholdDistance;
686 int32_t demotionPerDesiredLocale;
691 const Locale ** supportedLocales;
693 int32_t supportedLocalesLength;
698 const LSR **supportedLSRs;
699 int32_t *supportedIndexes;
700 int32_t supportedLSRsLength;
701 Locale *ownedDefaultLocale;
702 const Locale *defaultLocale;
707 #endif // U_SHOW_CPLUSPLUS_API
708 #endif // __LOCALEMATCHER_H__
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.
Earlier desired locales are preferred.
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.
int32_t getDesiredIndex() const
Returns the index of the best-matching desired locale in the input Iterable order.
ULocMatchDirection
Builder option for whether to include or ignore one-way (fallback) match data.
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.
const Locale * getDesiredLocale() const
Returns the best-matching desired locale.
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...
int32_t getSupportedIndex() const
Returns the index of the best-matching supported locale in the constructor’s or builder’s input order...
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.