ICU 56.1: dcfmtsym.h Source File

ICU 56.1 56.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

dcfmtsym.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File DCFMTSYM.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 02/19/97 aliu Converted from java.
13 * 03/18/97 clhuang Updated per C++ implementation.
14 * 03/27/97 helena Updated to pass the simple test after code review.
15 * 08/26/97 aliu Added currency/intl currency symbol support.
16 * 07/22/98 stephen Changed to match C++ style
17 * currencySymbol -> fCurrencySymbol
18 * Constants changed from CAPS to kCaps
19 * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes
20 * 09/22/00 grhoten Marked deprecation tags with a pointer to replacement
21 * functions.
22 ********************************************************************************
23 */
24
25 #ifndef DCFMTSYM_H
26 #define DCFMTSYM_H
27
28 #include "unicode/utypes.h"
29 #include "unicode/uchar.h"
30
31 #if !UCONFIG_NO_FORMATTING
32
33 #include "unicode/uobject.h"
34 #include "unicode/locid.h"
35 #include "unicode/unum.h"
36
43 U_NAMESPACE_BEGIN
44
84 class U_I18N_API DecimalFormatSymbols : public UObject {
85 public:
90 enum ENumberFormatSymbol {
92 kDecimalSeparatorSymbol,
94 kGroupingSeparatorSymbol,
96 kPatternSeparatorSymbol,
98 kPercentSymbol,
100 kZeroDigitSymbol,
102 kDigitSymbol,
104 kMinusSignSymbol,
106 kPlusSignSymbol,
108 kCurrencySymbol,
110 kIntlCurrencySymbol,
112 kMonetarySeparatorSymbol,
114 kExponentialSymbol,
116 kPerMillSymbol,
118 kPadEscapeSymbol,
120 kInfinitySymbol,
122 kNaNSymbol,
125 kSignificantDigitSymbol,
129 kMonetaryGroupingSeparatorSymbol,
133 kOneDigitSymbol,
137 kTwoDigitSymbol,
141 kThreeDigitSymbol,
145 kFourDigitSymbol,
149 kFiveDigitSymbol,
153 kSixDigitSymbol,
157 kSevenDigitSymbol,
161 kEightDigitSymbol,
165 kNineDigitSymbol,
169 kExponentMultiplicationSymbol,
171 kFormatSymbolCount = kNineDigitSymbol + 2
172 };
173
182 DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
183
194 DecimalFormatSymbols(UErrorCode& status);
195
211 static DecimalFormatSymbols* createWithLastResortData(UErrorCode& status);
212
217 DecimalFormatSymbols(const DecimalFormatSymbols&);
218
223 DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
224
229 virtual ~DecimalFormatSymbols();
230
238 UBool operator==(const DecimalFormatSymbols& other) const;
239
247 UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
248
258 inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
259
272 void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits);
273
278 inline Locale getLocale() const;
279
285 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
286
303 const UnicodeString& getPatternForCurrencySpacing(UCurrencySpacing type,
304 UBool beforeCurrency,
305 UErrorCode& status) const;
316 void setPatternForCurrencySpacing(UCurrencySpacing type,
317 UBool beforeCurrency,
318 const UnicodeString& pattern);
319
325 virtual UClassID getDynamicClassID() const;
326
332 static UClassID U_EXPORT2 getStaticClassID();
333
334 private:
335 DecimalFormatSymbols();
336
347 void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
348
352 void initialize();
353
354 void setCurrencyForSymbols();
355
356 public:
357
358 #ifndef U_HIDE_INTERNAL_API
359
362 inline UBool isCustomCurrencySymbol() const {
363 return fIsCustomCurrencySymbol;
364 }
365
369 inline UBool isCustomIntlCurrencySymbol() const {
370 return fIsCustomIntlCurrencySymbol;
371 }
372 #endif /* U_HIDE_INTERNAL_API */
373
386 inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
387
388 #ifndef U_HIDE_INTERNAL_API
389
393 inline const UChar* getCurrencyPattern(void) const;
394 #endif /* U_HIDE_INTERNAL_API */
395
396 private:
412 UnicodeString fSymbols[kFormatSymbolCount];
413
418 UnicodeString fNoSymbol;
419
420 Locale locale;
421
422 char actualLocale[ULOC_FULLNAME_CAPACITY];
423 char validLocale[ULOC_FULLNAME_CAPACITY];
424 const UChar* currPattern;
425
426 UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT];
427 UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT];
428 UBool fIsCustomCurrencySymbol;
429 UBool fIsCustomIntlCurrencySymbol;
430 };
431
432 // -------------------------------------
433
434 inline UnicodeString
435 DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
436 const UnicodeString *strPtr;
437 if(symbol < kFormatSymbolCount) {
438 strPtr = &fSymbols[symbol];
439 } else {
440 strPtr = &fNoSymbol;
441 }
442 return *strPtr;
443 }
444
445 //#ifndef U_HIDE_INTERNAL_API
446 // See comments above for this function. Not hidden.
447 inline const UnicodeString &
448 DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
449 const UnicodeString *strPtr;
450 if(symbol < kFormatSymbolCount) {
451 strPtr = &fSymbols[symbol];
452 } else {
453 strPtr = &fNoSymbol;
454 }
455 return *strPtr;
456 }
457
458 //#endif /* U_HIDE_INTERNAL_API */
459
460
461 // -------------------------------------
462
463 inline void
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 }
471 if(symbol<kFormatSymbolCount) {
472 fSymbols[symbol]=value;
473 }
474
475 // If the zero digit is being set to a known zero digit according to Unicode,
476 // then we automatically set the corresponding 1-9 digits
477 if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() == 1 ) {
478 UChar32 sym = value.char32At(0);
479 if ( u_charDigitValue(sym) == 0 ) {
480 for ( int8_t i = 1 ; i<= 9 ; i++ ) {
481 sym++;
482 fSymbols[(int)kOneDigitSymbol+i-1] = UnicodeString(sym);
483 }
484 }
485 }
486 }
487
488 // -------------------------------------
489
490 inline Locale
491 DecimalFormatSymbols::getLocale() const {
492 return locale;
493 }
494
495 #ifndef U_HIDE_INTERNAL_API
496 inline const UChar*
497 DecimalFormatSymbols::getCurrencyPattern() const {
498 return currPattern;
499 }
500 #endif /* U_HIDE_INTERNAL_API */
501
502 U_NAMESPACE_END
503
504 #endif /* #if !UCONFIG_NO_FORMATTING */
505
506 #endif // _DCFMTSYM
507 //eof
icu::DecimalFormatSymbols::kInfinitySymbol
Infinity symbol.
Definition: dcfmtsym.h:120
icu::DecimalFormatSymbols::isCustomIntlCurrencySymbol
UBool isCustomIntlCurrencySymbol() const
Definition: dcfmtsym.h:369
icu::DecimalFormatSymbols::kExponentialSymbol
The exponential symbol.
Definition: dcfmtsym.h:114
icu::DecimalFormatSymbols::kFourDigitSymbol
Four.
Definition: dcfmtsym.h:145
icu::DecimalFormatSymbols
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:84
icu::DecimalFormatSymbols::kPadEscapeSymbol
Escape padding character.
Definition: dcfmtsym.h:118
icu::DecimalFormatSymbols::kSixDigitSymbol
Six.
Definition: dcfmtsym.h:153
icu::DecimalFormatSymbols::kNaNSymbol
Nan symbol.
Definition: dcfmtsym.h:122
icu::DecimalFormatSymbols::kExponentMultiplicationSymbol
Multiplication sign.
Definition: dcfmtsym.h:169
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
icu::DecimalFormatSymbols::kPercentSymbol
The percent sign.
Definition: dcfmtsym.h:98
icu::DecimalFormatSymbols::kIntlCurrencySymbol
The international currency symbol.
Definition: dcfmtsym.h:110
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::DecimalFormatSymbols::kSevenDigitSymbol
Seven.
Definition: dcfmtsym.h:157
UCurrencySpacing
UCurrencySpacing
Constants for specifying currency spacing.
Definition: unum.h:319
icu::DecimalFormatSymbols::kPatternSeparatorSymbol
The pattern separator.
Definition: dcfmtsym.h:96
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
icu::DecimalFormatSymbols::kTwoDigitSymbol
Two.
Definition: dcfmtsym.h:137
u_charDigitValue
int32_t u_charDigitValue(UChar32 c)
Returns the decimal digit value of a decimal digit character.
ULOC_FULLNAME_CAPACITY
#define ULOC_FULLNAME_CAPACITY
Useful constant for the maximum size of the whole locale ID (including the terminating NULL and all k...
Definition: uloc.h:262
icu::DecimalFormatSymbols::ENumberFormatSymbol
ENumberFormatSymbol
Constants for specifying a number format symbol.
Definition: dcfmtsym.h:90
icu::DecimalFormatSymbols::kThreeDigitSymbol
Three.
Definition: dcfmtsym.h:141
icu::DecimalFormatSymbols::kMonetaryGroupingSeparatorSymbol
The monetary grouping separator.
Definition: dcfmtsym.h:129
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
icu::DecimalFormatSymbols::kZeroDigitSymbol
Zero.
Definition: dcfmtsym.h:100
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::DecimalFormatSymbols::kGroupingSeparatorSymbol
The grouping separator.
Definition: dcfmtsym.h:94
icu::DecimalFormatSymbols::operator!=
UBool operator!=(const DecimalFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition: dcfmtsym.h:247
icu::DecimalFormatSymbols::isCustomCurrencySymbol
UBool isCustomCurrencySymbol() const
Definition: dcfmtsym.h:362
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:332
TRUE
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:238
icu::DecimalFormatSymbols::kCurrencySymbol
The currency symbol.
Definition: dcfmtsym.h:108
icu::DecimalFormatSymbols::kMonetarySeparatorSymbol
The monetary separator.
Definition: dcfmtsym.h:112
uchar.h
C API: Unicode Properties.
uobject.h
C++ API: Common ICU base class UObject.
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:312
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
icu::DecimalFormatSymbols::kDecimalSeparatorSymbol
The decimal separator.
Definition: dcfmtsym.h:92
icu::DecimalFormatSymbols::kEightDigitSymbol
Eight.
Definition: dcfmtsym.h:161
icu::DecimalFormatSymbols::kNineDigitSymbol
Nine.
Definition: dcfmtsym.h:165
icu::UnicodeString::char32At
UChar32 char32At(int32_t offset) const
Return the code point that contains the code unit at offset offset.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:336
locid.h
C++ API: Locale ID object.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::DecimalFormatSymbols::kDigitSymbol
Character representing a digit in the pattern.
Definition: dcfmtsym.h:102
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:242
icu::UnicodeString::countChar32
int32_t countChar32(int32_t start=0, int32_t length=INT32_MAX) const
Count Unicode code points in the length UChar code units of the string.
icu::DecimalFormatSymbols::kFiveDigitSymbol
Five.
Definition: dcfmtsym.h:149
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
icu::DecimalFormatSymbols::kMinusSignSymbol
The minus sign.
Definition: dcfmtsym.h:104
icu::DecimalFormatSymbols::kPerMillSymbol
Per mill symbol - replaces kPermillSymbol.
Definition: dcfmtsym.h:116
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UNUM_CURRENCY_SPACING_COUNT
Definition: unum.h:327
icu::DecimalFormatSymbols::kSignificantDigitSymbol
Significant digit symbol.
Definition: dcfmtsym.h:125
icu::DecimalFormatSymbols::kOneDigitSymbol
One.
Definition: dcfmtsym.h:133
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
unum.h
C API: NumberFormat.
icu::DecimalFormatSymbols::kPlusSignSymbol
The plus sign.
Definition: dcfmtsym.h:106
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185