intl/icu/source/i18n/upluralrules.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial