Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: source/i18n/standardplural.h

Issue 1621943002: ICU 56 step 4: Apply post-56 fixes for measure/date format (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@56goog
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/reldatefmt.cpp ('k') | source/i18n/standardplural.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 *******************************************************************************
3 * Copyright (C) 2015, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 *******************************************************************************
6 * standardplural.h
7 *
8 * created on: 2015dec14
9 * created by: Markus W. Scherer
10 */
11
12 #ifndef __STANDARDPLURAL_H__
13 #define __STANDARDPLURAL_H__
14
15 #include "unicode/utypes.h"
16
17 #if !UCONFIG_NO_FORMATTING
18
19 U_NAMESPACE_BEGIN
20
21 class UnicodeString;
22
23 /**
24 * Standard CLDR plural form/category constants.
25 * See http://www.unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rul es
26 */
27 class U_I18N_API StandardPlural {
28 public:
29 enum Form {
30 ZERO,
31 ONE,
32 TWO,
33 FEW,
34 MANY,
35 OTHER,
36 COUNT
37 };
38
39 /**
40 * @return the lowercase CLDR keyword string for the plural form
41 */
42 static const char *getKeyword(Form p);
43
44 /**
45 * @param keyword for example "few" or "other"
46 * @return the plural form corresponding to the keyword, or OTHER
47 */
48 static Form orOtherFromString(const char *keyword) {
49 return static_cast<Form>(indexOrOtherIndexFromString(keyword));
50 }
51
52 /**
53 * @param keyword for example "few" or "other"
54 * @return the plural form corresponding to the keyword, or OTHER
55 */
56 static Form orOtherFromString(const UnicodeString &keyword) {
57 return static_cast<Form>(indexOrOtherIndexFromString(keyword));
58 }
59
60 /**
61 * Sets U_ILLEGAL_ARGUMENT_ERROR if the keyword is not a plural form.
62 *
63 * @param keyword for example "few" or "other"
64 * @return the plural form corresponding to the keyword
65 */
66 static Form fromString(const char *keyword, UErrorCode &errorCode) {
67 return static_cast<Form>(indexFromString(keyword, errorCode));
68 }
69
70 /**
71 * Sets U_ILLEGAL_ARGUMENT_ERROR if the keyword is not a plural form.
72 *
73 * @param keyword for example "few" or "other"
74 * @return the plural form corresponding to the keyword
75 */
76 static Form fromString(const UnicodeString &keyword, UErrorCode &errorCode) {
77 return static_cast<Form>(indexFromString(keyword, errorCode));
78 }
79
80 /**
81 * @param keyword for example "few" or "other"
82 * @return the index of the plural form corresponding to the keyword, or a n egative value
83 */
84 static int32_t indexOrNegativeFromString(const char *keyword);
85
86 /**
87 * @param keyword for example "few" or "other"
88 * @return the index of the plural form corresponding to the keyword, or a n egative value
89 */
90 static int32_t indexOrNegativeFromString(const UnicodeString &keyword);
91
92 /**
93 * @param keyword for example "few" or "other"
94 * @return the index of the plural form corresponding to the keyword, or OTH ER
95 */
96 static int32_t indexOrOtherIndexFromString(const char *keyword) {
97 int32_t i = indexOrNegativeFromString(keyword);
98 return i >= 0 ? i : OTHER;
99 }
100
101 /**
102 * @param keyword for example "few" or "other"
103 * @return the index of the plural form corresponding to the keyword, or OTH ER
104 */
105 static int32_t indexOrOtherIndexFromString(const UnicodeString &keyword) {
106 int32_t i = indexOrNegativeFromString(keyword);
107 return i >= 0 ? i : OTHER;
108 }
109
110 /**
111 * Sets U_ILLEGAL_ARGUMENT_ERROR if the keyword is not a plural form.
112 *
113 * @param keyword for example "few" or "other"
114 * @return the index of the plural form corresponding to the keyword
115 */
116 static int32_t indexFromString(const char *keyword, UErrorCode &errorCode);
117
118 /**
119 * Sets U_ILLEGAL_ARGUMENT_ERROR if the keyword is not a plural form.
120 *
121 * @param keyword for example "few" or "other"
122 * @return the index of the plural form corresponding to the keyword
123 */
124 static int32_t indexFromString(const UnicodeString &keyword, UErrorCode &err orCode);
125 };
126
127 U_NAMESPACE_END
128
129 #endif // !UCONFIG_NO_FORMATTING
130 #endif // __STANDARDPLURAL_H__
OLDNEW
« no previous file with comments | « source/i18n/reldatefmt.cpp ('k') | source/i18n/standardplural.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698