intl/icu/source/i18n/currunit.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 **********************************************************************
michael@0 3 * Copyright (c) 2004-2012, International Business Machines
michael@0 4 * Corporation and others. All Rights Reserved.
michael@0 5 **********************************************************************
michael@0 6 * Author: Alan Liu
michael@0 7 * Created: April 26, 2004
michael@0 8 * Since: ICU 3.0
michael@0 9 **********************************************************************
michael@0 10 */
michael@0 11 #include "utypeinfo.h" // for 'typeid' to work
michael@0 12
michael@0 13 #include "unicode/utypes.h"
michael@0 14
michael@0 15 #if !UCONFIG_NO_FORMATTING
michael@0 16
michael@0 17 #include "unicode/currunit.h"
michael@0 18 #include "unicode/ustring.h"
michael@0 19
michael@0 20 U_NAMESPACE_BEGIN
michael@0 21
michael@0 22 CurrencyUnit::CurrencyUnit(const UChar* _isoCode, UErrorCode& ec) {
michael@0 23 *isoCode = 0;
michael@0 24 if (U_SUCCESS(ec)) {
michael@0 25 if (_isoCode && u_strlen(_isoCode)==3) {
michael@0 26 u_strcpy(isoCode, _isoCode);
michael@0 27 } else {
michael@0 28 ec = U_ILLEGAL_ARGUMENT_ERROR;
michael@0 29 }
michael@0 30 }
michael@0 31 }
michael@0 32
michael@0 33 CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) :
michael@0 34 MeasureUnit(other) {
michael@0 35 *this = other;
michael@0 36 }
michael@0 37
michael@0 38 CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) {
michael@0 39 if (this != &other) {
michael@0 40 u_strcpy(isoCode, other.isoCode);
michael@0 41 }
michael@0 42 return *this;
michael@0 43 }
michael@0 44
michael@0 45 UObject* CurrencyUnit::clone() const {
michael@0 46 return new CurrencyUnit(*this);
michael@0 47 }
michael@0 48
michael@0 49 CurrencyUnit::~CurrencyUnit() {
michael@0 50 }
michael@0 51
michael@0 52 UBool CurrencyUnit::operator==(const UObject& other) const {
michael@0 53 const CurrencyUnit& c = (const CurrencyUnit&) other;
michael@0 54 return typeid(*this) == typeid(other) &&
michael@0 55 u_strcmp(isoCode, c.isoCode) == 0;
michael@0 56 }
michael@0 57
michael@0 58 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit)
michael@0 59
michael@0 60 U_NAMESPACE_END
michael@0 61
michael@0 62 #endif // !UCONFIG_NO_FORMATTING

mercurial