1 // Copyright (C) 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ********************************************************************** 5 * Copyright (c) 2004-2014, International Business Machines 6 * Corporation and others. All Rights Reserved. 7 ********************************************************************** 8 * Author: Alan Liu 9 * Created: April 26, 2004 10 * Since: ICU 3.0 11 ********************************************************************** 12 */ 13 #ifndef __CURRENCYUNIT_H__ 14 #define __CURRENCYUNIT_H__ 15 16 #include "unicode/utypes.h" 17 18 #if !UCONFIG_NO_FORMATTING 19 20 #include "unicode/measunit.h" 21 22 /** 23 * \file 24 * \brief C++ API: Currency Unit Information. 25 */ 26 27 U_NAMESPACE_BEGIN 28 29 /** 30 * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese 31 * yen). This class is a thin wrapper over a UChar string that 32 * subclasses MeasureUnit, for use with Measure and MeasureFormat. 33 * 34 * @author Alan Liu 35 * @stable ICU 3.0 36 */ 37 class U_I18N_API CurrencyUnit: public MeasureUnit { 38 public: 39 /** 40 * Construct an object with the given ISO currency code. 41 * @param isoCode the 3-letter ISO 4217 currency code; must not be 42 * NULL and must have length 3 43 * @param ec input-output error code. If the isoCode is invalid, 44 * then this will be set to a failing value. 45 * @stable ICU 3.0 46 */ 47 CurrencyUnit(const UChar* isoCode, UErrorCode &ec); 48 49 /** 50 * Copy constructor 51 * @stable ICU 3.0 52 */ 53 CurrencyUnit(const CurrencyUnit& other); 54 55 /** 56 * Assignment operator 57 * @stable ICU 3.0 58 */ 59 CurrencyUnit& operator=(const CurrencyUnit& other); 60 61 /** 62 * Return a polymorphic clone of this object. The result will 63 * have the same class as returned by getDynamicClassID(). 64 * @stable ICU 3.0 65 */ 66 virtual UObject* clone() const; 67 68 /** 69 * Destructor 70 * @stable ICU 3.0 71 */ 72 virtual ~CurrencyUnit(); 73 74 /** 75 * Returns a unique class ID for this object POLYMORPHICALLY. 76 * This method implements a simple form of RTTI used by ICU. 77 * @return The class ID for this object. All objects of a given 78 * class have the same class ID. Objects of other classes have 79 * different class IDs. 80 * @stable ICU 3.0 81 */ 82 virtual UClassID getDynamicClassID() const; 83 84 /** 85 * Returns the class ID for this class. This is used to compare to 86 * the return value of getDynamicClassID(). 87 * @return The class ID for all objects of this class. 88 * @stable ICU 3.0 89 */ 90 static UClassID U_EXPORT2 getStaticClassID(); 91 92 /** 93 * Return the ISO currency code of this object. 94 * @stable ICU 3.0 95 */ 96 inline const UChar* getISOCurrency() const; 97 98 private: 99 /** 100 * The ISO 4217 code of this object. 101 */ 102 UChar isoCode[4]; 103 }; 104 getISOCurrency()105inline const UChar* CurrencyUnit::getISOCurrency() const { 106 return isoCode; 107 } 108 109 U_NAMESPACE_END 110 111 #endif // !UCONFIG_NO_FORMATTING 112 #endif // __CURRENCYUNIT_H__ 113