1 // © 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 char16_t 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 * Default constructor. Initializes currency code to "XXX" (no currency). 41 * @draft ICU 60 42 */ 43 CurrencyUnit(); 44 45 /** 46 * Construct an object with the given ISO currency code. 47 * @param isoCode the 3-letter ISO 4217 currency code; must not be 48 * NULL and must have length 3 49 * @param ec input-output error code. If the isoCode is invalid, 50 * then this will be set to a failing value. 51 * @stable ICU 3.0 52 */ 53 CurrencyUnit(ConstChar16Ptr isoCode, UErrorCode &ec); 54 55 /** 56 * Copy constructor 57 * @stable ICU 3.0 58 */ 59 CurrencyUnit(const CurrencyUnit& other); 60 61 #ifndef U_HIDE_DRAFT_API 62 /** 63 * Copy constructor from MeasureUnit. This constructor allows you to 64 * restore a CurrencyUnit that was sliced to MeasureUnit. 65 * 66 * @param measureUnit The MeasureUnit to copy from. 67 * @param ec Set to a failing value if the MeasureUnit is not a currency. 68 * @draft ICU 60 69 */ 70 CurrencyUnit(const MeasureUnit& measureUnit, UErrorCode &ec); 71 #endif /* U_HIDE_DRAFT_API */ 72 73 /** 74 * Assignment operator 75 * @stable ICU 3.0 76 */ 77 CurrencyUnit& operator=(const CurrencyUnit& other); 78 79 /** 80 * Return a polymorphic clone of this object. The result will 81 * have the same class as returned by getDynamicClassID(). 82 * @stable ICU 3.0 83 */ 84 virtual UObject* clone() const; 85 86 /** 87 * Destructor 88 * @stable ICU 3.0 89 */ 90 virtual ~CurrencyUnit(); 91 92 /** 93 * Returns a unique class ID for this object POLYMORPHICALLY. 94 * This method implements a simple form of RTTI used by ICU. 95 * @return The class ID for this object. All objects of a given 96 * class have the same class ID. Objects of other classes have 97 * different class IDs. 98 * @stable ICU 3.0 99 */ 100 virtual UClassID getDynamicClassID() const; 101 102 /** 103 * Returns the class ID for this class. This is used to compare to 104 * the return value of getDynamicClassID(). 105 * @return The class ID for all objects of this class. 106 * @stable ICU 3.0 107 */ 108 static UClassID U_EXPORT2 getStaticClassID(); 109 110 /** 111 * Return the ISO currency code of this object. 112 * @stable ICU 3.0 113 */ 114 inline const char16_t* getISOCurrency() const; 115 116 private: 117 /** 118 * The ISO 4217 code of this object. 119 */ 120 char16_t isoCode[4]; 121 }; 122 getISOCurrency()123inline const char16_t* CurrencyUnit::getISOCurrency() const { 124 return isoCode; 125 } 126 127 U_NAMESPACE_END 128 129 #endif // !UCONFIG_NO_FORMATTING 130 #endif // __CURRENCYUNIT_H__ 131