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) 2007-2014, International Business Machines Corporation and 6*0e209d39SAndroid Build Coastguard Worker * others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker 10*0e209d39SAndroid Build Coastguard Worker * File PLURFMT.H 11*0e209d39SAndroid Build Coastguard Worker ******************************************************************************** 12*0e209d39SAndroid Build Coastguard Worker */ 13*0e209d39SAndroid Build Coastguard Worker 14*0e209d39SAndroid Build Coastguard Worker #ifndef PLURFMT 15*0e209d39SAndroid Build Coastguard Worker #define PLURFMT 16*0e209d39SAndroid Build Coastguard Worker 17*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 18*0e209d39SAndroid Build Coastguard Worker 19*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker /** 22*0e209d39SAndroid Build Coastguard Worker * \file 23*0e209d39SAndroid Build Coastguard Worker * \brief C++ API: PluralFormat object 24*0e209d39SAndroid Build Coastguard Worker */ 25*0e209d39SAndroid Build Coastguard Worker 26*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 27*0e209d39SAndroid Build Coastguard Worker 28*0e209d39SAndroid Build Coastguard Worker #include "unicode/messagepattern.h" 29*0e209d39SAndroid Build Coastguard Worker #include "unicode/numfmt.h" 30*0e209d39SAndroid Build Coastguard Worker #include "unicode/plurrule.h" 31*0e209d39SAndroid Build Coastguard Worker 32*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 33*0e209d39SAndroid Build Coastguard Worker 34*0e209d39SAndroid Build Coastguard Worker class Hashtable; 35*0e209d39SAndroid Build Coastguard Worker class NFRule; 36*0e209d39SAndroid Build Coastguard Worker 37*0e209d39SAndroid Build Coastguard Worker /** 38*0e209d39SAndroid Build Coastguard Worker * <p> 39*0e209d39SAndroid Build Coastguard Worker * <code>PluralFormat</code> supports the creation of internationalized 40*0e209d39SAndroid Build Coastguard Worker * messages with plural inflection. It is based on <i>plural 41*0e209d39SAndroid Build Coastguard Worker * selection</i>, i.e. the caller specifies messages for each 42*0e209d39SAndroid Build Coastguard Worker * plural case that can appear in the user's language and the 43*0e209d39SAndroid Build Coastguard Worker * <code>PluralFormat</code> selects the appropriate message based on 44*0e209d39SAndroid Build Coastguard Worker * the number. 45*0e209d39SAndroid Build Coastguard Worker * </p> 46*0e209d39SAndroid Build Coastguard Worker * <h4>The Problem of Plural Forms in Internationalized Messages</h4> 47*0e209d39SAndroid Build Coastguard Worker * <p> 48*0e209d39SAndroid Build Coastguard Worker * Different languages have different ways to inflect 49*0e209d39SAndroid Build Coastguard Worker * plurals. Creating internationalized messages that include plural 50*0e209d39SAndroid Build Coastguard Worker * forms is only feasible when the framework is able to handle plural 51*0e209d39SAndroid Build Coastguard Worker * forms of <i>all</i> languages correctly. <code>ChoiceFormat</code> 52*0e209d39SAndroid Build Coastguard Worker * doesn't handle this well, because it attaches a number interval to 53*0e209d39SAndroid Build Coastguard Worker * each message and selects the message whose interval contains a 54*0e209d39SAndroid Build Coastguard Worker * given number. This can only handle a finite number of 55*0e209d39SAndroid Build Coastguard Worker * intervals. But in some languages, like Polish, one plural case 56*0e209d39SAndroid Build Coastguard Worker * applies to infinitely many intervals (e.g., the plural case applies to 57*0e209d39SAndroid Build Coastguard Worker * numbers ending with 2, 3, or 4 except those ending with 12, 13, or 58*0e209d39SAndroid Build Coastguard Worker * 14). Thus <code>ChoiceFormat</code> is not adequate. 59*0e209d39SAndroid Build Coastguard Worker * </p><p> 60*0e209d39SAndroid Build Coastguard Worker * <code>PluralFormat</code> deals with this by breaking the problem 61*0e209d39SAndroid Build Coastguard Worker * into two parts: 62*0e209d39SAndroid Build Coastguard Worker * <ul> 63*0e209d39SAndroid Build Coastguard Worker * <li>It uses <code>PluralRules</code> that can define more complex 64*0e209d39SAndroid Build Coastguard Worker * conditions for a plural case than just a single interval. These plural 65*0e209d39SAndroid Build Coastguard Worker * rules define both what plural cases exist in a language, and to 66*0e209d39SAndroid Build Coastguard Worker * which numbers these cases apply. 67*0e209d39SAndroid Build Coastguard Worker * <li>It provides predefined plural rules for many languages. Thus, the programmer 68*0e209d39SAndroid Build Coastguard Worker * need not worry about the plural cases of a language and 69*0e209d39SAndroid Build Coastguard Worker * does not have to define the plural cases; they can simply 70*0e209d39SAndroid Build Coastguard Worker * use the predefined keywords. The whole plural formatting of messages can 71*0e209d39SAndroid Build Coastguard Worker * be done using localized patterns from resource bundles. For predefined plural 72*0e209d39SAndroid Build Coastguard Worker * rules, see the CLDR <i>Language Plural Rules</i> page at 73*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html 74*0e209d39SAndroid Build Coastguard Worker * </ul> 75*0e209d39SAndroid Build Coastguard Worker * </p> 76*0e209d39SAndroid Build Coastguard Worker * <h4>Usage of <code>PluralFormat</code></h4> 77*0e209d39SAndroid Build Coastguard Worker * <p>Note: Typically, plural formatting is done via <code>MessageFormat</code> 78*0e209d39SAndroid Build Coastguard Worker * with a <code>plural</code> argument type, 79*0e209d39SAndroid Build Coastguard Worker * rather than using a stand-alone <code>PluralFormat</code>. 80*0e209d39SAndroid Build Coastguard Worker * </p><p> 81*0e209d39SAndroid Build Coastguard Worker * This discussion assumes that you use <code>PluralFormat</code> with 82*0e209d39SAndroid Build Coastguard Worker * a predefined set of plural rules. You can create one using one of 83*0e209d39SAndroid Build Coastguard Worker * the constructors that takes a <code>locale</code> object. To 84*0e209d39SAndroid Build Coastguard Worker * specify the message pattern, you can either pass it to the 85*0e209d39SAndroid Build Coastguard Worker * constructor or set it explicitly using the 86*0e209d39SAndroid Build Coastguard Worker * <code>applyPattern()</code> method. The <code>format()</code> 87*0e209d39SAndroid Build Coastguard Worker * method takes a number object and selects the message of the 88*0e209d39SAndroid Build Coastguard Worker * matching plural case. This message will be returned. 89*0e209d39SAndroid Build Coastguard Worker * </p> 90*0e209d39SAndroid Build Coastguard Worker * <h5>Patterns and Their Interpretation</h5> 91*0e209d39SAndroid Build Coastguard Worker * <p> 92*0e209d39SAndroid Build Coastguard Worker * The pattern text defines the message output for each plural case of the 93*0e209d39SAndroid Build Coastguard Worker * specified locale. Syntax: 94*0e209d39SAndroid Build Coastguard Worker * <pre> 95*0e209d39SAndroid Build Coastguard Worker * pluralStyle = [offsetValue] (selector '{' message '}')+ 96*0e209d39SAndroid Build Coastguard Worker * offsetValue = "offset:" number 97*0e209d39SAndroid Build Coastguard Worker * selector = explicitValue | keyword 98*0e209d39SAndroid Build Coastguard Worker * explicitValue = '=' number // adjacent, no white space in between 99*0e209d39SAndroid Build Coastguard Worker * keyword = [^[[:Pattern_Syntax:][:Pattern_White_Space:]]]+ 100*0e209d39SAndroid Build Coastguard Worker * message: see {@link MessageFormat} 101*0e209d39SAndroid Build Coastguard Worker * </pre> 102*0e209d39SAndroid Build Coastguard Worker * Pattern_White_Space between syntax elements is ignored, except 103*0e209d39SAndroid Build Coastguard Worker * between the {curly braces} and their sub-message, 104*0e209d39SAndroid Build Coastguard Worker * and between the '=' and the number of an explicitValue. 105*0e209d39SAndroid Build Coastguard Worker * 106*0e209d39SAndroid Build Coastguard Worker * </p><p> 107*0e209d39SAndroid Build Coastguard Worker * There are 6 predefined casekeyword in CLDR/ICU - 'zero', 'one', 'two', 'few', 'many' and 108*0e209d39SAndroid Build Coastguard Worker * 'other'. You always have to define a message text for the default plural case 109*0e209d39SAndroid Build Coastguard Worker * <code>other</code> which is contained in every rule set. 110*0e209d39SAndroid Build Coastguard Worker * If you do not specify a message text for a particular plural case, the 111*0e209d39SAndroid Build Coastguard Worker * message text of the plural case <code>other</code> gets assigned to this 112*0e209d39SAndroid Build Coastguard Worker * plural case. 113*0e209d39SAndroid Build Coastguard Worker * </p><p> 114*0e209d39SAndroid Build Coastguard Worker * When formatting, the input number is first matched against the explicitValue clauses. 115*0e209d39SAndroid Build Coastguard Worker * If there is no exact-number match, then a keyword is selected by calling 116*0e209d39SAndroid Build Coastguard Worker * the <code>PluralRules</code> with the input number <em>minus the offset</em>. 117*0e209d39SAndroid Build Coastguard Worker * (The offset defaults to 0 if it is omitted from the pattern string.) 118*0e209d39SAndroid Build Coastguard Worker * If there is no clause with that keyword, then the "other" clauses is returned. 119*0e209d39SAndroid Build Coastguard Worker * </p><p> 120*0e209d39SAndroid Build Coastguard Worker * An unquoted pound sign (<code>#</code>) in the selected sub-message 121*0e209d39SAndroid Build Coastguard Worker * itself (i.e., outside of arguments nested in the sub-message) 122*0e209d39SAndroid Build Coastguard Worker * is replaced by the input number minus the offset. 123*0e209d39SAndroid Build Coastguard Worker * The number-minus-offset value is formatted using a 124*0e209d39SAndroid Build Coastguard Worker * <code>NumberFormat</code> for the <code>PluralFormat</code>'s locale. If you 125*0e209d39SAndroid Build Coastguard Worker * need special number formatting, you have to use a <code>MessageFormat</code> 126*0e209d39SAndroid Build Coastguard Worker * and explicitly specify a <code>NumberFormat</code> argument. 127*0e209d39SAndroid Build Coastguard Worker * <strong>Note:</strong> That argument is formatting without subtracting the offset! 128*0e209d39SAndroid Build Coastguard Worker * If you need a custom format and have a non-zero offset, then you need to pass the 129*0e209d39SAndroid Build Coastguard Worker * number-minus-offset value as a separate parameter. 130*0e209d39SAndroid Build Coastguard Worker * </p> 131*0e209d39SAndroid Build Coastguard Worker * For a usage example, see the {@link MessageFormat} class documentation. 132*0e209d39SAndroid Build Coastguard Worker * 133*0e209d39SAndroid Build Coastguard Worker * <h4>Defining Custom Plural Rules</h4> 134*0e209d39SAndroid Build Coastguard Worker * <p>If you need to use <code>PluralFormat</code> with custom rules, you can 135*0e209d39SAndroid Build Coastguard Worker * create a <code>PluralRules</code> object and pass it to 136*0e209d39SAndroid Build Coastguard Worker * <code>PluralFormat</code>'s constructor. If you also specify a locale in this 137*0e209d39SAndroid Build Coastguard Worker * constructor, this locale will be used to format the number in the message 138*0e209d39SAndroid Build Coastguard Worker * texts. 139*0e209d39SAndroid Build Coastguard Worker * </p><p> 140*0e209d39SAndroid Build Coastguard Worker * For more information about <code>PluralRules</code>, see 141*0e209d39SAndroid Build Coastguard Worker * {@link PluralRules}. 142*0e209d39SAndroid Build Coastguard Worker * </p> 143*0e209d39SAndroid Build Coastguard Worker * 144*0e209d39SAndroid Build Coastguard Worker * ported from Java 145*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 146*0e209d39SAndroid Build Coastguard Worker */ 147*0e209d39SAndroid Build Coastguard Worker 148*0e209d39SAndroid Build Coastguard Worker class U_I18N_API PluralFormat : public Format { 149*0e209d39SAndroid Build Coastguard Worker public: 150*0e209d39SAndroid Build Coastguard Worker 151*0e209d39SAndroid Build Coastguard Worker /** 152*0e209d39SAndroid Build Coastguard Worker * Creates a new cardinal-number <code>PluralFormat</code> for the default locale. 153*0e209d39SAndroid Build Coastguard Worker * This locale will be used to get the set of plural rules and for standard 154*0e209d39SAndroid Build Coastguard Worker * number formatting. 155*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 156*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 157*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 158*0e209d39SAndroid Build Coastguard Worker */ 159*0e209d39SAndroid Build Coastguard Worker PluralFormat(UErrorCode& status); 160*0e209d39SAndroid Build Coastguard Worker 161*0e209d39SAndroid Build Coastguard Worker /** 162*0e209d39SAndroid Build Coastguard Worker * Creates a new cardinal-number <code>PluralFormat</code> for a given locale. 163*0e209d39SAndroid Build Coastguard Worker * @param locale the <code>PluralFormat</code> will be configured with 164*0e209d39SAndroid Build Coastguard Worker * rules for this locale. This locale will also be used for 165*0e209d39SAndroid Build Coastguard Worker * standard number formatting. 166*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 167*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 168*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 169*0e209d39SAndroid Build Coastguard Worker */ 170*0e209d39SAndroid Build Coastguard Worker PluralFormat(const Locale& locale, UErrorCode& status); 171*0e209d39SAndroid Build Coastguard Worker 172*0e209d39SAndroid Build Coastguard Worker /** 173*0e209d39SAndroid Build Coastguard Worker * Creates a new <code>PluralFormat</code> for a given set of rules. 174*0e209d39SAndroid Build Coastguard Worker * The standard number formatting will be done using the default locale. 175*0e209d39SAndroid Build Coastguard Worker * @param rules defines the behavior of the <code>PluralFormat</code> 176*0e209d39SAndroid Build Coastguard Worker * object. 177*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 178*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 179*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 180*0e209d39SAndroid Build Coastguard Worker */ 181*0e209d39SAndroid Build Coastguard Worker PluralFormat(const PluralRules& rules, UErrorCode& status); 182*0e209d39SAndroid Build Coastguard Worker 183*0e209d39SAndroid Build Coastguard Worker /** 184*0e209d39SAndroid Build Coastguard Worker * Creates a new <code>PluralFormat</code> for a given set of rules. 185*0e209d39SAndroid Build Coastguard Worker * The standard number formatting will be done using the given locale. 186*0e209d39SAndroid Build Coastguard Worker * @param locale the default number formatting will be done using this 187*0e209d39SAndroid Build Coastguard Worker * locale. 188*0e209d39SAndroid Build Coastguard Worker * @param rules defines the behavior of the <code>PluralFormat</code> 189*0e209d39SAndroid Build Coastguard Worker * object. 190*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 191*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 192*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 193*0e209d39SAndroid Build Coastguard Worker */ 194*0e209d39SAndroid Build Coastguard Worker PluralFormat(const Locale& locale, const PluralRules& rules, UErrorCode& status); 195*0e209d39SAndroid Build Coastguard Worker 196*0e209d39SAndroid Build Coastguard Worker /** 197*0e209d39SAndroid Build Coastguard Worker * Creates a new <code>PluralFormat</code> for the plural type. 198*0e209d39SAndroid Build Coastguard Worker * The standard number formatting will be done using the given locale. 199*0e209d39SAndroid Build Coastguard Worker * @param locale the default number formatting will be done using this 200*0e209d39SAndroid Build Coastguard Worker * locale. 201*0e209d39SAndroid Build Coastguard Worker * @param type The plural type (e.g., cardinal or ordinal). 202*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 203*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 204*0e209d39SAndroid Build Coastguard Worker * @stable ICU 50 205*0e209d39SAndroid Build Coastguard Worker */ 206*0e209d39SAndroid Build Coastguard Worker PluralFormat(const Locale& locale, UPluralType type, UErrorCode& status); 207*0e209d39SAndroid Build Coastguard Worker 208*0e209d39SAndroid Build Coastguard Worker /** 209*0e209d39SAndroid Build Coastguard Worker * Creates a new cardinal-number <code>PluralFormat</code> for a given pattern string. 210*0e209d39SAndroid Build Coastguard Worker * The default locale will be used to get the set of plural rules and for 211*0e209d39SAndroid Build Coastguard Worker * standard number formatting. 212*0e209d39SAndroid Build Coastguard Worker * @param pattern the pattern for this <code>PluralFormat</code>. 213*0e209d39SAndroid Build Coastguard Worker * errors are returned to status if the pattern is invalid. 214*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 215*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 216*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 217*0e209d39SAndroid Build Coastguard Worker */ 218*0e209d39SAndroid Build Coastguard Worker PluralFormat(const UnicodeString& pattern, UErrorCode& status); 219*0e209d39SAndroid Build Coastguard Worker 220*0e209d39SAndroid Build Coastguard Worker /** 221*0e209d39SAndroid Build Coastguard Worker * Creates a new cardinal-number <code>PluralFormat</code> for a given pattern string and 222*0e209d39SAndroid Build Coastguard Worker * locale. 223*0e209d39SAndroid Build Coastguard Worker * The locale will be used to get the set of plural rules and for 224*0e209d39SAndroid Build Coastguard Worker * standard number formatting. 225*0e209d39SAndroid Build Coastguard Worker * @param locale the <code>PluralFormat</code> will be configured with 226*0e209d39SAndroid Build Coastguard Worker * rules for this locale. This locale will also be used for 227*0e209d39SAndroid Build Coastguard Worker * standard number formatting. 228*0e209d39SAndroid Build Coastguard Worker * @param pattern the pattern for this <code>PluralFormat</code>. 229*0e209d39SAndroid Build Coastguard Worker * errors are returned to status if the pattern is invalid. 230*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 231*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 232*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 233*0e209d39SAndroid Build Coastguard Worker */ 234*0e209d39SAndroid Build Coastguard Worker PluralFormat(const Locale& locale, const UnicodeString& pattern, UErrorCode& status); 235*0e209d39SAndroid Build Coastguard Worker 236*0e209d39SAndroid Build Coastguard Worker /** 237*0e209d39SAndroid Build Coastguard Worker * Creates a new <code>PluralFormat</code> for a given set of rules, a 238*0e209d39SAndroid Build Coastguard Worker * pattern and a locale. 239*0e209d39SAndroid Build Coastguard Worker * @param rules defines the behavior of the <code>PluralFormat</code> 240*0e209d39SAndroid Build Coastguard Worker * object. 241*0e209d39SAndroid Build Coastguard Worker * @param pattern the pattern for this <code>PluralFormat</code>. 242*0e209d39SAndroid Build Coastguard Worker * errors are returned to status if the pattern is invalid. 243*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 244*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 245*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 246*0e209d39SAndroid Build Coastguard Worker */ 247*0e209d39SAndroid Build Coastguard Worker PluralFormat(const PluralRules& rules, 248*0e209d39SAndroid Build Coastguard Worker const UnicodeString& pattern, 249*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 250*0e209d39SAndroid Build Coastguard Worker 251*0e209d39SAndroid Build Coastguard Worker /** 252*0e209d39SAndroid Build Coastguard Worker * Creates a new <code>PluralFormat</code> for a given set of rules, a 253*0e209d39SAndroid Build Coastguard Worker * pattern and a locale. 254*0e209d39SAndroid Build Coastguard Worker * @param locale the <code>PluralFormat</code> will be configured with 255*0e209d39SAndroid Build Coastguard Worker * rules for this locale. This locale will also be used for 256*0e209d39SAndroid Build Coastguard Worker * standard number formatting. 257*0e209d39SAndroid Build Coastguard Worker * @param rules defines the behavior of the <code>PluralFormat</code> 258*0e209d39SAndroid Build Coastguard Worker * object. 259*0e209d39SAndroid Build Coastguard Worker * @param pattern the pattern for this <code>PluralFormat</code>. 260*0e209d39SAndroid Build Coastguard Worker * errors are returned to status if the pattern is invalid. 261*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 262*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 263*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 264*0e209d39SAndroid Build Coastguard Worker */ 265*0e209d39SAndroid Build Coastguard Worker PluralFormat(const Locale& locale, 266*0e209d39SAndroid Build Coastguard Worker const PluralRules& rules, 267*0e209d39SAndroid Build Coastguard Worker const UnicodeString& pattern, 268*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 269*0e209d39SAndroid Build Coastguard Worker 270*0e209d39SAndroid Build Coastguard Worker /** 271*0e209d39SAndroid Build Coastguard Worker * Creates a new <code>PluralFormat</code> for a plural type, a 272*0e209d39SAndroid Build Coastguard Worker * pattern and a locale. 273*0e209d39SAndroid Build Coastguard Worker * @param locale the <code>PluralFormat</code> will be configured with 274*0e209d39SAndroid Build Coastguard Worker * rules for this locale. This locale will also be used for 275*0e209d39SAndroid Build Coastguard Worker * standard number formatting. 276*0e209d39SAndroid Build Coastguard Worker * @param type The plural type (e.g., cardinal or ordinal). 277*0e209d39SAndroid Build Coastguard Worker * @param pattern the pattern for this <code>PluralFormat</code>. 278*0e209d39SAndroid Build Coastguard Worker * errors are returned to status if the pattern is invalid. 279*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 280*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 281*0e209d39SAndroid Build Coastguard Worker * @stable ICU 50 282*0e209d39SAndroid Build Coastguard Worker */ 283*0e209d39SAndroid Build Coastguard Worker PluralFormat(const Locale& locale, 284*0e209d39SAndroid Build Coastguard Worker UPluralType type, 285*0e209d39SAndroid Build Coastguard Worker const UnicodeString& pattern, 286*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 287*0e209d39SAndroid Build Coastguard Worker 288*0e209d39SAndroid Build Coastguard Worker /** 289*0e209d39SAndroid Build Coastguard Worker * copy constructor. 290*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 291*0e209d39SAndroid Build Coastguard Worker */ 292*0e209d39SAndroid Build Coastguard Worker PluralFormat(const PluralFormat& other); 293*0e209d39SAndroid Build Coastguard Worker 294*0e209d39SAndroid Build Coastguard Worker /** 295*0e209d39SAndroid Build Coastguard Worker * Destructor. 296*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 297*0e209d39SAndroid Build Coastguard Worker */ 298*0e209d39SAndroid Build Coastguard Worker virtual ~PluralFormat(); 299*0e209d39SAndroid Build Coastguard Worker 300*0e209d39SAndroid Build Coastguard Worker /** 301*0e209d39SAndroid Build Coastguard Worker * Sets the pattern used by this plural format. 302*0e209d39SAndroid Build Coastguard Worker * The method parses the pattern and creates a map of format strings 303*0e209d39SAndroid Build Coastguard Worker * for the plural rules. 304*0e209d39SAndroid Build Coastguard Worker * Patterns and their interpretation are specified in the class description. 305*0e209d39SAndroid Build Coastguard Worker * 306*0e209d39SAndroid Build Coastguard Worker * @param pattern the pattern for this plural format 307*0e209d39SAndroid Build Coastguard Worker * errors are returned to status if the pattern is invalid. 308*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 309*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 310*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 311*0e209d39SAndroid Build Coastguard Worker */ 312*0e209d39SAndroid Build Coastguard Worker void applyPattern(const UnicodeString& pattern, UErrorCode& status); 313*0e209d39SAndroid Build Coastguard Worker 314*0e209d39SAndroid Build Coastguard Worker 315*0e209d39SAndroid Build Coastguard Worker using Format::format; 316*0e209d39SAndroid Build Coastguard Worker 317*0e209d39SAndroid Build Coastguard Worker /** 318*0e209d39SAndroid Build Coastguard Worker * Formats a plural message for a given number. 319*0e209d39SAndroid Build Coastguard Worker * 320*0e209d39SAndroid Build Coastguard Worker * @param number a number for which the plural message should be formatted 321*0e209d39SAndroid Build Coastguard Worker * for. If no pattern has been applied to this 322*0e209d39SAndroid Build Coastguard Worker * <code>PluralFormat</code> object yet, the formatted number 323*0e209d39SAndroid Build Coastguard Worker * will be returned. 324*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 325*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 326*0e209d39SAndroid Build Coastguard Worker * @return the string containing the formatted plural message. 327*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 328*0e209d39SAndroid Build Coastguard Worker */ 329*0e209d39SAndroid Build Coastguard Worker UnicodeString format(int32_t number, UErrorCode& status) const; 330*0e209d39SAndroid Build Coastguard Worker 331*0e209d39SAndroid Build Coastguard Worker /** 332*0e209d39SAndroid Build Coastguard Worker * Formats a plural message for a given number. 333*0e209d39SAndroid Build Coastguard Worker * 334*0e209d39SAndroid Build Coastguard Worker * @param number a number for which the plural message should be formatted 335*0e209d39SAndroid Build Coastguard Worker * for. If no pattern has been applied to this 336*0e209d39SAndroid Build Coastguard Worker * PluralFormat object yet, the formatted number 337*0e209d39SAndroid Build Coastguard Worker * will be returned. 338*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success or failure code on exit, which 339*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 340*0e209d39SAndroid Build Coastguard Worker * @return the string containing the formatted plural message. 341*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 342*0e209d39SAndroid Build Coastguard Worker */ 343*0e209d39SAndroid Build Coastguard Worker UnicodeString format(double number, UErrorCode& status) const; 344*0e209d39SAndroid Build Coastguard Worker 345*0e209d39SAndroid Build Coastguard Worker /** 346*0e209d39SAndroid Build Coastguard Worker * Formats a plural message for a given number. 347*0e209d39SAndroid Build Coastguard Worker * 348*0e209d39SAndroid Build Coastguard Worker * @param number a number for which the plural message should be formatted 349*0e209d39SAndroid Build Coastguard Worker * for. If no pattern has been applied to this 350*0e209d39SAndroid Build Coastguard Worker * <code>PluralFormat</code> object yet, the formatted number 351*0e209d39SAndroid Build Coastguard Worker * will be returned. 352*0e209d39SAndroid Build Coastguard Worker * @param appendTo output parameter to receive result. 353*0e209d39SAndroid Build Coastguard Worker * result is appended to existing contents. 354*0e209d39SAndroid Build Coastguard Worker * @param pos On input: an alignment field, if desired. 355*0e209d39SAndroid Build Coastguard Worker * On output: the offsets of the alignment field. 356*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 357*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 358*0e209d39SAndroid Build Coastguard Worker * @return the string containing the formatted plural message. 359*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 360*0e209d39SAndroid Build Coastguard Worker */ 361*0e209d39SAndroid Build Coastguard Worker UnicodeString& format(int32_t number, 362*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 363*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos, 364*0e209d39SAndroid Build Coastguard Worker UErrorCode& status) const; 365*0e209d39SAndroid Build Coastguard Worker 366*0e209d39SAndroid Build Coastguard Worker /** 367*0e209d39SAndroid Build Coastguard Worker * Formats a plural message for a given number. 368*0e209d39SAndroid Build Coastguard Worker * 369*0e209d39SAndroid Build Coastguard Worker * @param number a number for which the plural message should be formatted 370*0e209d39SAndroid Build Coastguard Worker * for. If no pattern has been applied to this 371*0e209d39SAndroid Build Coastguard Worker * PluralFormat object yet, the formatted number 372*0e209d39SAndroid Build Coastguard Worker * will be returned. 373*0e209d39SAndroid Build Coastguard Worker * @param appendTo output parameter to receive result. 374*0e209d39SAndroid Build Coastguard Worker * result is appended to existing contents. 375*0e209d39SAndroid Build Coastguard Worker * @param pos On input: an alignment field, if desired. 376*0e209d39SAndroid Build Coastguard Worker * On output: the offsets of the alignment field. 377*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 378*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 379*0e209d39SAndroid Build Coastguard Worker * @return the string containing the formatted plural message. 380*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 381*0e209d39SAndroid Build Coastguard Worker */ 382*0e209d39SAndroid Build Coastguard Worker UnicodeString& format(double number, 383*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 384*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos, 385*0e209d39SAndroid Build Coastguard Worker UErrorCode& status) const; 386*0e209d39SAndroid Build Coastguard Worker 387*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 388*0e209d39SAndroid Build Coastguard Worker /** 389*0e209d39SAndroid Build Coastguard Worker * Sets the locale used by this <code>PluraFormat</code> object. 390*0e209d39SAndroid Build Coastguard Worker * Note: Calling this method resets this <code>PluraFormat</code> object, 391*0e209d39SAndroid Build Coastguard Worker * i.e., a pattern that was applied previously will be removed, 392*0e209d39SAndroid Build Coastguard Worker * and the NumberFormat is set to the default number format for 393*0e209d39SAndroid Build Coastguard Worker * the locale. The resulting format behaves the same as one 394*0e209d39SAndroid Build Coastguard Worker * constructed from {@link #PluralFormat(const Locale& locale, UPluralType type, UErrorCode& status)} 395*0e209d39SAndroid Build Coastguard Worker * with UPLURAL_TYPE_CARDINAL. 396*0e209d39SAndroid Build Coastguard Worker * @param locale the <code>locale</code> to use to configure the formatter. 397*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 398*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 399*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 50 This method clears the pattern and might create 400*0e209d39SAndroid Build Coastguard Worker * a different kind of PluralRules instance; 401*0e209d39SAndroid Build Coastguard Worker * use one of the constructors to create a new instance instead. 402*0e209d39SAndroid Build Coastguard Worker */ 403*0e209d39SAndroid Build Coastguard Worker void setLocale(const Locale& locale, UErrorCode& status); 404*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 405*0e209d39SAndroid Build Coastguard Worker 406*0e209d39SAndroid Build Coastguard Worker /** 407*0e209d39SAndroid Build Coastguard Worker * Sets the number format used by this formatter. You only need to 408*0e209d39SAndroid Build Coastguard Worker * call this if you want a different number format than the default 409*0e209d39SAndroid Build Coastguard Worker * formatter for the locale. 410*0e209d39SAndroid Build Coastguard Worker * @param format the number format to use. 411*0e209d39SAndroid Build Coastguard Worker * @param status output param set to success/failure code on exit, which 412*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 413*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 414*0e209d39SAndroid Build Coastguard Worker */ 415*0e209d39SAndroid Build Coastguard Worker void setNumberFormat(const NumberFormat* format, UErrorCode& status); 416*0e209d39SAndroid Build Coastguard Worker 417*0e209d39SAndroid Build Coastguard Worker /** 418*0e209d39SAndroid Build Coastguard Worker * Assignment operator 419*0e209d39SAndroid Build Coastguard Worker * 420*0e209d39SAndroid Build Coastguard Worker * @param other the PluralFormat object to copy from. 421*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 422*0e209d39SAndroid Build Coastguard Worker */ 423*0e209d39SAndroid Build Coastguard Worker PluralFormat& operator=(const PluralFormat& other); 424*0e209d39SAndroid Build Coastguard Worker 425*0e209d39SAndroid Build Coastguard Worker /** 426*0e209d39SAndroid Build Coastguard Worker * Return true if another object is semantically equal to this one. 427*0e209d39SAndroid Build Coastguard Worker * 428*0e209d39SAndroid Build Coastguard Worker * @param other the PluralFormat object to be compared with. 429*0e209d39SAndroid Build Coastguard Worker * @return true if other is semantically equal to this. 430*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 431*0e209d39SAndroid Build Coastguard Worker */ 432*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const Format& other) const override; 433*0e209d39SAndroid Build Coastguard Worker 434*0e209d39SAndroid Build Coastguard Worker /** 435*0e209d39SAndroid Build Coastguard Worker * Return true if another object is semantically unequal to this one. 436*0e209d39SAndroid Build Coastguard Worker * 437*0e209d39SAndroid Build Coastguard Worker * @param other the PluralFormat object to be compared with. 438*0e209d39SAndroid Build Coastguard Worker * @return true if other is semantically unequal to this. 439*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 440*0e209d39SAndroid Build Coastguard Worker */ 441*0e209d39SAndroid Build Coastguard Worker virtual bool operator!=(const Format& other) const; 442*0e209d39SAndroid Build Coastguard Worker 443*0e209d39SAndroid Build Coastguard Worker /** 444*0e209d39SAndroid Build Coastguard Worker * Clones this Format object polymorphically. The caller owns the 445*0e209d39SAndroid Build Coastguard Worker * result and should delete it when done. 446*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 447*0e209d39SAndroid Build Coastguard Worker */ 448*0e209d39SAndroid Build Coastguard Worker virtual PluralFormat* clone() const override; 449*0e209d39SAndroid Build Coastguard Worker 450*0e209d39SAndroid Build Coastguard Worker /** 451*0e209d39SAndroid Build Coastguard Worker * Formats a plural message for a number taken from a Formattable object. 452*0e209d39SAndroid Build Coastguard Worker * 453*0e209d39SAndroid Build Coastguard Worker * @param obj The object containing a number for which the 454*0e209d39SAndroid Build Coastguard Worker * plural message should be formatted. 455*0e209d39SAndroid Build Coastguard Worker * The object must be of a numeric type. 456*0e209d39SAndroid Build Coastguard Worker * @param appendTo output parameter to receive result. 457*0e209d39SAndroid Build Coastguard Worker * Result is appended to existing contents. 458*0e209d39SAndroid Build Coastguard Worker * @param pos On input: an alignment field, if desired. 459*0e209d39SAndroid Build Coastguard Worker * On output: the offsets of the alignment field. 460*0e209d39SAndroid Build Coastguard Worker * @param status output param filled with success/failure status. 461*0e209d39SAndroid Build Coastguard Worker * @return Reference to 'appendTo' parameter. 462*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 463*0e209d39SAndroid Build Coastguard Worker */ 464*0e209d39SAndroid Build Coastguard Worker UnicodeString& format(const Formattable& obj, 465*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 466*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos, 467*0e209d39SAndroid Build Coastguard Worker UErrorCode& status) const override; 468*0e209d39SAndroid Build Coastguard Worker 469*0e209d39SAndroid Build Coastguard Worker /** 470*0e209d39SAndroid Build Coastguard Worker * Returns the pattern from applyPattern() or constructor(). 471*0e209d39SAndroid Build Coastguard Worker * 472*0e209d39SAndroid Build Coastguard Worker * @param appendTo output parameter to receive result. 473*0e209d39SAndroid Build Coastguard Worker * Result is appended to existing contents. 474*0e209d39SAndroid Build Coastguard Worker * @return the UnicodeString with inserted pattern. 475*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 476*0e209d39SAndroid Build Coastguard Worker */ 477*0e209d39SAndroid Build Coastguard Worker UnicodeString& toPattern(UnicodeString& appendTo); 478*0e209d39SAndroid Build Coastguard Worker 479*0e209d39SAndroid Build Coastguard Worker /** 480*0e209d39SAndroid Build Coastguard Worker * This method is not yet supported by <code>PluralFormat</code>. 481*0e209d39SAndroid Build Coastguard Worker * <P> 482*0e209d39SAndroid Build Coastguard Worker * Before calling, set parse_pos.index to the offset you want to start 483*0e209d39SAndroid Build Coastguard Worker * parsing at in the source. After calling, parse_pos.index is the end of 484*0e209d39SAndroid Build Coastguard Worker * the text you parsed. If error occurs, index is unchanged. 485*0e209d39SAndroid Build Coastguard Worker * <P> 486*0e209d39SAndroid Build Coastguard Worker * When parsing, leading whitespace is discarded (with a successful parse), 487*0e209d39SAndroid Build Coastguard Worker * while trailing whitespace is left as is. 488*0e209d39SAndroid Build Coastguard Worker * <P> 489*0e209d39SAndroid Build Coastguard Worker * See Format::parseObject() for more. 490*0e209d39SAndroid Build Coastguard Worker * 491*0e209d39SAndroid Build Coastguard Worker * @param source The string to be parsed into an object. 492*0e209d39SAndroid Build Coastguard Worker * @param result Formattable to be set to the parse result. 493*0e209d39SAndroid Build Coastguard Worker * If parse fails, return contents are undefined. 494*0e209d39SAndroid Build Coastguard Worker * @param parse_pos The position to start parsing at. Upon return 495*0e209d39SAndroid Build Coastguard Worker * this param is set to the position after the 496*0e209d39SAndroid Build Coastguard Worker * last character successfully parsed. If the 497*0e209d39SAndroid Build Coastguard Worker * source is not parsed successfully, this param 498*0e209d39SAndroid Build Coastguard Worker * will remain unchanged. 499*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 500*0e209d39SAndroid Build Coastguard Worker */ 501*0e209d39SAndroid Build Coastguard Worker virtual void parseObject(const UnicodeString& source, 502*0e209d39SAndroid Build Coastguard Worker Formattable& result, 503*0e209d39SAndroid Build Coastguard Worker ParsePosition& parse_pos) const override; 504*0e209d39SAndroid Build Coastguard Worker 505*0e209d39SAndroid Build Coastguard Worker /** 506*0e209d39SAndroid Build Coastguard Worker * ICU "poor man's RTTI", returns a UClassID for this class. 507*0e209d39SAndroid Build Coastguard Worker * 508*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 509*0e209d39SAndroid Build Coastguard Worker * 510*0e209d39SAndroid Build Coastguard Worker */ 511*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 512*0e209d39SAndroid Build Coastguard Worker 513*0e209d39SAndroid Build Coastguard Worker /** 514*0e209d39SAndroid Build Coastguard Worker * ICU "poor man's RTTI", returns a UClassID for the actual class. 515*0e209d39SAndroid Build Coastguard Worker * 516*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 517*0e209d39SAndroid Build Coastguard Worker */ 518*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 519*0e209d39SAndroid Build Coastguard Worker 520*0e209d39SAndroid Build Coastguard Worker private: 521*0e209d39SAndroid Build Coastguard Worker /** 522*0e209d39SAndroid Build Coastguard Worker * @internal (private) 523*0e209d39SAndroid Build Coastguard Worker */ 524*0e209d39SAndroid Build Coastguard Worker class U_I18N_API PluralSelector : public UMemory { 525*0e209d39SAndroid Build Coastguard Worker public: 526*0e209d39SAndroid Build Coastguard Worker virtual ~PluralSelector(); 527*0e209d39SAndroid Build Coastguard Worker /** 528*0e209d39SAndroid Build Coastguard Worker * Given a number, returns the appropriate PluralFormat keyword. 529*0e209d39SAndroid Build Coastguard Worker * 530*0e209d39SAndroid Build Coastguard Worker * @param context worker object for the selector. 531*0e209d39SAndroid Build Coastguard Worker * @param number The number to be plural-formatted. 532*0e209d39SAndroid Build Coastguard Worker * @param ec Error code. 533*0e209d39SAndroid Build Coastguard Worker * @return The selected PluralFormat keyword. 534*0e209d39SAndroid Build Coastguard Worker * @internal (private) 535*0e209d39SAndroid Build Coastguard Worker */ 536*0e209d39SAndroid Build Coastguard Worker virtual UnicodeString select(void *context, double number, UErrorCode& ec) const = 0; 537*0e209d39SAndroid Build Coastguard Worker }; 538*0e209d39SAndroid Build Coastguard Worker 539*0e209d39SAndroid Build Coastguard Worker class U_I18N_API PluralSelectorAdapter : public PluralSelector { 540*0e209d39SAndroid Build Coastguard Worker public: PluralSelectorAdapter()541*0e209d39SAndroid Build Coastguard Worker PluralSelectorAdapter() : pluralRules(nullptr) { 542*0e209d39SAndroid Build Coastguard Worker } 543*0e209d39SAndroid Build Coastguard Worker 544*0e209d39SAndroid Build Coastguard Worker virtual ~PluralSelectorAdapter(); 545*0e209d39SAndroid Build Coastguard Worker 546*0e209d39SAndroid Build Coastguard Worker virtual UnicodeString select(void *context, double number, UErrorCode& /*ec*/) const override; 547*0e209d39SAndroid Build Coastguard Worker 548*0e209d39SAndroid Build Coastguard Worker void reset(); 549*0e209d39SAndroid Build Coastguard Worker 550*0e209d39SAndroid Build Coastguard Worker PluralRules* pluralRules; 551*0e209d39SAndroid Build Coastguard Worker }; 552*0e209d39SAndroid Build Coastguard Worker 553*0e209d39SAndroid Build Coastguard Worker Locale locale; 554*0e209d39SAndroid Build Coastguard Worker MessagePattern msgPattern; 555*0e209d39SAndroid Build Coastguard Worker NumberFormat* numberFormat; 556*0e209d39SAndroid Build Coastguard Worker double offset; 557*0e209d39SAndroid Build Coastguard Worker PluralSelectorAdapter pluralRulesWrapper; 558*0e209d39SAndroid Build Coastguard Worker 559*0e209d39SAndroid Build Coastguard Worker PluralFormat() = delete; // default constructor not implemented 560*0e209d39SAndroid Build Coastguard Worker void init(const PluralRules* rules, UPluralType type, UErrorCode& status); 561*0e209d39SAndroid Build Coastguard Worker /** 562*0e209d39SAndroid Build Coastguard Worker * Copies dynamically allocated values (pointer fields). 563*0e209d39SAndroid Build Coastguard Worker * Others are copied using their copy constructors and assignment operators. 564*0e209d39SAndroid Build Coastguard Worker */ 565*0e209d39SAndroid Build Coastguard Worker void copyObjects(const PluralFormat& other); 566*0e209d39SAndroid Build Coastguard Worker 567*0e209d39SAndroid Build Coastguard Worker UnicodeString& format(const Formattable& numberObject, double number, 568*0e209d39SAndroid Build Coastguard Worker UnicodeString& appendTo, 569*0e209d39SAndroid Build Coastguard Worker FieldPosition& pos, 570*0e209d39SAndroid Build Coastguard Worker UErrorCode& status) const; 571*0e209d39SAndroid Build Coastguard Worker 572*0e209d39SAndroid Build Coastguard Worker /** 573*0e209d39SAndroid Build Coastguard Worker * Finds the PluralFormat sub-message for the given number, or the "other" sub-message. 574*0e209d39SAndroid Build Coastguard Worker * @param pattern A MessagePattern. 575*0e209d39SAndroid Build Coastguard Worker * @param partIndex the index of the first PluralFormat argument style part. 576*0e209d39SAndroid Build Coastguard Worker * @param selector the PluralSelector for mapping the number (minus offset) to a keyword. 577*0e209d39SAndroid Build Coastguard Worker * @param context worker object for the selector. 578*0e209d39SAndroid Build Coastguard Worker * @param number a number to be matched to one of the PluralFormat argument's explicit values, 579*0e209d39SAndroid Build Coastguard Worker * or mapped via the PluralSelector. 580*0e209d39SAndroid Build Coastguard Worker * @param ec ICU error code. 581*0e209d39SAndroid Build Coastguard Worker * @return the sub-message start part index. 582*0e209d39SAndroid Build Coastguard Worker */ 583*0e209d39SAndroid Build Coastguard Worker static int32_t findSubMessage( 584*0e209d39SAndroid Build Coastguard Worker const MessagePattern& pattern, int32_t partIndex, 585*0e209d39SAndroid Build Coastguard Worker const PluralSelector& selector, void *context, double number, UErrorCode& ec); 586*0e209d39SAndroid Build Coastguard Worker 587*0e209d39SAndroid Build Coastguard Worker void parseType(const UnicodeString& source, const NFRule *rbnfLenientScanner, 588*0e209d39SAndroid Build Coastguard Worker Formattable& result, FieldPosition& pos) const; 589*0e209d39SAndroid Build Coastguard Worker 590*0e209d39SAndroid Build Coastguard Worker friend class MessageFormat; 591*0e209d39SAndroid Build Coastguard Worker friend class NFRule; 592*0e209d39SAndroid Build Coastguard Worker }; 593*0e209d39SAndroid Build Coastguard Worker 594*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 595*0e209d39SAndroid Build Coastguard Worker 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 // _PLURFMT 601*0e209d39SAndroid Build Coastguard Worker //eof 602