intl/icu/source/i18n/measure.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2 **********************************************************************
     3 * Copyright (c) 2004-2012, International Business Machines
     4 * Corporation and others.  All Rights Reserved.
     5 **********************************************************************
     6 * Author: Alan Liu
     7 * Created: April 26, 2004
     8 * Since: ICU 3.0
     9 **********************************************************************
    10 */
    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"
    20 U_NAMESPACE_BEGIN
    22 Measure::Measure() {}
    24 Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit,
    25                  UErrorCode& ec) :
    26     number(_number), unit(adoptedUnit) {
    27     if (U_SUCCESS(ec) &&
    28         (!number.isNumeric() || adoptedUnit == 0)) {
    29         ec = U_ILLEGAL_ARGUMENT_ERROR;
    30     }
    31 }
    33 Measure::Measure(const Measure& other) :
    34     UObject(other), unit(0) {
    35     *this = other;
    36 }
    38 Measure& Measure::operator=(const Measure& other) {
    39     if (this != &other) {
    40         delete unit;
    41         number = other.number;
    42         unit = (MeasureUnit*) other.unit->clone();
    43     }
    44     return *this;
    45 }
    47 Measure::~Measure() {
    48     delete unit;
    49 }
    51 UBool Measure::operator==(const UObject& other) const {
    52     const Measure* m = (const Measure*) &other;
    53     return typeid(*this) == typeid(other) &&
    54         number == m->getNumber() && 
    55         (unit != NULL && *unit == m->getUnit());
    56 }
    58 //----------------------------------------------------------------------
    59 // MeasureUnit implementation
    61 MeasureUnit:: MeasureUnit() {}
    63 MeasureUnit::~MeasureUnit() {}
    65 U_NAMESPACE_END
    67 #endif // !UCONFIG_NO_FORMATTING

mercurial