1*0e209d39SAndroid Build Coastguard Worker // © 2018 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker 4*0e209d39SAndroid Build Coastguard Worker #ifndef __PLURALRANGES_H__ 5*0e209d39SAndroid Build Coastguard Worker #define __PLURALRANGES_H__ 6*0e209d39SAndroid Build Coastguard Worker 7*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 8*0e209d39SAndroid Build Coastguard Worker 9*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 10*0e209d39SAndroid Build Coastguard Worker 11*0e209d39SAndroid Build Coastguard Worker #include "unicode/uobject.h" 12*0e209d39SAndroid Build Coastguard Worker #include "unicode/locid.h" 13*0e209d39SAndroid Build Coastguard Worker #include "unicode/plurrule.h" 14*0e209d39SAndroid Build Coastguard Worker #include "standardplural.h" 15*0e209d39SAndroid Build Coastguard Worker #include "cmemory.h" 16*0e209d39SAndroid Build Coastguard Worker 17*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 18*0e209d39SAndroid Build Coastguard Worker 19*0e209d39SAndroid Build Coastguard Worker // Forward declarations 20*0e209d39SAndroid Build Coastguard Worker namespace number::impl { 21*0e209d39SAndroid Build Coastguard Worker class UFormattedNumberRangeData; 22*0e209d39SAndroid Build Coastguard Worker } 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker class StandardPluralRanges : public UMemory { 25*0e209d39SAndroid Build Coastguard Worker public: 26*0e209d39SAndroid Build Coastguard Worker /** Create a new StandardPluralRanges for the given locale */ 27*0e209d39SAndroid Build Coastguard Worker static StandardPluralRanges forLocale(const Locale& locale, UErrorCode& status); 28*0e209d39SAndroid Build Coastguard Worker 29*0e209d39SAndroid Build Coastguard Worker /** Explicit copy constructor */ 30*0e209d39SAndroid Build Coastguard Worker StandardPluralRanges copy(UErrorCode& status) const; 31*0e209d39SAndroid Build Coastguard Worker 32*0e209d39SAndroid Build Coastguard Worker /** Create an object (called on an rvalue) */ 33*0e209d39SAndroid Build Coastguard Worker LocalPointer<StandardPluralRanges> toPointer(UErrorCode& status) && noexcept; 34*0e209d39SAndroid Build Coastguard Worker 35*0e209d39SAndroid Build Coastguard Worker /** Select rule based on the first and second forms */ 36*0e209d39SAndroid Build Coastguard Worker StandardPlural::Form resolve(StandardPlural::Form first, StandardPlural::Form second) const; 37*0e209d39SAndroid Build Coastguard Worker 38*0e209d39SAndroid Build Coastguard Worker /** Used for data loading. */ 39*0e209d39SAndroid Build Coastguard Worker void addPluralRange( 40*0e209d39SAndroid Build Coastguard Worker StandardPlural::Form first, 41*0e209d39SAndroid Build Coastguard Worker StandardPlural::Form second, 42*0e209d39SAndroid Build Coastguard Worker StandardPlural::Form result); 43*0e209d39SAndroid Build Coastguard Worker 44*0e209d39SAndroid Build Coastguard Worker /** Used for data loading. */ 45*0e209d39SAndroid Build Coastguard Worker void setCapacity(int32_t length, UErrorCode& status); 46*0e209d39SAndroid Build Coastguard Worker 47*0e209d39SAndroid Build Coastguard Worker private: 48*0e209d39SAndroid Build Coastguard Worker struct StandardPluralRangeTriple { 49*0e209d39SAndroid Build Coastguard Worker StandardPlural::Form first; 50*0e209d39SAndroid Build Coastguard Worker StandardPlural::Form second; 51*0e209d39SAndroid Build Coastguard Worker StandardPlural::Form result; 52*0e209d39SAndroid Build Coastguard Worker }; 53*0e209d39SAndroid Build Coastguard Worker 54*0e209d39SAndroid Build Coastguard Worker // TODO: An array is simple here, but it results in linear lookup time. 55*0e209d39SAndroid Build Coastguard Worker // Certain locales have 20-30 entries in this list. 56*0e209d39SAndroid Build Coastguard Worker // Consider changing to a smarter data structure. 57*0e209d39SAndroid Build Coastguard Worker typedef MaybeStackArray<StandardPluralRangeTriple, 3> PluralRangeTriples; 58*0e209d39SAndroid Build Coastguard Worker PluralRangeTriples fTriples; 59*0e209d39SAndroid Build Coastguard Worker int32_t fTriplesLen = 0; 60*0e209d39SAndroid Build Coastguard Worker }; 61*0e209d39SAndroid Build Coastguard Worker 62*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 63*0e209d39SAndroid Build Coastguard Worker 64*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 65*0e209d39SAndroid Build Coastguard Worker #endif //__PLURALRANGES_H__ 66