]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
374ca955 A |
3 | /* |
4 | ********************************************************************** | |
57a6839d | 5 | * Copyright (c) 2004-2014, International Business Machines |
374ca955 A |
6 | * Corporation and others. All Rights Reserved. |
7 | ********************************************************************** | |
8 | * Author: Alan Liu | |
9 | * Created: April 26, 2004 | |
10 | * Since: ICU 3.0 | |
11 | ********************************************************************** | |
12 | */ | |
13 | #ifndef __CURRENCYUNIT_H__ | |
14 | #define __CURRENCYUNIT_H__ | |
15 | ||
16 | #include "unicode/utypes.h" | |
17 | ||
340931cb A |
18 | #if U_SHOW_CPLUSPLUS_API |
19 | ||
374ca955 A |
20 | #if !UCONFIG_NO_FORMATTING |
21 | ||
22 | #include "unicode/measunit.h" | |
23 | ||
73c04bcf A |
24 | /** |
25 | * \file | |
26 | * \brief C++ API: Currency Unit Information. | |
27 | */ | |
28 | ||
374ca955 A |
29 | U_NAMESPACE_BEGIN |
30 | ||
31 | /** | |
32 | * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese | |
f3c0d7a5 | 33 | * yen). This class is a thin wrapper over a char16_t string that |
374ca955 A |
34 | * subclasses MeasureUnit, for use with Measure and MeasureFormat. |
35 | * | |
36 | * @author Alan Liu | |
73c04bcf | 37 | * @stable ICU 3.0 |
374ca955 A |
38 | */ |
39 | class U_I18N_API CurrencyUnit: public MeasureUnit { | |
40 | public: | |
0f5d89e8 A |
41 | /** |
42 | * Default constructor. Initializes currency code to "XXX" (no currency). | |
3d1f044b | 43 | * @stable ICU 60 |
0f5d89e8 A |
44 | */ |
45 | CurrencyUnit(); | |
46 | ||
374ca955 A |
47 | /** |
48 | * Construct an object with the given ISO currency code. | |
3d1f044b | 49 | * |
0f5d89e8 A |
50 | * @param isoCode the 3-letter ISO 4217 currency code; must have |
51 | * length 3 and need not be NUL-terminated. If NULL, the currency | |
52 | * is initialized to the unknown currency XXX. | |
374ca955 A |
53 | * @param ec input-output error code. If the isoCode is invalid, |
54 | * then this will be set to a failing value. | |
73c04bcf | 55 | * @stable ICU 3.0 |
374ca955 | 56 | */ |
f3c0d7a5 | 57 | CurrencyUnit(ConstChar16Ptr isoCode, UErrorCode &ec); |
374ca955 | 58 | |
3d1f044b A |
59 | #ifndef U_HIDE_DRAFT_API |
60 | /** | |
61 | * Construct an object with the given ISO currency code. | |
62 | * | |
63 | * @param isoCode the 3-letter ISO 4217 currency code; must have | |
64 | * length 3. If invalid, the currency is initialized to XXX. | |
65 | * @param ec input-output error code. If the isoCode is invalid, | |
66 | * then this will be set to a failing value. | |
67 | * @draft ICU 64 | |
68 | */ | |
69 | CurrencyUnit(StringPiece isoCode, UErrorCode &ec); | |
70 | #endif /* U_HIDE_DRAFT_API */ | |
71 | ||
374ca955 A |
72 | /** |
73 | * Copy constructor | |
73c04bcf | 74 | * @stable ICU 3.0 |
374ca955 A |
75 | */ |
76 | CurrencyUnit(const CurrencyUnit& other); | |
77 | ||
0f5d89e8 A |
78 | /** |
79 | * Copy constructor from MeasureUnit. This constructor allows you to | |
80 | * restore a CurrencyUnit that was sliced to MeasureUnit. | |
81 | * | |
82 | * @param measureUnit The MeasureUnit to copy from. | |
83 | * @param ec Set to a failing value if the MeasureUnit is not a currency. | |
3d1f044b | 84 | * @stable ICU 60 |
0f5d89e8 A |
85 | */ |
86 | CurrencyUnit(const MeasureUnit& measureUnit, UErrorCode &ec); | |
0f5d89e8 | 87 | |
374ca955 A |
88 | /** |
89 | * Assignment operator | |
73c04bcf | 90 | * @stable ICU 3.0 |
374ca955 A |
91 | */ |
92 | CurrencyUnit& operator=(const CurrencyUnit& other); | |
93 | ||
94 | /** | |
95 | * Return a polymorphic clone of this object. The result will | |
96 | * have the same class as returned by getDynamicClassID(). | |
73c04bcf | 97 | * @stable ICU 3.0 |
374ca955 | 98 | */ |
340931cb | 99 | virtual CurrencyUnit* clone() const; |
374ca955 A |
100 | |
101 | /** | |
102 | * Destructor | |
73c04bcf | 103 | * @stable ICU 3.0 |
374ca955 A |
104 | */ |
105 | virtual ~CurrencyUnit(); | |
106 | ||
374ca955 A |
107 | /** |
108 | * Returns a unique class ID for this object POLYMORPHICALLY. | |
109 | * This method implements a simple form of RTTI used by ICU. | |
110 | * @return The class ID for this object. All objects of a given | |
111 | * class have the same class ID. Objects of other classes have | |
112 | * different class IDs. | |
73c04bcf | 113 | * @stable ICU 3.0 |
374ca955 A |
114 | */ |
115 | virtual UClassID getDynamicClassID() const; | |
116 | ||
117 | /** | |
118 | * Returns the class ID for this class. This is used to compare to | |
119 | * the return value of getDynamicClassID(). | |
120 | * @return The class ID for all objects of this class. | |
73c04bcf | 121 | * @stable ICU 3.0 |
374ca955 A |
122 | */ |
123 | static UClassID U_EXPORT2 getStaticClassID(); | |
124 | ||
125 | /** | |
126 | * Return the ISO currency code of this object. | |
73c04bcf | 127 | * @stable ICU 3.0 |
374ca955 | 128 | */ |
f3c0d7a5 | 129 | inline const char16_t* getISOCurrency() const; |
374ca955 A |
130 | |
131 | private: | |
132 | /** | |
133 | * The ISO 4217 code of this object. | |
134 | */ | |
f3c0d7a5 | 135 | char16_t isoCode[4]; |
374ca955 A |
136 | }; |
137 | ||
f3c0d7a5 | 138 | inline const char16_t* CurrencyUnit::getISOCurrency() const { |
374ca955 A |
139 | return isoCode; |
140 | } | |
141 | ||
142 | U_NAMESPACE_END | |
143 | ||
144 | #endif // !UCONFIG_NO_FORMATTING | |
340931cb A |
145 | |
146 | #endif /* U_SHOW_CPLUSPLUS_API */ | |
147 | ||
374ca955 | 148 | #endif // __CURRENCYUNIT_H__ |