]> git.saurik.com Git - apple/icu.git/blame_incremental - icuSources/i18n/currunit.cpp
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / currunit.cpp
... / ...
CommitLineData
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
20U_NAMESPACE_BEGIN
21
22CurrencyUnit::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
36CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) :
37 MeasureUnit(other) {
38 u_strcpy(isoCode, other.isoCode);
39}
40
41CurrencyUnit& 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
50UObject* CurrencyUnit::clone() const {
51 return new CurrencyUnit(*this);
52}
53
54CurrencyUnit::~CurrencyUnit() {
55}
56
57UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit)
58
59U_NAMESPACE_END
60
61#endif // !UCONFIG_NO_FORMATTING