plurfmt.h 26 KB

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