w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

upluralrules.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *****************************************************************************************
5 * Copyright (C) 2010-2013, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *****************************************************************************************
8 */
9 
10 #ifndef UPLURALRULES_H
11 #define UPLURALRULES_H
12 
13 #include "unicode/utypes.h"
14 
15 #if !UCONFIG_NO_FORMATTING
16 
17 #include "unicode/uenum.h"
18 
19 #if U_SHOW_CPLUSPLUS_API
20 #include "unicode/localpointer.h"
21 #endif // U_SHOW_CPLUSPLUS_API
22 
23 #ifndef U_HIDE_INTERNAL_API
24 #include "unicode/unum.h"
25 #endif /* U_HIDE_INTERNAL_API */
26 
27 // Forward-declaration
28 struct UFormattedNumber;
30 
31 /**
32  * \file
33  * \brief C API: Plural rules, select plural keywords for numeric values.
34  *
35  * A UPluralRules object defines rules for mapping non-negative numeric
36  * values onto a small set of keywords. Rules are constructed from a text
37  * description, consisting of a series of keywords and conditions.
38  * The uplrules_select function examines each condition in order and
39  * returns the keyword for the first condition that matches the number.
40  * If none match, the default rule(other) is returned.
41  *
42  * For more information, see the LDML spec, C.11 Language Plural Rules:
43  * http://www.unicode.org/reports/tr35/#Language_Plural_Rules
44  *
45  * Keywords: ICU locale data has 6 predefined values -
46  * 'zero', 'one', 'two', 'few', 'many' and 'other'. Callers need to check
47  * the value of keyword returned by the uplrules_select function.
48  *
49  * These are based on CLDR <i>Language Plural Rules</i>. For these
50  * predefined rules, see the CLDR page at
51  * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
52  */
53 
54 /**
55  * Type of plurals and PluralRules.
56  * @stable ICU 50
57  */
59  /**
60  * Plural rules for cardinal numbers: 1 file vs. 2 files.
61  * @stable ICU 50
62  */
64  /**
65  * Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc.
66  * @stable ICU 50
67  */
69 #ifndef U_HIDE_DEPRECATED_API
70  /**
71  * One more than the highest normal UPluralType value.
72  * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
73  */
75 #endif /* U_HIDE_DEPRECATED_API */
76 };
77 /**
78  * @stable ICU 50
79  */
80 typedef enum UPluralType UPluralType;
81 
82 /**
83  * Opaque UPluralRules object for use in C programs.
84  * @stable ICU 4.8
85  */
86 struct UPluralRules;
87 typedef struct UPluralRules UPluralRules; /**< C typedef for struct UPluralRules. @stable ICU 4.8 */
88 
89 /**
90  * Opens a new UPluralRules object using the predefined cardinal-number plural rules for a
91  * given locale.
92  * Same as uplrules_openForType(locale, UPLURAL_TYPE_CARDINAL, status).
93  * @param locale The locale for which the rules are desired.
94  * @param status A pointer to a UErrorCode to receive any errors.
95  * @return A UPluralRules for the specified locale, or NULL if an error occurred.
96  * @stable ICU 4.8
97  */
99 uplrules_open(const char *locale, UErrorCode *status);
100 
101 /**
102  * Opens a new UPluralRules object using the predefined plural rules for a
103  * given locale and the plural type.
104  * @param locale The locale for which the rules are desired.
105  * @param type The plural type (e.g., cardinal or ordinal).
106  * @param status A pointer to a UErrorCode to receive any errors.
107  * @return A UPluralRules for the specified locale, or NULL if an error occurred.
108  * @stable ICU 50
109  */
112 
113 /**
114  * Closes a UPluralRules object. Once closed it may no longer be used.
115  * @param uplrules The UPluralRules object to close.
116  * @stable ICU 4.8
117  */
118 U_CAPI void U_EXPORT2
119 uplrules_close(UPluralRules *uplrules);
120 
121 
122 #if U_SHOW_CPLUSPLUS_API
123 
125 
126 /**
127  * \class LocalUPluralRulesPointer
128  * "Smart pointer" class, closes a UPluralRules via uplrules_close().
129  * For most methods see the LocalPointerBase base class.
130  *
131  * @see LocalPointerBase
132  * @see LocalPointer
133  * @stable ICU 4.8
134  */
135 U_DEFINE_LOCAL_OPEN_POINTER(LocalUPluralRulesPointer, UPluralRules, uplrules_close);
136 
138 
139 #endif
140 
141 
142 /**
143  * Given a floating-point number, returns the keyword of the first rule that
144  * applies to the number, according to the supplied UPluralRules object.
145  * @param uplrules The UPluralRules object specifying the rules.
146  * @param number The number for which the rule has to be determined.
147  * @param keyword An output buffer to write the keyword of the rule that
148  * applies to number.
149  * @param capacity The capacity of the keyword buffer.
150  * @param status A pointer to a UErrorCode to receive any errors.
151  * @return The length of the keyword.
152  * @stable ICU 4.8
153  */
155 uplrules_select(const UPluralRules *uplrules,
156  double number,
158  UErrorCode *status);
159 
160 /**
161  * Given a formatted number, returns the keyword of the first rule
162  * that applies to the number, according to the supplied UPluralRules object.
163  *
164  * A UFormattedNumber allows you to specify an exponent or trailing zeros,
165  * which can affect the plural category. To get a UFormattedNumber, see
166  * {@link UNumberFormatter}.
167  *
168  * @param uplrules The UPluralRules object specifying the rules.
169  * @param number The formatted number for which the rule has to be determined.
170  * @param keyword The destination buffer for the keyword of the rule that
171  * applies to the number.
172  * @param capacity The capacity of the keyword buffer.
173  * @param status A pointer to a UErrorCode to receive any errors.
174  * @return The length of the keyword.
175  * @stable ICU 64
176  */
179  const struct UFormattedNumber* number,
181  UErrorCode *status);
182 
183 #ifndef U_HIDE_DRAFT_API
184 /**
185  * Given a formatted number range, returns the overall plural form of the
186  * range. For example, "3-5" returns "other" in English.
187  *
188  * To get a UFormattedNumberRange, see UNumberRangeFormatter.
189  *
190  * @param uplrules The UPluralRules object specifying the rules.
191  * @param urange The number range onto which the rules will be applied.
192  * @param keyword The destination buffer for the keyword of the rule that
193  * applies to the number range.
194  * @param capacity The capacity of the keyword buffer.
195  * @param status A pointer to a UErrorCode to receive any errors.
196  * @return The length of the keyword.
197  * @draft ICU 68
198  */
201  const struct UFormattedNumberRange* urange,
203  UErrorCode *status);
204 #endif // U_HIDE_DRAFT_API
205 
206 #ifndef U_HIDE_INTERNAL_API
207 /**
208  * Given a number, returns the keyword of the first rule that applies to the
209  * number, according to the UPluralRules object and given the number format
210  * specified by the UNumberFormat object.
211  * Note: This internal preview interface may be removed in the future if
212  * an architecturally cleaner solution reaches stable status.
213  * @param uplrules The UPluralRules object specifying the rules.
214  * @param number The number for which the rule has to be determined.
215  * @param fmt The UNumberFormat specifying how the number will be formatted
216  * (this can affect the plural form, e.g. "1 dollar" vs "1.0 dollars").
217  * If this is NULL, the function behaves like uplrules_select.
218  * @param keyword An output buffer to write the keyword of the rule that
219  * applies to number.
220  * @param capacity The capacity of the keyword buffer.
221  * @param status A pointer to a UErrorCode to receive any errors.
222  * @return The length of keyword.
223  * @internal ICU 59 technology preview, may be removed in the future
224  */
227  double number,
228  const UNumberFormat *fmt,
230  UErrorCode *status);
231 
232 #endif /* U_HIDE_INTERNAL_API */
233 
234 /**
235  * Creates a string enumeration of all plural rule keywords used in this
236  * UPluralRules object. The rule "other" is always present by default.
237  * @param uplrules The UPluralRules object specifying the rules for
238  * a given locale.
239  * @param status A pointer to a UErrorCode to receive any errors.
240  * @return a string enumeration over plural rule keywords, or NULL
241  * upon error. The caller is responsible for closing the result.
242  * @stable ICU 59
243  */
245 uplrules_getKeywords(const UPluralRules *uplrules,
246  UErrorCode *status);
247 
248 #endif /* #if !UCONFIG_NO_FORMATTING */
249 
250 #endif
#define type(a)
Definition: aptex-macros.h:171
unsigned char UChar
Definition: bzip2.c:163
signed int int32_t
Definition: stdint.h:77
int capacity
Definition: pdfcolor.c:1335
#define U_EXPORT2
Definition: platform.h:844
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define status
def_key keyword[6]
Definition: t1part.c:256
char fmt[256]
Definition: tex4ht.c:3925
C API: String Enumeration.
U_DEFINE_LOCAL_OPEN_POINTER(LocalULanguageTagPointer, ULanguageTag, ultag_close)
#define U_CAPI
Definition: umachine.h:110
C API: Compatibility APIs for number formatting.
void * UNumberFormat
Definition: unum.h:144
struct UFormattedNumber UFormattedNumber
struct UFormattedNumberRange UFormattedNumberRange
struct UPluralRules UPluralRules
Definition: upluralrules.h:87
UPluralType
Definition: upluralrules.h:58
@ UPLURAL_TYPE_ORDINAL
Definition: upluralrules.h:68
@ UPLURAL_TYPE_CARDINAL
Definition: upluralrules.h:63
@ UPLURAL_TYPE_COUNT
Definition: upluralrules.h:74
#define uplrules_selectFormatted
Definition: urename.h:1279
#define uplrules_selectWithFormat
Definition: urename.h:1280
#define uplrules_open
Definition: urename.h:1275
#define uplrules_selectForRange
Definition: urename.h:1278
#define uplrules_openForType
Definition: urename.h:1276
#define uplrules_select
Definition: urename.h:1277
#define uplrules_getKeywords
Definition: urename.h:1274
#define uplrules_close
Definition: urename.h:1273
static const char * locale
Definition: uresb.c:52
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Definition: utypes.h:431