LEFT | RIGHT |
(no file at all) | |
| 1 // © 2016 and later: Unicode, Inc. and others. |
| 2 // License & terms of use: http://www.unicode.org/copyright.html |
| 3 |
| 4 #include "unicode/utypes.h" |
| 5 |
| 6 #if !UCONFIG_NO_FORMATTING |
| 7 |
| 8 #include "hash.h" |
| 9 #include "standardplural.h" |
| 10 |
| 11 U_NAMESPACE_BEGIN |
| 12 |
| 13 /** |
| 14 * In ICU4J, there is a currencyStrings array. |
| 15 * In ICU4C, this struct is used instead. |
| 16 */ |
| 17 struct CurrencyStrings { |
| 18 const UChar* displayName; |
| 19 const UChar* symbol; |
| 20 const UChar* narrowSymbol; |
| 21 const UChar* formatPattern; |
| 22 const UChar* decimalSeparator; |
| 23 const UChar* groupingSeparator; |
| 24 const UChar* pluralNames[StandardPlural::COUNT]; |
| 25 }; |
| 26 |
| 27 /** |
| 28 * The primary data structure is isoCodeToCurrencyStrings. In that structure, |
| 29 * the String arrays contain the following elements: |
| 30 * |
| 31 * [DISPLAY_NAME] => display name |
| 32 * [SYMBOL] => symbol |
| 33 * [NARROW_SYMBOL] => narrow symbol |
| 34 * [FORMAT_PATTERN] => currency format pattern |
| 35 * [DECIMAL_SEPARATOR] => currency decimal separator |
| 36 * [GROUPING_SEPARATOR] => currency grouping separator |
| 37 * [PLURALS_OFFSET+p] => plural name where p=standardPlural.ordinal() |
| 38 */ |
| 39 struct RawCurrencyData { |
| 40 // No copying for now. |
| 41 RawCurrencyData(const RawCurrencyData& other) = delete; |
| 42 const RawCurrencyData& operator=(const RawCurrencyData& other) = delete; |
| 43 |
| 44 // ICU4J: HashMap<String, String[]> |
| 45 Hashtable* isoCodeToCurrencyStrings = nullptr; |
| 46 |
| 47 // Other currency-related data |
| 48 CurrencySpacingInfo spacingInfo = new CurrencySpacingInfo(); |
| 49 Map<String, String> currencyUnitPatterns = new HashMap<String, String>(); |
| 50 |
| 51 // TODO: Add data structures for parsing, like symbolToIsoCode and nameToIso
Code in ICU4J. |
| 52 |
| 53 /** |
| 54 * Gets an entry out of isoCodeToCurrencyStrings or creates it if it does no
t exist yet. |
| 55 */ |
| 56 String[] getOrCreateCurrencyStrings(String isoCode) { |
| 57 String[] currencyStrings = isoCodeToCurrencyStrings.get(isoCode); |
| 58 if (currencyStrings == null) { |
| 59 currencyStrings = new String[CURRENCY_STRINGS_LENGTH]; |
| 60 isoCodeToCurrencyStrings.put(isoCode, currencyStrings); |
| 61 } |
| 62 return currencyStrings; |
| 63 } |
| 64 |
| 65 /** |
| 66 * Called after all data is loaded to convert the externally visible Maps
to Unmodifiable. |
| 67 */ |
| 68 void freezeMaps() { |
| 69 symbolToIsoCode = Collections.unmodifiableMap(symbolToIsoCode); |
| 70 nameToIsoCode = Collections.unmodifiableMap(nameToIsoCode); |
| 71 currencyUnitPatterns = Collections.unmodifiableMap(currencyUnitPatterns)
; |
| 72 } |
| 73 } |
| 74 |
| 75 U_NAMESPACE_END |
| 76 |
| 77 #endif // !UCONFIG_NO_FORMATTING |
LEFT | RIGHT |