OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************** | 2 ******************************************************************************** |
3 * Copyright (C) 1997-2014, International Business Machines | 3 * Copyright (C) 1997-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************** | 5 ******************************************************************************** |
6 * | 6 * |
7 * File DCFMTSYM.H | 7 * File DCFMTSYM.H |
8 * | 8 * |
9 * Modification History: | 9 * Modification History: |
10 * | 10 * |
11 * Date Name Description | 11 * Date Name Description |
12 * 02/19/97 aliu Converted from java. | 12 * 02/19/97 aliu Converted from java. |
13 * 03/18/97 clhuang Updated per C++ implementation. | 13 * 03/18/97 clhuang Updated per C++ implementation. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 kSevenDigitSymbol, | 157 kSevenDigitSymbol, |
158 /** Eight | 158 /** Eight |
159 * @stable ICU 4.6 | 159 * @stable ICU 4.6 |
160 */ | 160 */ |
161 kEightDigitSymbol, | 161 kEightDigitSymbol, |
162 /** Nine | 162 /** Nine |
163 * @stable ICU 4.6 | 163 * @stable ICU 4.6 |
164 */ | 164 */ |
165 kNineDigitSymbol, | 165 kNineDigitSymbol, |
166 /** Multiplication sign. | 166 /** Multiplication sign. |
167 * @draft ICU 54 | 167 * @stable ICU 54 |
168 */ | 168 */ |
169 kExponentMultiplicationSymbol, | 169 kExponentMultiplicationSymbol, |
170 /** count symbol constants */ | 170 /** count symbol constants */ |
171 kFormatSymbolCount | 171 kFormatSymbolCount = kNineDigitSymbol + 2 |
172 }; | 172 }; |
173 | 173 |
174 /** | 174 /** |
175 * Create a DecimalFormatSymbols object for the given locale. | 175 * Create a DecimalFormatSymbols object for the given locale. |
176 * | 176 * |
177 * @param locale The locale to get symbols for. | 177 * @param locale The locale to get symbols for. |
178 * @param status Input/output parameter, set to success or | 178 * @param status Input/output parameter, set to success or |
179 * failure code upon return. | 179 * failure code upon return. |
180 * @stable ICU 2.0 | 180 * @stable ICU 2.0 |
181 */ | 181 */ |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 void initialize(const Locale& locale, UErrorCode& success, UBool useLastReso
rtData = FALSE); | 347 void initialize(const Locale& locale, UErrorCode& success, UBool useLastReso
rtData = FALSE); |
348 | 348 |
349 /** | 349 /** |
350 * Initialize the symbols with default values. | 350 * Initialize the symbols with default values. |
351 */ | 351 */ |
352 void initialize(); | 352 void initialize(); |
353 | 353 |
354 void setCurrencyForSymbols(); | 354 void setCurrencyForSymbols(); |
355 | 355 |
356 public: | 356 public: |
| 357 |
| 358 #ifndef U_HIDE_INTERNAL_API |
| 359 /** |
| 360 * @internal For ICU use only |
| 361 */ |
| 362 inline UBool isCustomCurrencySymbol() const { |
| 363 return fIsCustomCurrencySymbol; |
| 364 } |
| 365 |
| 366 /** |
| 367 * @internal For ICU use only |
| 368 */ |
| 369 inline UBool isCustomIntlCurrencySymbol() const { |
| 370 return fIsCustomIntlCurrencySymbol; |
| 371 } |
| 372 #endif /* U_HIDE_INTERNAL_API */ |
| 373 |
357 /** | 374 /** |
358 * _Internal_ function - more efficient version of getSymbol, | 375 * _Internal_ function - more efficient version of getSymbol, |
359 * returning a const reference to one of the symbol strings. | 376 * returning a const reference to one of the symbol strings. |
360 * The returned reference becomes invalid when the symbol is changed | 377 * The returned reference becomes invalid when the symbol is changed |
361 * or when the DecimalFormatSymbols are destroyed. | 378 * or when the DecimalFormatSymbols are destroyed. |
362 * ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be real
ly public. | 379 * ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be real
ly public. |
363 * Note: moved #ifndef U_HIDE_INTERNAL_API after this, since this is needed
for inline in DecimalFormat | 380 * Note: moved #ifndef U_HIDE_INTERNAL_API after this, since this is needed
for inline in DecimalFormat |
364 * | 381 * |
365 * @param symbol Constant to indicate a number format symbol. | 382 * @param symbol Constant to indicate a number format symbol. |
366 * @return the format symbol by the param 'symbol' | 383 * @return the format symbol by the param 'symbol' |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 UnicodeString fNoSymbol; | 418 UnicodeString fNoSymbol; |
402 | 419 |
403 Locale locale; | 420 Locale locale; |
404 | 421 |
405 char actualLocale[ULOC_FULLNAME_CAPACITY]; | 422 char actualLocale[ULOC_FULLNAME_CAPACITY]; |
406 char validLocale[ULOC_FULLNAME_CAPACITY]; | 423 char validLocale[ULOC_FULLNAME_CAPACITY]; |
407 const UChar* currPattern; | 424 const UChar* currPattern; |
408 | 425 |
409 UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT]; | 426 UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT]; |
410 UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT]; | 427 UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT]; |
| 428 UBool fIsCustomCurrencySymbol; |
| 429 UBool fIsCustomIntlCurrencySymbol; |
411 }; | 430 }; |
412 | 431 |
413 // ------------------------------------- | 432 // ------------------------------------- |
414 | 433 |
415 inline UnicodeString | 434 inline UnicodeString |
416 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const { | 435 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const { |
417 const UnicodeString *strPtr; | 436 const UnicodeString *strPtr; |
418 if(symbol < kFormatSymbolCount) { | 437 if(symbol < kFormatSymbolCount) { |
419 strPtr = &fSymbols[symbol]; | 438 strPtr = &fSymbols[symbol]; |
420 } else { | 439 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
436 return *strPtr; | 455 return *strPtr; |
437 } | 456 } |
438 | 457 |
439 //#endif /* U_HIDE_INTERNAL_API */ | 458 //#endif /* U_HIDE_INTERNAL_API */ |
440 | 459 |
441 | 460 |
442 // ------------------------------------- | 461 // ------------------------------------- |
443 | 462 |
444 inline void | 463 inline void |
445 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString
&value, const UBool propogateDigits = TRUE) { | 464 DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString
&value, const UBool propogateDigits = TRUE) { |
| 465 if (symbol == kCurrencySymbol) { |
| 466 fIsCustomCurrencySymbol = TRUE; |
| 467 } |
| 468 else if (symbol == kIntlCurrencySymbol) { |
| 469 fIsCustomIntlCurrencySymbol = TRUE; |
| 470 } |
446 if(symbol<kFormatSymbolCount) { | 471 if(symbol<kFormatSymbolCount) { |
447 fSymbols[symbol]=value; | 472 fSymbols[symbol]=value; |
448 } | 473 } |
449 | 474 |
450 // If the zero digit is being set to a known zero digit according to Unicode
, | 475 // If the zero digit is being set to a known zero digit according to Unicode
, |
451 // then we automatically set the corresponding 1-9 digits | 476 // then we automatically set the corresponding 1-9 digits |
452 if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() ==
1 ) { | 477 if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() ==
1 ) { |
453 UChar32 sym = value.char32At(0); | 478 UChar32 sym = value.char32At(0); |
454 if ( u_charDigitValue(sym) == 0 ) { | 479 if ( u_charDigitValue(sym) == 0 ) { |
455 for ( int8_t i = 1 ; i<= 9 ; i++ ) { | 480 for ( int8_t i = 1 ; i<= 9 ; i++ ) { |
(...skipping 17 matching lines...) Expand all Loading... |
473 return currPattern; | 498 return currPattern; |
474 } | 499 } |
475 #endif /* U_HIDE_INTERNAL_API */ | 500 #endif /* U_HIDE_INTERNAL_API */ |
476 | 501 |
477 U_NAMESPACE_END | 502 U_NAMESPACE_END |
478 | 503 |
479 #endif /* #if !UCONFIG_NO_FORMATTING */ | 504 #endif /* #if !UCONFIG_NO_FORMATTING */ |
480 | 505 |
481 #endif // _DCFMTSYM | 506 #endif // _DCFMTSYM |
482 //eof | 507 //eof |
OLD | NEW |