]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/currunit.h
ICU-62141.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / currunit.h
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 #if U_SHOW_CPLUSPLUS_API
28 U_NAMESPACE_BEGIN
29
30 /**
31 * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
32 * yen). This class is a thin wrapper over a char16_t string that
33 * subclasses MeasureUnit, for use with Measure and MeasureFormat.
34 *
35 * @author Alan Liu
36 * @stable ICU 3.0
37 */
38 class U_I18N_API CurrencyUnit: public MeasureUnit {
39 public:
40 /**
41 * Default constructor. Initializes currency code to "XXX" (no currency).
42 * @draft ICU 60
43 */
44 CurrencyUnit();
45
46 /**
47 * Construct an object with the given ISO currency code.
48 * @param isoCode the 3-letter ISO 4217 currency code; must have
49 * length 3 and need not be NUL-terminated. If NULL, the currency
50 * is initialized to the unknown currency XXX.
51 * @param ec input-output error code. If the isoCode is invalid,
52 * then this will be set to a failing value.
53 * @stable ICU 3.0
54 */
55 CurrencyUnit(ConstChar16Ptr isoCode, UErrorCode &ec);
56
57 /**
58 * Copy constructor
59 * @stable ICU 3.0
60 */
61 CurrencyUnit(const CurrencyUnit& other);
62
63 #ifndef U_HIDE_DRAFT_API
64 /**
65 * Copy constructor from MeasureUnit. This constructor allows you to
66 * restore a CurrencyUnit that was sliced to MeasureUnit.
67 *
68 * @param measureUnit The MeasureUnit to copy from.
69 * @param ec Set to a failing value if the MeasureUnit is not a currency.
70 * @draft ICU 60
71 */
72 CurrencyUnit(const MeasureUnit& measureUnit, UErrorCode &ec);
73 #endif /* U_HIDE_DRAFT_API */
74
75 /**
76 * Assignment operator
77 * @stable ICU 3.0
78 */
79 CurrencyUnit& operator=(const CurrencyUnit& other);
80
81 /**
82 * Return a polymorphic clone of this object. The result will
83 * have the same class as returned by getDynamicClassID().
84 * @stable ICU 3.0
85 */
86 virtual UObject* clone() const;
87
88 /**
89 * Destructor
90 * @stable ICU 3.0
91 */
92 virtual ~CurrencyUnit();
93
94 /**
95 * Returns a unique class ID for this object POLYMORPHICALLY.
96 * This method implements a simple form of RTTI used by ICU.
97 * @return The class ID for this object. All objects of a given
98 * class have the same class ID. Objects of other classes have
99 * different class IDs.
100 * @stable ICU 3.0
101 */
102 virtual UClassID getDynamicClassID() const;
103
104 /**
105 * Returns the class ID for this class. This is used to compare to
106 * the return value of getDynamicClassID().
107 * @return The class ID for all objects of this class.
108 * @stable ICU 3.0
109 */
110 static UClassID U_EXPORT2 getStaticClassID();
111
112 /**
113 * Return the ISO currency code of this object.
114 * @stable ICU 3.0
115 */
116 inline const char16_t* getISOCurrency() const;
117
118 private:
119 /**
120 * The ISO 4217 code of this object.
121 */
122 char16_t isoCode[4];
123 };
124
125 inline const char16_t* CurrencyUnit::getISOCurrency() const {
126 return isoCode;
127 }
128
129 U_NAMESPACE_END
130 #endif // U_SHOW_CPLUSPLUS_API
131
132 #endif // !UCONFIG_NO_FORMATTING
133 #endif // __CURRENCYUNIT_H__