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