]>
Commit | Line | Data |
---|---|---|
374ca955 A |
1 | /* |
2 | ********************************************************************** | |
3 | * Copyright (c) 2004, International Business Machines | |
4 | * Corporation and others. All Rights Reserved. | |
5 | ********************************************************************** | |
6 | * Author: Alan Liu | |
7 | * Created: April 26, 2004 | |
8 | * Since: ICU 3.0 | |
9 | ********************************************************************** | |
10 | */ | |
11 | #ifndef __CURRENCYUNIT_H__ | |
12 | #define __CURRENCYUNIT_H__ | |
13 | ||
14 | #include "unicode/utypes.h" | |
15 | ||
16 | #if !UCONFIG_NO_FORMATTING | |
17 | ||
18 | #include "unicode/measunit.h" | |
19 | ||
20 | U_NAMESPACE_BEGIN | |
21 | ||
22 | /** | |
23 | * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese | |
24 | * yen). This class is a thin wrapper over a UChar string that | |
25 | * subclasses MeasureUnit, for use with Measure and MeasureFormat. | |
26 | * | |
27 | * @author Alan Liu | |
28 | * @draft ICU 3.0 | |
29 | */ | |
30 | class U_I18N_API CurrencyUnit: public MeasureUnit { | |
31 | public: | |
32 | /** | |
33 | * Construct an object with the given ISO currency code. | |
34 | * @param isoCode the 3-letter ISO 4217 currency code; must not be | |
35 | * NULL and must have length 3 | |
36 | * @param ec input-output error code. If the isoCode is invalid, | |
37 | * then this will be set to a failing value. | |
38 | * @draft ICU 3.0 | |
39 | */ | |
40 | CurrencyUnit(const UChar* isoCode, UErrorCode &ec); | |
41 | ||
42 | /** | |
43 | * Copy constructor | |
44 | * @draft ICU 3.0 | |
45 | */ | |
46 | CurrencyUnit(const CurrencyUnit& other); | |
47 | ||
48 | /** | |
49 | * Assignment operator | |
50 | * @draft ICU 3.0 | |
51 | */ | |
52 | CurrencyUnit& operator=(const CurrencyUnit& other); | |
53 | ||
54 | /** | |
55 | * Return a polymorphic clone of this object. The result will | |
56 | * have the same class as returned by getDynamicClassID(). | |
57 | * @draft ICU 3.0 | |
58 | */ | |
59 | virtual UObject* clone() const; | |
60 | ||
61 | /** | |
62 | * Destructor | |
63 | * @draft ICU 3.0 | |
64 | */ | |
65 | virtual ~CurrencyUnit(); | |
66 | ||
67 | /** | |
68 | * Equality operator. Return true if this object is equal | |
69 | * to the given object. | |
70 | * @draft ICU 3.0 | |
71 | */ | |
72 | UBool operator==(const UObject& other) const; | |
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 | * @draft 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 | * @draft ICU 3.0 | |
89 | */ | |
90 | static UClassID U_EXPORT2 getStaticClassID(); | |
91 | ||
92 | /** | |
93 | * Return the ISO currency code of this object. | |
94 | * @draft 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 | ||
105 | inline const UChar* CurrencyUnit::getISOCurrency() const { | |
106 | return isoCode; | |
107 | } | |
108 | ||
109 | U_NAMESPACE_END | |
110 | ||
111 | #endif // !UCONFIG_NO_FORMATTING | |
112 | #endif // __CURRENCYUNIT_H__ |