1b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho/* 2b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho***************************************************************************************** 354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius* Copyright (C) 2010-2012, International Business Machines 4b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho* Corporation and others. All Rights Reserved. 5b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho***************************************************************************************** 6b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho*/ 7b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 8b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/utypes.h" 9b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 10b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#if !UCONFIG_NO_FORMATTING 11b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 12b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/upluralrules.h" 13b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/plurrule.h" 14b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/locid.h" 15b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/unistr.h" 16b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 17b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoU_NAMESPACE_USE 18b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 19b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 20b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoU_CAPI UPluralRules* U_EXPORT2 2154dcd9b6a06071f647dac967e9e267abb9410720Craig Corneliusuplrules_open(const char *locale, UErrorCode *status) 22b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho{ 2354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius return uplrules_openForType(locale, UPLURAL_TYPE_CARDINAL, status); 2454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius} 2554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius 2654dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_CAPI UPluralRules* U_EXPORT2 2754dcd9b6a06071f647dac967e9e267abb9410720Craig Corneliusuplrules_openForType(const char *locale, UPluralType type, UErrorCode *status) 2854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius{ 2954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius return (UPluralRules*)PluralRules::forLocale(Locale(locale), type, *status); 30b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 31b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 32b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoU_CAPI void U_EXPORT2 33b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehouplrules_close(UPluralRules *uplrules) 34b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho{ 35b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho delete (PluralRules*)uplrules; 36b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 37b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 38b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoU_CAPI int32_t U_EXPORT2 39b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehouplrules_select(const UPluralRules *uplrules, 40b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho double number, 41b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UChar *keyword, int32_t capacity, 42b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UErrorCode *status) 43b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho{ 44b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho if (U_FAILURE(*status)) { 45b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho return 0; 46b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho } 47b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho if (keyword == NULL ? capacity != 0 : capacity < 0) { 48b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *status = U_ILLEGAL_ARGUMENT_ERROR; 49b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho return 0; 50b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho } 51b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho UnicodeString result = ((PluralRules*)uplrules)->select(number); 52b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho return result.extract(keyword, capacity, *status); 53b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho} 54b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 55b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho 56b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#endif /* #if !UCONFIG_NO_FORMATTING */ 57