Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ***************************************************************************************** |
michael@0 | 3 | * Copyright (C) 2010-2012, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ***************************************************************************************** |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #include "unicode/utypes.h" |
michael@0 | 9 | |
michael@0 | 10 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 11 | |
michael@0 | 12 | #include "unicode/upluralrules.h" |
michael@0 | 13 | #include "unicode/plurrule.h" |
michael@0 | 14 | #include "unicode/locid.h" |
michael@0 | 15 | #include "unicode/unistr.h" |
michael@0 | 16 | |
michael@0 | 17 | U_NAMESPACE_USE |
michael@0 | 18 | |
michael@0 | 19 | |
michael@0 | 20 | U_CAPI UPluralRules* U_EXPORT2 |
michael@0 | 21 | uplrules_open(const char *locale, UErrorCode *status) |
michael@0 | 22 | { |
michael@0 | 23 | return uplrules_openForType(locale, UPLURAL_TYPE_CARDINAL, status); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | U_CAPI UPluralRules* U_EXPORT2 |
michael@0 | 27 | uplrules_openForType(const char *locale, UPluralType type, UErrorCode *status) |
michael@0 | 28 | { |
michael@0 | 29 | return (UPluralRules*)PluralRules::forLocale(Locale(locale), type, *status); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | U_CAPI void U_EXPORT2 |
michael@0 | 33 | uplrules_close(UPluralRules *uplrules) |
michael@0 | 34 | { |
michael@0 | 35 | delete (PluralRules*)uplrules; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | U_CAPI int32_t U_EXPORT2 |
michael@0 | 39 | uplrules_select(const UPluralRules *uplrules, |
michael@0 | 40 | double number, |
michael@0 | 41 | UChar *keyword, int32_t capacity, |
michael@0 | 42 | UErrorCode *status) |
michael@0 | 43 | { |
michael@0 | 44 | if (U_FAILURE(*status)) { |
michael@0 | 45 | return 0; |
michael@0 | 46 | } |
michael@0 | 47 | if (keyword == NULL ? capacity != 0 : capacity < 0) { |
michael@0 | 48 | *status = U_ILLEGAL_ARGUMENT_ERROR; |
michael@0 | 49 | return 0; |
michael@0 | 50 | } |
michael@0 | 51 | UnicodeString result = ((PluralRules*)uplrules)->select(number); |
michael@0 | 52 | return result.extract(keyword, capacity, *status); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | |
michael@0 | 56 | #endif /* #if !UCONFIG_NO_FORMATTING */ |