]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/pluralmap.cpp
2 * Copyright (C) 2015, International Business Machines Corporation and
3 * others. All Rights Reserved.
6 #include "unicode/unistr.h"
13 static const char * const gPluralForms
[] = {
14 "other", "zero", "one", "two", "few", "many"};
16 PluralMapBase::Category
17 PluralMapBase::toCategory(const char *pluralForm
) {
18 for (int32_t i
= 0; i
< UPRV_LENGTHOF(gPluralForms
); ++i
) {
19 if (uprv_strcmp(pluralForm
, gPluralForms
[i
]) == 0) {
20 return static_cast<Category
>(i
);
26 PluralMapBase::Category
27 PluralMapBase::toCategory(const UnicodeString
&pluralForm
) {
29 UErrorCode status
= U_ZERO_ERROR
;
30 cCategory
.appendInvariantChars(pluralForm
, status
);
31 return U_FAILURE(status
) ? NONE
: toCategory(cCategory
.data());
34 const char *PluralMapBase::getCategoryName(Category c
) {
36 return (index
< 0 || index
>= UPRV_LENGTHOF(gPluralForms
)) ?
37 NULL
: gPluralForms
[index
];