]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/pluralmap.cpp
   1 // © 2016 and later: Unicode, Inc. and others. 
   2 // License & terms of use: http://www.unicode.org/copyright.html 
   4  * Copyright (C) 2015, International Business Machines Corporation and 
   5  * others. All Rights Reserved. 
   8 #include "unicode/unistr.h" 
  11 #include "pluralmap.h" 
  15 static const char * const gPluralForms
[] = { 
  16         "other", "zero", "one", "two", "few", "many"}; 
  18 PluralMapBase::Category
 
  19 PluralMapBase::toCategory(const char *pluralForm
) { 
  20     for (int32_t i 
= 0; i 
< UPRV_LENGTHOF(gPluralForms
); ++i
) { 
  21         if (uprv_strcmp(pluralForm
, gPluralForms
[i
]) == 0) { 
  22             return static_cast<Category
>(i
); 
  28 PluralMapBase::Category
 
  29 PluralMapBase::toCategory(const UnicodeString 
&pluralForm
) { 
  31     UErrorCode status 
= U_ZERO_ERROR
; 
  32     cCategory
.appendInvariantChars(pluralForm
, status
);     
  33     return U_FAILURE(status
) ? NONE 
: toCategory(cCategory
.data()); 
  36 const char *PluralMapBase::getCategoryName(Category c
) { 
  38     return (index 
< 0 || index 
>= UPRV_LENGTHOF(gPluralForms
)) ? 
  39             NULL 
: gPluralForms
[index
];