]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/currunit.cpp
ICU-8.11.4.tar.gz
[apple/icu.git] / icuSources / i18n / currunit.cpp
CommitLineData
374ca955
A
1/*
2**********************************************************************
3* Copyright (c) 2004, International Business Machines
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
18U_NAMESPACE_BEGIN
19
20CurrencyUnit::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);
25 } else {
26 ec = U_ILLEGAL_ARGUMENT_ERROR;
27 }
28 }
29}
30
31CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) :
32 MeasureUnit(other) {
33 *this = other;
34}
35
36CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) {
37 if (this != &other) {
38 u_strcpy(isoCode, other.isoCode);
39 }
40 return *this;
41}
42
43UObject* CurrencyUnit::clone() const {
44 return new CurrencyUnit(*this);
45}
46
47CurrencyUnit::~CurrencyUnit() {
48}
49
50UBool CurrencyUnit::operator==(const UObject& other) const {
51 const CurrencyUnit& c = (const CurrencyUnit&) other;
52 return other.getDynamicClassID() == CurrencyUnit::getStaticClassID() &&
53 u_strcmp(isoCode, c.isoCode) == 0;
54}
55
56UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit)
57
58U_NAMESPACE_END
59
60#endif // !UCONFIG_NO_FORMATTING