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