ICU 50.2 50.2
measure.h
Go to the documentation of this file.
1/*
2**********************************************************************
3* Copyright (c) 2004-2006, 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#ifndef __MEASURE_H__
12#define __MEASURE_H__
13
14#include "unicode/utypes.h"
15
20
21#if !UCONFIG_NO_FORMATTING
22
23#include "unicode/fmtable.h"
24
26
27class MeasureUnit;
28
45class U_I18N_API Measure: public UObject {
46 public:
57 Measure(const Formattable& number, MeasureUnit* adoptedUnit,
58 UErrorCode& ec);
59
64 Measure(const Measure& other);
65
70 Measure& operator=(const Measure& other);
71
77 virtual UObject* clone() const = 0;
78
83 virtual ~Measure();
84
90 UBool operator==(const UObject& other) const;
91
98 inline const Formattable& getNumber() const;
99
104 inline const MeasureUnit& getUnit() const;
105
106 protected:
112
113 private:
117 Formattable number;
118
123 MeasureUnit* unit;
124};
125
126inline const Formattable& Measure::getNumber() const {
127 return number;
128}
129
130inline const MeasureUnit& Measure::getUnit() const {
131 return *unit;
132}
133
135
136#endif // !UCONFIG_NO_FORMATTING
137#endif // __MEASURE_H__
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition fmtable.h:62
A unit such as length, mass, volume, currency, etc.
Definition measunit.h:36
UBool operator==(const UObject &other) const
Equality operator.
Measure & operator=(const Measure &other)
Assignment operator.
const MeasureUnit & getUnit() const
Return a reference to the unit of this object.
Definition measure.h:130
Measure(const Formattable &number, MeasureUnit *adoptedUnit, UErrorCode &ec)
Construct an object with the given numeric amount and the given unit.
Measure(const Measure &other)
Copy constructor.
virtual ~Measure()
Destructor.
virtual UObject * clone() const =0
Return a polymorphic clone of this object.
const Formattable & getNumber() const
Return a reference to the numeric value of this object.
Definition measure.h:126
Measure()
Default constructor.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:229
C++ API: Formattable is a thin wrapper for primitive numeric types.
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129