summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/i18n/pluralaffix.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /intl/icu/source/i18n/pluralaffix.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'intl/icu/source/i18n/pluralaffix.cpp')
-rw-r--r--intl/icu/source/i18n/pluralaffix.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/pluralaffix.cpp b/intl/icu/source/i18n/pluralaffix.cpp
new file mode 100644
index 000000000..f6a51a79e
--- /dev/null
+++ b/intl/icu/source/i18n/pluralaffix.cpp
@@ -0,0 +1,104 @@
+// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+/*
+ * Copyright (C) 2015, International Business Machines
+ * Corporation and others. All Rights Reserved.
+ *
+ * file name: pluralaffix.cpp
+ */
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "cstring.h"
+#include "digitaffix.h"
+#include "pluralaffix.h"
+
+U_NAMESPACE_BEGIN
+
+UBool
+PluralAffix::setVariant(
+ const char *variant, const UnicodeString &value, UErrorCode &status) {
+ DigitAffix *current = affixes.getMutable(variant, status);
+ if (U_FAILURE(status)) {
+ return FALSE;
+ }
+ current->remove();
+ current->append(value);
+ return TRUE;
+}
+
+void
+PluralAffix::remove() {
+ affixes.clear();
+}
+
+void
+PluralAffix::appendUChar(
+ const UChar value, int32_t fieldId) {
+ PluralMapBase::Category index = PluralMapBase::NONE;
+ for (DigitAffix *current = affixes.nextMutable(index);
+ current != NULL; current = affixes.nextMutable(index)) {
+ current->appendUChar(value, fieldId);
+ }
+}
+
+void
+PluralAffix::append(
+ const UnicodeString &value, int32_t fieldId) {
+ PluralMapBase::Category index = PluralMapBase::NONE;
+ for (DigitAffix *current = affixes.nextMutable(index);
+ current != NULL; current = affixes.nextMutable(index)) {
+ current->append(value, fieldId);
+ }
+}
+
+void
+PluralAffix::append(
+ const UChar *value, int32_t charCount, int32_t fieldId) {
+ PluralMapBase::Category index = PluralMapBase::NONE;
+ for (DigitAffix *current = affixes.nextMutable(index);
+ current != NULL; current = affixes.nextMutable(index)) {
+ current->append(value, charCount, fieldId);
+ }
+}
+
+UBool
+PluralAffix::append(
+ const PluralAffix &rhs, int32_t fieldId, UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return FALSE;
+ }
+ PluralMapBase::Category index = PluralMapBase::NONE;
+ while(rhs.affixes.next(index) != NULL) {
+ affixes.getMutableWithDefault(index, affixes.getOther(), status);
+ }
+ index = PluralMapBase::NONE;
+ for (DigitAffix *current = affixes.nextMutable(index);
+ current != NULL; current = affixes.nextMutable(index)) {
+ current->append(rhs.affixes.get(index).toString(), fieldId);
+ }
+ return TRUE;
+}
+
+const DigitAffix &
+PluralAffix::getByCategory(const char *category) const {
+ return affixes.get(category);
+}
+
+const DigitAffix &
+PluralAffix::getByCategory(const UnicodeString &category) const {
+ return affixes.get(category);
+}
+
+UBool
+PluralAffix::hasMultipleVariants() const {
+ // This works because OTHER is guaranteed to be the first enum value
+ PluralMapBase::Category index = PluralMapBase::OTHER;
+ return (affixes.next(index) != NULL);
+}
+
+U_NAMESPACE_END
+
+#endif /* #if !UCONFIG_NO_FORMATTING */