]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | ***************************************************************************************** | |
3 | * Copyright (C) 2010 Apple Inc. All Rights Reserved. | |
4 | ***************************************************************************************** | |
5 | */ | |
6 | ||
7 | #include "unicode/utypes.h" | |
8 | ||
9 | #if !UCONFIG_NO_FORMATTING | |
10 | ||
11 | #include "unicode/uplrule.h" | |
12 | #include "unicode/plurrule.h" | |
13 | #include "unicode/locid.h" | |
14 | #include "unicode/unistr.h" | |
15 | ||
16 | U_NAMESPACE_USE | |
17 | ||
18 | U_CAPI UPluralRules* U_EXPORT2 | |
19 | uplrule_open(const char *locale, | |
20 | UErrorCode *status) | |
21 | { | |
22 | if (status == NULL || U_FAILURE(*status)) { | |
23 | return 0; | |
24 | } | |
25 | return (UPluralRules*)PluralRules::forLocale(Locale(locale), *status); | |
26 | } | |
27 | ||
28 | U_CAPI void U_EXPORT2 | |
29 | uplrule_close(UPluralRules *plrules) | |
30 | { | |
31 | delete (PluralRules*)plrules; | |
32 | } | |
33 | ||
34 | U_CAPI int32_t U_EXPORT2 | |
35 | uplrule_select(const UPluralRules *plrules, | |
36 | int32_t number, | |
37 | UChar *keyword, int32_t capacity, | |
38 | UErrorCode *status) | |
39 | { | |
40 | if (status == NULL || U_FAILURE(*status)) { | |
41 | return 0; | |
42 | } | |
43 | UnicodeString result = ((PluralRules*)plrules)->select(number); | |
44 | return result.extract(keyword, capacity, *status); | |
45 | } | |
46 | ||
47 | U_CAPI int32_t U_EXPORT2 | |
48 | uplrule_selectDouble(const UPluralRules *plrules, | |
49 | double number, | |
50 | UChar *keyword, int32_t capacity, | |
51 | UErrorCode *status) | |
52 | { | |
53 | if (status == NULL || U_FAILURE(*status)) { | |
54 | return 0; | |
55 | } | |
56 | UnicodeString result = ((PluralRules*)plrules)->select(number); | |
57 | return result.extract(keyword, capacity, *status); | |
58 | } | |
59 | ||
60 | #endif /* #if !UCONFIG_NO_FORMATTING */ |