2 **********************************************************************
3 * Copyright (c) 2004-2006, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
7 * Created: April 26, 2004
9 **********************************************************************
11 #ifndef __CURRENCYAMOUNT_H__
12 #define __CURRENCYAMOUNT_H__
14 #include "unicode/utypes.h"
16 #if !UCONFIG_NO_FORMATTING
18 #include "unicode/measure.h"
19 #include "unicode/currunit.h"
23 * \brief C++ API: Currency Amount Object.
30 * A currency together with a numeric amount, such as 200 USD.
35 class U_I18N_API CurrencyAmount
: public Measure
{
38 * Construct an object with the given numeric amount and the given
40 * @param amount a numeric object; amount.isNumeric() must be TRUE
41 * @param isoCode the 3-letter ISO 4217 currency code; must not be
42 * NULL and must have length 3
43 * @param ec input-output error code. If the amount or the isoCode
44 * is invalid, then this will be set to a failing value.
47 CurrencyAmount(const Formattable
& amount
, const UChar
* isoCode
,
51 * Construct an object with the given numeric amount and the given
53 * @param amount the amount of the given currency
54 * @param isoCode the 3-letter ISO 4217 currency code; must not be
55 * NULL and must have length 3
56 * @param ec input-output error code. If the isoCode is invalid,
57 * then this will be set to a failing value.
60 CurrencyAmount(double amount
, const UChar
* isoCode
,
67 CurrencyAmount(const CurrencyAmount
& other
);
73 CurrencyAmount
& operator=(const CurrencyAmount
& other
);
76 * Return a polymorphic clone of this object. The result will
77 * have the same class as returned by getDynamicClassID().
80 virtual UObject
* clone() const;
86 virtual ~CurrencyAmount();
89 * Returns a unique class ID for this object POLYMORPHICALLY.
90 * This method implements a simple form of RTTI used by ICU.
91 * @return The class ID for this object. All objects of a given
92 * class have the same class ID. Objects of other classes have
93 * different class IDs.
96 virtual UClassID
getDynamicClassID() const;
99 * Returns the class ID for this class. This is used to compare to
100 * the return value of getDynamicClassID().
101 * @return The class ID for all objects of this class.
104 static UClassID U_EXPORT2
getStaticClassID();
107 * Return the currency unit object of this object.
110 inline const CurrencyUnit
& getCurrency() const;
113 * Return the ISO currency code of this object.
116 inline const UChar
* getISOCurrency() const;
119 inline const CurrencyUnit
& CurrencyAmount::getCurrency() const {
120 return (const CurrencyUnit
&) getUnit();
123 inline const UChar
* CurrencyAmount::getISOCurrency() const {
124 return getCurrency().getISOCurrency();
129 #endif // !UCONFIG_NO_FORMATTING
130 #endif // __CURRENCYAMOUNT_H__