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