ICU 64.2 64.2

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/localpointer.h"
18 #include "unicode/uenum.h"
19 #ifndef U_HIDE_INTERNAL_API
20 #include "unicode/unum.h"
21 #endif /* U_HIDE_INTERNAL_API */
22
23 // Forward-declaration
24 struct UFormattedNumber;
25
53 enum UPluralType {
58 UPLURAL_TYPE_CARDINAL,
63 UPLURAL_TYPE_ORDINAL,
64 #ifndef U_HIDE_DEPRECATED_API
65
69 UPLURAL_TYPE_COUNT
70 #endif /* U_HIDE_DEPRECATED_API */
71 };
75 typedef enum UPluralType UPluralType;
76
81 struct UPluralRules;
82 typedef struct UPluralRules UPluralRules;
93 U_CAPI UPluralRules* U_EXPORT2
94 uplrules_open(const char *locale, UErrorCode *status);
95
105 U_CAPI UPluralRules* U_EXPORT2
106 uplrules_openForType(const char *locale, UPluralType type, UErrorCode *status);
107
113 U_CAPI void U_EXPORT2
114 uplrules_close(UPluralRules *uplrules);
115
116
117 #if U_SHOW_CPLUSPLUS_API
118
119 U_NAMESPACE_BEGIN
120
130 U_DEFINE_LOCAL_OPEN_POINTER(LocalUPluralRulesPointer, UPluralRules, uplrules_close);
131
132 U_NAMESPACE_END
133
134 #endif
135
136
149 U_CAPI int32_t U_EXPORT2
150 uplrules_select(const UPluralRules *uplrules,
151 double number,
152 UChar *keyword, int32_t capacity,
153 UErrorCode *status);
154
155 #ifndef U_HIDE_DRAFT_API
156
173 U_CAPI int32_t U_EXPORT2
174 uplrules_selectFormatted(const UPluralRules *uplrules,
175 const struct UFormattedNumber* number,
176 UChar *keyword, int32_t capacity,
177 UErrorCode *status);
178 #endif /* U_HIDE_DRAFT_API */
179
180 #ifndef U_HIDE_INTERNAL_API
181
199 U_INTERNAL int32_t U_EXPORT2
200 uplrules_selectWithFormat(const UPluralRules *uplrules,
201 double number,
202 const UNumberFormat *fmt,
203 UChar *keyword, int32_t capacity,
204 UErrorCode *status);
205
206 #endif /* U_HIDE_INTERNAL_API */
207
218 U_STABLE UEnumeration* U_EXPORT2
219 uplrules_getKeywords(const UPluralRules *uplrules,
220 UErrorCode *status);
221
222 #endif /* #if !UCONFIG_NO_FORMATTING */
223
224 #endif
uplrules_getKeywords
UEnumeration * uplrules_getKeywords(const UPluralRules *uplrules, UErrorCode *status)
Creates a string enumeration of all plural rule keywords used in this UPluralRules object.
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:109
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:43
U_INTERNAL
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition: umachine.h:119
uplrules_close
U_CAPI void uplrules_close(UPluralRules *uplrules)
Closes a UPluralRules object.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:562
UFormattedNumber
struct UFormattedNumber UFormattedNumber
C-compatible version of icu::number::FormattedNumber.
Definition: unumberformatter.h:426
UNumberFormat
void * UNumberFormat
A number formatter.
Definition: unum.h:141
UPLURAL_TYPE_ORDINAL
Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc.
Definition: upluralrules.h:63
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UPLURAL_TYPE_CARDINAL
Plural rules for cardinal numbers: 1 file vs.
Definition: upluralrules.h:58
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,...
uplrules_selectWithFormat
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...
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.
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...
UChar
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:342
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UPLURAL_TYPE_COUNT
One more than the highest normal UPluralType value.
Definition: upluralrules.h:69
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:401
UPluralType
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:53
uenum.h
C API: String Enumeration.
UPluralRules
struct UPluralRules UPluralRules
C typedef for struct UPluralRules.
Definition: upluralrules.h:82
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
LocalUPluralRulesPointer
"Smart pointer" class, closes a UPluralRules via uplrules_close().
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,...
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
unum.h
C API: Compatibility APIs for number formatting.