ICU 69.1 69.1

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;
29 struct UFormattedNumberRange;
30
58 enum UPluralType {
63 UPLURAL_TYPE_CARDINAL,
68 UPLURAL_TYPE_ORDINAL,
69 #ifndef U_HIDE_DEPRECATED_API
70
74 UPLURAL_TYPE_COUNT
75 #endif /* U_HIDE_DEPRECATED_API */
76 };
80 typedef enum UPluralType UPluralType;
81
86 struct UPluralRules;
87 typedef struct UPluralRules UPluralRules;
98 U_CAPI UPluralRules* U_EXPORT2
99 uplrules_open(const char *locale, UErrorCode *status);
100
110 U_CAPI UPluralRules* U_EXPORT2
111 uplrules_openForType(const char *locale, UPluralType type, UErrorCode *status);
112
118 U_CAPI void U_EXPORT2
119 uplrules_close(UPluralRules *uplrules);
120
121
122 #if U_SHOW_CPLUSPLUS_API
123
124 U_NAMESPACE_BEGIN
125
135 U_DEFINE_LOCAL_OPEN_POINTER(LocalUPluralRulesPointer, UPluralRules, uplrules_close);
136
137 U_NAMESPACE_END
138
139 #endif
140
141
154 U_CAPI int32_t U_EXPORT2
155 uplrules_select(const UPluralRules *uplrules,
156 double number,
157 UChar *keyword, int32_t capacity,
158 UErrorCode *status);
159
177 U_CAPI int32_t U_EXPORT2
178 uplrules_selectFormatted(const UPluralRules *uplrules,
179 const struct UFormattedNumber* number,
180 UChar *keyword, int32_t capacity,
181 UErrorCode *status);
182
183 #ifndef U_HIDE_DRAFT_API
184
199 U_CAPI int32_t U_EXPORT2
200 uplrules_selectForRange(const UPluralRules *uplrules,
201 const struct UFormattedNumberRange* urange,
202 UChar *keyword, int32_t capacity,
203 UErrorCode *status);
204 #endif // U_HIDE_DRAFT_API
205
206 #ifndef U_HIDE_INTERNAL_API
207
225 U_CAPI int32_t U_EXPORT2
226 uplrules_selectWithFormat(const UPluralRules *uplrules,
227 double number,
228 const UNumberFormat *fmt,
229 UChar *keyword, int32_t capacity,
230 UErrorCode *status);
231
232 #endif /* U_HIDE_INTERNAL_API */
233
244 U_CAPI UEnumeration* U_EXPORT2
245 uplrules_getKeywords(const UPluralRules *uplrules,
246 UErrorCode *status);
247
248 #endif /* #if !UCONFIG_NO_FORMATTING */
249
250 #endif
UPluralType
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:58
uplrules_close
U_CAPI void uplrules_close(UPluralRules *uplrules)
Closes a UPluralRules object.
UPluralRules
struct UPluralRules UPluralRules
C typedef for struct UPluralRules.
Definition: upluralrules.h:87
uplrules_selectForRange
U_CAPI int32_t uplrules_selectForRange(const UPluralRules *uplrules, const struct UFormattedNumberRange *urange, UChar *keyword, int32_t capacity, UErrorCode *status)
Given a formatted number range, returns the overall plural form of the range.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
uplrules_selectWithFormat
U_CAPI int32_t uplrules_selectWithFormat(const UPluralRules *uplrules, double number, const UNumberFormat *fmt, UChar *keyword, int32_t capacity, UErrorCode *status)
Given a number, returns the keyword of the first rule that applies to the number, according to the UP...
UFormattedNumber
struct UFormattedNumber UFormattedNumber
C-compatible version of icu::number::FormattedNumber.
Definition: unumberformatter.h:547
UPLURAL_TYPE_COUNT
@ UPLURAL_TYPE_COUNT
One more than the highest normal UPluralType value.
Definition: upluralrules.h:74
uplrules_selectFormatted
U_CAPI int32_t uplrules_selectFormatted(const UPluralRules *uplrules, const struct UFormattedNumber *number, UChar *keyword, int32_t capacity, UErrorCode *status)
Given a formatted number, returns the keyword of the first rule that applies to the number,...
unum.h
C API: Compatibility APIs for number formatting.
LocalUPluralRulesPointer
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
uplrules_openForType
U_CAPI UPluralRules * uplrules_openForType(const char *locale, UPluralType type, UErrorCode *status)
Opens a new UPluralRules object using the predefined plural rules for a given locale and the plural t...
UPLURAL_TYPE_CARDINAL
@ UPLURAL_TYPE_CARDINAL
Plural rules for cardinal numbers: 1 file vs.
Definition: upluralrules.h:63
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
Definition: localpointer.h:550
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UNumberFormat
void * UNumberFormat
A number formatter.
Definition: unum.h:144
uplrules_getKeywords
U_CAPI UEnumeration * uplrules_getKeywords(const UPluralRules *uplrules, UErrorCode *status)
Creates a string enumeration of all plural rule keywords used in this UPluralRules object.
uplrules_select
U_CAPI int32_t uplrules_select(const UPluralRules *uplrules, double number, UChar *keyword, int32_t capacity, UErrorCode *status)
Given a floating-point number, returns the keyword of the first rule that applies to the number,...
UChar
char16_t UChar
Definition: umachine.h:418
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:44
UPLURAL_TYPE_ORDINAL
@ UPLURAL_TYPE_ORDINAL
Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc.
Definition: upluralrules.h:68
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
uplrules_open
U_CAPI UPluralRules * uplrules_open(const char *locale, UErrorCode *status)
Opens a new UPluralRules object using the predefined cardinal-number plural rules for a given locale.
uenum.h
C API: String Enumeration.
UFormattedNumberRange
struct UFormattedNumberRange UFormattedNumberRange
C-compatible version of icu::number::FormattedNumberRange.
Definition: unumberrangeformatter.h:222