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