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) 2008-2015, 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 PLURRULE.H 11*0e209d39SAndroid Build Coastguard Worker * 12*0e209d39SAndroid Build Coastguard Worker * Modification History:* 13*0e209d39SAndroid Build Coastguard Worker * Date Name Description 14*0e209d39SAndroid Build Coastguard Worker * 15*0e209d39SAndroid Build Coastguard Worker ******************************************************************************** 16*0e209d39SAndroid Build Coastguard Worker */ 17*0e209d39SAndroid Build Coastguard Worker 18*0e209d39SAndroid Build Coastguard Worker #ifndef PLURRULE 19*0e209d39SAndroid Build Coastguard Worker #define PLURRULE 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 22*0e209d39SAndroid Build Coastguard Worker 23*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 24*0e209d39SAndroid Build Coastguard Worker 25*0e209d39SAndroid Build Coastguard Worker /** 26*0e209d39SAndroid Build Coastguard Worker * \file 27*0e209d39SAndroid Build Coastguard Worker * \brief C++ API: PluralRules object 28*0e209d39SAndroid Build Coastguard Worker */ 29*0e209d39SAndroid Build Coastguard Worker 30*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 31*0e209d39SAndroid Build Coastguard Worker 32*0e209d39SAndroid Build Coastguard Worker #include "unicode/format.h" 33*0e209d39SAndroid Build Coastguard Worker #include "unicode/upluralrules.h" 34*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 35*0e209d39SAndroid Build Coastguard Worker #include "unicode/numfmt.h" 36*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 37*0e209d39SAndroid Build Coastguard Worker 38*0e209d39SAndroid Build Coastguard Worker /** 39*0e209d39SAndroid Build Coastguard Worker * Value returned by PluralRules::getUniqueKeywordValue() when there is no 40*0e209d39SAndroid Build Coastguard Worker * unique value to return. 41*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 42*0e209d39SAndroid Build Coastguard Worker */ 43*0e209d39SAndroid Build Coastguard Worker #define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777) 44*0e209d39SAndroid Build Coastguard Worker 45*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 46*0e209d39SAndroid Build Coastguard Worker 47*0e209d39SAndroid Build Coastguard Worker class Hashtable; 48*0e209d39SAndroid Build Coastguard Worker class IFixedDecimal; 49*0e209d39SAndroid Build Coastguard Worker class FixedDecimal; 50*0e209d39SAndroid Build Coastguard Worker class RuleChain; 51*0e209d39SAndroid Build Coastguard Worker class PluralRuleParser; 52*0e209d39SAndroid Build Coastguard Worker class PluralKeywordEnumeration; 53*0e209d39SAndroid Build Coastguard Worker class AndConstraint; 54*0e209d39SAndroid Build Coastguard Worker class SharedPluralRules; 55*0e209d39SAndroid Build Coastguard Worker class StandardPluralRanges; 56*0e209d39SAndroid Build Coastguard Worker 57*0e209d39SAndroid Build Coastguard Worker namespace number { 58*0e209d39SAndroid Build Coastguard Worker class FormattedNumber; 59*0e209d39SAndroid Build Coastguard Worker class FormattedNumberRange; 60*0e209d39SAndroid Build Coastguard Worker namespace impl { 61*0e209d39SAndroid Build Coastguard Worker class UFormattedNumberRangeData; 62*0e209d39SAndroid Build Coastguard Worker class DecimalQuantity; 63*0e209d39SAndroid Build Coastguard Worker class DecNum; 64*0e209d39SAndroid Build Coastguard Worker } 65*0e209d39SAndroid Build Coastguard Worker } 66*0e209d39SAndroid Build Coastguard Worker 67*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 68*0e209d39SAndroid Build Coastguard Worker using icu::number::impl::DecimalQuantity; 69*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 70*0e209d39SAndroid Build Coastguard Worker 71*0e209d39SAndroid Build Coastguard Worker /** 72*0e209d39SAndroid Build Coastguard Worker * Defines rules for mapping non-negative numeric values onto a small set of 73*0e209d39SAndroid Build Coastguard Worker * keywords. Rules are constructed from a text description, consisting 74*0e209d39SAndroid Build Coastguard Worker * of a series of keywords and conditions. The {@link #select} method 75*0e209d39SAndroid Build Coastguard Worker * examines each condition in order and returns the keyword for the 76*0e209d39SAndroid Build Coastguard Worker * first condition that matches the number. If none match, 77*0e209d39SAndroid Build Coastguard Worker * default rule(other) is returned. 78*0e209d39SAndroid Build Coastguard Worker * 79*0e209d39SAndroid Build Coastguard Worker * For more information, details, and tips for writing rules, see the 80*0e209d39SAndroid Build Coastguard Worker * LDML spec, Part 3.5 Language Plural Rules: 81*0e209d39SAndroid Build Coastguard Worker * https://www.unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules 82*0e209d39SAndroid Build Coastguard Worker * 83*0e209d39SAndroid Build Coastguard Worker * Examples:<pre> 84*0e209d39SAndroid Build Coastguard Worker * "one: n is 1; few: n in 2..4"</pre> 85*0e209d39SAndroid Build Coastguard Worker * This defines two rules, for 'one' and 'few'. The condition for 86*0e209d39SAndroid Build Coastguard Worker * 'one' is "n is 1" which means that the number must be equal to 87*0e209d39SAndroid Build Coastguard Worker * 1 for this condition to pass. The condition for 'few' is 88*0e209d39SAndroid Build Coastguard Worker * "n in 2..4" which means that the number must be between 2 and 89*0e209d39SAndroid Build Coastguard Worker * 4 inclusive for this condition to pass. All other numbers 90*0e209d39SAndroid Build Coastguard Worker * are assigned the keyword "other" by the default rule. 91*0e209d39SAndroid Build Coastguard Worker * </p><pre> 92*0e209d39SAndroid Build Coastguard Worker * "zero: n is 0; one: n is 1; zero: n mod 100 in 1..19"</pre> 93*0e209d39SAndroid Build Coastguard Worker * This illustrates that the same keyword can be defined multiple times. 94*0e209d39SAndroid Build Coastguard Worker * Each rule is examined in order, and the first keyword whose condition 95*0e209d39SAndroid Build Coastguard Worker * passes is the one returned. Also notes that a modulus is applied 96*0e209d39SAndroid Build Coastguard Worker * to n in the last rule. Thus its condition holds for 119, 219, 319... 97*0e209d39SAndroid Build Coastguard Worker * </p><pre> 98*0e209d39SAndroid Build Coastguard Worker * "one: n is 1; few: n mod 10 in 2..4 and n mod 100 not in 12..14"</pre> 99*0e209d39SAndroid Build Coastguard Worker * This illustrates conjunction and negation. The condition for 'few' 100*0e209d39SAndroid Build Coastguard Worker * has two parts, both of which must be met: "n mod 10 in 2..4" and 101*0e209d39SAndroid Build Coastguard Worker * "n mod 100 not in 12..14". The first part applies a modulus to n 102*0e209d39SAndroid Build Coastguard Worker * before the test as in the previous example. The second part applies 103*0e209d39SAndroid Build Coastguard Worker * a different modulus and also uses negation, thus it matches all 104*0e209d39SAndroid Build Coastguard Worker * numbers _not_ in 12, 13, 14, 112, 113, 114, 212, 213, 214... 105*0e209d39SAndroid Build Coastguard Worker * </p> 106*0e209d39SAndroid Build Coastguard Worker * <p> 107*0e209d39SAndroid Build Coastguard Worker * Syntax:<pre> 108*0e209d39SAndroid Build Coastguard Worker * \code 109*0e209d39SAndroid Build Coastguard Worker * rules = rule (';' rule)* 110*0e209d39SAndroid Build Coastguard Worker * rule = keyword ':' condition 111*0e209d39SAndroid Build Coastguard Worker * keyword = <identifier> 112*0e209d39SAndroid Build Coastguard Worker * condition = and_condition ('or' and_condition)* 113*0e209d39SAndroid Build Coastguard Worker * and_condition = relation ('and' relation)* 114*0e209d39SAndroid Build Coastguard Worker * relation = is_relation | in_relation | within_relation | 'n' <EOL> 115*0e209d39SAndroid Build Coastguard Worker * is_relation = expr 'is' ('not')? value 116*0e209d39SAndroid Build Coastguard Worker * in_relation = expr ('not')? 'in' range_list 117*0e209d39SAndroid Build Coastguard Worker * within_relation = expr ('not')? 'within' range 118*0e209d39SAndroid Build Coastguard Worker * expr = ('n' | 'i' | 'f' | 'v' | 'j') ('mod' value)? 119*0e209d39SAndroid Build Coastguard Worker * range_list = (range | value) (',' range_list)* 120*0e209d39SAndroid Build Coastguard Worker * value = digit+ ('.' digit+)? 121*0e209d39SAndroid Build Coastguard Worker * digit = 0|1|2|3|4|5|6|7|8|9 122*0e209d39SAndroid Build Coastguard Worker * range = value'..'value 123*0e209d39SAndroid Build Coastguard Worker * \endcode 124*0e209d39SAndroid Build Coastguard Worker * </pre></p> 125*0e209d39SAndroid Build Coastguard Worker * <p> 126*0e209d39SAndroid Build Coastguard Worker * <p> 127*0e209d39SAndroid Build Coastguard Worker * The i, f, and v values are defined as follows: 128*0e209d39SAndroid Build Coastguard Worker * </p> 129*0e209d39SAndroid Build Coastguard Worker * <ul> 130*0e209d39SAndroid Build Coastguard Worker * <li>i to be the integer digits.</li> 131*0e209d39SAndroid Build Coastguard Worker * <li>f to be the visible fractional digits, as an integer.</li> 132*0e209d39SAndroid Build Coastguard Worker * <li>v to be the number of visible fraction digits.</li> 133*0e209d39SAndroid Build Coastguard Worker * <li>j is defined to only match integers. That is j is 3 fails if v != 0 (eg for 3.1 or 3.0).</li> 134*0e209d39SAndroid Build Coastguard Worker * </ul> 135*0e209d39SAndroid Build Coastguard Worker * <p> 136*0e209d39SAndroid Build Coastguard Worker * Examples are in the following table: 137*0e209d39SAndroid Build Coastguard Worker * </p> 138*0e209d39SAndroid Build Coastguard Worker * <table border='1' style="border-collapse:collapse"> 139*0e209d39SAndroid Build Coastguard Worker * <tr> 140*0e209d39SAndroid Build Coastguard Worker * <th>n</th> 141*0e209d39SAndroid Build Coastguard Worker * <th>i</th> 142*0e209d39SAndroid Build Coastguard Worker * <th>f</th> 143*0e209d39SAndroid Build Coastguard Worker * <th>v</th> 144*0e209d39SAndroid Build Coastguard Worker * </tr> 145*0e209d39SAndroid Build Coastguard Worker * <tr> 146*0e209d39SAndroid Build Coastguard Worker * <td>1.0</td> 147*0e209d39SAndroid Build Coastguard Worker * <td>1</td> 148*0e209d39SAndroid Build Coastguard Worker * <td align="right">0</td> 149*0e209d39SAndroid Build Coastguard Worker * <td>1</td> 150*0e209d39SAndroid Build Coastguard Worker * </tr> 151*0e209d39SAndroid Build Coastguard Worker * <tr> 152*0e209d39SAndroid Build Coastguard Worker * <td>1.00</td> 153*0e209d39SAndroid Build Coastguard Worker * <td>1</td> 154*0e209d39SAndroid Build Coastguard Worker * <td align="right">0</td> 155*0e209d39SAndroid Build Coastguard Worker * <td>2</td> 156*0e209d39SAndroid Build Coastguard Worker * </tr> 157*0e209d39SAndroid Build Coastguard Worker * <tr> 158*0e209d39SAndroid Build Coastguard Worker * <td>1.3</td> 159*0e209d39SAndroid Build Coastguard Worker * <td>1</td> 160*0e209d39SAndroid Build Coastguard Worker * <td align="right">3</td> 161*0e209d39SAndroid Build Coastguard Worker * <td>1</td> 162*0e209d39SAndroid Build Coastguard Worker * </tr> 163*0e209d39SAndroid Build Coastguard Worker * <tr> 164*0e209d39SAndroid Build Coastguard Worker * <td>1.03</td> 165*0e209d39SAndroid Build Coastguard Worker * <td>1</td> 166*0e209d39SAndroid Build Coastguard Worker * <td align="right">3</td> 167*0e209d39SAndroid Build Coastguard Worker * <td>2</td> 168*0e209d39SAndroid Build Coastguard Worker * </tr> 169*0e209d39SAndroid Build Coastguard Worker * <tr> 170*0e209d39SAndroid Build Coastguard Worker * <td>1.23</td> 171*0e209d39SAndroid Build Coastguard Worker * <td>1</td> 172*0e209d39SAndroid Build Coastguard Worker * <td align="right">23</td> 173*0e209d39SAndroid Build Coastguard Worker * <td>2</td> 174*0e209d39SAndroid Build Coastguard Worker * </tr> 175*0e209d39SAndroid Build Coastguard Worker * </table> 176*0e209d39SAndroid Build Coastguard Worker * <p> 177*0e209d39SAndroid Build Coastguard Worker * The difference between 'in' and 'within' is that 'in' only includes integers in the specified range, while 'within' 178*0e209d39SAndroid Build Coastguard Worker * includes all values. Using 'within' with a range_list consisting entirely of values is the same as using 'in' (it's 179*0e209d39SAndroid Build Coastguard Worker * not an error). 180*0e209d39SAndroid Build Coastguard Worker * </p> 181*0e209d39SAndroid Build Coastguard Worker 182*0e209d39SAndroid Build Coastguard Worker * An "identifier" is a sequence of characters that do not have the 183*0e209d39SAndroid Build Coastguard Worker * Unicode Pattern_Syntax or Pattern_White_Space properties. 184*0e209d39SAndroid Build Coastguard Worker * <p> 185*0e209d39SAndroid Build Coastguard Worker * The difference between 'in' and 'within' is that 'in' only includes 186*0e209d39SAndroid Build Coastguard Worker * integers in the specified range, while 'within' includes all values. 187*0e209d39SAndroid Build Coastguard Worker * Using 'within' with a range_list consisting entirely of values is the 188*0e209d39SAndroid Build Coastguard Worker * same as using 'in' (it's not an error). 189*0e209d39SAndroid Build Coastguard Worker *</p> 190*0e209d39SAndroid Build Coastguard Worker * <p> 191*0e209d39SAndroid Build Coastguard Worker * Keywords 192*0e209d39SAndroid Build Coastguard Worker * could be defined by users or from ICU locale data. There are 6 193*0e209d39SAndroid Build Coastguard Worker * predefined values in ICU - 'zero', 'one', 'two', 'few', 'many' and 194*0e209d39SAndroid Build Coastguard Worker * 'other'. Callers need to check the value of keyword returned by 195*0e209d39SAndroid Build Coastguard Worker * {@link #select} method. 196*0e209d39SAndroid Build Coastguard Worker * </p> 197*0e209d39SAndroid Build Coastguard Worker * 198*0e209d39SAndroid Build Coastguard Worker * Examples:<pre> 199*0e209d39SAndroid Build Coastguard Worker * UnicodeString keyword = pl->select(number); 200*0e209d39SAndroid Build Coastguard Worker * if (keyword== UnicodeString("one") { 201*0e209d39SAndroid Build Coastguard Worker * ... 202*0e209d39SAndroid Build Coastguard Worker * } 203*0e209d39SAndroid Build Coastguard Worker * else if ( ... ) 204*0e209d39SAndroid Build Coastguard Worker * </pre> 205*0e209d39SAndroid Build Coastguard Worker * <strong>Note:</strong><br> 206*0e209d39SAndroid Build Coastguard Worker * <p> 207*0e209d39SAndroid Build Coastguard Worker * ICU defines plural rules for many locales based on CLDR <i>Language Plural Rules</i>. 208*0e209d39SAndroid Build Coastguard Worker * For these predefined rules, see CLDR page at 209*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html 210*0e209d39SAndroid Build Coastguard Worker * </p> 211*0e209d39SAndroid Build Coastguard Worker */ 212*0e209d39SAndroid Build Coastguard Worker class U_I18N_API PluralRules : public UObject { 213*0e209d39SAndroid Build Coastguard Worker public: 214*0e209d39SAndroid Build Coastguard Worker 215*0e209d39SAndroid Build Coastguard Worker /** 216*0e209d39SAndroid Build Coastguard Worker * Constructor. 217*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on exit, which 218*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 219*0e209d39SAndroid Build Coastguard Worker * 220*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 221*0e209d39SAndroid Build Coastguard Worker */ 222*0e209d39SAndroid Build Coastguard Worker PluralRules(UErrorCode& status); 223*0e209d39SAndroid Build Coastguard Worker 224*0e209d39SAndroid Build Coastguard Worker /** 225*0e209d39SAndroid Build Coastguard Worker * Copy constructor. 226*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 227*0e209d39SAndroid Build Coastguard Worker */ 228*0e209d39SAndroid Build Coastguard Worker PluralRules(const PluralRules& other); 229*0e209d39SAndroid Build Coastguard Worker 230*0e209d39SAndroid Build Coastguard Worker /** 231*0e209d39SAndroid Build Coastguard Worker * Destructor. 232*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 233*0e209d39SAndroid Build Coastguard Worker */ 234*0e209d39SAndroid Build Coastguard Worker virtual ~PluralRules(); 235*0e209d39SAndroid Build Coastguard Worker 236*0e209d39SAndroid Build Coastguard Worker /** 237*0e209d39SAndroid Build Coastguard Worker * Clone 238*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 239*0e209d39SAndroid Build Coastguard Worker */ 240*0e209d39SAndroid Build Coastguard Worker PluralRules* clone() const; 241*0e209d39SAndroid Build Coastguard Worker 242*0e209d39SAndroid Build Coastguard Worker /** 243*0e209d39SAndroid Build Coastguard Worker * Assignment operator. 244*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 245*0e209d39SAndroid Build Coastguard Worker */ 246*0e209d39SAndroid Build Coastguard Worker PluralRules& operator=(const PluralRules&); 247*0e209d39SAndroid Build Coastguard Worker 248*0e209d39SAndroid Build Coastguard Worker /** 249*0e209d39SAndroid Build Coastguard Worker * Creates a PluralRules from a description if it is parsable, otherwise 250*0e209d39SAndroid Build Coastguard Worker * returns nullptr. 251*0e209d39SAndroid Build Coastguard Worker * 252*0e209d39SAndroid Build Coastguard Worker * @param description rule description 253*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on exit, which 254*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 255*0e209d39SAndroid Build Coastguard Worker * @return new PluralRules pointer. nullptr if there is an error. 256*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 257*0e209d39SAndroid Build Coastguard Worker */ 258*0e209d39SAndroid Build Coastguard Worker static PluralRules* U_EXPORT2 createRules(const UnicodeString& description, 259*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 260*0e209d39SAndroid Build Coastguard Worker 261*0e209d39SAndroid Build Coastguard Worker /** 262*0e209d39SAndroid Build Coastguard Worker * The default rules that accept any number. 263*0e209d39SAndroid Build Coastguard Worker * 264*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on exit, which 265*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 266*0e209d39SAndroid Build Coastguard Worker * @return new PluralRules pointer. nullptr if there is an error. 267*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 268*0e209d39SAndroid Build Coastguard Worker */ 269*0e209d39SAndroid Build Coastguard Worker static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status); 270*0e209d39SAndroid Build Coastguard Worker 271*0e209d39SAndroid Build Coastguard Worker /** 272*0e209d39SAndroid Build Coastguard Worker * Provides access to the predefined cardinal-number <code>PluralRules</code> for a given 273*0e209d39SAndroid Build Coastguard Worker * locale. 274*0e209d39SAndroid Build Coastguard Worker * Same as forLocale(locale, UPLURAL_TYPE_CARDINAL, status). 275*0e209d39SAndroid Build Coastguard Worker * 276*0e209d39SAndroid Build Coastguard Worker * @param locale The locale for which a <code>PluralRules</code> object is 277*0e209d39SAndroid Build Coastguard Worker * returned. 278*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on exit, which 279*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 280*0e209d39SAndroid Build Coastguard Worker * @return The predefined <code>PluralRules</code> object pointer for 281*0e209d39SAndroid Build Coastguard Worker * this locale. If there's no predefined rules for this locale, 282*0e209d39SAndroid Build Coastguard Worker * the rules for the closest parent in the locale hierarchy 283*0e209d39SAndroid Build Coastguard Worker * that has one will be returned. The final fallback always 284*0e209d39SAndroid Build Coastguard Worker * returns the default 'other' rules. 285*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 286*0e209d39SAndroid Build Coastguard Worker */ 287*0e209d39SAndroid Build Coastguard Worker static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status); 288*0e209d39SAndroid Build Coastguard Worker 289*0e209d39SAndroid Build Coastguard Worker /** 290*0e209d39SAndroid Build Coastguard Worker * Provides access to the predefined <code>PluralRules</code> for a given 291*0e209d39SAndroid Build Coastguard Worker * locale and the plural type. 292*0e209d39SAndroid Build Coastguard Worker * 293*0e209d39SAndroid Build Coastguard Worker * @param locale The locale for which a <code>PluralRules</code> object is 294*0e209d39SAndroid Build Coastguard Worker * returned. 295*0e209d39SAndroid Build Coastguard Worker * @param type The plural type (e.g., cardinal or ordinal). 296*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on exit, which 297*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 298*0e209d39SAndroid Build Coastguard Worker * @return The predefined <code>PluralRules</code> object pointer for 299*0e209d39SAndroid Build Coastguard Worker * this locale. If there's no predefined rules for this locale, 300*0e209d39SAndroid Build Coastguard Worker * the rules for the closest parent in the locale hierarchy 301*0e209d39SAndroid Build Coastguard Worker * that has one will be returned. The final fallback always 302*0e209d39SAndroid Build Coastguard Worker * returns the default 'other' rules. 303*0e209d39SAndroid Build Coastguard Worker * @stable ICU 50 304*0e209d39SAndroid Build Coastguard Worker */ 305*0e209d39SAndroid Build Coastguard Worker static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status); 306*0e209d39SAndroid Build Coastguard Worker 307*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 308*0e209d39SAndroid Build Coastguard Worker /** 309*0e209d39SAndroid Build Coastguard Worker * Return a StringEnumeration over the locales for which there is plurals data. 310*0e209d39SAndroid Build Coastguard Worker * @return a StringEnumeration over the locales available. 311*0e209d39SAndroid Build Coastguard Worker * @internal 312*0e209d39SAndroid Build Coastguard Worker */ 313*0e209d39SAndroid Build Coastguard Worker static StringEnumeration* U_EXPORT2 getAvailableLocales(UErrorCode &status); 314*0e209d39SAndroid Build Coastguard Worker 315*0e209d39SAndroid Build Coastguard Worker /** 316*0e209d39SAndroid Build Coastguard Worker * For ICU use only. 317*0e209d39SAndroid Build Coastguard Worker * creates a SharedPluralRules object 318*0e209d39SAndroid Build Coastguard Worker * @internal 319*0e209d39SAndroid Build Coastguard Worker */ 320*0e209d39SAndroid Build Coastguard Worker static PluralRules* U_EXPORT2 internalForLocale(const Locale& locale, UPluralType type, UErrorCode& status); 321*0e209d39SAndroid Build Coastguard Worker 322*0e209d39SAndroid Build Coastguard Worker /** 323*0e209d39SAndroid Build Coastguard Worker * For ICU use only. 324*0e209d39SAndroid Build Coastguard Worker * Returns handle to the shared, cached PluralRules instance. 325*0e209d39SAndroid Build Coastguard Worker * Caller must call removeRef() on returned value once it is done with 326*0e209d39SAndroid Build Coastguard Worker * the shared instance. 327*0e209d39SAndroid Build Coastguard Worker * @internal 328*0e209d39SAndroid Build Coastguard Worker */ 329*0e209d39SAndroid Build Coastguard Worker static const SharedPluralRules* U_EXPORT2 createSharedInstance( 330*0e209d39SAndroid Build Coastguard Worker const Locale& locale, UPluralType type, UErrorCode& status); 331*0e209d39SAndroid Build Coastguard Worker 332*0e209d39SAndroid Build Coastguard Worker 333*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 334*0e209d39SAndroid Build Coastguard Worker 335*0e209d39SAndroid Build Coastguard Worker /** 336*0e209d39SAndroid Build Coastguard Worker * Given an integer, returns the keyword of the first rule 337*0e209d39SAndroid Build Coastguard Worker * that applies to the number. This function can be used with 338*0e209d39SAndroid Build Coastguard Worker * isKeyword* functions to determine the keyword for default plural rules. 339*0e209d39SAndroid Build Coastguard Worker * 340*0e209d39SAndroid Build Coastguard Worker * @param number The number for which the rule has to be determined. 341*0e209d39SAndroid Build Coastguard Worker * @return The keyword of the selected rule. 342*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 343*0e209d39SAndroid Build Coastguard Worker */ 344*0e209d39SAndroid Build Coastguard Worker UnicodeString select(int32_t number) const; 345*0e209d39SAndroid Build Coastguard Worker 346*0e209d39SAndroid Build Coastguard Worker /** 347*0e209d39SAndroid Build Coastguard Worker * Given a floating-point number, returns the keyword of the first rule 348*0e209d39SAndroid Build Coastguard Worker * that applies to the number. This function can be used with 349*0e209d39SAndroid Build Coastguard Worker * isKeyword* functions to determine the keyword for default plural rules. 350*0e209d39SAndroid Build Coastguard Worker * 351*0e209d39SAndroid Build Coastguard Worker * @param number The number for which the rule has to be determined. 352*0e209d39SAndroid Build Coastguard Worker * @return The keyword of the selected rule. 353*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 354*0e209d39SAndroid Build Coastguard Worker */ 355*0e209d39SAndroid Build Coastguard Worker UnicodeString select(double number) const; 356*0e209d39SAndroid Build Coastguard Worker 357*0e209d39SAndroid Build Coastguard Worker /** 358*0e209d39SAndroid Build Coastguard Worker * Given a formatted number, returns the keyword of the first rule 359*0e209d39SAndroid Build Coastguard Worker * that applies to the number. This function can be used with 360*0e209d39SAndroid Build Coastguard Worker * isKeyword* functions to determine the keyword for default plural rules. 361*0e209d39SAndroid Build Coastguard Worker * 362*0e209d39SAndroid Build Coastguard Worker * A FormattedNumber allows you to specify an exponent or trailing zeros, 363*0e209d39SAndroid Build Coastguard Worker * which can affect the plural category. To get a FormattedNumber, see 364*0e209d39SAndroid Build Coastguard Worker * NumberFormatter. 365*0e209d39SAndroid Build Coastguard Worker * 366*0e209d39SAndroid Build Coastguard Worker * @param number The number for which the rule has to be determined. 367*0e209d39SAndroid Build Coastguard Worker * @param status Set if an error occurs while selecting plural keyword. 368*0e209d39SAndroid Build Coastguard Worker * This could happen if the FormattedNumber is invalid. 369*0e209d39SAndroid Build Coastguard Worker * @return The keyword of the selected rule. 370*0e209d39SAndroid Build Coastguard Worker * @stable ICU 64 371*0e209d39SAndroid Build Coastguard Worker */ 372*0e209d39SAndroid Build Coastguard Worker UnicodeString select(const number::FormattedNumber& number, UErrorCode& status) const; 373*0e209d39SAndroid Build Coastguard Worker 374*0e209d39SAndroid Build Coastguard Worker /** 375*0e209d39SAndroid Build Coastguard Worker * Given a formatted number range, returns the overall plural form of the 376*0e209d39SAndroid Build Coastguard Worker * range. For example, "3-5" returns "other" in English. 377*0e209d39SAndroid Build Coastguard Worker * 378*0e209d39SAndroid Build Coastguard Worker * To get a FormattedNumberRange, see NumberRangeFormatter. 379*0e209d39SAndroid Build Coastguard Worker * 380*0e209d39SAndroid Build Coastguard Worker * This method only works if PluralRules was created with a locale. If it was created 381*0e209d39SAndroid Build Coastguard Worker * from PluralRules::createRules(), this method sets status code U_UNSUPPORTED_ERROR. 382*0e209d39SAndroid Build Coastguard Worker * 383*0e209d39SAndroid Build Coastguard Worker * @param range The number range onto which the rules will be applied. 384*0e209d39SAndroid Build Coastguard Worker * @param status Set if an error occurs while selecting plural keyword. 385*0e209d39SAndroid Build Coastguard Worker * This could happen if the FormattedNumberRange is invalid, 386*0e209d39SAndroid Build Coastguard Worker * or if plural ranges data is unavailable. 387*0e209d39SAndroid Build Coastguard Worker * @return The keyword of the selected rule. 388*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 389*0e209d39SAndroid Build Coastguard Worker */ 390*0e209d39SAndroid Build Coastguard Worker UnicodeString select(const number::FormattedNumberRange& range, UErrorCode& status) const; 391*0e209d39SAndroid Build Coastguard Worker 392*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 393*0e209d39SAndroid Build Coastguard Worker /** 394*0e209d39SAndroid Build Coastguard Worker * @internal 395*0e209d39SAndroid Build Coastguard Worker */ 396*0e209d39SAndroid Build Coastguard Worker UnicodeString select(const IFixedDecimal &number) const; 397*0e209d39SAndroid Build Coastguard Worker /** 398*0e209d39SAndroid Build Coastguard Worker * @internal 399*0e209d39SAndroid Build Coastguard Worker */ 400*0e209d39SAndroid Build Coastguard Worker UnicodeString select(const number::impl::UFormattedNumberRangeData* urange, UErrorCode& status) const; 401*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 402*0e209d39SAndroid Build Coastguard Worker 403*0e209d39SAndroid Build Coastguard Worker /** 404*0e209d39SAndroid Build Coastguard Worker * Returns a list of all rule keywords used in this <code>PluralRules</code> 405*0e209d39SAndroid Build Coastguard Worker * object. The rule 'other' is always present by default. 406*0e209d39SAndroid Build Coastguard Worker * 407*0e209d39SAndroid Build Coastguard Worker * @param status Output param set to success/failure code on exit, which 408*0e209d39SAndroid Build Coastguard Worker * must not indicate a failure before the function call. 409*0e209d39SAndroid Build Coastguard Worker * @return StringEnumeration with the keywords. 410*0e209d39SAndroid Build Coastguard Worker * The caller must delete the object. 411*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 412*0e209d39SAndroid Build Coastguard Worker */ 413*0e209d39SAndroid Build Coastguard Worker StringEnumeration* getKeywords(UErrorCode& status) const; 414*0e209d39SAndroid Build Coastguard Worker 415*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 416*0e209d39SAndroid Build Coastguard Worker /** 417*0e209d39SAndroid Build Coastguard Worker * Deprecated Function, does not return useful results. 418*0e209d39SAndroid Build Coastguard Worker * 419*0e209d39SAndroid Build Coastguard Worker * Originally intended to return a unique value for this keyword if it exists, 420*0e209d39SAndroid Build Coastguard Worker * else the constant UPLRULES_NO_UNIQUE_VALUE. 421*0e209d39SAndroid Build Coastguard Worker * 422*0e209d39SAndroid Build Coastguard Worker * @param keyword The keyword. 423*0e209d39SAndroid Build Coastguard Worker * @return Stub deprecated function returns UPLRULES_NO_UNIQUE_VALUE always. 424*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 425*0e209d39SAndroid Build Coastguard Worker */ 426*0e209d39SAndroid Build Coastguard Worker double getUniqueKeywordValue(const UnicodeString& keyword); 427*0e209d39SAndroid Build Coastguard Worker 428*0e209d39SAndroid Build Coastguard Worker /** 429*0e209d39SAndroid Build Coastguard Worker * Deprecated Function, does not produce useful results. 430*0e209d39SAndroid Build Coastguard Worker * 431*0e209d39SAndroid Build Coastguard Worker * Originally intended to return all the values for which select() would return the keyword. 432*0e209d39SAndroid Build Coastguard Worker * If the keyword is unknown, returns no values, but this is not an error. If 433*0e209d39SAndroid Build Coastguard Worker * the number of values is unlimited, returns no values and -1 as the 434*0e209d39SAndroid Build Coastguard Worker * count. 435*0e209d39SAndroid Build Coastguard Worker * 436*0e209d39SAndroid Build Coastguard Worker * The number of returned values is typically small. 437*0e209d39SAndroid Build Coastguard Worker * 438*0e209d39SAndroid Build Coastguard Worker * @param keyword The keyword. 439*0e209d39SAndroid Build Coastguard Worker * @param dest Array into which to put the returned values. May 440*0e209d39SAndroid Build Coastguard Worker * be nullptr if destCapacity is 0. 441*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The capacity of the array, must be at least 0. 442*0e209d39SAndroid Build Coastguard Worker * @param status The error code. Deprecated function, always sets U_UNSUPPORTED_ERROR. 443*0e209d39SAndroid Build Coastguard Worker * @return The count of values available, or -1. This count 444*0e209d39SAndroid Build Coastguard Worker * can be larger than destCapacity, but no more than 445*0e209d39SAndroid Build Coastguard Worker * destCapacity values will be written. 446*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 447*0e209d39SAndroid Build Coastguard Worker */ 448*0e209d39SAndroid Build Coastguard Worker int32_t getAllKeywordValues(const UnicodeString &keyword, 449*0e209d39SAndroid Build Coastguard Worker double *dest, int32_t destCapacity, 450*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 451*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 452*0e209d39SAndroid Build Coastguard Worker 453*0e209d39SAndroid Build Coastguard Worker /** 454*0e209d39SAndroid Build Coastguard Worker * Returns sample values for which select() would return the keyword. If 455*0e209d39SAndroid Build Coastguard Worker * the keyword is unknown, returns no values, but this is not an error. 456*0e209d39SAndroid Build Coastguard Worker * 457*0e209d39SAndroid Build Coastguard Worker * The number of returned values is typically small. 458*0e209d39SAndroid Build Coastguard Worker * 459*0e209d39SAndroid Build Coastguard Worker * @param keyword The keyword. 460*0e209d39SAndroid Build Coastguard Worker * @param dest Array into which to put the returned values. May 461*0e209d39SAndroid Build Coastguard Worker * be nullptr if destCapacity is 0. 462*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The capacity of the array, must be at least 0. 463*0e209d39SAndroid Build Coastguard Worker * @param status The error code. 464*0e209d39SAndroid Build Coastguard Worker * @return The count of values written. 465*0e209d39SAndroid Build Coastguard Worker * If more than destCapacity samples are available, then 466*0e209d39SAndroid Build Coastguard Worker * only destCapacity are written, and destCapacity is returned as the count, 467*0e209d39SAndroid Build Coastguard Worker * rather than setting a U_BUFFER_OVERFLOW_ERROR. 468*0e209d39SAndroid Build Coastguard Worker * (The actual number of keyword values could be unlimited.) 469*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 470*0e209d39SAndroid Build Coastguard Worker */ 471*0e209d39SAndroid Build Coastguard Worker int32_t getSamples(const UnicodeString &keyword, 472*0e209d39SAndroid Build Coastguard Worker double *dest, int32_t destCapacity, 473*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 474*0e209d39SAndroid Build Coastguard Worker 475*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 476*0e209d39SAndroid Build Coastguard Worker /** 477*0e209d39SAndroid Build Coastguard Worker * Internal-only function that returns DecimalQuantitys instead of doubles. 478*0e209d39SAndroid Build Coastguard Worker * 479*0e209d39SAndroid Build Coastguard Worker * Returns sample values for which select() would return the keyword. If 480*0e209d39SAndroid Build Coastguard Worker * the keyword is unknown, returns no values, but this is not an error. 481*0e209d39SAndroid Build Coastguard Worker * 482*0e209d39SAndroid Build Coastguard Worker * The number of returned values is typically small. 483*0e209d39SAndroid Build Coastguard Worker * 484*0e209d39SAndroid Build Coastguard Worker * @param keyword The keyword. 485*0e209d39SAndroid Build Coastguard Worker * @param dest Array into which to put the returned values. May 486*0e209d39SAndroid Build Coastguard Worker * be nullptr if destCapacity is 0. 487*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The capacity of the array, must be at least 0. 488*0e209d39SAndroid Build Coastguard Worker * @param status The error code. 489*0e209d39SAndroid Build Coastguard Worker * @return The count of values written. 490*0e209d39SAndroid Build Coastguard Worker * If more than destCapacity samples are available, then 491*0e209d39SAndroid Build Coastguard Worker * only destCapacity are written, and destCapacity is returned as the count, 492*0e209d39SAndroid Build Coastguard Worker * rather than setting a U_BUFFER_OVERFLOW_ERROR. 493*0e209d39SAndroid Build Coastguard Worker * (The actual number of keyword values could be unlimited.) 494*0e209d39SAndroid Build Coastguard Worker * @internal 495*0e209d39SAndroid Build Coastguard Worker */ 496*0e209d39SAndroid Build Coastguard Worker int32_t getSamples(const UnicodeString &keyword, 497*0e209d39SAndroid Build Coastguard Worker DecimalQuantity *dest, int32_t destCapacity, 498*0e209d39SAndroid Build Coastguard Worker UErrorCode& status); 499*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 500*0e209d39SAndroid Build Coastguard Worker 501*0e209d39SAndroid Build Coastguard Worker /** 502*0e209d39SAndroid Build Coastguard Worker * Returns true if the given keyword is defined in this 503*0e209d39SAndroid Build Coastguard Worker * <code>PluralRules</code> object. 504*0e209d39SAndroid Build Coastguard Worker * 505*0e209d39SAndroid Build Coastguard Worker * @param keyword the input keyword. 506*0e209d39SAndroid Build Coastguard Worker * @return true if the input keyword is defined. 507*0e209d39SAndroid Build Coastguard Worker * Otherwise, return false. 508*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 509*0e209d39SAndroid Build Coastguard Worker */ 510*0e209d39SAndroid Build Coastguard Worker UBool isKeyword(const UnicodeString& keyword) const; 511*0e209d39SAndroid Build Coastguard Worker 512*0e209d39SAndroid Build Coastguard Worker 513*0e209d39SAndroid Build Coastguard Worker /** 514*0e209d39SAndroid Build Coastguard Worker * Returns keyword for default plural form. 515*0e209d39SAndroid Build Coastguard Worker * 516*0e209d39SAndroid Build Coastguard Worker * @return keyword for default plural form. 517*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 518*0e209d39SAndroid Build Coastguard Worker */ 519*0e209d39SAndroid Build Coastguard Worker UnicodeString getKeywordOther() const; 520*0e209d39SAndroid Build Coastguard Worker 521*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 522*0e209d39SAndroid Build Coastguard Worker /** 523*0e209d39SAndroid Build Coastguard Worker * 524*0e209d39SAndroid Build Coastguard Worker * @internal 525*0e209d39SAndroid Build Coastguard Worker */ 526*0e209d39SAndroid Build Coastguard Worker UnicodeString getRules() const; 527*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 528*0e209d39SAndroid Build Coastguard Worker 529*0e209d39SAndroid Build Coastguard Worker /** 530*0e209d39SAndroid Build Coastguard Worker * Compares the equality of two PluralRules objects. 531*0e209d39SAndroid Build Coastguard Worker * 532*0e209d39SAndroid Build Coastguard Worker * @param other The other PluralRules object to be compared with. 533*0e209d39SAndroid Build Coastguard Worker * @return true if the given PluralRules is the same as this 534*0e209d39SAndroid Build Coastguard Worker * PluralRules; false otherwise. 535*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 536*0e209d39SAndroid Build Coastguard Worker */ 537*0e209d39SAndroid Build Coastguard Worker virtual bool operator==(const PluralRules& other) const; 538*0e209d39SAndroid Build Coastguard Worker 539*0e209d39SAndroid Build Coastguard Worker /** 540*0e209d39SAndroid Build Coastguard Worker * Compares the inequality of two PluralRules objects. 541*0e209d39SAndroid Build Coastguard Worker * 542*0e209d39SAndroid Build Coastguard Worker * @param other The PluralRules object to be compared with. 543*0e209d39SAndroid Build Coastguard Worker * @return true if the given PluralRules is not the same as this 544*0e209d39SAndroid Build Coastguard Worker * PluralRules; false otherwise. 545*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 546*0e209d39SAndroid Build Coastguard Worker */ 547*0e209d39SAndroid Build Coastguard Worker bool operator!=(const PluralRules& other) const {return !operator==(other);} 548*0e209d39SAndroid Build Coastguard Worker 549*0e209d39SAndroid Build Coastguard Worker 550*0e209d39SAndroid Build Coastguard Worker /** 551*0e209d39SAndroid Build Coastguard Worker * ICU "poor man's RTTI", returns a UClassID for this class. 552*0e209d39SAndroid Build Coastguard Worker * 553*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 554*0e209d39SAndroid Build Coastguard Worker * 555*0e209d39SAndroid Build Coastguard Worker */ 556*0e209d39SAndroid Build Coastguard Worker static UClassID U_EXPORT2 getStaticClassID(); 557*0e209d39SAndroid Build Coastguard Worker 558*0e209d39SAndroid Build Coastguard Worker /** 559*0e209d39SAndroid Build Coastguard Worker * ICU "poor man's RTTI", returns a UClassID for the actual class. 560*0e209d39SAndroid Build Coastguard Worker * 561*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 562*0e209d39SAndroid Build Coastguard Worker */ 563*0e209d39SAndroid Build Coastguard Worker virtual UClassID getDynamicClassID() const override; 564*0e209d39SAndroid Build Coastguard Worker 565*0e209d39SAndroid Build Coastguard Worker 566*0e209d39SAndroid Build Coastguard Worker private: 567*0e209d39SAndroid Build Coastguard Worker RuleChain *mRules; 568*0e209d39SAndroid Build Coastguard Worker StandardPluralRanges *mStandardPluralRanges; 569*0e209d39SAndroid Build Coastguard Worker 570*0e209d39SAndroid Build Coastguard Worker PluralRules() = delete; // default constructor not implemented 571*0e209d39SAndroid Build Coastguard Worker UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status); 572*0e209d39SAndroid Build Coastguard Worker RuleChain *rulesForKeyword(const UnicodeString &keyword) const; 573*0e209d39SAndroid Build Coastguard Worker PluralRules *clone(UErrorCode& status) const; 574*0e209d39SAndroid Build Coastguard Worker 575*0e209d39SAndroid Build Coastguard Worker /** 576*0e209d39SAndroid Build Coastguard Worker * An internal status variable used to indicate that the object is in an 'invalid' state. 577*0e209d39SAndroid Build Coastguard Worker * Used by copy constructor, the assignment operator and the clone method. 578*0e209d39SAndroid Build Coastguard Worker */ 579*0e209d39SAndroid Build Coastguard Worker UErrorCode mInternalStatus; 580*0e209d39SAndroid Build Coastguard Worker 581*0e209d39SAndroid Build Coastguard Worker friend class PluralRuleParser; 582*0e209d39SAndroid Build Coastguard Worker }; 583*0e209d39SAndroid Build Coastguard Worker 584*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 585*0e209d39SAndroid Build Coastguard Worker 586*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 587*0e209d39SAndroid Build Coastguard Worker 588*0e209d39SAndroid Build Coastguard Worker #endif /* U_SHOW_CPLUSPLUS_API */ 589*0e209d39SAndroid Build Coastguard Worker 590*0e209d39SAndroid Build Coastguard Worker #endif // _PLURRULE 591*0e209d39SAndroid Build Coastguard Worker //eof 592