1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (c) 2004-2006, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
9 * Created: April 26, 2004
11 **********************************************************************
13 #ifndef __CURRENCYAMOUNT_H__
14 #define __CURRENCYAMOUNT_H__
16 #include "unicode/utypes.h"
18 #if U_SHOW_CPLUSPLUS_API
20 #if !UCONFIG_NO_FORMATTING
22 #include "unicode/measure.h"
23 #include "unicode/currunit.h"
27 * \brief C++ API: Currency Amount Object.
34 * A currency together with a numeric amount, such as 200 USD.
39 class U_I18N_API CurrencyAmount
: public Measure
{
42 * Construct an object with the given numeric amount and the given
44 * @param amount a numeric object; amount.isNumeric() must be TRUE
45 * @param isoCode the 3-letter ISO 4217 currency code; must not be
46 * NULL and must have length 3
47 * @param ec input-output error code. If the amount or the isoCode
48 * is invalid, then this will be set to a failing value.
51 CurrencyAmount(const Formattable
& amount
, ConstChar16Ptr isoCode
,
55 * Construct an object with the given numeric amount and the given
57 * @param amount the amount of the given currency
58 * @param isoCode the 3-letter ISO 4217 currency code; must not be
59 * NULL and must have length 3
60 * @param ec input-output error code. If the isoCode is invalid,
61 * then this will be set to a failing value.
64 CurrencyAmount(double amount
, ConstChar16Ptr isoCode
,
71 CurrencyAmount(const CurrencyAmount
& other
);
77 CurrencyAmount
& operator=(const CurrencyAmount
& other
);
80 * Return a polymorphic clone of this object. The result will
81 * have the same class as returned by getDynamicClassID().
84 virtual CurrencyAmount
* clone() const;
90 virtual ~CurrencyAmount();
93 * Returns a unique class ID for this object POLYMORPHICALLY.
94 * This method implements a simple form of RTTI used by ICU.
95 * @return The class ID for this object. All objects of a given
96 * class have the same class ID. Objects of other classes have
97 * different class IDs.
100 virtual UClassID
getDynamicClassID() const;
103 * Returns the class ID for this class. This is used to compare to
104 * the return value of getDynamicClassID().
105 * @return The class ID for all objects of this class.
108 static UClassID U_EXPORT2
getStaticClassID();
111 * Return the currency unit object of this object.
114 inline const CurrencyUnit
& getCurrency() const;
117 * Return the ISO currency code of this object.
120 inline const char16_t* getISOCurrency() const;
123 inline const CurrencyUnit
& CurrencyAmount::getCurrency() const {
124 return (const CurrencyUnit
&) getUnit();
127 inline const char16_t* CurrencyAmount::getISOCurrency() const {
128 return getCurrency().getISOCurrency();
133 #endif // !UCONFIG_NO_FORMATTING
135 #endif /* U_SHOW_CPLUSPLUS_API */
137 #endif // __CURRENCYAMOUNT_H__