2 **********************************************************************
3 * Copyright (c) 2004, 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"
24 * A currency together with a numeric amount, such as 200 USD.
29 class U_I18N_API CurrencyAmount
: public Measure
{
32 * Construct an object with the given numeric amount and the given
34 * @param amount a numeric object; amount.isNumeric() must be TRUE
35 * @param isoCode the 3-letter ISO 4217 currency code; must not be
36 * NULL and must have length 3
37 * @param ec input-output error code. If the amount or the isoCode
38 * is invalid, then this will be set to a failing value.
41 CurrencyAmount(const Formattable
& amount
, const UChar
* isoCode
,
45 * Construct an object with the given numeric amount and the given
47 * @param amount the amount of the given currency
48 * @param isoCode the 3-letter ISO 4217 currency code; must not be
49 * NULL and must have length 3
50 * @param ec input-output error code. If the isoCode is invalid,
51 * then this will be set to a failing value.
54 CurrencyAmount(double amount
, const UChar
* isoCode
,
61 CurrencyAmount(const CurrencyAmount
& other
);
67 CurrencyAmount
& operator=(const CurrencyAmount
& other
);
70 * Return a polymorphic clone of this object. The result will
71 * have the same class as returned by getDynamicClassID().
74 virtual UObject
* clone() const;
80 virtual ~CurrencyAmount();
83 * Returns a unique class ID for this object POLYMORPHICALLY.
84 * This method implements a simple form of RTTI used by ICU.
85 * @return The class ID for this object. All objects of a given
86 * class have the same class ID. Objects of other classes have
87 * different class IDs.
90 virtual UClassID
getDynamicClassID() const;
93 * Returns the class ID for this class. This is used to compare to
94 * the return value of getDynamicClassID().
95 * @return The class ID for all objects of this class.
98 static UClassID U_EXPORT2
getStaticClassID();
101 * Return the currency unit object of this object.
104 inline const CurrencyUnit
& getCurrency() const;
107 * Return the ISO currency code of this object.
110 inline const UChar
* getISOCurrency() const;
113 inline const CurrencyUnit
& CurrencyAmount::getCurrency() const {
114 return (const CurrencyUnit
&) getUnit();
117 inline const UChar
* CurrencyAmount::getISOCurrency() const {
118 return getCurrency().getISOCurrency();
123 #endif // !UCONFIG_NO_FORMATTING
124 #endif // __CURRENCYAMOUNT_H__