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