]>
Commit | Line | Data |
---|---|---|
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 | #include "unicode/utypes.h" | |
14 | ||
15 | #if !UCONFIG_NO_FORMATTING | |
16 | ||
17 | #include "unicode/currunit.h" | |
18 | #include "unicode/ustring.h" | |
19 | ||
20 | U_NAMESPACE_BEGIN | |
21 | ||
f3c0d7a5 | 22 | CurrencyUnit::CurrencyUnit(ConstChar16Ptr _isoCode, UErrorCode& ec) { |
374ca955 A |
23 | *isoCode = 0; |
24 | if (U_SUCCESS(ec)) { | |
f3c0d7a5 | 25 | if (_isoCode != nullptr && u_strlen(_isoCode)==3) { |
374ca955 | 26 | u_strcpy(isoCode, _isoCode); |
57a6839d A |
27 | char simpleIsoCode[4]; |
28 | u_UCharsToChars(isoCode, simpleIsoCode, 4); | |
29 | initCurrency(simpleIsoCode); | |
374ca955 A |
30 | } else { |
31 | ec = U_ILLEGAL_ARGUMENT_ERROR; | |
32 | } | |
33 | } | |
34 | } | |
35 | ||
36 | CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) : | |
37 | MeasureUnit(other) { | |
57a6839d | 38 | u_strcpy(isoCode, other.isoCode); |
374ca955 A |
39 | } |
40 | ||
41 | CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) { | |
57a6839d A |
42 | if (this == &other) { |
43 | return *this; | |
374ca955 | 44 | } |
57a6839d A |
45 | MeasureUnit::operator=(other); |
46 | u_strcpy(isoCode, other.isoCode); | |
374ca955 A |
47 | return *this; |
48 | } | |
49 | ||
50 | UObject* CurrencyUnit::clone() const { | |
51 | return new CurrencyUnit(*this); | |
52 | } | |
53 | ||
54 | CurrencyUnit::~CurrencyUnit() { | |
55 | } | |
56 | ||
374ca955 A |
57 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit) |
58 | ||
59 | U_NAMESPACE_END | |
60 | ||
61 | #endif // !UCONFIG_NO_FORMATTING |