]>
Commit | Line | Data |
---|---|---|
1 | // © 2016 and later: Unicode, Inc. and others. | |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
3 | /* | |
4 | ********************************************************************** | |
5 | * Copyright (c) 2004-2014, International Business Machines | |
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 | ||
22 | CurrencyUnit::CurrencyUnit(ConstChar16Ptr _isoCode, UErrorCode& ec) { | |
23 | *isoCode = 0; | |
24 | if (U_SUCCESS(ec)) { | |
25 | if (_isoCode != nullptr && u_strlen(_isoCode)==3) { | |
26 | u_strcpy(isoCode, _isoCode); | |
27 | char simpleIsoCode[4]; | |
28 | u_UCharsToChars(isoCode, simpleIsoCode, 4); | |
29 | initCurrency(simpleIsoCode); | |
30 | } else { | |
31 | ec = U_ILLEGAL_ARGUMENT_ERROR; | |
32 | } | |
33 | } | |
34 | } | |
35 | ||
36 | CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) : | |
37 | MeasureUnit(other) { | |
38 | u_strcpy(isoCode, other.isoCode); | |
39 | } | |
40 | ||
41 | CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) { | |
42 | if (this == &other) { | |
43 | return *this; | |
44 | } | |
45 | MeasureUnit::operator=(other); | |
46 | u_strcpy(isoCode, other.isoCode); | |
47 | return *this; | |
48 | } | |
49 | ||
50 | UObject* CurrencyUnit::clone() const { | |
51 | return new CurrencyUnit(*this); | |
52 | } | |
53 | ||
54 | CurrencyUnit::~CurrencyUnit() { | |
55 | } | |
56 | ||
57 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit) | |
58 | ||
59 | U_NAMESPACE_END | |
60 | ||
61 | #endif // !UCONFIG_NO_FORMATTING |