]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/measure.cpp
2 **********************************************************************
3 * Copyright (c) 2004-2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
7 * Created: April 26, 2004
9 **********************************************************************
11 #include "utypeinfo.h" // for 'typeid' to work
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_FORMATTING
17 #include "unicode/measure.h"
18 #include "unicode/measunit.h"
22 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Measure
)
26 Measure::Measure(const Formattable
& _number
, MeasureUnit
* adoptedUnit
,
28 number(_number
), unit(adoptedUnit
) {
30 (!number
.isNumeric() || adoptedUnit
== 0)) {
31 ec
= U_ILLEGAL_ARGUMENT_ERROR
;
35 Measure::Measure(const Measure
& other
) :
36 UObject(other
), unit(0) {
40 Measure
& Measure::operator=(const Measure
& other
) {
43 number
= other
.number
;
44 unit
= (MeasureUnit
*) other
.unit
->clone();
49 UObject
*Measure::clone() const {
50 return new Measure(*this);
57 UBool
Measure::operator==(const UObject
& other
) const {
58 if (this == &other
) { // Same object, equal
61 if (typeid(*this) != typeid(other
)) { // Different types, not equal
64 const Measure
&m
= static_cast<const Measure
&>(other
);
65 return number
== m
.number
&&
66 ((unit
== NULL
) == (m
.unit
== NULL
)) &&
67 (unit
== NULL
|| *unit
== *m
.unit
);
72 #endif // !UCONFIG_NO_FORMATTING