ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dcfmtsym.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2009, 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 
30 #if !UCONFIG_NO_FORMATTING
31 
32 #include "unicode/uobject.h"
33 #include "unicode/locid.h"
34 
42 
83 public:
129  kFormatSymbolCount
130  };
131 
137  kCurrencyMatch,
138  kSurroundingMatch,
139  kInsert,
140  kCurrencySpacingCount
141  };
142 
151  DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
152 
164 
170 
175  DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
176 
181  virtual ~DecimalFormatSymbols();
182 
190  UBool operator==(const DecimalFormatSymbols& other) const;
191 
199  UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
200 
210  inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
211 
221  void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value);
222 
227  inline Locale getLocale() const;
228 
234  Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
235 
252  const UnicodeString& getPatternForCurrencySpacing(ECurrencySpacing type,
253  UBool beforeCurrency,
254  UErrorCode& status) const;
265  void setPatternForCurrencySpacing(ECurrencySpacing type,
266  UBool beforeCurrency,
267  const UnicodeString& pattern);
268 
274  virtual UClassID getDynamicClassID() const;
275 
281  static UClassID U_EXPORT2 getStaticClassID();
282 
283 private:
284  DecimalFormatSymbols(); // default constructor not implemented
285 
296  void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
297 
305  void initialize(const UChar** numberElements, int32_t *numberElementsStrLen, int32_t numberElementsLength);
306 
310  void initialize();
311 
312  void setCurrencyForSymbols();
313 
314 public:
326  inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
327 
332  inline const UChar* getCurrencyPattern(void) const;
333 
334 private:
350  UnicodeString fSymbols[kFormatSymbolCount];
351 
356  UnicodeString fNoSymbol;
357 
358  Locale locale;
359 
360  char actualLocale[ULOC_FULLNAME_CAPACITY];
361  char validLocale[ULOC_FULLNAME_CAPACITY];
362  const UChar* currPattern;
363 
364  UnicodeString currencySpcBeforeSym[kCurrencySpacingCount];
365  UnicodeString currencySpcAfterSym[kCurrencySpacingCount];
366 };
367 
368 // -------------------------------------
369 
370 inline UnicodeString
372  const UnicodeString *strPtr;
373  if(symbol < kFormatSymbolCount) {
374  strPtr = &fSymbols[symbol];
375  } else {
376  strPtr = &fNoSymbol;
377  }
378  return *strPtr;
379 }
380 
381 inline const UnicodeString &
383  const UnicodeString *strPtr;
384  if(symbol < kFormatSymbolCount) {
385  strPtr = &fSymbols[symbol];
386  } else {
387  strPtr = &fNoSymbol;
388  }
389  return *strPtr;
390 }
391 
392 // -------------------------------------
393 
394 inline void
396  if(symbol<kFormatSymbolCount) {
397  fSymbols[symbol]=value;
398  }
399 }
400 
401 // -------------------------------------
402 
403 inline Locale
405  return locale;
406 }
407 
408 inline const UChar*
410  return currPattern;
411 }
413 
414 #endif /* #if !UCONFIG_NO_FORMATTING */
415 
416 #endif // _DCFMTSYM
417 //eof
const UChar * getCurrencyPattern(void) const
Returns that pattern stored in currecy info.
Definition: dcfmtsym.h:409
Locale getLocale() const
Returns the locale for which this object was constructed.
Definition: dcfmtsym.h:404
Character representing a digit in the pattern.
Definition: dcfmtsym.h:100
#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
This class represents the set of symbols needed by DecimalFormat to format numbers.
Definition: dcfmtsym.h:82
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:475
void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value)
Set one of the format symbols by its enum constant.
Definition: dcfmtsym.h:395
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:183
Per mill symbol - replaces kPermillSymbol.
Definition: dcfmtsym.h:114
ENumberFormatSymbol
Constants for specifying a number format symbol.
Definition: dcfmtsym.h:88
UBool operator!=(const DecimalFormatSymbols &other) const
Return true if another object is semantically unequal to this one.
Definition: dcfmtsym.h:199
The international currency symbol.
Definition: dcfmtsym.h:108
const UnicodeString & getConstSymbol(ENumberFormatSymbol symbol) const
Internal function - more efficient version of getSymbol, returning a const reference to one of the sy...
Definition: dcfmtsym.h:382
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
#define U_EXPORT2
Definition: platform.h:338
C++ API: Common ICU base class UObject.
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:299
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API If the compiler doesn&#39;t support namespaces...
Definition: uversion.h:184
UObject is the common ICU &quot;boilerplate&quot; class.
Definition: uobject.h:212
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:339
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:314
C++ API: Locale ID object.
Basic definitions for ICU, for both C and C++ APIs.
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:216
ECurrencySpacing
Constants for specifying currency spacing.
Definition: dcfmtsym.h:136
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:181
UnicodeString getSymbol(ENumberFormatSymbol symbol) const
Get one of the format symbols by its enum constant.
Definition: dcfmtsym.h:371
virtual UClassID getDynamicClassID() const =0
ICU4C &quot;poor man&#39;s RTTI&quot;, returns a UClassID for the actual ICU class.
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
The exponential symbol.
Definition: dcfmtsym.h:112
Escape padding character.
Definition: dcfmtsym.h:116
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208