michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (c) 2004-2012, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Author: Alan Liu michael@0: * Created: April 26, 2004 michael@0: * Since: ICU 3.0 michael@0: ********************************************************************** michael@0: */ michael@0: #include "utypeinfo.h" // for 'typeid' to work michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/currunit.h" michael@0: #include "unicode/ustring.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: CurrencyUnit::CurrencyUnit(const UChar* _isoCode, UErrorCode& ec) { michael@0: *isoCode = 0; michael@0: if (U_SUCCESS(ec)) { michael@0: if (_isoCode && u_strlen(_isoCode)==3) { michael@0: u_strcpy(isoCode, _isoCode); michael@0: } else { michael@0: ec = U_ILLEGAL_ARGUMENT_ERROR; michael@0: } michael@0: } michael@0: } michael@0: michael@0: CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) : michael@0: MeasureUnit(other) { michael@0: *this = other; michael@0: } michael@0: michael@0: CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) { michael@0: if (this != &other) { michael@0: u_strcpy(isoCode, other.isoCode); michael@0: } michael@0: return *this; michael@0: } michael@0: michael@0: UObject* CurrencyUnit::clone() const { michael@0: return new CurrencyUnit(*this); michael@0: } michael@0: michael@0: CurrencyUnit::~CurrencyUnit() { michael@0: } michael@0: michael@0: UBool CurrencyUnit::operator==(const UObject& other) const { michael@0: const CurrencyUnit& c = (const CurrencyUnit&) other; michael@0: return typeid(*this) == typeid(other) && michael@0: u_strcmp(isoCode, c.isoCode) == 0; michael@0: } michael@0: michael@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit) michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif // !UCONFIG_NO_FORMATTING