]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/pluralaffix.cpp
2 * Copyright (C) 2015, International Business Machines
3 * Corporation and others. All Rights Reserved.
5 * file name: pluralaffix.cpp
8 #include "unicode/utypes.h"
10 #if !UCONFIG_NO_FORMATTING
13 #include "digitaffix.h"
14 #include "pluralaffix.h"
19 PluralAffix::setVariant(
20 const char *variant
, const UnicodeString
&value
, UErrorCode
&status
) {
21 DigitAffix
*current
= affixes
.getMutable(variant
, status
);
22 if (U_FAILURE(status
)) {
26 current
->append(value
);
31 PluralAffix::remove() {
36 PluralAffix::appendUChar(
37 const UChar value
, int32_t fieldId
) {
38 PluralMapBase::Category index
= PluralMapBase::NONE
;
39 for (DigitAffix
*current
= affixes
.nextMutable(index
);
40 current
!= NULL
; current
= affixes
.nextMutable(index
)) {
41 current
->appendUChar(value
, fieldId
);
47 const UnicodeString
&value
, int32_t fieldId
) {
48 PluralMapBase::Category index
= PluralMapBase::NONE
;
49 for (DigitAffix
*current
= affixes
.nextMutable(index
);
50 current
!= NULL
; current
= affixes
.nextMutable(index
)) {
51 current
->append(value
, fieldId
);
57 const UChar
*value
, int32_t charCount
, int32_t fieldId
) {
58 PluralMapBase::Category index
= PluralMapBase::NONE
;
59 for (DigitAffix
*current
= affixes
.nextMutable(index
);
60 current
!= NULL
; current
= affixes
.nextMutable(index
)) {
61 current
->append(value
, charCount
, fieldId
);
67 const PluralAffix
&rhs
, int32_t fieldId
, UErrorCode
&status
) {
68 if (U_FAILURE(status
)) {
71 PluralMapBase::Category index
= PluralMapBase::NONE
;
72 while(rhs
.affixes
.next(index
) != NULL
) {
73 affixes
.getMutableWithDefault(index
, affixes
.getOther(), status
);
75 index
= PluralMapBase::NONE
;
76 for (DigitAffix
*current
= affixes
.nextMutable(index
);
77 current
!= NULL
; current
= affixes
.nextMutable(index
)) {
78 current
->append(rhs
.affixes
.get(index
).toString(), fieldId
);
84 PluralAffix::getByCategory(const char *category
) const {
85 return affixes
.get(category
);
89 PluralAffix::getByCategory(const UnicodeString
&category
) const {
90 return affixes
.get(category
);
94 PluralAffix::hasMultipleVariants() const {
95 // This works because OTHER is guaranteed to be the first enum value
96 PluralMapBase::Category index
= PluralMapBase::OTHER
;
97 return (affixes
.next(index
) != NULL
);
102 #endif /* #if !UCONFIG_NO_FORMATTING */