ICU 50.2 50.2
Measure Class Referenceabstract

An amount of a specified unit, consisting of a number and a Unit. More...

#include <measure.h>

Inheritance diagram for Measure:
UObject UMemory CurrencyAmount TimeUnitAmount

Public Member Functions

 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.
 
Measureoperator= (const Measure &other)
 Assignment operator.
 
virtual UObjectclone () const =0
 Return a polymorphic clone of this object.
 
virtual ~Measure ()
 Destructor.
 
UBool operator== (const UObject &other) const
 Equality operator.
 
const FormattablegetNumber () const
 Return a reference to the numeric value of this object.
 
const MeasureUnitgetUnit () const
 Return a reference to the unit of this object.
 
- Public Member Functions inherited from UObject
virtual ~UObject ()
 Destructor.
 
virtual UClassID getDynamicClassID () const =0
 ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
 

Protected Member Functions

 Measure ()
 Default constructor.
 

Detailed Description

An amount of a specified unit, consisting of a number and a Unit.

For example, a length measure consists of a number and a length unit, such as feet or meters. This is an abstract class. Subclasses specify a concrete Unit type.

Measure objects are parsed and formatted by subclasses of MeasureFormat.

Measure objects are immutable.

This is an abstract class.

Author
Alan Liu
Stable
ICU 3.0

Definition at line 45 of file measure.h.

Constructor & Destructor Documentation

◆ Measure() [1/3]

Measure::Measure ( const Formattable & number,
MeasureUnit * adoptedUnit,
UErrorCode & ec )

Construct an object with the given numeric amount and the given unit.

After this call, the caller must not delete the given unit object.

Parameters
numbera numeric object; amount.isNumeric() must be TRUE
adoptedUnitthe unit object, which must not be NULL
ecinput-output error code. If the amount or the unit is invalid, then this will be set to a failing value.
Stable
ICU 3.0

Referenced by Measure(), and operator=().

◆ Measure() [2/3]

Measure::Measure ( const Measure & other)

Copy constructor.

Stable
ICU 3.0

References Measure().

◆ ~Measure()

virtual Measure::~Measure ( )
virtual

Destructor.

Stable
ICU 3.0

◆ Measure() [3/3]

Measure::Measure ( )
protected

Default constructor.

Stable
ICU 3.0

Member Function Documentation

◆ clone()

virtual UObject * Measure::clone ( ) const
pure virtual

Return a polymorphic clone of this object.

The result will have the same class as returned by getDynamicClassID().

Stable
ICU 3.0

Implemented in CurrencyAmount, and TimeUnitAmount.

◆ getNumber()

const Formattable & Measure::getNumber ( ) const
inline

Return a reference to the numeric value of this object.

The numeric value may be of any numeric type supported by Formattable.

Stable
ICU 3.0

Definition at line 126 of file measure.h.

Referenced by operator==().

◆ getUnit()

const MeasureUnit & Measure::getUnit ( ) const
inline

Return a reference to the unit of this object.

Stable
ICU 3.0

Definition at line 130 of file measure.h.

Referenced by CurrencyAmount::getCurrency(), and operator==().

◆ operator=()

Measure & Measure::operator= ( const Measure & other)

Assignment operator.

Stable
ICU 3.0

References Measure().

◆ operator==()

UBool Measure::operator== ( const UObject & other) const

Equality operator.

Return true if this object is equal to the given object.

Stable
ICU 3.0

References getNumber(), and getUnit().


The documentation for this class was generated from the following file: