Index: source/i18n/measure.cpp |
diff --git a/source/i18n/measure.cpp b/source/i18n/measure.cpp |
index 639de3e6db17ac4aef8eb1e50d2fcb1c7d8dab92..eb610e6f8fde461ce669dab5f4314e78a96df3f4 100644 |
--- a/source/i18n/measure.cpp |
+++ b/source/i18n/measure.cpp |
@@ -1,6 +1,6 @@ |
/* |
********************************************************************** |
-* Copyright (c) 2004-2012, International Business Machines |
+* Copyright (c) 2004-2014, International Business Machines |
* Corporation and others. All Rights Reserved. |
********************************************************************** |
* Author: Alan Liu |
@@ -19,6 +19,8 @@ |
U_NAMESPACE_BEGIN |
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Measure) |
+ |
Measure::Measure() {} |
Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit, |
@@ -44,24 +46,27 @@ Measure& Measure::operator=(const Measure& other) { |
return *this; |
} |
+UObject *Measure::clone() const { |
+ return new Measure(*this); |
+} |
+ |
Measure::~Measure() { |
delete unit; |
} |
UBool Measure::operator==(const UObject& other) const { |
- const Measure* m = (const Measure*) &other; |
- return typeid(*this) == typeid(other) && |
- number == m->getNumber() && |
- (unit != NULL && *unit == m->getUnit()); |
+ if (this == &other) { // Same object, equal |
+ return TRUE; |
+ } |
+ if (typeid(*this) != typeid(other)) { // Different types, not equal |
+ return FALSE; |
+ } |
+ const Measure &m = static_cast<const Measure&>(other); |
+ return number == m.number && |
+ ((unit == NULL) == (m.unit == NULL)) && |
+ (unit == NULL || *unit == *m.unit); |
} |
-//---------------------------------------------------------------------- |
-// MeasureUnit implementation |
- |
-MeasureUnit:: MeasureUnit() {} |
- |
-MeasureUnit::~MeasureUnit() {} |
- |
U_NAMESPACE_END |
#endif // !UCONFIG_NO_FORMATTING |