Line data Source code
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 0 : CurrencyUnit::CurrencyUnit(ConstChar16Ptr _isoCode, UErrorCode& ec) {
23 0 : *isoCode = 0;
24 0 : if (U_SUCCESS(ec)) {
25 0 : if (_isoCode != nullptr && u_strlen(_isoCode)==3) {
26 0 : u_strcpy(isoCode, _isoCode);
27 : char simpleIsoCode[4];
28 0 : u_UCharsToChars(isoCode, simpleIsoCode, 4);
29 0 : initCurrency(simpleIsoCode);
30 : } else {
31 0 : ec = U_ILLEGAL_ARGUMENT_ERROR;
32 : }
33 : }
34 0 : }
35 :
36 0 : CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) :
37 0 : MeasureUnit(other) {
38 0 : u_strcpy(isoCode, other.isoCode);
39 0 : }
40 :
41 0 : CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) {
42 0 : if (this == &other) {
43 0 : return *this;
44 : }
45 0 : MeasureUnit::operator=(other);
46 0 : u_strcpy(isoCode, other.isoCode);
47 0 : return *this;
48 : }
49 :
50 0 : UObject* CurrencyUnit::clone() const {
51 0 : return new CurrencyUnit(*this);
52 : }
53 :
54 0 : CurrencyUnit::~CurrencyUnit() {
55 0 : }
56 :
57 0 : UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit)
58 :
59 : U_NAMESPACE_END
60 :
61 : #endif // !UCONFIG_NO_FORMATTING
|