Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: source/i18n/plurrule.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/plurfmt.cpp ('k') | source/i18n/plurrule_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************* 2 *******************************************************************************
3 * Copyright (C) 2007-2014, International Business Machines Corporation and 3 * Copyright (C) 2007-2015, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ******************************************************************************* 5 *******************************************************************************
6 * 6 *
7 * File plurrule.cpp 7 * File plurrule.cpp
8 */ 8 */
9 9
10 #include <math.h> 10 #include <math.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 12
13 #include "unicode/utypes.h" 13 #include "unicode/utypes.h"
(...skipping 10 matching lines...) Expand all
24 #include "mutex.h" 24 #include "mutex.h"
25 #include "patternprops.h" 25 #include "patternprops.h"
26 #include "plurrule_impl.h" 26 #include "plurrule_impl.h"
27 #include "putilimp.h" 27 #include "putilimp.h"
28 #include "ucln_in.h" 28 #include "ucln_in.h"
29 #include "ustrfmt.h" 29 #include "ustrfmt.h"
30 #include "uassert.h" 30 #include "uassert.h"
31 #include "uvectr32.h" 31 #include "uvectr32.h"
32 #include "sharedpluralrules.h" 32 #include "sharedpluralrules.h"
33 #include "unifiedcache.h" 33 #include "unifiedcache.h"
34 #include "digitinterval.h"
35 #include "visibledigits.h"
36
34 37
35 #if !UCONFIG_NO_FORMATTING 38 #if !UCONFIG_NO_FORMATTING
36 39
37 U_NAMESPACE_BEGIN 40 U_NAMESPACE_BEGIN
38 41
39 #define ARRAY_SIZE(array) (int32_t)(sizeof array / sizeof array[0]) 42 #define ARRAY_SIZE(array) (int32_t)(sizeof array / sizeof array[0])
40 43
41 static const UChar PLURAL_KEYWORD_OTHER[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,0}; 44 static const UChar PLURAL_KEYWORD_OTHER[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,0};
42 static const UChar PLURAL_DEFAULT_RULE[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,COLON,SP ACE,LOW_N,0}; 45 static const UChar PLURAL_DEFAULT_RULE[]={LOW_O,LOW_T,LOW_H,LOW_E,LOW_R,COLON,SP ACE,LOW_N,0};
43 static const UChar PK_IN[]={LOW_I,LOW_N,0}; 46 static const UChar PK_IN[]={LOW_I,LOW_N,0};
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 UnicodeString 249 UnicodeString
247 PluralRules::select(const FixedDecimal &number) const { 250 PluralRules::select(const FixedDecimal &number) const {
248 if (mRules == NULL) { 251 if (mRules == NULL) {
249 return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1); 252 return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1);
250 } 253 }
251 else { 254 else {
252 return mRules->select(number); 255 return mRules->select(number);
253 } 256 }
254 } 257 }
255 258
259 UnicodeString
260 PluralRules::select(const VisibleDigitsWithExponent &number) const {
261 if (number.getExponent() != NULL) {
262 return UnicodeString(TRUE, PLURAL_DEFAULT_RULE, -1);
263 }
264 return select(FixedDecimal(number.getMantissa()));
265 }
266
267
268
256 StringEnumeration* 269 StringEnumeration*
257 PluralRules::getKeywords(UErrorCode& status) const { 270 PluralRules::getKeywords(UErrorCode& status) const {
258 if (U_FAILURE(status)) return NULL; 271 if (U_FAILURE(status)) return NULL;
259 StringEnumeration* nameEnumerator = new PluralKeywordEnumeration(mRules, sta tus); 272 StringEnumeration* nameEnumerator = new PluralKeywordEnumeration(mRules, sta tus);
260 if (U_FAILURE(status)) { 273 if (U_FAILURE(status)) {
261 delete nameEnumerator; 274 delete nameEnumerator;
262 return NULL; 275 return NULL;
263 } 276 }
264 277
265 return nameEnumerator; 278 return nameEnumerator;
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 } 1376 }
1364 1377
1365 int32_t 1378 int32_t
1366 PluralKeywordEnumeration::count(UErrorCode& /*status*/) const { 1379 PluralKeywordEnumeration::count(UErrorCode& /*status*/) const {
1367 return fKeywordNames.size(); 1380 return fKeywordNames.size();
1368 } 1381 }
1369 1382
1370 PluralKeywordEnumeration::~PluralKeywordEnumeration() { 1383 PluralKeywordEnumeration::~PluralKeywordEnumeration() {
1371 } 1384 }
1372 1385
1373 1386 FixedDecimal::FixedDecimal(const VisibleDigits &digits) {
1387 digits.getFixedDecimal(
1388 source, intValue, decimalDigits,
1389 decimalDigitsWithoutTrailingZeros,
1390 visibleDecimalDigitCount, hasIntegerValue);
1391 isNegative = digits.isNegative();
1392 isNanOrInfinity = digits.isNaNOrInfinity();
1393 }
1374 1394
1375 FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f) { 1395 FixedDecimal::FixedDecimal(double n, int32_t v, int64_t f) {
1376 init(n, v, f); 1396 init(n, v, f);
1377 // check values. TODO make into unit test. 1397 // check values. TODO make into unit test.
1378 // 1398 //
1379 // long visiblePower = (int) Math.pow(10, v); 1399 // long visiblePower = (int) Math.pow(10, v);
1380 // if (decimalDigits > visiblePower) { 1400 // if (decimalDigits > visiblePower) {
1381 // throw new IllegalArgumentException(); 1401 // throw new IllegalArgumentException();
1382 // } 1402 // }
1383 // double fraction = intValue + (decimalDigits / (double) visible Power); 1403 // double fraction = intValue + (decimalDigits / (double) visible Power);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 } 1670 }
1651 return ures_getSize(fLocales); 1671 return ures_getSize(fLocales);
1652 } 1672 }
1653 1673
1654 U_NAMESPACE_END 1674 U_NAMESPACE_END
1655 1675
1656 1676
1657 #endif /* #if !UCONFIG_NO_FORMATTING */ 1677 #endif /* #if !UCONFIG_NO_FORMATTING */
1658 1678
1659 //eof 1679 //eof
OLDNEW
« no previous file with comments | « source/i18n/plurfmt.cpp ('k') | source/i18n/plurrule_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698