upluralrules.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*****************************************************************************************
* Copyright (C) 2010-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*****************************************************************************************
*/
#ifndef UPLURALRULES_H
#define UPLURALRULES_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/uenum.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
#ifndef U_HIDE_INTERNAL_API
#include "unicode/unum.h"
#endif /* U_HIDE_INTERNAL_API */
// Forward-declaration
struct UFormattedNumber;
struct UFormattedNumberRange;
enum UPluralType {
UPLURAL_TYPE_CARDINAL,
UPLURAL_TYPE_ORDINAL,
#ifndef U_HIDE_DEPRECATED_API
UPLURAL_TYPE_COUNT
#endif /* U_HIDE_DEPRECATED_API */
};
typedef enum UPluralType UPluralType;
struct UPluralRules;
typedef struct UPluralRules UPluralRules;
U_CAPI UPluralRules* U_EXPORT2
uplrules_open(const char *locale, UErrorCode *status);
U_CAPI UPluralRules* U_EXPORT2
uplrules_openForType(const char *locale, UPluralType type, UErrorCode *status);
U_CAPI void U_EXPORT2
uplrules_close(UPluralRules *uplrules);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUPluralRulesPointer, UPluralRules, uplrules_close);
U_NAMESPACE_END
#endif
U_CAPI int32_t U_EXPORT2
uplrules_select(const UPluralRules *uplrules,
double number,
UChar *keyword, int32_t capacity,
UErrorCode *status);
U_CAPI int32_t U_EXPORT2
uplrules_selectFormatted(const UPluralRules *uplrules,
const struct UFormattedNumber* number,
UChar *keyword, int32_t capacity,
UErrorCode *status);
U_CAPI int32_t U_EXPORT2
uplrules_selectForRange(const UPluralRules *uplrules,
const struct UFormattedNumberRange* urange,
UChar *keyword, int32_t capacity,
UErrorCode *status);
#ifndef U_HIDE_INTERNAL_API
U_CAPI int32_t U_EXPORT2
uplrules_selectWithFormat(const UPluralRules *uplrules,
double number,
const UNumberFormat *fmt,
UChar *keyword, int32_t capacity,
UErrorCode *status);
#endif /* U_HIDE_INTERNAL_API */
U_CAPI UEnumeration* U_EXPORT2
uplrules_getKeywords(const UPluralRules *uplrules,
UErrorCode *status);
#endif /* #if !UCONFIG_NO_FORMATTING */
#endif
LocalUPluralRulesPointer
"Smart pointer" class, closes a UPluralRules via uplrules_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
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:550
uenum.h
C API: String Enumeration.
UEnumeration
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:44
UFormattedNumber
struct UFormattedNumber UFormattedNumber
C-compatible version of icu::number::FormattedNumber.
Definition: uformattednumber.h:43
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:386
unum.h
C API: Compatibility APIs for number formatting.
UNumberFormat
void * UNumberFormat
A number formatter.
Definition: unum.h:145
UFormattedNumberRange
struct UFormattedNumberRange UFormattedNumberRange
C-compatible version of icu::number::FormattedNumberRange.
Definition: unumberrangeformatter.h:220
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...
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_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.
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.
UPluralRules
struct UPluralRules UPluralRules
C typedef for struct UPluralRules.
Definition: upluralrules.h:88
uplrules_close
U_CAPI void uplrules_close(UPluralRules *uplrules)
Closes a UPluralRules object.
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,...
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
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...
UPluralType
UPluralType
Type of plurals and PluralRules.
Definition: upluralrules.h:59
UPLURAL_TYPE_ORDINAL
@ UPLURAL_TYPE_ORDINAL
Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc.
Definition: upluralrules.h:69
UPLURAL_TYPE_CARDINAL
@ UPLURAL_TYPE_CARDINAL
Plural rules for cardinal numbers: 1 file vs.
Definition: upluralrules.h:64
UPLURAL_TYPE_COUNT
@ UPLURAL_TYPE_COUNT
One more than the highest normal UPluralType value.
Definition: upluralrules.h:75
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415