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