]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/currunit.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (c) 2004-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
9 * Created: April 26, 2004
11 **********************************************************************
13 #ifndef __CURRENCYUNIT_H__
14 #define __CURRENCYUNIT_H__
16 #include "unicode/utypes.h"
18 #if U_SHOW_CPLUSPLUS_API
20 #if !UCONFIG_NO_FORMATTING
22 #include "unicode/measunit.h"
26 * \brief C++ API: Currency Unit Information.
32 * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
33 * yen). This class is a thin wrapper over a char16_t string that
34 * subclasses MeasureUnit, for use with Measure and MeasureFormat.
39 class U_I18N_API CurrencyUnit
: public MeasureUnit
{
42 * Default constructor. Initializes currency code to "XXX" (no currency).
48 * Construct an object with the given ISO currency code.
50 * @param isoCode the 3-letter ISO 4217 currency code; must have
51 * length 3 and need not be NUL-terminated. If NULL, the currency
52 * is initialized to the unknown currency XXX.
53 * @param ec input-output error code. If the isoCode is invalid,
54 * then this will be set to a failing value.
57 CurrencyUnit(ConstChar16Ptr isoCode
, UErrorCode
&ec
);
59 #ifndef U_HIDE_DRAFT_API
61 * Construct an object with the given ISO currency code.
63 * @param isoCode the 3-letter ISO 4217 currency code; must have
64 * length 3. If invalid, the currency is initialized to XXX.
65 * @param ec input-output error code. If the isoCode is invalid,
66 * then this will be set to a failing value.
69 CurrencyUnit(StringPiece isoCode
, UErrorCode
&ec
);
70 #endif /* U_HIDE_DRAFT_API */
76 CurrencyUnit(const CurrencyUnit
& other
);
79 * Copy constructor from MeasureUnit. This constructor allows you to
80 * restore a CurrencyUnit that was sliced to MeasureUnit.
82 * @param measureUnit The MeasureUnit to copy from.
83 * @param ec Set to a failing value if the MeasureUnit is not a currency.
86 CurrencyUnit(const MeasureUnit
& measureUnit
, UErrorCode
&ec
);
92 CurrencyUnit
& operator=(const CurrencyUnit
& other
);
95 * Return a polymorphic clone of this object. The result will
96 * have the same class as returned by getDynamicClassID().
99 virtual CurrencyUnit
* clone() const;
105 virtual ~CurrencyUnit();
108 * Returns a unique class ID for this object POLYMORPHICALLY.
109 * This method implements a simple form of RTTI used by ICU.
110 * @return The class ID for this object. All objects of a given
111 * class have the same class ID. Objects of other classes have
112 * different class IDs.
115 virtual UClassID
getDynamicClassID() const;
118 * Returns the class ID for this class. This is used to compare to
119 * the return value of getDynamicClassID().
120 * @return The class ID for all objects of this class.
123 static UClassID U_EXPORT2
getStaticClassID();
126 * Return the ISO currency code of this object.
129 inline const char16_t* getISOCurrency() const;
133 * The ISO 4217 code of this object.
138 inline const char16_t* CurrencyUnit::getISOCurrency() const {
144 #endif // !UCONFIG_NO_FORMATTING
146 #endif /* U_SHOW_CPLUSPLUS_API */
148 #endif // __CURRENCYUNIT_H__