]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/measure.cpp
ICU-8.11.tar.gz
[apple/icu.git] / icuSources / i18n / measure.cpp
CommitLineData
374ca955
A
1/*
2**********************************************************************
3* Copyright (c) 2004, 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 "unicode/utypes.h"
12
13#if !UCONFIG_NO_FORMATTING
14
15#include "unicode/measure.h"
16#include "unicode/measunit.h"
17
18U_NAMESPACE_BEGIN
19
20Measure::Measure() {}
21
22Measure::Measure(const Formattable& _number, MeasureUnit* adoptedUnit,
23 UErrorCode& ec) :
24 number(_number), unit(adoptedUnit) {
25 if (U_SUCCESS(ec) &&
26 (!number.isNumeric() || adoptedUnit == 0)) {
27 ec = U_ILLEGAL_ARGUMENT_ERROR;
28 }
29}
30
31Measure::Measure(const Measure& other) :
32 UObject(other), unit(0) {
33 *this = other;
34}
35
36Measure& Measure::operator=(const Measure& other) {
37 if (this != &other) {
38 delete unit;
39 number = other.number;
40 unit = (MeasureUnit*) other.unit->clone();
41 }
42 return *this;
43}
44
45Measure::~Measure() {
46 delete unit;
47}
48
49UBool Measure::operator==(const UObject& other) const {
50 const Measure* m = (const Measure*) &other;
51 return getDynamicClassID() == other.getDynamicClassID() &&
52 number == m->getNumber() &&
53 *unit == m->getUnit();
54}
55
56//----------------------------------------------------------------------
57// MeasureUnit implementation
58
59MeasureUnit:: MeasureUnit() {}
60
61MeasureUnit::~MeasureUnit() {}
62
63U_NAMESPACE_END
64
65#endif // !UCONFIG_NO_FORMATTING