1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/currunit.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* 1.5 +********************************************************************** 1.6 +* Copyright (c) 2004-2012, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +********************************************************************** 1.9 +* Author: Alan Liu 1.10 +* Created: April 26, 2004 1.11 +* Since: ICU 3.0 1.12 +********************************************************************** 1.13 +*/ 1.14 +#include "utypeinfo.h" // for 'typeid' to work 1.15 + 1.16 +#include "unicode/utypes.h" 1.17 + 1.18 +#if !UCONFIG_NO_FORMATTING 1.19 + 1.20 +#include "unicode/currunit.h" 1.21 +#include "unicode/ustring.h" 1.22 + 1.23 +U_NAMESPACE_BEGIN 1.24 + 1.25 +CurrencyUnit::CurrencyUnit(const UChar* _isoCode, UErrorCode& ec) { 1.26 + *isoCode = 0; 1.27 + if (U_SUCCESS(ec)) { 1.28 + if (_isoCode && u_strlen(_isoCode)==3) { 1.29 + u_strcpy(isoCode, _isoCode); 1.30 + } else { 1.31 + ec = U_ILLEGAL_ARGUMENT_ERROR; 1.32 + } 1.33 + } 1.34 +} 1.35 + 1.36 +CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) : 1.37 + MeasureUnit(other) { 1.38 + *this = other; 1.39 +} 1.40 + 1.41 +CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) { 1.42 + if (this != &other) { 1.43 + u_strcpy(isoCode, other.isoCode); 1.44 + } 1.45 + return *this; 1.46 +} 1.47 + 1.48 +UObject* CurrencyUnit::clone() const { 1.49 + return new CurrencyUnit(*this); 1.50 +} 1.51 + 1.52 +CurrencyUnit::~CurrencyUnit() { 1.53 +} 1.54 + 1.55 +UBool CurrencyUnit::operator==(const UObject& other) const { 1.56 + const CurrencyUnit& c = (const CurrencyUnit&) other; 1.57 + return typeid(*this) == typeid(other) && 1.58 + u_strcmp(isoCode, c.isoCode) == 0; 1.59 +} 1.60 + 1.61 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit) 1.62 + 1.63 +U_NAMESPACE_END 1.64 + 1.65 +#endif // !UCONFIG_NO_FORMATTING