Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ********************************************************************** |
michael@0 | 3 | * Copyright (c) 2004-2006, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * Author: Alan Liu |
michael@0 | 7 | * Created: April 26, 2004 |
michael@0 | 8 | * Since: ICU 3.0 |
michael@0 | 9 | ********************************************************************** |
michael@0 | 10 | */ |
michael@0 | 11 | #ifndef __CURRENCYAMOUNT_H__ |
michael@0 | 12 | #define __CURRENCYAMOUNT_H__ |
michael@0 | 13 | |
michael@0 | 14 | #include "unicode/utypes.h" |
michael@0 | 15 | |
michael@0 | 16 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 17 | |
michael@0 | 18 | #include "unicode/measure.h" |
michael@0 | 19 | #include "unicode/currunit.h" |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * \file |
michael@0 | 23 | * \brief C++ API: Currency Amount Object. |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | U_NAMESPACE_BEGIN |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * |
michael@0 | 30 | * A currency together with a numeric amount, such as 200 USD. |
michael@0 | 31 | * |
michael@0 | 32 | * @author Alan Liu |
michael@0 | 33 | * @stable ICU 3.0 |
michael@0 | 34 | */ |
michael@0 | 35 | class U_I18N_API CurrencyAmount: public Measure { |
michael@0 | 36 | public: |
michael@0 | 37 | /** |
michael@0 | 38 | * Construct an object with the given numeric amount and the given |
michael@0 | 39 | * ISO currency code. |
michael@0 | 40 | * @param amount a numeric object; amount.isNumeric() must be TRUE |
michael@0 | 41 | * @param isoCode the 3-letter ISO 4217 currency code; must not be |
michael@0 | 42 | * NULL and must have length 3 |
michael@0 | 43 | * @param ec input-output error code. If the amount or the isoCode |
michael@0 | 44 | * is invalid, then this will be set to a failing value. |
michael@0 | 45 | * @stable ICU 3.0 |
michael@0 | 46 | */ |
michael@0 | 47 | CurrencyAmount(const Formattable& amount, const UChar* isoCode, |
michael@0 | 48 | UErrorCode &ec); |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Construct an object with the given numeric amount and the given |
michael@0 | 52 | * ISO currency code. |
michael@0 | 53 | * @param amount the amount of the given currency |
michael@0 | 54 | * @param isoCode the 3-letter ISO 4217 currency code; must not be |
michael@0 | 55 | * NULL and must have length 3 |
michael@0 | 56 | * @param ec input-output error code. If the isoCode is invalid, |
michael@0 | 57 | * then this will be set to a failing value. |
michael@0 | 58 | * @stable ICU 3.0 |
michael@0 | 59 | */ |
michael@0 | 60 | CurrencyAmount(double amount, const UChar* isoCode, |
michael@0 | 61 | UErrorCode &ec); |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * Copy constructor |
michael@0 | 65 | * @stable ICU 3.0 |
michael@0 | 66 | */ |
michael@0 | 67 | CurrencyAmount(const CurrencyAmount& other); |
michael@0 | 68 | |
michael@0 | 69 | /** |
michael@0 | 70 | * Assignment operator |
michael@0 | 71 | * @stable ICU 3.0 |
michael@0 | 72 | */ |
michael@0 | 73 | CurrencyAmount& operator=(const CurrencyAmount& other); |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * Return a polymorphic clone of this object. The result will |
michael@0 | 77 | * have the same class as returned by getDynamicClassID(). |
michael@0 | 78 | * @stable ICU 3.0 |
michael@0 | 79 | */ |
michael@0 | 80 | virtual UObject* clone() const; |
michael@0 | 81 | |
michael@0 | 82 | /** |
michael@0 | 83 | * Destructor |
michael@0 | 84 | * @stable ICU 3.0 |
michael@0 | 85 | */ |
michael@0 | 86 | virtual ~CurrencyAmount(); |
michael@0 | 87 | |
michael@0 | 88 | /** |
michael@0 | 89 | * Returns a unique class ID for this object POLYMORPHICALLY. |
michael@0 | 90 | * This method implements a simple form of RTTI used by ICU. |
michael@0 | 91 | * @return The class ID for this object. All objects of a given |
michael@0 | 92 | * class have the same class ID. Objects of other classes have |
michael@0 | 93 | * different class IDs. |
michael@0 | 94 | * @stable ICU 3.0 |
michael@0 | 95 | */ |
michael@0 | 96 | virtual UClassID getDynamicClassID() const; |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Returns the class ID for this class. This is used to compare to |
michael@0 | 100 | * the return value of getDynamicClassID(). |
michael@0 | 101 | * @return The class ID for all objects of this class. |
michael@0 | 102 | * @stable ICU 3.0 |
michael@0 | 103 | */ |
michael@0 | 104 | static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 105 | |
michael@0 | 106 | /** |
michael@0 | 107 | * Return the currency unit object of this object. |
michael@0 | 108 | * @stable ICU 3.0 |
michael@0 | 109 | */ |
michael@0 | 110 | inline const CurrencyUnit& getCurrency() const; |
michael@0 | 111 | |
michael@0 | 112 | /** |
michael@0 | 113 | * Return the ISO currency code of this object. |
michael@0 | 114 | * @stable ICU 3.0 |
michael@0 | 115 | */ |
michael@0 | 116 | inline const UChar* getISOCurrency() const; |
michael@0 | 117 | }; |
michael@0 | 118 | |
michael@0 | 119 | inline const CurrencyUnit& CurrencyAmount::getCurrency() const { |
michael@0 | 120 | return (const CurrencyUnit&) getUnit(); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | inline const UChar* CurrencyAmount::getISOCurrency() const { |
michael@0 | 124 | return getCurrency().getISOCurrency(); |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | U_NAMESPACE_END |
michael@0 | 128 | |
michael@0 | 129 | #endif // !UCONFIG_NO_FORMATTING |
michael@0 | 130 | #endif // __CURRENCYAMOUNT_H__ |