michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (c) 2004-2006, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Author: Alan Liu michael@0: * Created: April 26, 2004 michael@0: * Since: ICU 3.0 michael@0: ********************************************************************** michael@0: */ michael@0: #ifndef __CURRENCYAMOUNT_H__ michael@0: #define __CURRENCYAMOUNT_H__ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/measure.h" michael@0: #include "unicode/currunit.h" michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C++ API: Currency Amount Object. michael@0: */ michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * michael@0: * A currency together with a numeric amount, such as 200 USD. michael@0: * michael@0: * @author Alan Liu michael@0: * @stable ICU 3.0 michael@0: */ michael@0: class U_I18N_API CurrencyAmount: public Measure { michael@0: public: michael@0: /** michael@0: * Construct an object with the given numeric amount and the given michael@0: * ISO currency code. michael@0: * @param amount a numeric object; amount.isNumeric() must be TRUE michael@0: * @param isoCode the 3-letter ISO 4217 currency code; must not be michael@0: * NULL and must have length 3 michael@0: * @param ec input-output error code. If the amount or the isoCode michael@0: * is invalid, then this will be set to a failing value. michael@0: * @stable ICU 3.0 michael@0: */ michael@0: CurrencyAmount(const Formattable& amount, const UChar* isoCode, michael@0: UErrorCode &ec); michael@0: michael@0: /** michael@0: * Construct an object with the given numeric amount and the given michael@0: * ISO currency code. michael@0: * @param amount the amount of the given currency michael@0: * @param isoCode the 3-letter ISO 4217 currency code; must not be michael@0: * NULL and must have length 3 michael@0: * @param ec input-output error code. If the isoCode is invalid, michael@0: * then this will be set to a failing value. michael@0: * @stable ICU 3.0 michael@0: */ michael@0: CurrencyAmount(double amount, const UChar* isoCode, michael@0: UErrorCode &ec); michael@0: michael@0: /** michael@0: * Copy constructor michael@0: * @stable ICU 3.0 michael@0: */ michael@0: CurrencyAmount(const CurrencyAmount& other); michael@0: michael@0: /** michael@0: * Assignment operator michael@0: * @stable ICU 3.0 michael@0: */ michael@0: CurrencyAmount& operator=(const CurrencyAmount& other); michael@0: michael@0: /** michael@0: * Return a polymorphic clone of this object. The result will michael@0: * have the same class as returned by getDynamicClassID(). michael@0: * @stable ICU 3.0 michael@0: */ michael@0: virtual UObject* clone() const; michael@0: michael@0: /** michael@0: * Destructor michael@0: * @stable ICU 3.0 michael@0: */ michael@0: virtual ~CurrencyAmount(); michael@0: michael@0: /** michael@0: * Returns a unique class ID for this object POLYMORPHICALLY. michael@0: * This method implements a simple form of RTTI used by ICU. michael@0: * @return The class ID for this object. All objects of a given michael@0: * class have the same class ID. Objects of other classes have michael@0: * different class IDs. michael@0: * @stable ICU 3.0 michael@0: */ michael@0: virtual UClassID getDynamicClassID() const; michael@0: michael@0: /** michael@0: * Returns the class ID for this class. This is used to compare to michael@0: * the return value of getDynamicClassID(). michael@0: * @return The class ID for all objects of this class. michael@0: * @stable ICU 3.0 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(); michael@0: michael@0: /** michael@0: * Return the currency unit object of this object. michael@0: * @stable ICU 3.0 michael@0: */ michael@0: inline const CurrencyUnit& getCurrency() const; michael@0: michael@0: /** michael@0: * Return the ISO currency code of this object. michael@0: * @stable ICU 3.0 michael@0: */ michael@0: inline const UChar* getISOCurrency() const; michael@0: }; michael@0: michael@0: inline const CurrencyUnit& CurrencyAmount::getCurrency() const { michael@0: return (const CurrencyUnit&) getUnit(); michael@0: } michael@0: michael@0: inline const UChar* CurrencyAmount::getISOCurrency() const { michael@0: return getCurrency().getISOCurrency(); michael@0: } michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif // !UCONFIG_NO_FORMATTING michael@0: #endif // __CURRENCYAMOUNT_H__