2004-04-27 21:47:09 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2014-02-04 00:29:17 +00:00
|
|
|
* Copyright (c) 2004-2014, International Business Machines
|
2004-04-27 21:47:09 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Author: Alan Liu
|
|
|
|
* Created: April 26, 2004
|
|
|
|
* Since: ICU 3.0
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
2012-06-28 23:28:00 +00:00
|
|
|
#include "utypeinfo.h" // for 'typeid' to work
|
2010-05-19 17:29:33 +00:00
|
|
|
|
2004-04-27 21:47:09 +00:00
|
|
|
#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);
|
2014-02-04 00:29:17 +00:00
|
|
|
char simpleIsoCode[4];
|
|
|
|
u_UCharsToChars(isoCode, simpleIsoCode, 4);
|
|
|
|
initCurrency(simpleIsoCode);
|
2004-04-27 21:47:09 +00:00
|
|
|
} else {
|
|
|
|
ec = U_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-28 18:12:14 +00:00
|
|
|
CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) :
|
|
|
|
MeasureUnit(other) {
|
2014-02-04 00:29:17 +00:00
|
|
|
u_strcpy(isoCode, other.isoCode);
|
2004-04-27 21:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CurrencyUnit& CurrencyUnit::operator=(const CurrencyUnit& other) {
|
2014-02-04 00:29:17 +00:00
|
|
|
if (this == &other) {
|
|
|
|
return *this;
|
2004-04-27 21:47:09 +00:00
|
|
|
}
|
2014-02-04 00:29:17 +00:00
|
|
|
MeasureUnit::operator=(other);
|
|
|
|
u_strcpy(isoCode, other.isoCode);
|
2004-04-27 21:47:09 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
UObject* CurrencyUnit::clone() const {
|
|
|
|
return new CurrencyUnit(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrencyUnit::~CurrencyUnit() {
|
|
|
|
}
|
|
|
|
|
|
|
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CurrencyUnit)
|
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif // !UCONFIG_NO_FORMATTING
|