]>
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 | ********************************************************************** | |
73c04bcf | 5 | * Copyright (c) 2004-2006, 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 __CURRENCYAMOUNT_H__ | |
14 | #define __CURRENCYAMOUNT_H__ | |
15 | ||
16 | #include "unicode/utypes.h" | |
17 | ||
18 | #if !UCONFIG_NO_FORMATTING | |
19 | ||
20 | #include "unicode/measure.h" | |
21 | #include "unicode/currunit.h" | |
22 | ||
73c04bcf A |
23 | /** |
24 | * \file | |
25 | * \brief C++ API: Currency Amount Object. | |
26 | */ | |
27 | ||
f3c0d7a5 | 28 | #if U_SHOW_CPLUSPLUS_API |
374ca955 A |
29 | U_NAMESPACE_BEGIN |
30 | ||
31 | /** | |
73c04bcf | 32 | * |
374ca955 A |
33 | * A currency together with a numeric amount, such as 200 USD. |
34 | * | |
35 | * @author Alan Liu | |
73c04bcf | 36 | * @stable ICU 3.0 |
374ca955 A |
37 | */ |
38 | class U_I18N_API CurrencyAmount: public Measure { | |
39 | public: | |
40 | /** | |
41 | * Construct an object with the given numeric amount and the given | |
42 | * ISO currency code. | |
43 | * @param amount a numeric object; amount.isNumeric() must be TRUE | |
44 | * @param isoCode the 3-letter ISO 4217 currency code; must not be | |
45 | * NULL and must have length 3 | |
46 | * @param ec input-output error code. If the amount or the isoCode | |
47 | * is invalid, then this will be set to a failing value. | |
73c04bcf | 48 | * @stable ICU 3.0 |
374ca955 | 49 | */ |
f3c0d7a5 | 50 | CurrencyAmount(const Formattable& amount, ConstChar16Ptr isoCode, |
374ca955 A |
51 | UErrorCode &ec); |
52 | ||
53 | /** | |
54 | * Construct an object with the given numeric amount and the given | |
55 | * ISO currency code. | |
56 | * @param amount the amount of the given currency | |
57 | * @param isoCode the 3-letter ISO 4217 currency code; must not be | |
58 | * NULL and must have length 3 | |
59 | * @param ec input-output error code. If the isoCode is invalid, | |
60 | * then this will be set to a failing value. | |
73c04bcf | 61 | * @stable ICU 3.0 |
374ca955 | 62 | */ |
f3c0d7a5 | 63 | CurrencyAmount(double amount, ConstChar16Ptr isoCode, |
374ca955 A |
64 | UErrorCode &ec); |
65 | ||
66 | /** | |
67 | * Copy constructor | |
73c04bcf | 68 | * @stable ICU 3.0 |
374ca955 A |
69 | */ |
70 | CurrencyAmount(const CurrencyAmount& other); | |
71 | ||
72 | /** | |
73 | * Assignment operator | |
73c04bcf | 74 | * @stable ICU 3.0 |
374ca955 A |
75 | */ |
76 | CurrencyAmount& operator=(const CurrencyAmount& other); | |
77 | ||
78 | /** | |
79 | * Return a polymorphic clone of this object. The result will | |
80 | * have the same class as returned by getDynamicClassID(). | |
73c04bcf | 81 | * @stable ICU 3.0 |
374ca955 A |
82 | */ |
83 | virtual UObject* clone() const; | |
84 | ||
85 | /** | |
86 | * Destructor | |
73c04bcf | 87 | * @stable ICU 3.0 |
374ca955 A |
88 | */ |
89 | virtual ~CurrencyAmount(); | |
90 | ||
91 | /** | |
92 | * Returns a unique class ID for this object POLYMORPHICALLY. | |
93 | * This method implements a simple form of RTTI used by ICU. | |
94 | * @return The class ID for this object. All objects of a given | |
95 | * class have the same class ID. Objects of other classes have | |
96 | * different class IDs. | |
73c04bcf | 97 | * @stable ICU 3.0 |
374ca955 A |
98 | */ |
99 | virtual UClassID getDynamicClassID() const; | |
100 | ||
101 | /** | |
102 | * Returns the class ID for this class. This is used to compare to | |
103 | * the return value of getDynamicClassID(). | |
104 | * @return The class ID for all objects of this class. | |
73c04bcf | 105 | * @stable ICU 3.0 |
374ca955 A |
106 | */ |
107 | static UClassID U_EXPORT2 getStaticClassID(); | |
108 | ||
109 | /** | |
110 | * Return the currency unit object of this object. | |
73c04bcf | 111 | * @stable ICU 3.0 |
374ca955 A |
112 | */ |
113 | inline const CurrencyUnit& getCurrency() const; | |
114 | ||
115 | /** | |
116 | * Return the ISO currency code of this object. | |
73c04bcf | 117 | * @stable ICU 3.0 |
374ca955 | 118 | */ |
f3c0d7a5 | 119 | inline const char16_t* getISOCurrency() const; |
374ca955 A |
120 | }; |
121 | ||
122 | inline const CurrencyUnit& CurrencyAmount::getCurrency() const { | |
123 | return (const CurrencyUnit&) getUnit(); | |
124 | } | |
125 | ||
f3c0d7a5 | 126 | inline const char16_t* CurrencyAmount::getISOCurrency() const { |
374ca955 A |
127 | return getCurrency().getISOCurrency(); |
128 | } | |
129 | ||
130 | U_NAMESPACE_END | |
f3c0d7a5 | 131 | #endif // U_SHOW_CPLUSPLUS_API |
374ca955 A |
132 | |
133 | #endif // !UCONFIG_NO_FORMATTING | |
134 | #endif // __CURRENCYAMOUNT_H__ |