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