summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-50.1/i18n/currunit.cpp
blob: 870d9d0c4ce8bb6f60500e9ac7ce9960ebd3f036 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
**********************************************************************
* Copyright (c) 2004-2012, International Business Machines
* Corporation and others.  All Rights Reserved.
**********************************************************************
* Author: Alan Liu
* Created: April 26, 2004
* Since: ICU 3.0
**********************************************************************
*/
#include "utypeinfo.h"  // for 'typeid' to work

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/currunit.h"
#include "unicode/ustring.h"

U_NAMESPACE_BEGIN

CurrencyUnit::CurrencyUnit(const UChar* _isoCode, UErrorCode& ec) {
    *isoCode = 0;
    if (U_SUCCESS(ec)) {
        if (_isoCode && u_strlen(_isoCode)==3) {
            u_strcpy(isoCode, _isoCode);
        } else {
            ec = U_ILLEGAL_ARGUMENT_ERROR;
        }
    }
}

CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) :
    MeasureUnit(other) {
    *this = other;
}

CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) {
    if (this != &other) {
        u_strcpy(isoCode, other.isoCode);
    }
    return *this;
}

UObject* CurrencyUnit::clone() const {
    return new CurrencyUnit(*this);
}

CurrencyUnit::~CurrencyUnit() {
}
    
UBool CurrencyUnit::operator==(const UObject& other) const {
    const CurrencyUnit& c = (const CurrencyUnit&) other;
    return typeid(*this) == typeid(other) &&
        u_strcmp(isoCode, c.isoCode) == 0;    
}

UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit)

U_NAMESPACE_END

#endif // !UCONFIG_NO_FORMATTING