]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/curramt.h
ICU-6.2.4.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / curramt.h
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 __CURRENCYAMOUNT_H__
12 #define __CURRENCYAMOUNT_H__
13
14 #include "unicode/utypes.h"
15
16 #if !UCONFIG_NO_FORMATTING
17
18 #include "unicode/measure.h"
19 #include "unicode/currunit.h"
20
21 U_NAMESPACE_BEGIN
22
23 /**
24 * A currency together with a numeric amount, such as 200 USD.
25 *
26 * @author Alan Liu
27 * @draft ICU 3.0
28 */
29 class U_I18N_API CurrencyAmount: public Measure {
30 public:
31 /**
32 * Construct an object with the given numeric amount and the given
33 * ISO currency code.
34 * @param amount a numeric object; amount.isNumeric() must be TRUE
35 * @param isoCode the 3-letter ISO 4217 currency code; must not be
36 * NULL and must have length 3
37 * @param ec input-output error code. If the amount or the isoCode
38 * is invalid, then this will be set to a failing value.
39 * @draft ICU 3.0
40 */
41 CurrencyAmount(const Formattable& amount, const UChar* isoCode,
42 UErrorCode &ec);
43
44 /**
45 * Construct an object with the given numeric amount and the given
46 * ISO currency code.
47 * @param amount the amount of the given currency
48 * @param isoCode the 3-letter ISO 4217 currency code; must not be
49 * NULL and must have length 3
50 * @param ec input-output error code. If the isoCode is invalid,
51 * then this will be set to a failing value.
52 * @draft ICU 3.0
53 */
54 CurrencyAmount(double amount, const UChar* isoCode,
55 UErrorCode &ec);
56
57 /**
58 * Copy constructor
59 * @draft ICU 3.0
60 */
61 CurrencyAmount(const CurrencyAmount& other);
62
63 /**
64 * Assignment operator
65 * @draft ICU 3.0
66 */
67 CurrencyAmount& operator=(const CurrencyAmount& other);
68
69 /**
70 * Return a polymorphic clone of this object. The result will
71 * have the same class as returned by getDynamicClassID().
72 * @draft ICU 3.0
73 */
74 virtual UObject* clone() const;
75
76 /**
77 * Destructor
78 * @draft ICU 3.0
79 */
80 virtual ~CurrencyAmount();
81
82 /**
83 * Returns a unique class ID for this object POLYMORPHICALLY.
84 * This method implements a simple form of RTTI used by ICU.
85 * @return The class ID for this object. All objects of a given
86 * class have the same class ID. Objects of other classes have
87 * different class IDs.
88 * @draft ICU 3.0
89 */
90 virtual UClassID getDynamicClassID() const;
91
92 /**
93 * Returns the class ID for this class. This is used to compare to
94 * the return value of getDynamicClassID().
95 * @return The class ID for all objects of this class.
96 * @draft ICU 3.0
97 */
98 static UClassID U_EXPORT2 getStaticClassID();
99
100 /**
101 * Return the currency unit object of this object.
102 * @draft ICU 3.0
103 */
104 inline const CurrencyUnit& getCurrency() const;
105
106 /**
107 * Return the ISO currency code of this object.
108 * @draft ICU 3.0
109 */
110 inline const UChar* getISOCurrency() const;
111 };
112
113 inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
114 return (const CurrencyUnit&) getUnit();
115 }
116
117 inline const UChar* CurrencyAmount::getISOCurrency() const {
118 return getCurrency().getISOCurrency();
119 }
120
121 U_NAMESPACE_END
122
123 #endif // !UCONFIG_NO_FORMATTING
124 #endif // __CURRENCYAMOUNT_H__