xref: /aosp_15_r20/external/icu/libicu/cts_headers/number_currencysymbols.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1 // © 2018 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 #ifndef __SOURCE_NUMBER_CURRENCYSYMBOLS_H__
8 #define __SOURCE_NUMBER_CURRENCYSYMBOLS_H__
9 
10 #include "numparse_types.h"
11 #include "charstr.h"
12 #include "number_decimfmtprops.h"
13 
14 U_NAMESPACE_BEGIN
15 namespace number::impl {
16 
17 // Exported as U_I18N_API for tests
18 class U_I18N_API CurrencySymbols : public UMemory {
19   public:
20     CurrencySymbols() = default; // default constructor: leaves class in valid but undefined state
21 
22     /** Creates an instance in which all symbols are loaded from data. */
23     CurrencySymbols(CurrencyUnit currency, const Locale& locale, UErrorCode& status);
24 
25     /** Creates an instance in which some symbols might be pre-populated. */
26     CurrencySymbols(CurrencyUnit currency, const Locale& locale, const DecimalFormatSymbols& symbols,
27                     UErrorCode& status);
28 
29     const char16_t* getIsoCode() const;
30 
31     UnicodeString getNarrowCurrencySymbol(UErrorCode& status) const;
32 
33     UnicodeString getFormalCurrencySymbol(UErrorCode& status) const;
34 
35     UnicodeString getVariantCurrencySymbol(UErrorCode& status) const;
36 
37     UnicodeString getCurrencySymbol(UErrorCode& status) const;
38 
39     UnicodeString getIntlCurrencySymbol(UErrorCode& status) const;
40 
41     UnicodeString getPluralName(StandardPlural::Form plural, UErrorCode& status) const;
42 
43     bool hasEmptyCurrencySymbol() const;
44 
45   protected:
46     // Required fields:
47     CurrencyUnit fCurrency;
48     CharString fLocaleName;
49 
50     // Optional fields:
51     UnicodeString fCurrencySymbol;
52     UnicodeString fIntlCurrencySymbol;
53 
54     UnicodeString loadSymbol(UCurrNameStyle selector, UErrorCode& status) const;
55 };
56 
57 
58 /**
59  * Resolves the effective currency from the property bag.
60  */
61 CurrencyUnit
62 resolveCurrency(const DecimalFormatProperties& properties, const Locale& locale, UErrorCode& status);
63 
64 } // namespace number::impl
65 U_NAMESPACE_END
66 
67 #endif //__SOURCE_NUMBER_CURRENCYSYMBOLS_H__
68 #endif /* #if !UCONFIG_NO_FORMATTING */
69