Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ********************************************************************** |
michael@0 | 3 | * Copyright (c) 2004-2012, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * Author: Alan Liu |
michael@0 | 7 | * Created: April 26, 2004 |
michael@0 | 8 | * Since: ICU 3.0 |
michael@0 | 9 | ********************************************************************** |
michael@0 | 10 | */ |
michael@0 | 11 | #include "utypeinfo.h" // for 'typeid' to work |
michael@0 | 12 | |
michael@0 | 13 | #include "unicode/utypes.h" |
michael@0 | 14 | |
michael@0 | 15 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 16 | |
michael@0 | 17 | #include "unicode/measure.h" |
michael@0 | 18 | #include "unicode/measunit.h" |
michael@0 | 19 | |
michael@0 | 20 | U_NAMESPACE_BEGIN |
michael@0 | 21 | |
michael@0 | 22 | Measure::Measure() {} |
michael@0 | 23 | |
michael@0 | 24 | Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit, |
michael@0 | 25 | UErrorCode& ec) : |
michael@0 | 26 | number(_number), unit(adoptedUnit) { |
michael@0 | 27 | if (U_SUCCESS(ec) && |
michael@0 | 28 | (!number.isNumeric() || adoptedUnit == 0)) { |
michael@0 | 29 | ec = U_ILLEGAL_ARGUMENT_ERROR; |
michael@0 | 30 | } |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | Measure::Measure(const Measure& other) : |
michael@0 | 34 | UObject(other), unit(0) { |
michael@0 | 35 | *this = other; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | Measure& Measure::operator=(const Measure& other) { |
michael@0 | 39 | if (this != &other) { |
michael@0 | 40 | delete unit; |
michael@0 | 41 | number = other.number; |
michael@0 | 42 | unit = (MeasureUnit*) other.unit->clone(); |
michael@0 | 43 | } |
michael@0 | 44 | return *this; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | Measure::~Measure() { |
michael@0 | 48 | delete unit; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | UBool Measure::operator==(const UObject& other) const { |
michael@0 | 52 | const Measure* m = (const Measure*) &other; |
michael@0 | 53 | return typeid(*this) == typeid(other) && |
michael@0 | 54 | number == m->getNumber() && |
michael@0 | 55 | (unit != NULL && *unit == m->getUnit()); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | //---------------------------------------------------------------------- |
michael@0 | 59 | // MeasureUnit implementation |
michael@0 | 60 | |
michael@0 | 61 | MeasureUnit:: MeasureUnit() {} |
michael@0 | 62 | |
michael@0 | 63 | MeasureUnit::~MeasureUnit() {} |
michael@0 | 64 | |
michael@0 | 65 | U_NAMESPACE_END |
michael@0 | 66 | |
michael@0 | 67 | #endif // !UCONFIG_NO_FORMATTING |