]> git.saurik.com Git - apple/icu.git/blame_incremental - icuSources/i18n/uplrule.cpp
ICU-461.18.tar.gz
[apple/icu.git] / icuSources / i18n / uplrule.cpp
... / ...
CommitLineData
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
16U_NAMESPACE_USE
17
18U_CAPI UPluralRules* U_EXPORT2
19uplrule_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
28U_CAPI void U_EXPORT2
29uplrule_close(UPluralRules *plrules)
30{
31 delete (PluralRules*)plrules;
32}
33
34U_CAPI int32_t U_EXPORT2
35uplrule_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
47U_CAPI int32_t U_EXPORT2
48uplrule_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 */