1*0e209d39SAndroid Build Coastguard Worker // © 2016 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 ******************************************************************************** 5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 1997-2013, International Business Machines 6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************** 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker * File CHOICFMT.H 10*0e209d39SAndroid Build Coastguard Worker * 11*0e209d39SAndroid Build Coastguard Worker * Modification History: 12*0e209d39SAndroid Build Coastguard Worker * 13*0e209d39SAndroid Build Coastguard Worker * Date Name Description 14*0e209d39SAndroid Build Coastguard Worker * 02/19/97 aliu Converted from java. 15*0e209d39SAndroid Build Coastguard Worker * 03/20/97 helena Finished first cut of implementation and got rid 16*0e209d39SAndroid Build Coastguard Worker * of nextDouble/previousDouble and replaced with 17*0e209d39SAndroid Build Coastguard Worker * boolean array. 18*0e209d39SAndroid Build Coastguard Worker * 4/10/97 aliu Clean up. Modified to work on AIX. 19*0e209d39SAndroid Build Coastguard Worker * 8/6/97 nos Removed overloaded constructor, member var 'buffer'. 20*0e209d39SAndroid Build Coastguard Worker * 07/22/98 stephen Removed operator!= (implemented in Format) 21*0e209d39SAndroid Build Coastguard Worker ******************************************************************************** 22*0e209d39SAndroid Build Coastguard Worker */ 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker #ifndef CHOICFMT_H 25*0e209d39SAndroid Build Coastguard Worker #define CHOICFMT_H 26*0e209d39SAndroid Build Coastguard Worker 27*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 28*0e209d39SAndroid Build Coastguard Worker 29*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 30*0e209d39SAndroid Build Coastguard Worker 31*0e209d39SAndroid Build Coastguard Worker /** 32*0e209d39SAndroid Build Coastguard Worker * \file 33*0e209d39SAndroid Build Coastguard Worker * \brief C++ API: Choice Format. 34*0e209d39SAndroid Build Coastguard Worker */ 35*0e209d39SAndroid Build Coastguard Worker 36*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 37*0e209d39SAndroid Build Coastguard Worker 38*0e209d39SAndroid Build Coastguard Worker #include "unicode/fieldpos.h" 39*0e209d39SAndroid Build Coastguard Worker #include "unicode/format.h" 40*0e209d39SAndroid Build Coastguard Worker #include "unicode/messagepattern.h" 41*0e209d39SAndroid Build Coastguard Worker #include "unicode/numfmt.h" 42*0e209d39SAndroid Build Coastguard Worker #include "unicode/unistr.h" 43*0e209d39SAndroid Build Coastguard Worker 44*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 45*0e209d39SAndroid Build Coastguard Worker 46*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 47*0e209d39SAndroid Build Coastguard Worker 48*0e209d39SAndroid Build Coastguard Worker class MessageFormat; 49*0e209d39SAndroid Build Coastguard Worker 50*0e209d39SAndroid Build Coastguard Worker /** 51*0e209d39SAndroid Build Coastguard Worker * ChoiceFormat converts between ranges of numeric values and strings for those ranges. 52*0e209d39SAndroid Build Coastguard Worker * The strings must conform to the MessageFormat pattern syntax. 53*0e209d39SAndroid Build Coastguard Worker * 54*0e209d39SAndroid Build Coastguard Worker * <p><em><code>ChoiceFormat</code> is probably not what you need. 55*0e209d39SAndroid Build Coastguard Worker * Please use <code>MessageFormat</code> 56*0e209d39SAndroid Build Coastguard Worker * with <code>plural</code> arguments for proper plural selection, 57*0e209d39SAndroid Build Coastguard Worker * and <code>select</code> arguments for simple selection among a fixed set of choices!</em></p> 58*0e209d39SAndroid Build Coastguard Worker * 59*0e209d39SAndroid Build Coastguard Worker * <p>A <code>ChoiceFormat</code> splits 60*0e209d39SAndroid Build Coastguard Worker * the real number line \htmlonly<code>-∞</code> to 61*0e209d39SAndroid Build Coastguard Worker * <code>+∞</code>\endhtmlonly into two 62*0e209d39SAndroid Build Coastguard Worker * or more contiguous ranges. Each range is mapped to a 63*0e209d39SAndroid Build Coastguard Worker * string.</p> 64*0e209d39SAndroid Build Coastguard Worker * 65*0e209d39SAndroid Build Coastguard Worker * <p><code>ChoiceFormat</code> was originally intended 66*0e209d39SAndroid Build Coastguard Worker * for displaying grammatically correct 67*0e209d39SAndroid Build Coastguard Worker * plurals such as "There is one file." vs. "There are 2 files." 68*0e209d39SAndroid Build Coastguard Worker * <em>However,</em> plural rules for many languages 69*0e209d39SAndroid Build Coastguard Worker * are too complex for the capabilities of ChoiceFormat, 70*0e209d39SAndroid Build Coastguard Worker * and its requirement of specifying the precise rules for each message 71*0e209d39SAndroid Build Coastguard Worker * is unmanageable for translators.</p> 72*0e209d39SAndroid Build Coastguard Worker * 73*0e209d39SAndroid Build Coastguard Worker * <p>There are two methods of defining a <code>ChoiceFormat</code>; both 74*0e209d39SAndroid Build Coastguard Worker * are equivalent. The first is by using a string pattern. This is the 75*0e209d39SAndroid Build Coastguard Worker * preferred method in most cases. The second method is through direct 76*0e209d39SAndroid Build Coastguard Worker * specification of the arrays that logically make up the 77*0e209d39SAndroid Build Coastguard Worker * <code>ChoiceFormat</code>.</p> 78*0e209d39SAndroid Build Coastguard Worker * 79*0e209d39SAndroid Build Coastguard Worker * <p>Note: Typically, choice formatting is done (if done at all) via <code>MessageFormat</code> 80*0e209d39SAndroid Build Coastguard Worker * with a <code>choice</code> argument type, 81*0e209d39SAndroid Build Coastguard Worker * rather than using a stand-alone <code>ChoiceFormat</code>.</p> 82*0e209d39SAndroid Build Coastguard Worker * 83*0e209d39SAndroid Build Coastguard Worker * <h5>Patterns and Their Interpretation</h5> 84*0e209d39SAndroid Build Coastguard Worker * 85*0e209d39SAndroid Build Coastguard Worker * <p>The pattern string defines the range boundaries and the strings for each number range. 86*0e209d39SAndroid Build Coastguard Worker * Syntax: 87*0e209d39SAndroid Build Coastguard Worker * <pre> 88*0e209d39SAndroid Build Coastguard Worker * choiceStyle = number separator message ('|' number separator message)* 89*0e209d39SAndroid Build Coastguard Worker * number = normal_number | ['-'] \htmlonly∞\endhtmlonly (U+221E, infinity) 90*0e209d39SAndroid Build Coastguard Worker * normal_number = double value (unlocalized ASCII string) 91*0e209d39SAndroid Build Coastguard Worker * separator = less_than | less_than_or_equal 92*0e209d39SAndroid Build Coastguard Worker * less_than = '<' 93*0e209d39SAndroid Build Coastguard Worker * less_than_or_equal = '#' | \htmlonly≤\endhtmlonly (U+2264) 94*0e209d39SAndroid Build Coastguard Worker * message: see {@link MessageFormat} 95*0e209d39SAndroid Build Coastguard Worker * </pre> 96*0e209d39SAndroid Build Coastguard Worker * Pattern_White_Space between syntax elements is ignored, except 97*0e209d39SAndroid Build Coastguard Worker * around each range's sub-message.</p> 98*0e209d39SAndroid Build Coastguard Worker * 99*0e209d39SAndroid Build Coastguard Worker * <p>Each numeric sub-range extends from the current range's number 100*0e209d39SAndroid Build Coastguard Worker * to the next range's number. 101*0e209d39SAndroid Build Coastguard Worker * The number itself is included in its range if a <code>less_than_or_equal</code> sign is used, 102*0e209d39SAndroid Build Coastguard Worker * and excluded from its range (and instead included in the previous range) 103*0e209d39SAndroid Build Coastguard Worker * if a <code>less_than</code> sign is used.</p> 104*0e209d39SAndroid Build Coastguard Worker * 105*0e209d39SAndroid Build Coastguard Worker * <p>When a <code>ChoiceFormat</code> is constructed from 106*0e209d39SAndroid Build Coastguard Worker * arrays of numbers, closure flags and strings, 107*0e209d39SAndroid Build Coastguard Worker * they are interpreted just like 108*0e209d39SAndroid Build Coastguard Worker * the sequence of <code>(number separator string)</code> in an equivalent pattern string. 109*0e209d39SAndroid Build Coastguard Worker * <code>closure[i]==true</code> corresponds to a <code>less_than</code> separator sign. 110*0e209d39SAndroid Build Coastguard Worker * The equivalent pattern string will be constructed automatically.</p> 111*0e209d39SAndroid Build Coastguard Worker * 112*0e209d39SAndroid Build Coastguard Worker * <p>During formatting, a number is mapped to the first range 113*0e209d39SAndroid Build Coastguard Worker * where the number is not greater than the range's upper limit. 114*0e209d39SAndroid Build Coastguard Worker * That range's message string is returned. A NaN maps to the very first range.</p> 115*0e209d39SAndroid Build Coastguard Worker * 116*0e209d39SAndroid Build Coastguard Worker * <p>During parsing, a range is selected for the longest match of 117*0e209d39SAndroid Build Coastguard Worker * any range's message. That range's number is returned, ignoring the separator/closure. 118*0e209d39SAndroid Build Coastguard Worker * Only a simple string match is performed, without parsing of arguments that 119*0e209d39SAndroid Build Coastguard Worker * might be specified in the message strings.</p> 120*0e209d39SAndroid Build Coastguard Worker * 121*0e209d39SAndroid Build Coastguard Worker * <p>Note that the first range's number is ignored in formatting 122*0e209d39SAndroid Build Coastguard Worker * but may be returned from parsing.</p> 123*0e209d39SAndroid Build Coastguard Worker * 124*0e209d39SAndroid Build Coastguard Worker * <h5>Examples</h5> 125*0e209d39SAndroid Build Coastguard Worker * 126*0e209d39SAndroid Build Coastguard Worker * <p>Here is an example of two arrays that map the number 127*0e209d39SAndroid Build Coastguard Worker * <code>1..7</code> to the English day of the week abbreviations 128*0e209d39SAndroid Build Coastguard Worker * <code>Sun..Sat</code>. No closures array is given; this is the same as 129*0e209d39SAndroid Build Coastguard Worker * specifying all closures to be <code>false</code>.</p> 130*0e209d39SAndroid Build Coastguard Worker * 131*0e209d39SAndroid Build Coastguard Worker * <pre> {1,2,3,4,5,6,7}, 132*0e209d39SAndroid Build Coastguard Worker * {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}</pre> 133*0e209d39SAndroid Build Coastguard Worker * 134*0e209d39SAndroid Build Coastguard Worker * <p>Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1, 135*0e209d39SAndroid Build Coastguard Worker * +Inf] to three strings. That is, the number line is split into three 136*0e209d39SAndroid Build Coastguard Worker * ranges: x < 1.0, x = 1.0, and x > 1.0. 137*0e209d39SAndroid Build Coastguard Worker * (The round parentheses in the notation above indicate an exclusive boundary, 138*0e209d39SAndroid Build Coastguard Worker * like the turned bracket in European notation: [-Inf, 1) == [-Inf, 1[ )</p> 139*0e209d39SAndroid Build Coastguard Worker * 140*0e209d39SAndroid Build Coastguard Worker * <pre> {0, 1, 1}, 141*0e209d39SAndroid Build Coastguard Worker * {false, false, true}, 142*0e209d39SAndroid Build Coastguard Worker * {"no files", "one file", "many files"}</pre> 143*0e209d39SAndroid Build Coastguard Worker * 144*0e209d39SAndroid Build Coastguard Worker * <p>Here is an example that shows formatting and parsing: </p> 145*0e209d39SAndroid Build Coastguard Worker * 146*0e209d39SAndroid Build Coastguard Worker * \code 147*0e209d39SAndroid Build Coastguard Worker * #include <unicode/choicfmt.h> 148*0e209d39SAndroid Build Coastguard Worker * #include <unicode/unistr.h> 149*0e209d39SAndroid Build Coastguard Worker * #include <iostream.h> 150*0e209d39SAndroid Build Coastguard Worker * 151*0e209d39SAndroid Build Coastguard Worker * int main(int argc, char *argv[]) { 152*0e209d39SAndroid Build Coastguard Worker * double limits[] = {1,2,3,4,5,6,7}; 153*0e209d39SAndroid Build Coastguard Worker * UnicodeString monthNames[] = { 154*0e209d39SAndroid Build Coastguard Worker * "Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; 155*0e209d39SAndroid Build Coastguard Worker * ChoiceFormat fmt(limits, monthNames, 7); 156*0e209d39SAndroid Build Coastguard Worker * UnicodeString str; 157*0e209d39SAndroid Build Coastguard Worker * char buf[256]; 158*0e209d39SAndroid Build Coastguard Worker * for (double x = 1.0; x <= 8.0; x += 1.0) { 159*0e209d39SAndroid Build Coastguard Worker * fmt.format(x, str); 160*0e209d39SAndroid Build Coastguard Worker * str.extract(0, str.length(), buf, 256, ""); 161*0e209d39SAndroid Build Coastguard Worker * str.truncate(0); 162*0e209d39SAndroid Build Coastguard Worker * cout << x << " -> " 163*0e209d39SAndroid Build Coastguard Worker * << buf << endl; 164*0e209d39SAndroid Build Coastguard Worker * } 165*0e209d39SAndroid Build Coastguard Worker * cout << endl; 166*0e209d39SAndroid Build Coastguard Worker * return 0; 167*0e209d39SAndroid Build Coastguard Worker * } 168*0e209d39SAndroid Build Coastguard Worker * \endcode 169*0e209d39SAndroid Build Coastguard Worker * 170*0e209d39SAndroid Build Coastguard Worker * <p><em>User subclasses are not supported.</em> While clients may write 171*0e209d39SAndroid Build Coastguard Worker * subclasses, such code will not necessarily work and will not be 172*0e209d39SAndroid Build Coastguard Worker * guaranteed to work stably from release to release. 173*0e209d39SAndroid Build Coastguard Worker * 174*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 175*0e209d39SAndroid Build Coastguard Worker */ 176*0e209d39SAndroid Build Coastguard Worker class U_I18N_API ChoiceFormat: public NumberFormat { 177*0e209d39SAndroid Build Coastguard Worker public: 178*0e209d39SAndroid Build Coastguard Worker /** 179*0e209d39SAndroid Build Coastguard Worker * Constructs a new ChoiceFormat from the pattern string. 180*0e209d39SAndroid Build Coastguard Worker * 181*0e209d39SAndroid Build Coastguard Worker * @param pattern Pattern used to construct object. 182*0e209d39SAndroid Build Coastguard Worker * @param status Output param to receive success code. If the 183*0e209d39SAndroid Build Coastguard Worker * pattern cannot be parsed, set to failure code. 184*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 185*0e209d39SAndroid Build Coastguard Worker */ 186*0e209d39SAndroid Build Coastguard Worker ChoiceFormat(const UnicodeString& pattern, 187*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 188*0e209d39SAndroid Build Coastguard Worker 189*0e209d39SAndroid Build Coastguard Worker 190*0e209d39SAndroid Build Coastguard Worker /** 191*0e209d39SAndroid Build Coastguard Worker * Constructs a new ChoiceFormat with the given limits and message strings. 192*0e209d39SAndroid Build Coastguard Worker * All closure flags default to <code>false</code>, 193*0e209d39SAndroid Build Coastguard Worker * equivalent to <code>less_than_or_equal</code> separators. 194*0e209d39SAndroid Build Coastguard Worker * 195*0e209d39SAndroid Build Coastguard Worker * Copies the limits and formats instead of adopting them. 196*0e209d39SAndroid Build Coastguard Worker * 197*0e209d39SAndroid Build Coastguard Worker * @param limits Array of limit values. 198*0e209d39SAndroid Build Coastguard Worker * @param formats Array of formats. 199*0e209d39SAndroid Build Coastguard Worker * @param count Size of 'limits' and 'formats' arrays. 200*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 201*0e209d39SAndroid Build Coastguard Worker */ 202*0e209d39SAndroid Build Coastguard Worker ChoiceFormat(const double* limits, 203*0e209d39SAndroid Build Coastguard Worker const UnicodeString* formats, 204*0e209d39SAndroid Build Coastguard Worker int32_t count ); 205*0e209d39SAndroid Build Coastguard Worker 206*0e209d39SAndroid Build Coastguard Worker /** 207*0e209d39SAndroid Build Coastguard Worker * Constructs a new ChoiceFormat with the given limits, closure flags and message strings. 208*0e209d39SAndroid Build Coastguard Worker * 209*0e209d39SAndroid Build Coastguard Worker * Copies the limits and formats instead of adopting them. 210*0e209d39SAndroid Build Coastguard Worker * 211*0e209d39SAndroid Build Coastguard Worker * @param limits Array of limit values 212*0e209d39SAndroid Build Coastguard Worker * @param closures Array of booleans specifying whether each 213*0e209d39SAndroid Build Coastguard Worker * element of 'limits' is open or closed. If false, then the 214*0e209d39SAndroid Build Coastguard Worker * corresponding limit number is a member of its range. 215*0e209d39SAndroid Build Coastguard Worker * If true, then the limit number belongs to the previous range it. 216*0e209d39SAndroid Build Coastguard Worker * @param formats Array of formats 217*0e209d39SAndroid Build Coastguard Worker * @param count Size of 'limits', 'closures', and 'formats' arrays 218*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 219*0e209d39SAndroid Build Coastguard Worker */ 220*0e209d39SAndroid Build Coastguard Worker ChoiceFormat(const double* limits, 221*0e209d39SAndroid Build Coastguard Worker const UBool* closures, 222*0e209d39SAndroid Build Coastguard Worker const UnicodeString* formats, 223*0e209d39SAndroid Build Coastguard Worker int32_t count); 224*0e209d39SAndroid Build Coastguard Worker 225*0e209d39SAndroid Build Coastguard Worker /** 226*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 227*0e209d39SAndroid Build Coastguard Worker * 228*0e209d39SAndroid Build Coastguard Worker * @param that ChoiceFormat object to be copied from 229*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 230*0e209d39SAndroid Build Coastguard Worker */ 231*0e209d39SAndroid Build Coastguard Worker ChoiceFormat(const ChoiceFormat& that); 232*0e209d39SAndroid Build Coastguard Worker 233*0e209d39SAndroid Build Coastguard Worker /** 234*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 235*0e209d39SAndroid Build Coastguard Worker * 236*0e209d39SAndroid Build Coastguard Worker * @param that ChoiceFormat object to be copied 237*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 238*0e209d39SAndroid Build Coastguard Worker */ 239*0e209d39SAndroid Build Coastguard Worker const ChoiceFormat& operator=(const ChoiceFormat& that); 240*0e209d39SAndroid Build Coastguard Worker 241*0e209d39SAndroid Build Coastguard Worker /** 242*0e209d39SAndroid Build Coastguard Worker * Destructor. 243*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 244*0e209d39SAndroid Build Coastguard Worker */ 245*0e209d39SAndroid Build Coastguard Worker virtual ~ChoiceFormat(); 246*0e209d39SAndroid Build Coastguard Worker 247*0e209d39SAndroid Build Coastguard Worker /** 248*0e209d39SAndroid Build Coastguard Worker * Clones this Format object. The caller owns the 249*0e209d39SAndroid Build Coastguard Worker * result and must delete it when done. 250*0e209d39SAndroid Build Coastguard Worker * 251*0e209d39SAndroid Build Coastguard Worker * @return a copy of this object 252*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 253*0e209d39SAndroid Build Coastguard Worker */ 254*0e209d39SAndroid Build Coastguard Worker virtual ChoiceFormat* clone() const override; 255*0e209d39SAndroid Build Coastguard Worker 256*0e209d39SAndroid Build Coastguard Worker /** 257*0e209d39SAndroid Build Coastguard Worker * Returns true if the given Format objects are semantically equal. 258*0e209d39SAndroid Build Coastguard Worker * Objects of different subclasses are considered unequal. 259*0e209d39SAndroid Build Coastguard Worker * 260*0e209d39SAndroid Build Coastguard Worker * @param other ChoiceFormat object to be compared 261*0e209d39SAndroid Build Coastguard Worker * @return true if other is the same as this. 262*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 263*0e209d39SAndroid Build Coastguard Worker */ 264*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const Format& other) const override; 265*0e209d39SAndroid Build Coastguard Worker 266*0e209d39SAndroid Build Coastguard Worker /** 267*0e209d39SAndroid Build Coastguard Worker * Sets the pattern. 268*0e209d39SAndroid Build Coastguard Worker * @param pattern The pattern to be applied. 269*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on 270*0e209d39SAndroid Build Coastguard Worker * exit. If the pattern is invalid, this will be 271*0e209d39SAndroid Build Coastguard Worker * set to a failure result. 272*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 273*0e209d39SAndroid Build Coastguard Worker */ 274*0e209d39SAndroid Build Coastguard Worker virtual void applyPattern(const UnicodeString& pattern, 275*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 276*0e209d39SAndroid Build Coastguard Worker 277*0e209d39SAndroid Build Coastguard Worker /** 278*0e209d39SAndroid Build Coastguard Worker * Sets the pattern. 279*0e209d39SAndroid Build Coastguard Worker * @param pattern The pattern to be applied. 280*0e209d39SAndroid Build Coastguard Worker * @param parseError Struct to receive information on position 281*0e209d39SAndroid Build Coastguard Worker * of error if an error is encountered 282*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on 283*0e209d39SAndroid Build Coastguard Worker * exit. If the pattern is invalid, this will be 284*0e209d39SAndroid Build Coastguard Worker * set to a failure result. 285*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 286*0e209d39SAndroid Build Coastguard Worker */ 287*0e209d39SAndroid Build Coastguard Worker virtual void applyPattern(const UnicodeString& pattern, 288*0e209d39SAndroid Build Coastguard Worker UParseError& parseError, 289*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 290*0e209d39SAndroid Build Coastguard Worker /** 291*0e209d39SAndroid Build Coastguard Worker * Gets the pattern. 292*0e209d39SAndroid Build Coastguard Worker * 293*0e209d39SAndroid Build Coastguard Worker * @param pattern Output param which will receive the pattern 294*0e209d39SAndroid Build Coastguard Worker * Previous contents are deleted. 295*0e209d39SAndroid Build Coastguard Worker * @return A reference to 'pattern' 296*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 297*0e209d39SAndroid Build Coastguard Worker */ 298*0e209d39SAndroid Build Coastguard Worker virtual UnicodeString& toPattern(UnicodeString &pattern) const; 299*0e209d39SAndroid Build Coastguard Worker 300*0e209d39SAndroid Build Coastguard Worker /** 301*0e209d39SAndroid Build Coastguard Worker * Sets the choices to be used in formatting. 302*0e209d39SAndroid Build Coastguard Worker * For details see the constructor with the same parameter list. 303*0e209d39SAndroid Build Coastguard Worker * 304*0e209d39SAndroid Build Coastguard Worker * @param limitsToCopy Contains the top value that you want 305*0e209d39SAndroid Build Coastguard Worker * parsed with that format,and should be in 306*0e209d39SAndroid Build Coastguard Worker * ascending sorted order. When formatting X, 307*0e209d39SAndroid Build Coastguard Worker * the choice will be the i, where limit[i] 308*0e209d39SAndroid Build Coastguard Worker * <= X < limit[i+1]. 309*0e209d39SAndroid Build Coastguard Worker * @param formatsToCopy The format strings you want to use for each limit. 310*0e209d39SAndroid Build Coastguard Worker * @param count The size of the above arrays. 311*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 312*0e209d39SAndroid Build Coastguard Worker */ 313*0e209d39SAndroid Build Coastguard Worker virtual void setChoices(const double* limitsToCopy, 314*0e209d39SAndroid Build Coastguard Worker const UnicodeString* formatsToCopy, 315*0e209d39SAndroid Build Coastguard Worker int32_t count ); 316*0e209d39SAndroid Build Coastguard Worker 317*0e209d39SAndroid Build Coastguard Worker /** 318*0e209d39SAndroid Build Coastguard Worker * Sets the choices to be used in formatting. 319*0e209d39SAndroid Build Coastguard Worker * For details see the constructor with the same parameter list. 320*0e209d39SAndroid Build Coastguard Worker * 321*0e209d39SAndroid Build Coastguard Worker * @param limits Array of limits 322*0e209d39SAndroid Build Coastguard Worker * @param closures Array of limit booleans 323*0e209d39SAndroid Build Coastguard Worker * @param formats Array of format string 324*0e209d39SAndroid Build Coastguard Worker * @param count The size of the above arrays 325*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 326*0e209d39SAndroid Build Coastguard Worker */ 327*0e209d39SAndroid Build Coastguard Worker virtual void setChoices(const double* limits, 328*0e209d39SAndroid Build Coastguard Worker const UBool* closures, 329*0e209d39SAndroid Build Coastguard Worker const UnicodeString* formats, 330*0e209d39SAndroid Build Coastguard Worker int32_t count); 331*0e209d39SAndroid Build Coastguard Worker 332*0e209d39SAndroid Build Coastguard Worker /** 333*0e209d39SAndroid Build Coastguard Worker * Returns nullptr and 0. 334*0e209d39SAndroid Build Coastguard Worker * Before ICU 4.8, this used to return the choice limits array. 335*0e209d39SAndroid Build Coastguard Worker * 336*0e209d39SAndroid Build Coastguard Worker * @param count Will be set to 0. 337*0e209d39SAndroid Build Coastguard Worker * @return nullptr 338*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern. 339*0e209d39SAndroid Build Coastguard Worker */ 340*0e209d39SAndroid Build Coastguard Worker virtual const double* getLimits(int32_t& count) const; 341*0e209d39SAndroid Build Coastguard Worker 342*0e209d39SAndroid Build Coastguard Worker /** 343*0e209d39SAndroid Build Coastguard Worker * Returns nullptr and 0. 344*0e209d39SAndroid Build Coastguard Worker * Before ICU 4.8, this used to return the limit booleans array. 345*0e209d39SAndroid Build Coastguard Worker * 346*0e209d39SAndroid Build Coastguard Worker * @param count Will be set to 0. 347*0e209d39SAndroid Build Coastguard Worker * @return nullptr 348*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern. 349*0e209d39SAndroid Build Coastguard Worker */ 350*0e209d39SAndroid Build Coastguard Worker virtual const UBool* getClosures(int32_t& count) const; 351*0e209d39SAndroid Build Coastguard Worker 352*0e209d39SAndroid Build Coastguard Worker /** 353*0e209d39SAndroid Build Coastguard Worker * Returns nullptr and 0. 354*0e209d39SAndroid Build Coastguard Worker * Before ICU 4.8, this used to return the array of choice strings. 355*0e209d39SAndroid Build Coastguard Worker * 356*0e209d39SAndroid Build Coastguard Worker * @param count Will be set to 0. 357*0e209d39SAndroid Build Coastguard Worker * @return nullptr 358*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern. 359*0e209d39SAndroid Build Coastguard Worker */ 360*0e209d39SAndroid Build Coastguard Worker virtual const UnicodeString* getFormats(int32_t& count) const; 361*0e209d39SAndroid Build Coastguard Worker 362*0e209d39SAndroid Build Coastguard Worker 363*0e209d39SAndroid Build Coastguard Worker using NumberFormat::format; 364*0e209d39SAndroid Build Coastguard Worker 365*0e209d39SAndroid Build Coastguard Worker /** 366*0e209d39SAndroid Build Coastguard Worker * Formats a double number using this object's choices. 367*0e209d39SAndroid Build Coastguard Worker * 368*0e209d39SAndroid Build Coastguard Worker * @param number The value to be formatted. 369*0e209d39SAndroid Build Coastguard Worker * @param appendTo Output parameter to receive result. 370*0e209d39SAndroid Build Coastguard Worker * Result is appended to existing contents. 371*0e209d39SAndroid Build Coastguard Worker * @param pos On input: an alignment field, if desired. 372*0e209d39SAndroid Build Coastguard Worker * On output: the offsets of the alignment field. 373*0e209d39SAndroid Build Coastguard Worker * @return Reference to 'appendTo' parameter. 374*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 375*0e209d39SAndroid Build Coastguard Worker */ 376*0e209d39SAndroid Build Coastguard Worker virtual UnicodeString& format(double number, 377*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 378*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos) const override; 379*0e209d39SAndroid Build Coastguard Worker /** 380*0e209d39SAndroid Build Coastguard Worker * Formats an int32_t number using this object's choices. 381*0e209d39SAndroid Build Coastguard Worker * 382*0e209d39SAndroid Build Coastguard Worker * @param number The value to be formatted. 383*0e209d39SAndroid Build Coastguard Worker * @param appendTo Output parameter to receive result. 384*0e209d39SAndroid Build Coastguard Worker * Result is appended to existing contents. 385*0e209d39SAndroid Build Coastguard Worker * @param pos On input: an alignment field, if desired. 386*0e209d39SAndroid Build Coastguard Worker * On output: the offsets of the alignment field. 387*0e209d39SAndroid Build Coastguard Worker * @return Reference to 'appendTo' parameter. 388*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 389*0e209d39SAndroid Build Coastguard Worker */ 390*0e209d39SAndroid Build Coastguard Worker virtual UnicodeString& format(int32_t number, 391*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 392*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos) const override; 393*0e209d39SAndroid Build Coastguard Worker 394*0e209d39SAndroid Build Coastguard Worker /** 395*0e209d39SAndroid Build Coastguard Worker * Formats an int64_t number using this object's choices. 396*0e209d39SAndroid Build Coastguard Worker * 397*0e209d39SAndroid Build Coastguard Worker * @param number The value to be formatted. 398*0e209d39SAndroid Build Coastguard Worker * @param appendTo Output parameter to receive result. 399*0e209d39SAndroid Build Coastguard Worker * Result is appended to existing contents. 400*0e209d39SAndroid Build Coastguard Worker * @param pos On input: an alignment field, if desired. 401*0e209d39SAndroid Build Coastguard Worker * On output: the offsets of the alignment field. 402*0e209d39SAndroid Build Coastguard Worker * @return Reference to 'appendTo' parameter. 403*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 404*0e209d39SAndroid Build Coastguard Worker */ 405*0e209d39SAndroid Build Coastguard Worker virtual UnicodeString& format(int64_t number, 406*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 407*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos) const override; 408*0e209d39SAndroid Build Coastguard Worker 409*0e209d39SAndroid Build Coastguard Worker /** 410*0e209d39SAndroid Build Coastguard Worker * Formats an array of objects using this object's choices. 411*0e209d39SAndroid Build Coastguard Worker * 412*0e209d39SAndroid Build Coastguard Worker * @param objs The array of objects to be formatted. 413*0e209d39SAndroid Build Coastguard Worker * @param cnt The size of objs. 414*0e209d39SAndroid Build Coastguard Worker * @param appendTo Output parameter to receive result. 415*0e209d39SAndroid Build Coastguard Worker * Result is appended to existing contents. 416*0e209d39SAndroid Build Coastguard Worker * @param pos On input: an alignment field, if desired. 417*0e209d39SAndroid Build Coastguard Worker * On output: the offsets of the alignment field. 418*0e209d39SAndroid Build Coastguard Worker * @param success Output param set to success/failure code on 419*0e209d39SAndroid Build Coastguard Worker * exit. 420*0e209d39SAndroid Build Coastguard Worker * @return Reference to 'appendTo' parameter. 421*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 422*0e209d39SAndroid Build Coastguard Worker */ 423*0e209d39SAndroid Build Coastguard Worker virtual UnicodeString& format(const Formattable* objs, 424*0e209d39SAndroid Build Coastguard Worker int32_t cnt, 425*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 426*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos, 427*0e209d39SAndroid Build Coastguard Worker UErrorCode& success) const; 428*0e209d39SAndroid Build Coastguard Worker 429*0e209d39SAndroid Build Coastguard Worker using NumberFormat::parse; 430*0e209d39SAndroid Build Coastguard Worker 431*0e209d39SAndroid Build Coastguard Worker /** 432*0e209d39SAndroid Build Coastguard Worker * Looks for the longest match of any message string on the input text and, 433*0e209d39SAndroid Build Coastguard Worker * if there is a match, sets the result object to the corresponding range's number. 434*0e209d39SAndroid Build Coastguard Worker * 435*0e209d39SAndroid Build Coastguard Worker * If no string matches, then the parsePosition is unchanged. 436*0e209d39SAndroid Build Coastguard Worker * 437*0e209d39SAndroid Build Coastguard Worker * @param text The text to be parsed. 438*0e209d39SAndroid Build Coastguard Worker * @param result Formattable to be set to the parse result. 439*0e209d39SAndroid Build Coastguard Worker * If parse fails, return contents are undefined. 440*0e209d39SAndroid Build Coastguard Worker * @param parsePosition The position to start parsing at on input. 441*0e209d39SAndroid Build Coastguard Worker * On output, moved to after the last successfully 442*0e209d39SAndroid Build Coastguard Worker * parse character. On parse failure, does not change. 443*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 444*0e209d39SAndroid Build Coastguard Worker */ 445*0e209d39SAndroid Build Coastguard Worker virtual void parse(const UnicodeString& text, 446*0e209d39SAndroid Build Coastguard Worker Formattable& result, 447*0e209d39SAndroid Build Coastguard Worker ParsePosition& parsePosition) const override; 448*0e209d39SAndroid Build Coastguard Worker 449*0e209d39SAndroid Build Coastguard Worker /** 450*0e209d39SAndroid Build Coastguard Worker * Returns a unique class ID POLYMORPHICALLY. Part of ICU's "poor man's RTTI". 451*0e209d39SAndroid Build Coastguard Worker * 452*0e209d39SAndroid Build Coastguard Worker * @return The class ID for this object. All objects of a 453*0e209d39SAndroid Build Coastguard Worker * given class have the same class ID. Objects of 454*0e209d39SAndroid Build Coastguard Worker * other classes have different class IDs. 455*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 456*0e209d39SAndroid Build Coastguard Worker */ 457*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 458*0e209d39SAndroid Build Coastguard Worker 459*0e209d39SAndroid Build Coastguard Worker /** 460*0e209d39SAndroid Build Coastguard Worker * Returns the class ID for this class. This is useful only for 461*0e209d39SAndroid Build Coastguard Worker * comparing to a return value from getDynamicClassID(). For example: 462*0e209d39SAndroid Build Coastguard Worker * <pre> 463*0e209d39SAndroid Build Coastguard Worker * . Base* polymorphic_pointer = createPolymorphicObject(); 464*0e209d39SAndroid Build Coastguard Worker * . if (polymorphic_pointer->getDynamicClassID() == 465*0e209d39SAndroid Build Coastguard Worker * . Derived::getStaticClassID()) ... 466*0e209d39SAndroid Build Coastguard Worker * </pre> 467*0e209d39SAndroid Build Coastguard Worker * @return The class ID for all objects of this class. 468*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments. 469*0e209d39SAndroid Build Coastguard Worker */ 470*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 471*0e209d39SAndroid Build Coastguard Worker 472*0e209d39SAndroid Build Coastguard Worker private: 473*0e209d39SAndroid Build Coastguard Worker /** 474*0e209d39SAndroid Build Coastguard Worker * Converts a double value to a string. 475*0e209d39SAndroid Build Coastguard Worker * @param value the double number to be converted. 476*0e209d39SAndroid Build Coastguard Worker * @param string the result string. 477*0e209d39SAndroid Build Coastguard Worker * @return the converted string. 478*0e209d39SAndroid Build Coastguard Worker */ 479*0e209d39SAndroid Build Coastguard Worker static UnicodeString& dtos(double value, UnicodeString& string); 480*0e209d39SAndroid Build Coastguard Worker 481*0e209d39SAndroid Build Coastguard Worker ChoiceFormat() = delete; // default constructor not implemented 482*0e209d39SAndroid Build Coastguard Worker 483*0e209d39SAndroid Build Coastguard Worker /** 484*0e209d39SAndroid Build Coastguard Worker * Construct a new ChoiceFormat with the limits and the corresponding formats 485*0e209d39SAndroid Build Coastguard Worker * based on the pattern. 486*0e209d39SAndroid Build Coastguard Worker * 487*0e209d39SAndroid Build Coastguard Worker * @param newPattern Pattern used to construct object. 488*0e209d39SAndroid Build Coastguard Worker * @param parseError Struct to receive information on position 489*0e209d39SAndroid Build Coastguard Worker * of error if an error is encountered. 490*0e209d39SAndroid Build Coastguard Worker * @param status Output param to receive success code. If the 491*0e209d39SAndroid Build Coastguard Worker * pattern cannot be parsed, set to failure code. 492*0e209d39SAndroid Build Coastguard Worker */ 493*0e209d39SAndroid Build Coastguard Worker ChoiceFormat(const UnicodeString& newPattern, 494*0e209d39SAndroid Build Coastguard Worker UParseError& parseError, 495*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 496*0e209d39SAndroid Build Coastguard Worker 497*0e209d39SAndroid Build Coastguard Worker friend class MessageFormat; 498*0e209d39SAndroid Build Coastguard Worker 499*0e209d39SAndroid Build Coastguard Worker virtual void setChoices(const double* limits, 500*0e209d39SAndroid Build Coastguard Worker const UBool* closures, 501*0e209d39SAndroid Build Coastguard Worker const UnicodeString* formats, 502*0e209d39SAndroid Build Coastguard Worker int32_t count, 503*0e209d39SAndroid Build Coastguard Worker UErrorCode &errorCode); 504*0e209d39SAndroid Build Coastguard Worker 505*0e209d39SAndroid Build Coastguard Worker /** 506*0e209d39SAndroid Build Coastguard Worker * Finds the ChoiceFormat sub-message for the given number. 507*0e209d39SAndroid Build Coastguard Worker * @param pattern A MessagePattern. 508*0e209d39SAndroid Build Coastguard Worker * @param partIndex the index of the first ChoiceFormat argument style part. 509*0e209d39SAndroid Build Coastguard Worker * @param number a number to be mapped to one of the ChoiceFormat argument's intervals 510*0e209d39SAndroid Build Coastguard Worker * @return the sub-message start part index. 511*0e209d39SAndroid Build Coastguard Worker */ 512*0e209d39SAndroid Build Coastguard Worker static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number); 513*0e209d39SAndroid Build Coastguard Worker 514*0e209d39SAndroid Build Coastguard Worker static double parseArgument( 515*0e209d39SAndroid Build Coastguard Worker const MessagePattern &pattern, int32_t partIndex, 516*0e209d39SAndroid Build Coastguard Worker const UnicodeString &source, ParsePosition &pos); 517*0e209d39SAndroid Build Coastguard Worker 518*0e209d39SAndroid Build Coastguard Worker /** 519*0e209d39SAndroid Build Coastguard Worker * Matches the pattern string from the end of the partIndex to 520*0e209d39SAndroid Build Coastguard Worker * the beginning of the limitPartIndex, 521*0e209d39SAndroid Build Coastguard Worker * including all syntax except SKIP_SYNTAX, 522*0e209d39SAndroid Build Coastguard Worker * against the source string starting at sourceOffset. 523*0e209d39SAndroid Build Coastguard Worker * If they match, returns the length of the source string match. 524*0e209d39SAndroid Build Coastguard Worker * Otherwise returns -1. 525*0e209d39SAndroid Build Coastguard Worker */ 526*0e209d39SAndroid Build Coastguard Worker static int32_t matchStringUntilLimitPart( 527*0e209d39SAndroid Build Coastguard Worker const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex, 528*0e209d39SAndroid Build Coastguard Worker const UnicodeString &source, int32_t sourceOffset); 529*0e209d39SAndroid Build Coastguard Worker 530*0e209d39SAndroid Build Coastguard Worker /** 531*0e209d39SAndroid Build Coastguard Worker * Some of the ChoiceFormat constructors do not have a UErrorCode parameter. 532*0e209d39SAndroid Build Coastguard Worker * We need _some_ way to provide one for the MessagePattern constructor. 533*0e209d39SAndroid Build Coastguard Worker * Alternatively, the MessagePattern could be a pointer field, but that is 534*0e209d39SAndroid Build Coastguard Worker * not nice either. 535*0e209d39SAndroid Build Coastguard Worker */ 536*0e209d39SAndroid Build Coastguard Worker UErrorCode constructorErrorCode; 537*0e209d39SAndroid Build Coastguard Worker 538*0e209d39SAndroid Build Coastguard Worker /** 539*0e209d39SAndroid Build Coastguard Worker * The MessagePattern which contains the parsed structure of the pattern string. 540*0e209d39SAndroid Build Coastguard Worker * 541*0e209d39SAndroid Build Coastguard Worker * Starting with ICU 4.8, the MessagePattern contains a sequence of 542*0e209d39SAndroid Build Coastguard Worker * numeric/selector/message parts corresponding to the parsed pattern. 543*0e209d39SAndroid Build Coastguard Worker * For details see the MessagePattern class API docs. 544*0e209d39SAndroid Build Coastguard Worker */ 545*0e209d39SAndroid Build Coastguard Worker MessagePattern msgPattern; 546*0e209d39SAndroid Build Coastguard Worker 547*0e209d39SAndroid Build Coastguard Worker /** 548*0e209d39SAndroid Build Coastguard Worker * Docs & fields from before ICU 4.8, before MessagePattern was used. 549*0e209d39SAndroid Build Coastguard Worker * Commented out, and left only for explanation of semantics. 550*0e209d39SAndroid Build Coastguard Worker * -------- 551*0e209d39SAndroid Build Coastguard Worker * Each ChoiceFormat divides the range -Inf..+Inf into fCount 552*0e209d39SAndroid Build Coastguard Worker * intervals. The intervals are: 553*0e209d39SAndroid Build Coastguard Worker * 554*0e209d39SAndroid Build Coastguard Worker * 0: fChoiceLimits[0]..fChoiceLimits[1] 555*0e209d39SAndroid Build Coastguard Worker * 1: fChoiceLimits[1]..fChoiceLimits[2] 556*0e209d39SAndroid Build Coastguard Worker * ... 557*0e209d39SAndroid Build Coastguard Worker * fCount-2: fChoiceLimits[fCount-2]..fChoiceLimits[fCount-1] 558*0e209d39SAndroid Build Coastguard Worker * fCount-1: fChoiceLimits[fCount-1]..+Inf 559*0e209d39SAndroid Build Coastguard Worker * 560*0e209d39SAndroid Build Coastguard Worker * Interval 0 is special; during formatting (mapping numbers to 561*0e209d39SAndroid Build Coastguard Worker * strings), it also contains all numbers less than 562*0e209d39SAndroid Build Coastguard Worker * fChoiceLimits[0], as well as NaN values. 563*0e209d39SAndroid Build Coastguard Worker * 564*0e209d39SAndroid Build Coastguard Worker * Interval i maps to and from string fChoiceFormats[i]. When 565*0e209d39SAndroid Build Coastguard Worker * parsing (mapping strings to numbers), then intervals map to 566*0e209d39SAndroid Build Coastguard Worker * their lower limit, that is, interval i maps to fChoiceLimit[i]. 567*0e209d39SAndroid Build Coastguard Worker * 568*0e209d39SAndroid Build Coastguard Worker * The intervals may be closed, half open, or open. This affects 569*0e209d39SAndroid Build Coastguard Worker * formatting but does not affect parsing. Interval i is affected 570*0e209d39SAndroid Build Coastguard Worker * by fClosures[i] and fClosures[i+1]. If fClosures[i] 571*0e209d39SAndroid Build Coastguard Worker * is false, then the value fChoiceLimits[i] is in interval i. 572*0e209d39SAndroid Build Coastguard Worker * That is, intervals i and i are: 573*0e209d39SAndroid Build Coastguard Worker * 574*0e209d39SAndroid Build Coastguard Worker * i-1: ... x < fChoiceLimits[i] 575*0e209d39SAndroid Build Coastguard Worker * i: fChoiceLimits[i] <= x ... 576*0e209d39SAndroid Build Coastguard Worker * 577*0e209d39SAndroid Build Coastguard Worker * If fClosures[i] is true, then the value fChoiceLimits[i] is 578*0e209d39SAndroid Build Coastguard Worker * in interval i-1. That is, intervals i-1 and i are: 579*0e209d39SAndroid Build Coastguard Worker * 580*0e209d39SAndroid Build Coastguard Worker * i-1: ... x <= fChoiceLimits[i] 581*0e209d39SAndroid Build Coastguard Worker * i: fChoiceLimits[i] < x ... 582*0e209d39SAndroid Build Coastguard Worker * 583*0e209d39SAndroid Build Coastguard Worker * Because of the nature of interval 0, fClosures[0] has no 584*0e209d39SAndroid Build Coastguard Worker * effect. 585*0e209d39SAndroid Build Coastguard Worker */ 586*0e209d39SAndroid Build Coastguard Worker // double* fChoiceLimits; 587*0e209d39SAndroid Build Coastguard Worker // UBool* fClosures; 588*0e209d39SAndroid Build Coastguard Worker // UnicodeString* fChoiceFormats; 589*0e209d39SAndroid Build Coastguard Worker // int32_t fCount; 590*0e209d39SAndroid Build Coastguard Worker }; 591*0e209d39SAndroid Build Coastguard Worker 592*0e209d39SAndroid Build Coastguard Worker 593*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 594*0e209d39SAndroid Build Coastguard Worker 595*0e209d39SAndroid Build Coastguard Worker #endif // U_HIDE_DEPRECATED_API 596*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 597*0e209d39SAndroid Build Coastguard Worker 598*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */ 599*0e209d39SAndroid Build Coastguard Worker 600*0e209d39SAndroid Build Coastguard Worker #endif // CHOICFMT_H 601*0e209d39SAndroid Build Coastguard Worker //eof 602